From 91845adabac1df67950f2abf21a011a4a5ba018d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 5 Mar 1999 16:04:32 +0000 Subject: [PATCH] checks for various thread functions added git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1864 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- configure | 227 +++++++++++++++++++++++++++++++++++++++++++----- configure.in | 51 +++++++---- setup/setup.hin | 10 ++- 3 files changed, 247 insertions(+), 41 deletions(-) diff --git a/configure b/configure index e41285f5be..377258541f 100755 --- a/configure +++ b/configure @@ -6346,7 +6346,7 @@ EOF fi if test "$USE_LINUX" = 1; then - echo $ac_n "checking for gettext in -lc""... $ac_c" 1>&6 + echo $ac_n "checking for gettext in -lc""... $ac_c" 1>&6 echo "configure:6351: checking for gettext in -lc" >&5 ac_lib_var=`echo c'_'gettext | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then @@ -7264,11 +7264,11 @@ fi + THREADS_LINK="" UNIX_THREAD="" if test "$wxUSE_THREADS" = "1"; then - echo $ac_n "checking for pthread_create in -lpthread-0.7""... $ac_c" 1>&6 echo "configure:7275: checking for pthread_create in -lpthread-0.7" >&5 @@ -7307,7 +7307,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 UNIX_THREAD="gtk/threadpsx.cpp" - THREADS_LINK="-lpthread-0.7" + THREADS_LINK="pthread-0.7" else echo "$ac_t""no" 1>&6 @@ -7386,7 +7386,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 UNIX_THREAD="gtk/threadpsx.cpp" - THREADS_LINK="-lpthread" + THREADS_LINK="pthread" else echo "$ac_t""no" 1>&6 @@ -7434,7 +7434,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 UNIX_THREAD="gtk/threadpsx.cpp" - THREADS_LINK="-lc_r" + THREADS_LINK="c_r" else echo "$ac_t""no" 1>&6 @@ -7448,29 +7448,39 @@ fi EOF fi +fi - - echo $ac_n "checking for printf in -lposix4""... $ac_c" 1>&6 -echo "configure:7455: checking for printf in -lposix4" >&5 -ac_lib_var=`echo posix4'_'printf | sed 'y%./+-%__p_%'` +if test "$wxUSE_MOTIF" = "1"; then + UNIX_THREAD="motif/thread.cpp" +fi + +if test -z "$UNIX_THREAD"; then + wxUSE_THREADS=0 +fi + +if test "$wxUSE_THREADS" = "1"; then + THREADS_LINK2="" + echo $ac_n "checking for sched_yield in -l$THREADS_LINK""... $ac_c" 1>&6 +echo "configure:7465: checking for sched_yield in -l$THREADS_LINK" >&5 +ac_lib_var=`echo $THREADS_LINK'_'sched_yield | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" -LIBS="-lposix4 $LIBS" +LIBS="-l$THREADS_LINK $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:7484: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7485,24 +7495,198 @@ LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 - - THREADS_LINK="$THREADS_LINK -lposix4" - + cat >> confdefs.h <<\EOF +#define HAVE_SCHED_YIELD 1 +EOF + else echo "$ac_t""no" 1>&6 +echo $ac_n "checking for sched_yield in -l"posix4"""... $ac_c" 1>&6 +echo "configure:7506: checking for sched_yield in -l"posix4"" >&5 +ac_lib_var=`echo "posix4"'_'sched_yield | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-l"posix4" $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" fi +rm -f conftest* +LIBS="$ac_save_LIBS" +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_SCHED_YIELD 1 +EOF + THREADS_LINK2="-lposix4" +else + echo "$ac_t""no" 1>&6 +echo "configure: warning: wxThread::Yield() will not work properly" 1>&2 + +fi + fi -if test "$wxUSE_MOTIF" = "1"; then - UNIX_THREAD="motif/thread.cpp" + + echo $ac_n "checking for sched_get_priority_min in -l$THREADS_LINK""... $ac_c" 1>&6 +echo "configure:7555: checking for sched_get_priority_min in -l$THREADS_LINK" >&5 +ac_lib_var=`echo $THREADS_LINK'_'sched_get_priority_min | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-l$THREADS_LINK $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" fi +rm -f conftest* +LIBS="$ac_save_LIBS" -if test -z "$UNIX_THREAD"; then - wxUSE_THREADS=0 fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_THREAD_PRIORITY_FUNCTIONS 1 +EOF +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for sched_get_priority_min in -l"posix4"""... $ac_c" 1>&6 +echo "configure:7596: checking for sched_get_priority_min in -l"posix4"" >&5 +ac_lib_var=`echo "posix4"'_'sched_get_priority_min | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-l"posix4" $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_THREAD_PRIORITY_FUNCTIONS 1 +EOF + THREADS_LINK2="-lposix4" +else + echo "$ac_t""no" 1>&6 +echo "configure: warning: Setting thread priority will not work" 1>&2 + +fi + + +fi + + + echo $ac_n "checking for pthread_cancel in -l$THREADS_LINK""... $ac_c" 1>&6 +echo "configure:7645: checking for pthread_cancel in -l$THREADS_LINK" >&5 +ac_lib_var=`echo $THREADS_LINK'_'pthread_cancel | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-l$THREADS_LINK $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_PTHREAD_CANCEL 1 +EOF + +else + echo "$ac_t""no" 1>&6 +echo "configure: warning: wxThread::Kill() will not work properly" 1>&2 +fi + + + THREADS_LINK="-l$THREADS_LINK $THREADS_LINK2" +fi @@ -7511,7 +7695,6 @@ fi PICFLAGS= CREATE_SHARED= case "${canonical}" in - *-hp-hpux* ) if test "$GCC" != "yes" ; then CXXFLAGS="${CXXFLAGS} +a1 -z -Aa -D_HPUX_SOURCE" diff --git a/configure.in b/configure.in index 905a8036fe..30088adaf4 100644 --- a/configure.in +++ b/configure.in @@ -1004,7 +1004,7 @@ dnl ---------------------------------------------------------------- dnl Linux: test for libc5/glibc2: glibc2 has gettext() included dnl ---------------------------------------------------------------- if test "$USE_LINUX" = 1; then - AC_CHECK_LIB(c,gettext,AC_DEFINE(wxHAVE_GLIBC2)) + AC_CHECK_LIB(c,gettext,AC_DEFINE(wxHAVE_GLIBC2)) fi dnl ---------------------------------------------------------------- @@ -1372,16 +1372,19 @@ dnl ---------------------------------------------------------------- dnl thread support dnl ---------------------------------------------------------------- +dnl defines UNIX_THREAD it contains the source file to use for threads. (GL) +dnl defines THREADS_LINK it contains the thread library to link with. (GL) +dnl defines wxUSE_THREADS if thread support is activated. (GL) + THREADS_LINK="" UNIX_THREAD="" if test "$wxUSE_THREADS" = "1"; then - dnl For glibc 2 users who have the old libc 5 too AC_CHECK_LIB(pthread-0.7, pthread_create, [ UNIX_THREAD="gtk/threadpsx.cpp" - THREADS_LINK="-lpthread-0.7" + THREADS_LINK="pthread-0.7" ],[ AC_CHECK_HEADER(sys/prctl.h, [ UNIX_THREAD="gtk/threadsgi.cpp" @@ -1392,7 +1395,7 @@ if test "$wxUSE_THREADS" = "1"; then AC_CHECK_LIB(pthread, pthread_setcanceltype, [ UNIX_THREAD="gtk/threadpsx.cpp" - THREADS_LINK="-lpthread" + THREADS_LINK="pthread" ]) ]) @@ -1401,20 +1404,13 @@ if test "$wxUSE_THREADS" = "1"; then AC_CHECK_LIB(c_r, pthread_create, [ UNIX_THREAD="gtk/threadpsx.cpp" - THREADS_LINK="-lc_r" + THREADS_LINK="c_r" ]) fi if test "$THREADS_LINK" != ""; then AC_DEFINE(wxUSE_THREADS) fi - - dnl -lposix4 seems to be required on Solaris - - AC_CHECK_LIB(posix4, printf, [ - THREADS_LINK="$THREADS_LINK -lposix4" - ]) - fi if test "$wxUSE_MOTIF" = "1"; then @@ -1425,13 +1421,35 @@ if test -z "$UNIX_THREAD"; then wxUSE_THREADS=0 fi +dnl do other tests only if we are using threads +if test "$wxUSE_THREADS" = "1"; then + THREADS_LINK2="" + AC_CHECK_LIB($THREADS_LINK, sched_yield, + AC_DEFINE(HAVE_SCHED_YIELD), + [AC_CHECK_LIB("posix4", sched_yield, + [AC_DEFINE(HAVE_SCHED_YIELD) THREADS_LINK2="-lposix4"], + AC_MSG_WARN(wxThread::Yield() will not work properly) + )] + ) + + AC_CHECK_LIB($THREADS_LINK, sched_get_priority_min, + AC_DEFINE(HAVE_THREAD_PRIORITY_FUNCTIONS), + [AC_CHECK_LIB("posix4", sched_get_priority_min, + [AC_DEFINE(HAVE_THREAD_PRIORITY_FUNCTIONS) THREADS_LINK2="-lposix4"], + AC_MSG_WARN(Setting thread priority will not work) + )] + ) + + AC_CHECK_LIB($THREADS_LINK, pthread_cancel, + AC_DEFINE(HAVE_PTHREAD_CANCEL), + AC_MSG_WARN(wxThread::Kill() will not work properly)) + + THREADS_LINK="-l$THREADS_LINK $THREADS_LINK2" +fi + AC_SUBST(UNIX_THREAD) AC_SUBST(THREADS_LINK) -dnl defines UNIX_THREAD it contains the source file to use for threads. (GL) -dnl defines THREADS_LINK it contains the thread library to link with. (GL) -dnl defines wxUSE_THREADS if thread support is activated. (GL) - dnl ------------------------------------------------------------------------ dnl compiler options for shared libs dnl ------------------------------------------------------------------------ @@ -1439,7 +1457,6 @@ dnl ------------------------------------------------------------------------ PICFLAGS= CREATE_SHARED= case "${canonical}" in - *-hp-hpux* ) if test "$GCC" != "yes" ; then CXXFLAGS="${CXXFLAGS} +a1 -z -Aa -D_HPUX_SOURCE" diff --git a/setup/setup.hin b/setup/setup.hin index 4e03e7f79e..3e81506da5 100644 --- a/setup/setup.hin +++ b/setup/setup.hin @@ -383,8 +383,14 @@ /* Define if you have usleep() */ #undef HAVE_USLEEP -/* Define if you have nanosleep() */ -#undef HAVE_NANOSLEEP +/* Define if you have sched_yield */ +#undef HAVE_SCHED_YIELD + +/* Define if you have pthread_cancel */ +#undef HAVE_PTHREAD_CANCEL + +/* Define if you have all functions to set thread priority */ +#undef HAVE_THREAD_PRIORITY_FUNCTIONS /* Define if your system has its own `getloadavg' function. */ #undef HAVE_GETLOADAVG -- 2.45.2