mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-18 11:05:48 +08:00
New pthread_try_link test. Looks for pthread_create and pthread_detach
and, if LinuxThreads, pthread_kill_other_threads_np().
This commit is contained in:
parent
30cdbc7657
commit
404f953ef0
@ -472,8 +472,48 @@ AC_DEFUN([OL_POSIX_THREAD_VERSION],
|
||||
])
|
||||
])dnl
|
||||
dnl
|
||||
dnl --------------------------------------------------------------------
|
||||
AC_DEFUN([OL_PTHREAD_TRY_LINK], [# Pthread try link: $1 ($2)
|
||||
if test "$ol_link_threads" = no ; then
|
||||
# try $1
|
||||
AC_CACHE_CHECK([for pthread link with $1], [$2], [
|
||||
# save the flags
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$1 $LIBS"
|
||||
|
||||
AC_TRY_LINK([
|
||||
#include <pthread.h>
|
||||
#ifndef NULL
|
||||
#define NULL (void*)0
|
||||
#endif
|
||||
],[
|
||||
pthread_t t;
|
||||
|
||||
#if HAVE_PTHREADS_D4
|
||||
pthread_create(&t, pthread_attr_default, NULL, NULL);
|
||||
pthread_detach( &t );
|
||||
#else
|
||||
pthread_create(&t, NULL, NULL, NULL);
|
||||
pthread_detach( t );
|
||||
#endif
|
||||
#ifdef HAVE_LINUX_THREADS
|
||||
pthread_kill_other_threads_np();
|
||||
#endif
|
||||
], [$2=yes], [$2=no])
|
||||
|
||||
# restore the LIBS
|
||||
LIBS="$save_LIBS"
|
||||
])
|
||||
|
||||
if test $$2 = yes ; then
|
||||
ol_link_pthreads="$1"
|
||||
ol_link_threads=posix
|
||||
fi
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl ====================================================================
|
||||
dnl Check LinuxThread Header
|
||||
dnl Check LinuxThreads Header
|
||||
dnl
|
||||
dnl defines ol_cv_header linux_threads to 'yes' or 'no'
|
||||
dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
|
||||
@ -482,19 +522,21 @@ dnl checked.
|
||||
dnl
|
||||
AC_DEFUN([OL_HEADER_LINUX_THREADS], [
|
||||
AC_CACHE_CHECK([for LinuxThreads pthread.h],
|
||||
[ol_cv_header_linux_threads],
|
||||
[
|
||||
AC_EGREP_CPP(pthread_kill_other_threads_np,
|
||||
[#include <pthread.h>],
|
||||
[ol_cv_header_linux_threads=yes],
|
||||
[ol_cv_header_linux_threads=no])
|
||||
])])dnl
|
||||
dnl
|
||||
[ol_cv_header_linux_threads],
|
||||
[AC_EGREP_CPP(pthread_kill_other_threads_np,
|
||||
[#include <pthread.h>],
|
||||
[ol_cv_header_linux_threads=yes],
|
||||
[ol_cv_header_linux_threads=no])
|
||||
])
|
||||
if test $ol_cv_header_linux_threads = yes; then
|
||||
AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
|
||||
fi
|
||||
])dnl
|
||||
dnl --------------------------------------------------------------------
|
||||
dnl Check LinuxThread Implementation
|
||||
dnl Check LinuxThreads Implementation
|
||||
dnl
|
||||
dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
|
||||
dnl 'no' implies pthreads implementation is not LinuxThreads.
|
||||
dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
|
||||
dnl 'no' implies pthreads implementation is not LinuxThreads.
|
||||
dnl
|
||||
AC_DEFUN([OL_SYS_LINUX_THREADS], [
|
||||
AC_CHECK_FUNC(pthread_kill_other_threads_np)
|
||||
@ -504,25 +546,21 @@ AC_DEFUN([OL_SYS_LINUX_THREADS], [
|
||||
])dnl
|
||||
dnl
|
||||
dnl --------------------------------------------------------------------
|
||||
dnl
|
||||
dnl Check LinuxThreads consistency
|
||||
AC_DEFUN([OL_LINUX_THREADS], [
|
||||
AC_REQUIRE([OL_HEADER_LINUX_THREADS])
|
||||
AC_REQUIRE([OL_SYS_LINUX_THREADS])
|
||||
AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
|
||||
if test $ol_cv_header_linux_threads = yes -a \
|
||||
$ol_cv_sys_linux_threads = yes; then
|
||||
$ol_cv_sys_linux_threads = yes; then
|
||||
ol_cv_linux_threads=yes
|
||||
elif test $ol_cv_header_linux_threads = no -a \
|
||||
$ol_cv_sys_linux_threads = no; then
|
||||
elif test $ol_cv_header_linux_threads = no -a \
|
||||
$ol_cv_sys_linux_threads = no; then
|
||||
ol_cv_linux_threads=no
|
||||
else
|
||||
else
|
||||
ol_cv_linux_threads=error
|
||||
fi
|
||||
fi
|
||||
])
|
||||
if test $ol_cv_linux_threads = yes; then
|
||||
AC_DEFINE(HAVE_LINUX_THREADS,1,
|
||||
[define if you have LinuxThreads])
|
||||
fi
|
||||
])dnl
|
||||
dnl
|
||||
dnl ====================================================================
|
||||
|
280
configure.in
280
configure.in
@ -672,265 +672,45 @@ int main(argc, argv)
|
||||
|
||||
if test $ol_cv_pthread_create != no ; then
|
||||
ol_link_threads=posix
|
||||
ol_link_pthreads=""
|
||||
fi
|
||||
|
||||
OL_PTHREAD_TRY_LINK([-mt], [ol_cv_pthread_mt])
|
||||
OL_PTHREAD_TRY_LINK([-kthread], [ol_cv_pthread_kthread])
|
||||
OL_PTHREAD_TRY_LINK([-pthread], [ol_cv_pthread_pthread])
|
||||
OL_PTHREAD_TRY_LINK([-pthreads],[ol_cv_pthread_pthreads])
|
||||
OL_PTHREAD_TRY_LINK([-thread], [ol_cv_pthread_thread])
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try -mt
|
||||
AC_CACHE_CHECK([for pthread_create with -mt],
|
||||
[ol_cv_pthread_mt_flag], [
|
||||
dnl save the flags
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="-mt $LIBS"
|
||||
AC_TRY_LINK([char pthread_create();],
|
||||
[pthread_create();],
|
||||
[ol_cv_pthread_mt_flag=yes], [ol_cv_pthread_mt_flag=no])
|
||||
dnl restore the LIBS
|
||||
LIBS="$save_LIBS"
|
||||
])
|
||||
OL_PTHREAD_TRY_LINK([-lpthread -lmach -lexc -lc_r],
|
||||
[ol_cv_pthread_lpthread_lmach_lexc_lc_r])
|
||||
OL_PTHREAD_TRY_LINK([-lpthread -lmach -lexc],
|
||||
[ol_cv_pthread_lpthread_lmach_lexc])
|
||||
OL_PTHREAD_TRY_LINK([-lpthread -lexc],
|
||||
[ol_cv_pthread_lpthread_lexc])
|
||||
|
||||
if test $ol_cv_pthread_mt_flag = yes ; then
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -mt"
|
||||
ol_link_threads=posix
|
||||
fi
|
||||
fi
|
||||
OL_PTHREAD_TRY_LINK([-lpthread -Wl,-woff,85],
|
||||
[ol_cv_pthread_lib_lpthread_woff])
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try -kthread
|
||||
AC_CACHE_CHECK([for pthread_create with -kthread],
|
||||
[ol_cv_kthread_flag], [
|
||||
dnl save the flags
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="-kthread $LIBS"
|
||||
AC_TRY_LINK([#include <pthread.h>],[
|
||||
#if HAVE_PTHREADS_D4
|
||||
pthread_create(NULL,pthread_attr_default,NULL,NULL);
|
||||
#else
|
||||
pthread_t t;
|
||||
pthread_create(&t,NULL,NULL,NULL);
|
||||
pthread_detach(t);
|
||||
#endif
|
||||
],
|
||||
[ol_cv_kthread_flag=yes], [ol_cv_kthread_flag=no])
|
||||
dnl restore the LIBS
|
||||
LIBS="$save_LIBS"
|
||||
])
|
||||
OL_PTHREAD_TRY_LINK([-lpthread],[ol_cv_pthread_lpthread])
|
||||
OL_PTHREAD_TRY_LINK([-lc_r], [ol_cv_pthread_lc_r])
|
||||
|
||||
if test $ol_cv_kthread_flag = yes ; then
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -kthread"
|
||||
ol_link_threads=posix
|
||||
fi
|
||||
fi
|
||||
OL_PTHREAD_TRY_LINK([-threads], [ol_cv_pthread_pthread])
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try -pthread
|
||||
AC_CACHE_CHECK([for pthread_create with -pthread],
|
||||
[ol_cv_pthread_flag], [
|
||||
dnl save the flags
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="-pthread $LIBS"
|
||||
AC_TRY_LINK([#include <pthread.h>],[
|
||||
#if HAVE_PTHREADS_D4
|
||||
pthread_create(NULL,pthread_attr_default,NULL,NULL);
|
||||
#else
|
||||
pthread_create(NULL,NULL,NULL,NULL);
|
||||
#endif
|
||||
],
|
||||
[ol_cv_pthread_flag=yes], [ol_cv_pthread_flag=no])
|
||||
dnl restore the LIBS
|
||||
LIBS="$save_LIBS"
|
||||
])
|
||||
OL_PTHREAD_TRY_LINK([-lpthreads -lmach -lexc -lc_r],
|
||||
[ol_cv_pthread_lpthreads_lmach_lexc_lc_r])
|
||||
OL_PTHREAD_TRY_LINK([-lpthreads -lmach -lexc],
|
||||
[ol_cv_pthread_lpthreads_lmach_lexc])
|
||||
OL_PTHREAD_TRY_LINK([-lpthreads -lexc],
|
||||
[ol_cv_pthread_lpthreads_lexc])
|
||||
|
||||
if test $ol_cv_pthread_flag = yes ; then
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -pthread"
|
||||
ol_link_threads=posix
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try -pthreads
|
||||
AC_CACHE_CHECK([for pthread_create with -pthreads],
|
||||
[ol_cv_pthreads_flag], [
|
||||
dnl save the flags
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="-pthreads $LIBS"
|
||||
AC_TRY_LINK([#include <pthread.h>],[
|
||||
#if HAVE_PTHREADS_D4
|
||||
pthread_create(NULL,pthread_attr_default,NULL,NULL);
|
||||
#else
|
||||
pthread_create(NULL,NULL,NULL,NULL);
|
||||
#endif
|
||||
],
|
||||
[ol_cv_pthreads_flag=yes], [ol_cv_pthreads_flag=no])
|
||||
dnl restore the LIBS
|
||||
LIBS="$save_LIBS"
|
||||
])
|
||||
|
||||
if test $ol_cv_pthreads_flag = yes ; then
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -pthreads"
|
||||
ol_link_threads=posix
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try -thread
|
||||
AC_CACHE_CHECK([for pthread_create with -thread],
|
||||
[ol_cv_thread_flag], [
|
||||
dnl save the flags
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="-thread $LIBS"
|
||||
AC_TRY_LINK([char pthread_create();],
|
||||
[pthread_create();],
|
||||
[ol_cv_thread_flag=yes], [ol_cv_thread_flag=no])
|
||||
dnl restore the LIBS
|
||||
LIBS="$save_LIBS"
|
||||
])
|
||||
|
||||
if test $ol_cv_thread_flag = yes ; then
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -thread"
|
||||
ol_link_threads=posix
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try DEC Threads -lpthread -lmach -lexc -lc_r
|
||||
save_LIBS="$LIBS"
|
||||
AC_CHECK_LIB(pthread, pthread_mutex_unlock, [
|
||||
ol_link_threads=posix
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc -lc_r"
|
||||
dnl if test $ol_with_yielding_select = auto ; then
|
||||
dnl ol_with_yielding_select=yes
|
||||
dnl fi
|
||||
],:,[-lmach -lexc -lc_r])
|
||||
LIBS="$save_LIBS"
|
||||
fi
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try DEC Threads -lpthread -lmach -lexc
|
||||
save_LIBS="$LIBS"
|
||||
AC_CHECK_LIB(pthread, pthread_mutex_lock, [
|
||||
ol_link_threads=posix
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc"
|
||||
dnl if test $ol_with_yielding_select = auto ; then
|
||||
dnl ol_with_yielding_select=yes
|
||||
dnl fi
|
||||
],:,[-lmach -lexc])
|
||||
LIBS="$save_LIBS"
|
||||
fi
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try DEC Threads -lpthread -lexc
|
||||
save_LIBS="$LIBS"
|
||||
AC_CHECK_LIB(pthread, pthread_mutex_trylock, [
|
||||
ol_link_threads=posix
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lexc"
|
||||
dnl if test $ol_with_yielding_select = auto ; then
|
||||
dnl ol_with_yielding_select=yes
|
||||
dnl fi
|
||||
],:,[-lexc])
|
||||
LIBS="$save_LIBS"
|
||||
fi
|
||||
|
||||
dnl IRIX Pthread check
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try IRIX Pthreads -Wl,-woff,85 -lpthread
|
||||
save_LIBS="$LIBS"
|
||||
AC_CHECK_LIB(pthread, pthread_join, [
|
||||
ol_link_threads=posix
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"
|
||||
],:,[-Wl,-woff,85])
|
||||
LIBS="$save_LIBS"
|
||||
fi
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try -lpthread
|
||||
save_LIBS="$LIBS"
|
||||
AC_CHECK_LIB(pthread, pthread_create, [
|
||||
ol_link_threads=posix
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"],:)
|
||||
LIBS="$save_LIBS"
|
||||
fi
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try -lc_r
|
||||
save_LIBS="$LIBS"
|
||||
AC_CHECK_LIB(c_r, pthread_create, [
|
||||
ol_link_threads=posix
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -lc_r"],:)
|
||||
LIBS="$save_LIBS"
|
||||
fi
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try -threads
|
||||
AC_CACHE_CHECK([for pthread_create with -threads],
|
||||
[ol_cv_threads_flag], [
|
||||
dnl save the flags
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="-threads $LIBS"
|
||||
AC_TRY_LINK([char pthread_create();],[
|
||||
pthread_create();
|
||||
], ol_cv_threads_flag=yes, ol_cv_threads_flag=no)
|
||||
dnl restore the LIBS
|
||||
LIBS="$save_LIBS"
|
||||
])
|
||||
|
||||
if test $ol_cv_threads_flag = yes ; then
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -threads"
|
||||
ol_link_threads=posix
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try DEC Threads -lpthreads -lmach -lexc -lc_r
|
||||
save_LIBS="$LIBS"
|
||||
AC_CHECK_LIB(pthreads, pthread_mutex_unlock, [
|
||||
ol_link_threads=posix
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads -lmach -lexc -lc_r"
|
||||
dnl if test $ol_with_yielding_select = auto ; then
|
||||
dnl ol_with_yielding_select=yes
|
||||
dnl fi
|
||||
],:,[-lmach -lexc -lc_r])
|
||||
LIBS="$save_LIBS"
|
||||
fi
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try DEC Threads -lpthreads -lmach -lexc
|
||||
save_LIBS="$LIBS"
|
||||
AC_CHECK_LIB(pthreads, pthread_mutex_lock, [
|
||||
ol_link_threads=posix
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads -lmach -lexc"
|
||||
dnl if test $ol_with_yielding_select = auto ; then
|
||||
dnl ol_with_yielding_select=yes
|
||||
dnl fi
|
||||
],:,[-lmach -lexc])
|
||||
LIBS="$save_LIBS"
|
||||
fi
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try DEC Threads -lpthreads -lexc
|
||||
save_LIBS="$LIBS"
|
||||
AC_CHECK_LIB(pthreads, pthread_mutex_trylock, [
|
||||
ol_link_threads=posix
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads -lexc"
|
||||
dnl if test $ol_with_yielding_select = auto ; then
|
||||
dnl ol_with_yielding_select=yes
|
||||
dnl fi
|
||||
],:,[-lexc])
|
||||
LIBS="$save_LIBS"
|
||||
fi
|
||||
|
||||
if test $ol_link_threads = no ; then
|
||||
dnl try -lpthreads
|
||||
save_LIBS="$LIBS"
|
||||
AC_CHECK_LIB(pthreads, pthread_create, [
|
||||
ol_link_threads=posix
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads"],:)
|
||||
LIBS="$save_LIBS"
|
||||
fi
|
||||
OL_PTHREAD_TRY_LINK([-lpthreads], [ol_cv_pthread_lib_lpthreads])
|
||||
|
||||
if test $ol_link_threads != no ; then
|
||||
AC_DEFINE(HAVE_PTHREADS,1,
|
||||
[define if you have POSIX Threads])
|
||||
|
||||
LTHREAD_LIBS="$LTHREAD_LIBS $ol_link_pthreads"
|
||||
|
||||
dnl save flags
|
||||
save_CPPFLAGS="$CPPFLAGS"
|
||||
save_LIBS="$LIBS"
|
||||
@ -999,8 +779,8 @@ dnl fi
|
||||
OL_SYS_LINUX_THREADS
|
||||
OL_LINUX_THREADS
|
||||
|
||||
if test $ol_cv_linux_threads = error ; then
|
||||
AC_MSG_ERROR([LinuxThreads header/library mismatch])
|
||||
if test $ol_cv_linux_threads = error; then
|
||||
AC_MSG_ERROR([LinuxThreads header/library mismatch]);
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([if pthread_create() works])
|
||||
@ -1242,7 +1022,7 @@ if test $ol_with_threads = manual ; then
|
||||
|
||||
AC_CHECK_HEADERS(pthread.h sched.h)
|
||||
AC_CHECK_FUNCS(sched_yield pthread_yield)
|
||||
OL_LINUX_THREADS
|
||||
OL_HEADER_LINUX_THREADS
|
||||
|
||||
AC_CHECK_HEADERS(mach/cthreads.h)
|
||||
AC_CHECK_HEADERS(lwp/lwp.h)
|
||||
|
@ -627,15 +627,15 @@
|
||||
/* define if pthreads API compatible with draft4 spec */
|
||||
#undef HAVE_PTHREADS_D4
|
||||
|
||||
/* if you have LinuxThreads */
|
||||
#undef HAVE_LINUX_THREADS
|
||||
|
||||
/* define if you have POSIX Threads */
|
||||
#undef HAVE_PTHREADS
|
||||
|
||||
/* define if you have pthread_detach function */
|
||||
#undef HAVE_PTHREAD_DETACH
|
||||
|
||||
/* define if you have LinuxThreads */
|
||||
#undef HAVE_LINUX_THREADS
|
||||
|
||||
/* define if you have Mach Cthreads */
|
||||
#undef HAVE_MACH_CTHREADS
|
||||
|
||||
@ -648,7 +648,7 @@
|
||||
/* define if select implicitly yields */
|
||||
#undef HAVE_YIELDING_SELECT
|
||||
|
||||
/* define if you have LinuxThreads */
|
||||
/* if you have LinuxThreads */
|
||||
#undef HAVE_LINUX_THREADS
|
||||
|
||||
/* define if you have (or want) no threads */
|
||||
|
Loading…
Reference in New Issue
Block a user