Commit f3eddc76 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

More Posix Thread detection.

parent ea3024f1
This diff is collapsed.
......@@ -239,28 +239,97 @@ else
AC_MSG_ERROR(unknown pthread version)
fi
AC_CACHE_CHECK([for LinuxThreads], cf_cv_linux_threads, [
res=`grep Linuxthreads /usr/include/pthread.h 2>/dev/null | wc -l`
if test "$res" -gt 0 ; then
cf_cv_linux_threads=yes
else
cf_cv_linux_threads=no
fi
])
if test $cf_cv_linux_threads = yes ; then
dnl AC_DEFINE(HAVE_LINUX_THREADS,1)
LTHREAD_DEFS="$LTHREAD_DEFS -DHAVE_LINUX_THREADS"
fi
dnl Now the hard part, how to link
AC_CACHE_CHECK([compiler for -pthread option], cf_cv_pthread_flag,[
dnl save the CPPFLAGS
save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-pthread $CPPFLAGS"
AC_TRY_LINK([#include <pthread.h>],[
if(0) pthread_create((pthread_t*) 0,(pthread_attr_t*) 0, 0, 0);
], cf_cv_pthread_flag=yes, cf_cv_pthread_flag=no)
dnl restore the CPPFLAGS
CPPFLAGS=$save_CPPFLAGS
])
dnl A few platforms have pthread support in standard libraries
AC_CHECK_FUNC(pthread_create,pthread_link=yes,pthread_link=no)
if test $pthread_link = no ; then
dnl try -pthread
AC_CACHE_CHECK([for pthread_create with -pthread],
cf_cv_pthread_flag, [
dnl save the CPPFLAGS
save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-pthread $CPPFLAGS"
AC_TRY_LINK([#include <pthread.h>],[
if(0) pthread_create((pthread_t*) 0,
(pthread_attr_t*) 0, 0, 0);
], cf_cv_pthread_flag=yes, cf_cv_pthread_flag=no)
dnl restore the CPPFLAGS
CPPFLAGS=$save_CPPFLAGS
])
if test $cf_cv_pthread_flag = yes ; then
LTHREAD_LIBS="$LTHREAD_LIBS -pthread"
pthread_link=yes
fi
fi
if test $cf_cv_pthread_flag = yes ; then
LTHREAD_LIBS="$LTHREAD_LIBS -pthread"
if test $pthread_link = no ; then
dnl try -lpthread
save_LIBS="$LIBS"
AC_CHECK_LIB(pthread, pthread_create, [
pthread_link=yes
LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"])
LIBS="$save_LIBS"
fi
if test $pthread_link = no ; then
dnl try -lc_r
save_LIBS="$LIBS"
AC_CHECK_LIB(c_r, pthread_create, [
pthread_link=yes
LTHREAD_LIBS="$LTHREAD_LIBS -lc_r"])
LIBS="$save_LIBS"
fi
if test $pthread_link = no ; then
dnl try DEC Threads
save_LIBS="$LIBS"
AC_CHECK_LIB(pthread, pthread_create, [
pthread_link=yes
LTHREAD_DEFS="$LTHREAD_DEFS -DDEC_THREADS"
LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc -lc"],,
[-lmach -lexc -lc])
LIBS="$save_LIBS"
fi
else
LTHREAD_DEFS="-DNO_THREADS"
fi
fi
# check for strtok_r
save_LIBS="$LIBS"
LIBS="$save_LIBS $LTHREAD_LIBS"
AC_CHECK_LIB(pthread,strtok_r)
if test $ac_cv_lib_pthread_strtok_r = no ; then
AC_CHECK_LIB(c_r,strtok_r)
AC_CHECK_FUNCS(strtok_r pthread_init)
if test $ac_cv_lib_c_r_strtok_r = yes ; then
LTHREAD_LIBS="$LTHREAD_LIBS -lc_r"
fi
else
AC_CHECK_FUNCS(strtok_r)
fi
LIBS="$save_LIBS"
ldbm_use="none"
LDBM_DEFS=
......@@ -429,10 +498,11 @@ AC_CHECK_FUNCS( \
strtod \
strtol \
strtoul \
strsep \
memcpy \
)
AC_REPLACE_FUNCS(strdup)
AC_REPLACE_FUNCS(strsep strdup)
dnl ----------------------------------------------------------------
# Check Configuration
......
......@@ -97,6 +97,9 @@
/* Define if you have the mktime function. */
#undef HAVE_MKTIME
/* Define if you have the pthread_init function. */
#undef HAVE_PTHREAD_INIT
/* Define if you have the select function. */
#undef HAVE_SELECT
......@@ -112,12 +115,18 @@
/* Define if you have the strrchr function. */
#undef HAVE_STRRCHR
/* Define if you have the strsep function. */
#undef HAVE_STRSEP
/* Define if you have the strstr function. */
#undef HAVE_STRSTR
/* Define if you have the strtod function. */
#undef HAVE_STRTOD
/* Define if you have the strtok_r function. */
#undef HAVE_STRTOK_R
/* Define if you have the strtol function. */
#undef HAVE_STRTOL
......@@ -178,6 +187,12 @@
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if you have the c_r library (-lc_r). */
#undef HAVE_LIBC_R
/* Define if you have the pthread library (-lpthread). */
#undef HAVE_LIBPTHREAD
#ifdef HAVE_STDDEF_H
# include <stddef.h>
#endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment