This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: _POSIX_THREADS


----- Original Message -----
From: "Norman Vine" <nhv@cape.com>
To: "'Robert Collins'" <robert.collins@itdomain.com.au>;
<cygwin@cygwin.com>
Sent: Wednesday, March 28, 2001 6:14 AM
Subject: _POSIX_THREADS


> < subject changed from re Python >
>
> Robert Collins writes:
> >
> >Yes but. _POSIX_THREADS should not be defined.
> >*** IMPORTANT: Can you see if you can find where it's getting
defined?
> >*** AFAICT It's only meant to be defined by the system headers to
> >indicate system conformance.
>
> Hmm...   IMHO this is a bit of a chicken egg situation
> _POSIX_THREADS is being set by the Python configure
> mechanism which correctly determines that the system has
> pthread_create() and then, in this case incorrectly, assumes
> that this is a _POSIX_THREADS system

Then, IMO Python is broken. _POSIX_THREADS is _NOT_ a userland symbol.
Lets say for example that linux canbebuilt with or without posix
threads. But the headers that define the prototypes, and the entry
points to the functions are all in glibc. Without replace glibc as well
you might have difficulties turning those prototypes "off". So what you
do is have your kernel headers define _POSIX_THREADS (and a bunch of
related symbols) if you have been built with pthread support.

What Python Should do is test for the #define, not #define it itself. If
the define is missing, it does not imply that pthreads aren't present,
so IMO, it should test _separately_ for the features it needs.

> perhaps we should rename the Cygwin threading module
> cygthread if in fact Cygwin threading is not going to be
> _POSIX_THREADS compliant to avoid this confusion.

No. Python is broken. It's the only thing I've seen that defines
_POSIX_THREADS other than threading libraries.

> To me It seems as if pthread_XXX implies _POSIX_THREADS

No. pthread_XXXX implies some part of _POSIX_THREADS. I'm working on
getting enough conformant functions in place that declaring
_POSIX_THREADS won't confuse everything. At the moment though, newlaib h
as badly broken user space headers for pthreads (ABI wise, not API) -
(hopefully that will get fixed soon).

>
> What actually sets this is the configure test below
> which seems to just work for all other systems.
>
> Cheers
>
> Norman Vine
>
> if test "$with_threads" = "no"
> then
>     USE_THREAD_MODULE="#"
> else
>     if test ! -z "$with_threads" -a -d "$with_threads">

<skip>

this is what glib uses... as you can see it _never_ defines
_POSIX_THREADS. Check /usr/include/pthread.h on any standard
POSIX_THREADS ready machine and it will define _POSIX_THREADS there.

I really don't know what the difficulty is: the expected behaviour is
clear. It's nice to know that Python is broken, but I'm not interested
in breaking Cygwin.

Rob

dnl determination of thread implementation
dnl ***************************************

have_threads=none
if test "x$want_threads" = xyes || test "x$want_threads" = xsolaris;
then
        case $host in
                *-*-solaris*)
                AC_CHECK_LIB(thread, cond_init, have_threads=solaris)
                ;;
        esac
fi
if test "x$want_threads" = xyes || test "x$want_threads" = xposix; then
        if test "x$have_threads" = xnone; then
                AC_CHECK_HEADER(pthread.h, have_threads=posix)
        fi
fi
if test "x$want_threads" = xyes || test "x$want_threads" = xnspr; then
        if test "x$have_threads" = xnone; then
                AC_CHECK_LIB(nspr21, PRP_NewNakedCondVar,
have_threads=nspr)
        fi
fi

AC_MSG_CHECKING(for thread implementation)

if test "x$have_threads" = xnone && test "x$want_threads" != xno; then
        AC_MSG_RESULT(none available)
        AC_MSG_WARN($THREAD_NO_IMPLEMENTATION)
else
        AC_MSG_RESULT($have_threads)
fi

dnl determination of G_THREAD_LIBS
dnl ******************************

G_THREAD_LIBS=
G_THREAD_CFLAGS=

mutex_has_default=no
case $have_threads in
        posix)
                G_THREAD_LIBS=error
                AC_CHECK_LIB(pthread, pthread_attr_init,
                             G_THREAD_LIBS="-lpthread")
                if test "x$G_THREAD_LIBS" = xerror; then
                        AC_CHECK_LIB(pthreads, pthread_attr_init,
                                G_THREAD_LIBS="-lpthreads")
                fi
                if test "x$G_THREAD_LIBS" = xerror; then
                        AC_CHECK_LIB(thread, pthread_attr_init,
                                G_THREAD_LIBS="-lthread")
                fi
                if test "x$G_THREAD_LIBS" = xerror; then
                        AC_CHECK_LIB(c_r, pthread_attr_init,
                                G_THREAD_LIBS="-lc_r")
                fi
                if test "x$G_THREAD_LIBS" = xerror; then
                        AC_CHECK_FUNC(pthread_attr_init,
G_THREAD_LIBS="")
                fi
                dnl ********** DG/UX ************
                if test "x$G_THREAD_LIBS" = xerror; then
                        AC_CHECK_LIB(thread, __d10_pthread_attr_init,
                                G_THREAD_LIBS="-lthread"

G_THREAD_CFLAGS="-D_POSIX4A_DRAFT10_SOURCE")
                fi
                dnl ********* HPUX 11 ***********
                if test "x$G_THREAD_LIBS" = xerror; then
                        AC_CHECK_LIB(pthread,
__pthread_attr_init_system,
                                G_THREAD_LIBS="-lpthread")
                fi
                mutex_has_default=yes
                mutex_default_type='pthread_mutex_t'
                mutex_default_init='PTHREAD_MUTEX_INITIALIZER'
                mutex_header_file='pthread.h'
                g_threads_impl="POSIX"
                ;;
        solaris)
                G_THREAD_LIBS=error
                AC_CHECK_LIB(thread, cond_init,
G_THREAD_LIBS="-lthread")
                mutex_has_default=yes
                mutex_default_type='mutex_t'
                mutex_default_init="DEFAULTMUTEX"
                mutex_header_file='thread.h'
                g_threads_impl="SOLARIS"
                ;;
        nspr)
                AC_CHECK_LIB(nspr21, PRP_NewNakedCondVar,
                             G_THREAD_LIBS="-lnspr21")
                g_threads_impl="NSPR"
                ;;
        none)
                g_threads_impl="NONE"
                ;;
        *)
                g_threads_impl="NONE"
                G_THREAD_LIBS=error
                ;;
esac

if test "x$G_THREAD_LIBS" = xerror; then
        AC_MSG_ERROR($LIBS_NOT_FOUND_1$have_threads$LIBS_NOT_FOUND_2)
fi



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]