You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by David Jones <os...@gmail.com> on 2007/11/14 17:02:22 UTC
[PATCH] threadproc/unix/thread.c compile failure
in trunk Revision 418351 introduced a pthread_yield() call, on zOS, however
pthread_yield has to be passed in a null arg, i.e. pthread_yield(NULL)
I've added further checking to 418351's patch to do a
APR_TRY_COMPILE_NO_WARNING, to see if pthread_yield needs be called with ()
or (NULL) args. Patch let zOS and linux compile correctly, but
didn't try other platforms.
These comments in apr_common.m4 got me if its safe though:
dnl APR_TRY_COMPILE_NO_WARNING(INCLUDES, FUNCTION-BODY,
dnl [ACTIONS-IF-NO-WARNINGS], [ACTIONS-IF-WARNINGS])
dnl
dnl Tries a compile test with warnings activated so that the result
dnl is false if the code doesn't compile cleanly. For compilers
dnl where it is not known how to activate a "fail-on-error" mode,
dnl it is undefined which of the sets of actions will be run.
so is patch below good enough, or do I need to be safer, ex:
ac_try_compile of pthread_yield() if works -> has_null_arg =no
else apr_try_compile_no_warningsof pthread_yield(0) if works ->
has_null_arg =yes
else has_null_arg = no
(or i could punt and add -DPTHREAD_YIELD_HAS_NULL_ARG to os390 leg in
apr_hints.m4)
Index: configure.in
===================================================================
--- configure.in (revision 594913)
+++ configure.in (working copy)
@@ -674,6 +674,14 @@
dnl ----------------------------- Checking for sched_yield
AC_CHECK_HEADERS([sched.h])
AC_CHECK_FUNCS([sched_yield])
+ else
+ AC_CACHE_CHECK([for pthread_yield args],
[apr_cv_pthread_yield_has_null_arg],
+ APR_TRY_COMPILE_NO_WARNING([#include <pthread.h>],
+ [pthread_yield(0);],
+ [apr_cv_pthread_yield_has_null_arg=yes],
[apr_cv_pthread_yield_has_null_arg=no]))
+ if test "$apr_cv_pthread_yield_has_null_arg" = "yes"; then
+ AC_DEFINE(PTHREAD_YIELD_HAS_NULL_ARG, 1, [Define if
pthread_yield has a NULL arg])
+ fi
fi
fi
fi
Index: threadproc/unix/thread.c
===================================================================
--- threadproc/unix/thread.c (revision 594914)
+++ threadproc/unix/thread.c (working copy)
@@ -251,7 +251,11 @@
APR_DECLARE(void) apr_thread_yield(void)
{
#ifdef HAVE_PTHREAD_YIELD
+#ifdef PTHREAD_YIELD_HAS_NULL_ARG
+ pthread_yield(NULL);
+#else
pthread_yield();
+#endif /* PTHREAD_YIELD_HAS_NULL_ARG */
#else
#ifdef HAVE_SCHED_YIELD
sched_yield();
Re: [PATCH] threadproc/unix/thread.c compile failure
Posted by David Jones <os...@gmail.com>.
we surrender!
Replacing all the zos pthread defines
(PTHREAD_ATTR_SETDETACHSTATE_ARG2_ADDR, PTHREAD_SETS_ERRNO,
PTHREAD_DETACH_ARG1_ADDR and the proposed PTHREAD_YIELD_HAS_NULL_ARG) with
the single HAVE_ZOS_PTHREADS.
Separated into 3 patches:
zos_pthreads.apr12x.patch replaces all zos pthread defines that can be
backported to 1.2.x
zos_pthreads.385523.patch replaces a PTHREAD_SETS_ERRNO introduced in rev
385523 in locks/unix/proc_mutex.c
zos_pthreads.418351.patch adds a ifdef HAVE_ZOS_PTHREADS around the
pthread_yield introduced in rev 418351 in threadproc/unix/thread.c
On Nov 15, 2007 9:29 AM, Joe Orton < jorton@redhat.com> wrote:
> On Wed, Nov 14, 2007 at 11:02:22AM -0500, David Jones wrote:
> > in trunk Revision 418351 introduced a pthread_yield() call, on zOS,
> however
> > pthread_yield has to be passed in a null arg, i.e. pthread_yield(NULL)
> >
> > I've added further checking to 418351's patch to do a
> > APR_TRY_COMPILE_NO_WARNING, to see if pthread_yield needs be called with
> ()
> > or (NULL) args. Patch let zOS and linux compile correctly, but
> > didn't try other platforms.
>
> IMO AC_DEFINE(HAVE_ZOS_PTHREADS) in apr_hints.m4 already and get rid of
> PTHREAD_ATTR_SETDETACHSTATE_ARG2_ADDR, PTHREAD_SETS_ERRNO and
> PTHREAD_DETACH_ARG1_ADDR. Call a spade a spade. These aren't lots of
> ways in which various POSIX implementations might happen to differ, they
> are all factors of *one* implementation which is uniquely non-standard.
>
> joe
>
>
>
Re: [PATCH] threadproc/unix/thread.c compile failure
Posted by Joe Orton <jo...@redhat.com>.
On Wed, Nov 14, 2007 at 11:02:22AM -0500, David Jones wrote:
> in trunk Revision 418351 introduced a pthread_yield() call, on zOS, however
> pthread_yield has to be passed in a null arg, i.e. pthread_yield(NULL)
>
> I've added further checking to 418351's patch to do a
> APR_TRY_COMPILE_NO_WARNING, to see if pthread_yield needs be called with ()
> or (NULL) args. Patch let zOS and linux compile correctly, but
> didn't try other platforms.
IMO AC_DEFINE(HAVE_ZOS_PTHREADS) in apr_hints.m4 already and get rid of
PTHREAD_ATTR_SETDETACHSTATE_ARG2_ADDR, PTHREAD_SETS_ERRNO and
PTHREAD_DETACH_ARG1_ADDR. Call a spade a spade. These aren't lots of
ways in which various POSIX implementations might happen to differ, they
are all factors of *one* implementation which is uniquely non-standard.
joe