+ glib_save_LIBS="$LIBS"
+ # we are not doing the following for now, as this might require glib
+ # to always be linked with the thread libs on some platforms.
+ # LIBS="$LIBS $G_THREAD_LIBS"
+ AC_CHECK_FUNCS(localtime_r)
+ if test "$ac_cv_header_pwd_h" = "yes"; then
+ AC_MSG_CHECKING([for getpwuid_r])
+ AC_CACHE_VAL(ac_cv_func_getpwuid_r,
+ [AC_TRY_RUN([#include <errno.h>
+ int main () { char buffer[10000], *pointer;
+ char getpwuid_r (long, void*, void*,
+ int, void*);
+ int error;
+ errno = 0;
+ error = getpwuid_r (0, &buffer, &buffer,
+ sizeof (buffer), &pointer);
+ return errno == ENOSYS || error == ENOSYS;}],
+ [ac_cv_func_getpwuid_r=yes],
+ [ac_cv_func_getpwuid_r=no])])
+ if test "$ac_cv_func_getpwuid_r" = yes; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_GETPWUID_R)
+ else
+ AC_MSG_RESULT(no)
+ fi
+ if test "$ac_cv_func_getpwuid_r" = "yes"; then
+ AC_MSG_CHECKING(whether getpwuid_r is posix like)
+ # The signature for the POSIX version is:
+ # int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **)
+ AC_TRY_COMPILE([#include <pwd.h>
+ #include <sys/types.h>
+ #include <stdlib.h>],
+ [getpwuid_r((uid_t)0, NULL, NULL, (size_t)0, NULL);],
+ [AC_DEFINE(HAVE_GETPWUID_R_POSIX)
+ AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)])
+ fi
+ fi
+ LIBS="$LIBS $G_THREAD_LIBS"
+ if test x"$have_threads" = xposix; then
+ glib_save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES"
+ GLIB_SIZEOF([#include <pthread.h>],
+ pthread_t,
+ system_thread)
+ # This is not AC_CHECK_FUNC to also work with function
+ # name mangling in header files.
+ AC_MSG_CHECKING(for pthread_attr_setstacksize)
+ AC_TRY_LINK([#include <pthread.h>],
+ [pthread_attr_t t; pthread_attr_setstacksize(&t,0)],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE)],
+ [AC_MSG_RESULT(no)])
+ AC_MSG_CHECKING(for minimal/maximal thread priority)
+ if test x"$posix_priority_min" = xnone; then
+ AC_EGREP_CPP(PX_PRIO_MIN,[#include <pthread.h>
+ PX_PRIO_MIN],,[
+ posix_priority_min=PX_PRIO_MIN
+ posix_priority_max=PX_PRIO_MAX])
+ fi
+ if test x"$posix_priority_min" = xnone; then
+ AC_EGREP_CPP(PRI_OTHER_MIN,[#include <pthread.h>
+ PRI_OTHER_MIN],,[
+ posix_priority_min=PRI_OTHER_MIN
+ posix_priority_max=PRI_OTHER_MAX])
+ fi
+ if test x"$posix_priority_min" = x; then
+ AC_MSG_RESULT(none found)
+ AC_MSG_WARN($POSIX_NO_PRIORITIES)
+ posix_priority_min=-1
+ posix_priority_max=-1
+ else
+ AC_MSG_RESULT($posix_priority_min/$posix_priority_max)
+ AC_DEFINE_UNQUOTED(POSIX_MIN_PRIORITY,$posix_priority_min)
+ AC_DEFINE_UNQUOTED(POSIX_MAX_PRIORITY,$posix_priority_max)
+ fi
+ posix_yield_func=none
+ AC_MSG_CHECKING(for posix yield function)
+ for yield_func in sched_yield pthread_yield_np pthread_yield \
+ thr_yield; do
+ AC_TRY_LINK([#include <pthread.h>],
+ [$yield_func()],
+ [posix_yield_func="$yield_func"
+ break])
+ done
+ if test x"$posix_yield_func" = xnone; then
+ AC_MSG_RESULT(none found)
+ AC_MSG_WARN($POSIX_NO_YIELD)
+ posix_yield_func="g_usleep(1000)"
+ else
+ AC_MSG_RESULT($posix_yield_func)
+ posix_yield_func="$posix_yield_func()"
+ fi
+ AC_DEFINE_UNQUOTED(POSIX_YIELD_FUNC,$posix_yield_func)
+ CPPFLAGS="$glib_save_CPPFLAGS"
+ else # solaris threads
+ GLIB_SIZEOF([#include <thread.h>],
+ thread_t,
+ system_thread)
+ fi