Revamped the thread configure stuff. Now dce threads (old posix draft) are

1999-03-11  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

	* configure.in: Revamped the thread configure stuff. Now dce
	threads (old posix draft) are recogniced. This is necessary,
	because dce threads are in fact working quite differently from
	posix threads. Also changed the conditions for checking for MT
	safe functions a bit, because G_THREADS_IMPL_NONE still have to
	compile thread safe.

	* gthread/gthread-posix.c: Now handle both dce and posix
	threads. They are sufficently equal.

NOTE: Please do not commit my change to
glib-1-2/{acconfig.h,configure.in,config.h.win32} from 1999-03-03, as
the current change will take care of that too.
This commit is contained in:
Sebastian Wilhelmi 1999-03-11 17:38:51 +00:00 committed by Sebastian Wilhelmi
parent fd7ba69e32
commit 4c63008b6c
11 changed files with 171 additions and 56 deletions

View File

@ -1,3 +1,14 @@
1999-03-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Revamped the thread configure stuff. Now dce
threads (old posix draft) are recogniced. This is necessary,
because dce threads are in fact working quite differently from
posix threads. Also changed the conditions for checking for MT
safe functions a bit, because G_THREADS_IMPL_NONE still have to
compile thread safe. NOTE: Please do not commit my change to
glib-1-2/{acconfig.h,configure.in,config.h.win32} from 1999-03-03,
as the current change will take care of that too.
Tue Mar 9 14:37:32 1999 Jeff Garzik <jgarzik@pobox.com>
* Makefile.am, glib.h, gstack.c, gqueue.c,

View File

@ -1,3 +1,14 @@
1999-03-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Revamped the thread configure stuff. Now dce
threads (old posix draft) are recogniced. This is necessary,
because dce threads are in fact working quite differently from
posix threads. Also changed the conditions for checking for MT
safe functions a bit, because G_THREADS_IMPL_NONE still have to
compile thread safe. NOTE: Please do not commit my change to
glib-1-2/{acconfig.h,configure.in,config.h.win32} from 1999-03-03,
as the current change will take care of that too.
Tue Mar 9 14:37:32 1999 Jeff Garzik <jgarzik@pobox.com>
* Makefile.am, glib.h, gstack.c, gqueue.c,

View File

@ -1,3 +1,14 @@
1999-03-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Revamped the thread configure stuff. Now dce
threads (old posix draft) are recogniced. This is necessary,
because dce threads are in fact working quite differently from
posix threads. Also changed the conditions for checking for MT
safe functions a bit, because G_THREADS_IMPL_NONE still have to
compile thread safe. NOTE: Please do not commit my change to
glib-1-2/{acconfig.h,configure.in,config.h.win32} from 1999-03-03,
as the current change will take care of that too.
Tue Mar 9 14:37:32 1999 Jeff Garzik <jgarzik@pobox.com>
* Makefile.am, glib.h, gstack.c, gqueue.c,

View File

@ -1,3 +1,14 @@
1999-03-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Revamped the thread configure stuff. Now dce
threads (old posix draft) are recogniced. This is necessary,
because dce threads are in fact working quite differently from
posix threads. Also changed the conditions for checking for MT
safe functions a bit, because G_THREADS_IMPL_NONE still have to
compile thread safe. NOTE: Please do not commit my change to
glib-1-2/{acconfig.h,configure.in,config.h.win32} from 1999-03-03,
as the current change will take care of that too.
Tue Mar 9 14:37:32 1999 Jeff Garzik <jgarzik@pobox.com>
* Makefile.am, glib.h, gstack.c, gqueue.c,

View File

@ -1,3 +1,14 @@
1999-03-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Revamped the thread configure stuff. Now dce
threads (old posix draft) are recogniced. This is necessary,
because dce threads are in fact working quite differently from
posix threads. Also changed the conditions for checking for MT
safe functions a bit, because G_THREADS_IMPL_NONE still have to
compile thread safe. NOTE: Please do not commit my change to
glib-1-2/{acconfig.h,configure.in,config.h.win32} from 1999-03-03,
as the current change will take care of that too.
Tue Mar 9 14:37:32 1999 Jeff Garzik <jgarzik@pobox.com>
* Makefile.am, glib.h, gstack.c, gqueue.c,

View File

@ -1,3 +1,14 @@
1999-03-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Revamped the thread configure stuff. Now dce
threads (old posix draft) are recogniced. This is necessary,
because dce threads are in fact working quite differently from
posix threads. Also changed the conditions for checking for MT
safe functions a bit, because G_THREADS_IMPL_NONE still have to
compile thread safe. NOTE: Please do not commit my change to
glib-1-2/{acconfig.h,configure.in,config.h.win32} from 1999-03-03,
as the current change will take care of that too.
Tue Mar 9 14:37:32 1999 Jeff Garzik <jgarzik@pobox.com>
* Makefile.am, glib.h, gstack.c, gqueue.c,

View File

