mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-18 11:05:48 +08:00
New pthread tests...
This commit is contained in:
parent
29274384a3
commit
8f970aa247
@ -528,43 +528,80 @@ 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
|
||||
ol_LIBS="$LIBS"
|
||||
LIBS="$1 $LIBS"
|
||||
|
||||
AC_TRY_LINK([
|
||||
AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
|
||||
[/* pthread test headers */
|
||||
#include <pthread.h>
|
||||
#ifndef NULL
|
||||
#define NULL (void*)0
|
||||
#endif
|
||||
],[
|
||||
pthread_t t;
|
||||
|
||||
static void *task(p)
|
||||
void *p;
|
||||
{
|
||||
return (void *) (p == NULL);
|
||||
}
|
||||
])
|
||||
AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
|
||||
/* pthread test function */
|
||||
pthread_t t;
|
||||
int status;
|
||||
|
||||
/* make sure pthread_create() isn't just a stub */
|
||||
#if HAVE_PTHREADS_D4
|
||||
pthread_create(&t, pthread_attr_default, NULL, NULL);
|
||||
pthread_detach( &t );
|
||||
status = pthread_create(&t, pthread_attr_default, task, NULL);
|
||||
#else
|
||||
pthread_create(&t, NULL, NULL, NULL);
|
||||
pthread_detach( t );
|
||||
status = pthread_create(&t, NULL, task, NULL);
|
||||
#endif
|
||||
|
||||
if( status ) exit( status );
|
||||
|
||||
/* make sure pthread_detach() isn't just a stub */
|
||||
#if HAVE_PTHREADS_D4
|
||||
status = pthread_detach( &t );
|
||||
#else
|
||||
status = pthread_detach( t );
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LINUX_THREADS
|
||||
pthread_kill_other_threads_np();
|
||||
#endif
|
||||
], [$2=yes], [$2=no])
|
||||
|
||||
exit( status );
|
||||
])
|
||||
|
||||
AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
|
||||
[OL_PTHREAD_TEST_INCLUDES
|
||||
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
OL_PTHREAD_TEST_FUNCTION
|
||||
}
|
||||
])
|
||||
dnl --------------------------------------------------------------------
|
||||
AC_DEFUN([OL_PTHREAD_TRY], [# 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
|
||||
ol_LIBS="$LIBS"
|
||||
LIBS="$1 $LIBS"
|
||||
|
||||
AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
|
||||
[$2=yes], [$2=no],
|
||||
[AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
|
||||
[$2=yes], [$2=no])])
|
||||
|
||||
# restore the LIBS
|
||||
LIBS="$ol_LIBS"
|
||||
])
|
||||
])
|
||||
|
||||
if test $$2 = yes ; then
|
||||
ol_link_pthreads="$1"
|
||||
ol_link_threads=posix
|
||||
fi
|
||||
if test $$2 = yes ; then
|
||||
ol_link_pthreads="$1"
|
||||
ol_link_threads=posix
|
||||
fi
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl ====================================================================
|
||||
|
103
configure.in
103
configure.in
@ -944,84 +944,48 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
|
||||
dnl pthread_create in $LIBS
|
||||
AC_CACHE_CHECK([for pthread_create in default libraries],
|
||||
ol_cv_pthread_create,[
|
||||
AC_TRY_RUN([
|
||||
#include <pthread.h>
|
||||
#ifndef NULL
|
||||
#define NULL (void*)0
|
||||
#endif
|
||||
|
||||
static void *task(p)
|
||||
void *p;
|
||||
{
|
||||
return (void *) (p == NULL);
|
||||
}
|
||||
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
pthread_t t;
|
||||
int status;
|
||||
|
||||
/* make sure pthread_create() isn't just a stub */
|
||||
#if HAVE_PTHREADS_D4
|
||||
status = pthread_create(&t, pthread_attr_default, task, NULL);
|
||||
#else
|
||||
status = pthread_create(&t, NULL, task, NULL);
|
||||
#endif
|
||||
|
||||
if( status ) return status;
|
||||
|
||||
/* make sure pthread_detach() isn't just a stub */
|
||||
#if HAVE_PTHREADS_D4
|
||||
status = pthread_detach( &t );
|
||||
#else
|
||||
status = pthread_detach( t );
|
||||
#endif
|
||||
|
||||
return status;
|
||||
}
|
||||
],
|
||||
AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
|
||||
[ol_cv_pthread_create=yes],
|
||||
[ol_cv_pthread_create=no],
|
||||
[dnl assume yes
|
||||
ol_cv_pthread_create=yes])])
|
||||
[AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
|
||||
[ol_cv_pthread_create=yes],
|
||||
[ol_cv_pthread_create=no])])])
|
||||
|
||||
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([-mthreads],[ol_cv_pthread_mthreads])
|
||||
OL_PTHREAD_TRY_LINK([-thread], [ol_cv_pthread_thread])
|
||||
OL_PTHREAD_TRY([-mt], [ol_cv_pthread_mt])
|
||||
OL_PTHREAD_TRY([-kthread], [ol_cv_pthread_kthread])
|
||||
OL_PTHREAD_TRY([-pthread], [ol_cv_pthread_pthread])
|
||||
OL_PTHREAD_TRY([-pthreads], [ol_cv_pthread_pthreads])
|
||||
OL_PTHREAD_TRY([-mthreads], [ol_cv_pthread_mthreads])
|
||||
OL_PTHREAD_TRY([-thread], [ol_cv_pthread_thread])
|
||||
|
||||
OL_PTHREAD_TRY_LINK([-lpthread -lmach -lexc -lc_r],
|
||||
OL_PTHREAD_TRY([-lpthread -lmach -lexc -lc_r],
|
||||
[ol_cv_pthread_lpthread_lmach_lexc_lc_r])
|
||||
OL_PTHREAD_TRY_LINK([-lpthread -lmach -lexc],
|
||||
OL_PTHREAD_TRY([-lpthread -lmach -lexc],
|
||||
[ol_cv_pthread_lpthread_lmach_lexc])
|
||||
dnl OL_PTHREAD_TRY_LINK([-lpthread -lexc],
|
||||
dnl OL_PTHREAD_TRY([-lpthread -lexc],
|
||||
dnl [ol_cv_pthread_lpthread_lexc])
|
||||
|
||||
OL_PTHREAD_TRY_LINK([-lpthread -Wl,-woff,85],
|
||||
OL_PTHREAD_TRY([-lpthread -Wl,-woff,85],
|
||||
[ol_cv_pthread_lib_lpthread_woff])
|
||||
|
||||
OL_PTHREAD_TRY_LINK([-lpthread],[ol_cv_pthread_lpthread])
|
||||
OL_PTHREAD_TRY_LINK([-lc_r], [ol_cv_pthread_lc_r])
|
||||
OL_PTHREAD_TRY([-lpthread], [ol_cv_pthread_lpthread])
|
||||
OL_PTHREAD_TRY([-lc_r], [ol_cv_pthread_lc_r])
|
||||
|
||||
OL_PTHREAD_TRY_LINK([-threads], [ol_cv_pthread_threads])
|
||||
OL_PTHREAD_TRY([-threads], [ol_cv_pthread_threads])
|
||||
|
||||
OL_PTHREAD_TRY_LINK([-lpthreads -lmach -lexc -lc_r],
|
||||
OL_PTHREAD_TRY([-lpthreads -lmach -lexc -lc_r],
|
||||
[ol_cv_pthread_lpthreads_lmach_lexc_lc_r])
|
||||
OL_PTHREAD_TRY_LINK([-lpthreads -lmach -lexc],
|
||||
OL_PTHREAD_TRY([-lpthreads -lmach -lexc],
|
||||
[ol_cv_pthread_lpthreads_lmach_lexc])
|
||||
OL_PTHREAD_TRY_LINK([-lpthreads -lexc],
|
||||
OL_PTHREAD_TRY([-lpthreads -lexc],
|
||||
[ol_cv_pthread_lpthreads_lexc])
|
||||
|
||||
OL_PTHREAD_TRY_LINK([-lpthreads], [ol_cv_pthread_lib_lpthreads])
|
||||
OL_PTHREAD_TRY([-lpthreads],[ol_cv_pthread_lib_lpthreads])
|
||||
|
||||
if test $ol_link_threads != no ; then
|
||||
AC_DEFINE(HAVE_PTHREADS,1,
|
||||
@ -1104,30 +1068,7 @@ dnl [ol_cv_pthread_lpthread_lexc])
|
||||
|
||||
AC_CACHE_CHECK([if pthread_create() works],
|
||||
ol_cv_pthread_create_works,[
|
||||
AC_TRY_RUN([
|
||||
#include <pthread.h>
|
||||
#ifndef NULL
|
||||
#define NULL (void*)0
|
||||
#endif
|
||||
|
||||
static void *task(p)
|
||||
void *p;
|
||||
{
|
||||
return (void *) (p == NULL);
|
||||
}
|
||||
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
pthread_t t;
|
||||
#if HAVE_PTHREADS_D4
|
||||
exit(pthread_create(&t, pthread_attr_default, task, NULL));
|
||||
#else
|
||||
exit(pthread_create(&t, NULL, task, NULL));
|
||||
#endif
|
||||
}
|
||||
],
|
||||
AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
|
||||
[ol_cv_pthread_create_works=yes],
|
||||
[ol_cv_pthread_create_works=no],
|
||||
[dnl assume yes
|
||||
|
Loading…
Reference in New Issue
Block a user