Made the thread flags determination tests first check for the canonical

2002-07-03  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

        * configure.in: Made the thread flags determination tests first
	check for the canonical form -pthread[s], then for other
	possibilities. Also recognize some more platforms. Modeled after
	patch from Miroslaw Dobrzanski-Neumann <mne@mosaic-ag.com>
	(#77981).
This commit is contained in:
Sebastian Wilhelmi
2002-07-03 16:43:22 +00:00
committed by Sebastian Wilhelmi
parent 8f167cbecd
commit 852ed69e87
8 changed files with 178 additions and 89 deletions

View File

@@ -1,9 +1,15 @@
2002-07-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2002-07-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Made the thread flags determination tests first
check for the canonical form -pthread[s], then for other
possibilities. Also recognize some more platforms. Modeled after
patch from Miroslaw Dobrzanski-Neumann <mne@mosaic-ag.com>
(#77981).
* configure.in: Fixed bugs in posix thread priority * configure.in: Fixed bugs in posix thread priority
resolution. Also added AIX priorities. Fix from resolution. Also added AIX priorities. Fix from
Laurent Vivier <Laurent.Vivier@bull.net>. (#82599) Laurent Vivier <Laurent.Vivier@bull.net>. (#82599)
* gthread/gthread-solaris.c: Use thr_min_stack() instead of * gthread/gthread-solaris.c: Use thr_min_stack() instead of
sysconf (_SC_THREAD_STACK_MIN). if stack_size is 0 on entry to sysconf (_SC_THREAD_STACK_MIN). if stack_size is 0 on entry to
g_thread_create_solaris_impl, also pass 0 to thr_create. Otherwise g_thread_create_solaris_impl, also pass 0 to thr_create. Otherwise

View File

@@ -1,9 +1,15 @@
2002-07-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2002-07-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Made the thread flags determination tests first
check for the canonical form -pthread[s], then for other
possibilities. Also recognize some more platforms. Modeled after
patch from Miroslaw Dobrzanski-Neumann <mne@mosaic-ag.com>
(#77981).
* configure.in: Fixed bugs in posix thread priority * configure.in: Fixed bugs in posix thread priority
resolution. Also added AIX priorities. Fix from resolution. Also added AIX priorities. Fix from
Laurent Vivier <Laurent.Vivier@bull.net>. (#82599) Laurent Vivier <Laurent.Vivier@bull.net>. (#82599)
* gthread/gthread-solaris.c: Use thr_min_stack() instead of * gthread/gthread-solaris.c: Use thr_min_stack() instead of
sysconf (_SC_THREAD_STACK_MIN). if stack_size is 0 on entry to sysconf (_SC_THREAD_STACK_MIN). if stack_size is 0 on entry to
g_thread_create_solaris_impl, also pass 0 to thr_create. Otherwise g_thread_create_solaris_impl, also pass 0 to thr_create. Otherwise

View File

@@ -1,9 +1,15 @@
2002-07-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2002-07-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Made the thread flags determination tests first
check for the canonical form -pthread[s], then for other
possibilities. Also recognize some more platforms. Modeled after
patch from Miroslaw Dobrzanski-Neumann <mne@mosaic-ag.com>
(#77981).
* configure.in: Fixed bugs in posix thread priority * configure.in: Fixed bugs in posix thread priority
resolution. Also added AIX priorities. Fix from resolution. Also added AIX priorities. Fix from
Laurent Vivier <Laurent.Vivier@bull.net>. (#82599) Laurent Vivier <Laurent.Vivier@bull.net>. (#82599)
* gthread/gthread-solaris.c: Use thr_min_stack() instead of * gthread/gthread-solaris.c: Use thr_min_stack() instead of
sysconf (_SC_THREAD_STACK_MIN). if stack_size is 0 on entry to sysconf (_SC_THREAD_STACK_MIN). if stack_size is 0 on entry to
g_thread_create_solaris_impl, also pass 0 to thr_create. Otherwise g_thread_create_solaris_impl, also pass 0 to thr_create. Otherwise

View File

@@ -1,9 +1,15 @@
2002-07-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2002-07-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Made the thread flags determination tests first
check for the canonical form -pthread[s], then for other
possibilities. Also recognize some more platforms. Modeled after
patch from Miroslaw Dobrzanski-Neumann <mne@mosaic-ag.com>
(#77981).
* configure.in: Fixed bugs in posix thread priority * configure.in: Fixed bugs in posix thread priority
resolution. Also added AIX priorities. Fix from resolution. Also added AIX priorities. Fix from
Laurent Vivier <Laurent.Vivier@bull.net>. (#82599) Laurent Vivier <Laurent.Vivier@bull.net>. (#82599)
* gthread/gthread-solaris.c: Use thr_min_stack() instead of * gthread/gthread-solaris.c: Use thr_min_stack() instead of
sysconf (_SC_THREAD_STACK_MIN). if stack_size is 0 on entry to sysconf (_SC_THREAD_STACK_MIN). if stack_size is 0 on entry to
g_thread_create_solaris_impl, also pass 0 to thr_create. Otherwise g_thread_create_solaris_impl, also pass 0 to thr_create. Otherwise

View File

@@ -1,9 +1,15 @@
2002-07-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2002-07-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Made the thread flags determination tests first
check for the canonical form -pthread[s], then for other
possibilities. Also recognize some more platforms. Modeled after
patch from Miroslaw Dobrzanski-Neumann <mne@mosaic-ag.com>
(#77981).
* configure.in: Fixed bugs in posix thread priority * configure.in: Fixed bugs in posix thread priority
resolution. Also added AIX priorities. Fix from resolution. Also added AIX priorities. Fix from
Laurent Vivier <Laurent.Vivier@bull.net>. (#82599) Laurent Vivier <Laurent.Vivier@bull.net>. (#82599)
* gthread/gthread-solaris.c: Use thr_min_stack() instead of * gthread/gthread-solaris.c: Use thr_min_stack() instead of
sysconf (_SC_THREAD_STACK_MIN). if stack_size is 0 on entry to sysconf (_SC_THREAD_STACK_MIN). if stack_size is 0 on entry to
g_thread_create_solaris_impl, also pass 0 to thr_create. Otherwise g_thread_create_solaris_impl, also pass 0 to thr_create. Otherwise

View File

@@ -1,9 +1,15 @@
2002-07-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2002-07-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Made the thread flags determination tests first
check for the canonical form -pthread[s], then for other
possibilities. Also recognize some more platforms. Modeled after
patch from Miroslaw Dobrzanski-Neumann <mne@mosaic-ag.com>
(#77981).
* configure.in: Fixed bugs in posix thread priority * configure.in: Fixed bugs in posix thread priority
resolution. Also added AIX priorities. Fix from resolution. Also added AIX priorities. Fix from
Laurent Vivier <Laurent.Vivier@bull.net>. (#82599) Laurent Vivier <Laurent.Vivier@bull.net>. (#82599)
* gthread/gthread-solaris.c: Use thr_min_stack() instead of * gthread/gthread-solaris.c: Use thr_min_stack() instead of
sysconf (_SC_THREAD_STACK_MIN). if stack_size is 0 on entry to sysconf (_SC_THREAD_STACK_MIN). if stack_size is 0 on entry to
g_thread_create_solaris_impl, also pass 0 to thr_create. Otherwise g_thread_create_solaris_impl, also pass 0 to thr_create. Otherwise

View File

@@ -1,9 +1,15 @@
2002-07-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2002-07-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Made the thread flags determination tests first
check for the canonical form -pthread[s], then for other
possibilities. Also recognize some more platforms. Modeled after
patch from Miroslaw Dobrzanski-Neumann <mne@mosaic-ag.com>
(#77981).
* configure.in: Fixed bugs in posix thread priority * configure.in: Fixed bugs in posix thread priority
resolution. Also added AIX priorities. Fix from resolution. Also added AIX priorities. Fix from
Laurent Vivier <Laurent.Vivier@bull.net>. (#82599) Laurent Vivier <Laurent.Vivier@bull.net>. (#82599)
* gthread/gthread-solaris.c: Use thr_min_stack() instead of * gthread/gthread-solaris.c: Use thr_min_stack() instead of
sysconf (_SC_THREAD_STACK_MIN). if stack_size is 0 on entry to sysconf (_SC_THREAD_STACK_MIN). if stack_size is 0 on entry to
g_thread_create_solaris_impl, also pass 0 to thr_create. Otherwise g_thread_create_solaris_impl, also pass 0 to thr_create. Otherwise

View File

@@ -1163,6 +1163,12 @@ POSIX_NO_PRIORITIES="I can not find the minimal and maximal priorities for
priority. If you happen to know these main/max priority. If you happen to know these main/max
priorities, please inform the GLib developers." priorities, please inform the GLib developers."
AIX_COMPILE_INFO="AIX's C compiler needs to be called by a different name, when
linking threaded applications. As GLib cannot do that
automatically, you will get an linkg error everytime you are
not using the right compiler. In that case you have to relink
with the right compiler. Ususally just '_r' is appended
to the compiler name."
dnl determination of thread implementation dnl determination of thread implementation
dnl *************************************** dnl ***************************************
@@ -1228,37 +1234,83 @@ G_THREAD_CFLAGS=
if test x"$have_threads" != xno; then if test x"$have_threads" != xno; then
G_THREAD_CFLAGS="-D_REENTRANT" # good default guess if test x"$have_threads" = xposix; then
# First we test for posix, whether -pthread or -pthreads do the trick as
# both CPPFLAG and LIBS.
# One of them does for most gcc versions and some other platforms/compilers
# too and could be considered as the canonical way to go.
for flag in pthread pthreads; do
glib_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -$flag"
AC_TRY_RUN([#include <pthread.h>
int check_me = 0;
void* func(void* data) {return check_me = 42;}
main()
{ pthread_t t;
void *ret;
pthread_create (&t, 0, func, 0);
pthread_join (t, &ret);
exit (check_me != 42 || ret != 42);
}],
[G_THREAD_CFLAGS=-$flag
G_THREAD_LIBS=-$flag])
CFLAGS="$glib_save_CFLAGS"
done
fi
if test x"$G_THREAD_CFLAGS" = x; then
# The canonical -pthread[s] does not work. Try something different.
case $host in case $host in
*-aix*) *-aix*)
G_THREAD_CFLAGS="$G_THREAD_CFLAGS -D_THREAD_SAFE"
if test x"$GCC" = xyes; then if test x"$GCC" = xyes; then
# GCC 3.0 and above needs -pthread # GCC 3.0 and above needs -pthread.
# Should be coverd by the case above.
# GCC 2.x and below needs -mthreads # GCC 2.x and below needs -mthreads
AC_TRY_COMPILE(,[#if __GNUC__ <= 2 G_THREAD_CFLAGS="-mthreads"
bail out here G_THREAD_LIBS=$G_THREAD_CFLAGS
#endif], else
G_THREAD_CFLAGS="$G_THREAD_CFLAGS -pthread", # We are probably using the aix compiler. Normaly a
G_THREAD_CFLAGS="$G_THREAD_CFLAGS -mthreads") # program would have to be compiled with the _r variant
# of the corresponding compiler, but we as GLib cannot
# do that: but the good news is that for compiling the
# only difference is the added -D_THREAD_SAFE compile
# option. This is according to the "C for AIX User's
# Guide".
G_THREAD_CFLAGS="-D_THREAD_SAFE"
fi fi
;; ;;
*-freebsd2.2*)
G_THREAD_CFLAGS="$G_THREAD_CFLAGS -D_THREAD_SAFE"
# FreeBSD 2.2.x shiped with gcc 2.7.2.x, which doesn't support
# -mthreads flag.
;;
*-sysv5uw7*) # UnixWare 7
if test "$GCC" != "yes"; then
G_THREAD_CFLAGS="$G_THREAD_CFLAGS -Kthread"
else
G_THREAD_CFLAGS="$G_THREAD_CFLAGS -pthread"
fi
;;
*-dg-dgux*) # DG/UX *-dg-dgux*) # DG/UX
G_THREAD_CFLAGS="$G_THREAD_CFLAGS -D_POSIX4A_DRAFT10_SOURCE" G_THREAD_CFLAGS="-D_REENTRANT -D_POSIX4A_DRAFT10_SOURCE"
;;
*-osf*)
# So we are using dce threads. posix threads are already
# catched above.
G_THREAD_CFLAGS="-threads"
G_THREAD_LIBS=$G_THREAD_CFLAGS
;;
*-solaris*)
if test x"$GCC" = xyes; then
# We are using solaris threads. posix threads are
# already catched above.
G_THREAD_CFLAGS="-threads"
else
G_THREAD_CFLAGS="-mt"
fi
G_THREAD_LIBS=$G_THREAD_CFLAGS
;;
*-sysv5uw7*) # UnixWare 7
# We are not using gcc with -pthread. Catched above.
G_THREAD_CFLAGS="-Kthread"
G_THREAD_LIBS=$G_THREAD_CFLAGS
;;
*)
G_THREAD_CFLAGS="-D_REENTRANT" # good default guess otherwise
;;
esac esac
fi
# if we are not finding the localtime_r function, then we probably are # if we are not finding the localtime_r function, then we probably are
# not using the proper multithread flag # not using the proper multithread flag
@@ -1290,25 +1342,19 @@ dnl ******************************
mutex_has_default=no mutex_has_default=no
case $have_threads in case $have_threads in
posix|dce) posix|dce)
glib_save_CPPFLAGS="$CPPFLAGS" if test x"$G_THREAD_LIBS" = x; then
CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES" case $host in
G_THREAD_LIBS=error *-aix*)
glib_save_LIBS="$LIBS" # We are not using gcc (would have set G_THREAD_LIBS) and thus
case $host in # probably using the aix compiler.
*-sysv5uw7*) # UnixWare 7 AC_MSG_WARN($AIX_COMPILE_INFO)
if test "$GCC" != "yes"; then ;;
G_THREAD_LIBS="-Kthread" *)
else glib_save_CPPFLAGS="$CPPFLAGS"
G_THREAD_LIBS="-pthread" CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES"
fi G_THREAD_LIBS=error
;; glib_save_LIBS="$LIBS"
*-*-openbsd* | *-*-freebsd*) for thread_lib in "" pthread pthread32 pthreads thread dce; do
# FreeBSD and OpenBSD want us to use the -pthread flag
# instead of linking to -lc_r and libtool enforces that.
G_THREAD_LIBS="-pthread"
;;
*)
for thread_lib in "" pthread pthread32 pthreads thread dce; do
if test x"$thread_lib" = x; then if test x"$thread_lib" = x; then
add_thread_lib="" add_thread_lib=""
IN="" IN=""
@@ -1340,52 +1386,54 @@ case $have_threads in
break], break],
[AC_MSG_RESULT(no)]) [AC_MSG_RESULT(no)])
done done
if test "x$G_THREAD_LIBS" = xerror; then
AC_MSG_ERROR($LIBS_NOT_FOUND_1$have_threads$LIBS_NOT_FOUND_2)
fi
LIBS="$glib_save_LIBS"
;; ;;
esac esac
if test "x$G_THREAD_LIBS" = xerror; then fi
AC_MSG_ERROR($LIBS_NOT_FOUND_1$have_threads$LIBS_NOT_FOUND_2)
fi glib_save_LIBS="$LIBS"
for thread_lib in "" rt rte; do for thread_lib in "" rt rte; do
if test x"$thread_lib" = x; then if test x"$thread_lib" = x; then
add_thread_lib="" add_thread_lib=""
IN="" IN=""
else else
add_thread_lib="-l$thread_lib" add_thread_lib="-l$thread_lib"
IN=" in -l$thread_lib" IN=" in -l$thread_lib"
fi fi
LIBS="$glib_save_LIBS $add_thread_lib" LIBS="$glib_save_LIBS $add_thread_lib"
AC_MSG_CHECKING(for sched_get_priority_min$IN) AC_MSG_CHECKING(for sched_get_priority_min$IN)
AC_TRY_RUN([#include <sched.h> AC_TRY_RUN([#include <sched.h>
#include <errno.h> #include <errno.h>
int main() { int main() {
errno = 0; errno = 0;
return sched_get_priority_min(SCHED_OTHER)==-1 return sched_get_priority_min(SCHED_OTHER)==-1
&& errno != 0;}], && errno != 0;}],
[AC_MSG_RESULT(yes) [AC_MSG_RESULT(yes)
G_THREAD_LIBS="$G_THREAD_LIBS $add_thread_lib" G_THREAD_LIBS="$G_THREAD_LIBS $add_thread_lib"
posix_priority_min="sched_get_priority_min(SCHED_OTHER)" posix_priority_min="sched_get_priority_min(SCHED_OTHER)"
posix_priority_max="sched_get_priority_max(SCHED_OTHER)" posix_priority_max="sched_get_priority_max(SCHED_OTHER)"
break], break],
[AC_MSG_RESULT(no)]) [AC_MSG_RESULT(no)])
done done
LIBS="$glib_save_LIBS" LIBS="$glib_save_LIBS"
mutex_has_default=yes mutex_has_default=yes
mutex_default_type='pthread_mutex_t' mutex_default_type='pthread_mutex_t'
mutex_default_init='PTHREAD_MUTEX_INITIALIZER' mutex_default_init='PTHREAD_MUTEX_INITIALIZER'
mutex_header_file='pthread.h' mutex_header_file='pthread.h'
if test "x$have_threads" = "xposix"; then if test "x$have_threads" = "xposix"; then
g_threads_impl="POSIX" g_threads_impl="POSIX"
else else
g_threads_impl="DCE" g_threads_impl="DCE"
have_threads="posix" have_threads="posix"
fi fi
AC_SUBST(GTHREAD_COMPILE_IMPL_DEFINES) AC_SUBST(GTHREAD_COMPILE_IMPL_DEFINES)
CPPFLAGS="$glib_save_CPPFLAGS" CPPFLAGS="$glib_save_CPPFLAGS"
;; ;;
solaris) solaris)
G_THREAD_LIBS=error
AC_CHECK_LIB(thread, cond_init, G_THREAD_LIBS="-lthread")
mutex_has_default=yes mutex_has_default=yes
mutex_default_type='mutex_t' mutex_default_type='mutex_t'
mutex_default_init="DEFAULTMUTEX" mutex_default_init="DEFAULTMUTEX"
@@ -1394,7 +1442,6 @@ case $have_threads in
;; ;;
win32) win32)
g_threads_impl="WIN32" g_threads_impl="WIN32"
G_THREAD_LIBS=""
;; ;;
none|no) none|no)
g_threads_impl="NONE" g_threads_impl="NONE"