@ -1,3 +1,14 @@
1999-03-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Revamped the thread configure stuff. Now dce
threads (old posix draft) are recogniced. This is necessary,
because dce threads are in fact working quite differently from
posix threads. Also changed the conditions for checking for MT
safe functions a bit, because G_THREADS_IMPL_NONE still have to
compile thread safe. NOTE: Please do not commit my change to
glib-1-2/{acconfig.h,configure.in,config.h.win32} from 1999-03-03,
as the current change will take care of that too.
Tue Mar 9 14:37:32 1999 Jeff Garzik <jgarzik@pobox.com>
* Makefile.am, glib.h, gstack.c, gqueue.c,

View File

@ -1,3 +1,14 @@
1999-03-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Revamped the thread configure stuff. Now dce
threads (old posix draft) are recogniced. This is necessary,
because dce threads are in fact working quite differently from
posix threads. Also changed the conditions for checking for MT
safe functions a bit, because G_THREADS_IMPL_NONE still have to
compile thread safe. NOTE: Please do not commit my change to
glib-1-2/{acconfig.h,configure.in,config.h.win32} from 1999-03-03,
as the current change will take care of that too.
Tue Mar 9 14:37:32 1999 Jeff Garzik <jgarzik@pobox.com>
* Makefile.am, glib.h, gstack.c, gqueue.c,

View File

@ -561,7 +561,7 @@ dnl ***********************
dnl *** g_thread checks ***
dnl ***********************
AC_ARG_WITH(threads, [ --with-threads=[none/posix/solaris/nspr] specify a thread implementation to use],
AC_ARG_WITH(threads, [ --with-threads=[none/posix/dce/solaris/nspr] specify a thread implementation to use],
if test "x$with_threads" = x; then
want_threads=yes
else
@ -579,7 +579,7 @@ dnl error and warning message
dnl *************************
THREAD_NO_IMPLEMENTATION="You do not have any known thread system on your
computer. glib will not be thread safe on your computer."
computer. GLib will not have a default thread implementation."
FLAG_DOES_NOT_WORK="I can't find the MACRO, that enables thread safety on your
platform (normaly it's "_REENTRANT"). I'll not use any flag on
@ -612,9 +612,17 @@ if test "x$want_threads" = xyes || test "x$want_threads" = xsolaris; then
;;
esac
fi
if test "x$want_threads" = xyes || test "x$want_threads" = xposix; then
if test "x$want_threads" = xyes || test "x$want_threads" = xposix \
|| test "x$want_threads" = xdce; then
if test "x$have_threads" = xnone; then
AC_CHECK_HEADER(pthread.h, have_threads=posix)
AC_EGREP_HEADER([[^a-zA-Z_]pthread_attr_create[^a-zA-Z_]],
pthread.h,
have_threads=dce)
fi
if test "x$have_threads" = xnone; then
AC_EGREP_HEADER([[^a-zA-Z_]pthread_attr_init[^a-zA-Z_]],
pthread.h,
have_threads=posix)
fi
fi
if test "x$want_threads" = xyes || test "x$want_threads" = xnspr; then
@ -641,37 +649,37 @@ G_THREAD_CFLAGS=
mutex_has_default=no
case $have_threads in
posix)
posix|dce)
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(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
glib_save_LIBS="$LIBS"
for thread_lib in "" pthread pthreads c_r thread; do
# This is not AC_CHECK_LIB to also work with function
# name mangling in header files.
LIBS="$glib_save_LIBS -l$thread_lib"
IN=
test x"$thread_lib" = x || IN=" in -l$thread_lib"
AC_MSG_CHECKING(for pthread_create$IN)
AC_TRY_LINK([#include <pthread.h>],
[pthread_create(NULL,NULL,NULL,NULL)],
[AC_MSG_RESULT(yes)
G_THREAD_LIBS="-l$thread_lib"
break],
[AC_MSG_RESULT(no)])
done
LIBS="$glib_save_LIBS"
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
AC_CHECK_LIB(thread, __d10_pthread_create,
G_THREAD_CFLAGS="-D_POSIX4A_DRAFT10_SOURCE")
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"
if test "x$have_threads" = "xposix"; then
g_threads_impl="POSIX"
else
g_threads_impl="DCE"
have_threads="posix"
fi
;;
solaris)
G_THREAD_LIBS=error
@ -700,14 +708,15 @@ if test "x$G_THREAD_LIBS" = xerror; then
AC_MSG_ERROR($LIBS_NOT_FOUND_1$have_threads$LIBS_NOT_FOUND_2)
fi
AC_MSG_CHECKING(necessary linker options)
AC_MSG_CHECKING(thread related libraries)
AC_MSG_RESULT($G_THREAD_LIBS)
dnl determination of G_THREAD_CFLAGS
dnl ********************************
if test x"$have_threads" != xnone; then
G_THREAD_CFLAGS="$G_THREAD_CFLAGS -D_REENTRANT" # good default guess
if test x"$enable_threads" = xyes; then
G_THREAD_CFLAGS="$G_THREAD_CFLAGS -D_REENTRANT" # good default guess
case $host in
*-aix*)
@ -733,17 +742,17 @@ G_THREAD_CFLAGS="$G_THREAD_CFLAGS -D_REENTRANT" # good default guess
AC_MSG_WARN($FLAG_DOES_NOT_WORK))
CPPFLAGS=$old_CPPFLAGS
AC_MSG_CHECKING(necessary compiler options)
AC_MSG_CHECKING(thread related cflags)
AC_MSG_RESULT($G_THREAD_CFLAGS)
else
G_THREAD_CFLAGS=
fi
dnl check for mt safe function variants
dnl ***********************************
dnl check for mt safe function variants and some posix functions
dnl ************************************************************
if test x"$have_threads" != xnone; then
if test x"$enable_threads" = xyes; then
glib_save_LIBS="$LIBS"
glib_save_CFLAGS="$CFLAGS"
# we are not doing the following for now, as this might require glib
@ -783,20 +792,10 @@ if test x"$have_threads" != xnone; then
AC_DEFINE(HAVE_GETPWUID_R_POSIX)])
fi
fi
if test x"$have_threads" = xposix; then
AC_MSG_CHECKING(whether pthread_getspecific is posix like)
# PCThreads has pthread_getspecific(pthread_key_t, void **);
AC_TRY_COMPILE([#include <pthread.h>],
[pthread_getspecific(0,NULL);],
[AC_MSG_RESULT(no)],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_PTHREAD_GETSPECIFIC_POSIX)])
fi
LIBS="$glib_save_LIBS"
CFLAGS="$glib_save_CFLAGS"
fi
if test "x$enable_threads" = "xyes"; then
# now spit out all the warnings.
if test "$ac_cv_func_getpwuid_r" != "yes"; then
AC_MSG_WARN($FUNC_NO_GETPWUID_R)
fi

