From: mquinson Date: Sat, 27 Oct 2007 13:13:52 +0000 (+0000) Subject: Check for pthread_mutex_timedlock() X-Git-Tag: v3.3~889 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/dffa003b02c6e414b70812cb95cb01d7203233d6 Check for pthread_mutex_timedlock() git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4913 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/configure b/configure index 195849e892..bddc4ec530 100755 --- a/configure +++ b/configure @@ -24633,6 +24633,131 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat >>confdefs.h <<\_ACEOF #define HAVE_SEM_TIMEDWAIT 1 +_ACEOF + + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + fi + fi + + { echo "$as_me:$LINENO: checking for pthread_mutex_timedlock in -lpthread" >&5 +echo $ECHO_N "checking for pthread_mutex_timedlock in -lpthread... $ECHO_C" >&6; } +if test "${ac_cv_lib_pthread_pthread_mutex_timedlock+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_mutex_timedlock (); +int +main () +{ +return pthread_mutex_timedlock (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_pthread_pthread_mutex_timedlock=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_pthread_pthread_mutex_timedlock=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_mutex_timedlock" >&5 +echo "${ECHO_T}$ac_cv_lib_pthread_pthread_mutex_timedlock" >&6; } +if test $ac_cv_lib_pthread_pthread_mutex_timedlock = yes; then + HAVE_MUTEX_TIMEDLOCK=yes +else + HAVE_MUTEX_TIMEDLOCK=no +fi + + if test ${HAVE_MUTEX_TIMEDLOCK} = yes ; then + { echo "$as_me:$LINENO: checking if pthread_mutex_timedlock is compilable" >&5 +echo $ECHO_N "checking if pthread_mutex_timedlock is compilable... $ECHO_C" >&6; } + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +pthread_mutex_t s; const struct timespec t; sem_timedlock(&s, &t); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + HAVE_MUTEX_TIMEDLOCK=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + HAVE_MUTEX_TIMEDLOCK=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test ${HAVE_MUTEX_TIMEDLOCK} = yes ; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_MUTEX_TIMEDLOCK 1 _ACEOF { echo "$as_me:$LINENO: result: yes" >&5 diff --git a/configure.ac b/configure.ac index 1f8e726b50..25a5cbad21 100644 --- a/configure.ac +++ b/configure.ac @@ -105,7 +105,20 @@ if test x$pthread = xyes ; then AC_TRY_COMPILE([#include ], [sem_t *s; const struct timespec * t; sem_timedwait(s, t);], HAVE_SEM_TIMEDWAIT=yes, HAVE_SEM_TIMEDWAIT=no) if test ${HAVE_SEM_TIMEDWAIT} = yes ; then - AC_DEFINE([HAVE_SEM_TIMEDWAIT],1,[Define if the sem_timedwait is avaible or not (part of XPG6 standard only)]) + AC_DEFINE([HAVE_SEM_TIMEDWAIT],1,[Define if sem_timedwait() is avaible or not (part of XPG6 standard only)]) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + fi + + AC_CHECK_LIB(pthread, pthread_mutex_timedlock, HAVE_MUTEX_TIMEDLOCK=yes, HAVE_MUTEX_TIMEDLOCK=no) + if test ${HAVE_MUTEX_TIMEDLOCK} = yes ; then + AC_MSG_CHECKING(if pthread_mutex_timedlock is compilable) + AC_TRY_COMPILE([#include ], + [pthread_mutex_t s; const struct timespec t; sem_timedlock(&s, &t);], HAVE_MUTEX_TIMEDLOCK=yes, HAVE_MUTEX_TIMEDLOCK=no) + if test ${HAVE_MUTEX_TIMEDLOCK} = yes ; then + AC_DEFINE([HAVE_MUTEX_TIMEDLOCK],1,[Define if pthread_mutex_timedlock() is avaible or not (part of XPG6 standard only?)]) AC_MSG_RESULT(yes) else AC_MSG_RESULT(no)