View File

@ -1,3 +1,10 @@
1999-03-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread-posix.c: Now handle both dce and posix threads. They are
sufficently equal. Please do not commit my change to
glib-1-2/gthread/gthread-posix.c from 1999-03-03, as the current
change will take care of that too.
1999-02-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* testgthread.c (test_mutexes): Use new signature of

View File

@ -43,10 +43,18 @@
__FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \
g_strerror((num)), #name )
#define posix_check_for_error( what ) G_STMT_START{ \
int error = (what); \
if( error ) { posix_print_error( what, error ); } \
}G_STMT_END
#if defined(G_THREADS_IMPL_POSIX)
# define posix_check_for_error( what ) G_STMT_START{ \
int error = (what); \
if( error ) { posix_print_error( what, error ); } \
}G_STMT_END
#elif defined(G_THREADS_IMPL_DCE)
# define posix_check_for_error( what ) G_STMT_START{ \
if( (what) == -1 ) { posix_print_error( what, errno ); } \
}G_STMT_END
#else /* neither G_THREADS_IMPL_POSIX nor G_THREADS_IMPL_DCE are defined */
# error This should not happen. Contact the GLb team.
#endif
static GMutex *
g_mutex_new_posix_impl (void)
@ -76,8 +84,14 @@ g_mutex_trylock_posix_impl (GMutex * mutex)
int result;
result = pthread_mutex_trylock ((pthread_mutex_t *) mutex);
if (result != EBUSY)
#ifdef G_THREADS_IMPL_POSIX
if (result == EBUSY)
return FALSE;
#else /* G_THREADS_IMPL_DCE */
if (result == 0)
return FALSE;
#endif
posix_check_for_error (result);
return TRUE;
@ -123,7 +137,13 @@ g_cond_timed_wait_posix_impl (GCond * cond,
result = pthread_cond_timedwait ((pthread_cond_t *) cond,
(pthread_mutex_t *) entered_mutex,
&end_time);
#ifdef G_THREADS_IMPL_POSIX
timed_out = (result == ETIMEDOUT);
#else /* G_THREADS_IMPL_DCE */
timed_out = (result == -1) && (errno = EAGAIN);
#endif
if (!timed_out)
posix_check_for_error (result);
return !timed_out;
@ -162,15 +182,16 @@ g_private_get_posix_impl (GPrivate * private_key)
{
if (!private_key)
return NULL;
#ifdef HAVE_PTHREAD_GETSPECIFIC_POSIX
#ifdef G_THREADS_IMPL_POSIX
return pthread_getspecific (*(pthread_key_t *) private_key);
#else /* HAVE_PTHREAD_GETSPECIFIC_POSIX */
#else /* G_THREADS_IMPL_DCE */
{
void* data;
pthread_getspecific (*(pthread_key_t *) private_key, &data);
posix_check_for_error (pthread_getspecific (*(pthread_key_t *)
private_key, &data);
return data;
}
#endif /* HAVE_PTHREAD_GETSPECIFIC_POSIX */
#endif
}
static GThreadFunctions g_thread_functions_for_glib_use_default =