From: Simon Marlow Date: Mon, 5 Mar 2007 14:36:43 +0000 (+0000) Subject: better autoconfery for timer_create() X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=df7dc3fa83d03a0ca903d3cd7d23debe045279cd better autoconfery for timer_create() --- diff --git a/aclocal.m4 b/aclocal.m4 index f908e9f..d7bed9a 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1016,4 +1016,42 @@ ProjectPatchLevel=`echo $ProjectPatchLevel | sed 's/\.//'` AC_SUBST([ProjectPatchLevel]) ])# FP_SETUP_PROJECT_VERSION +AC_DEFUN([FP_CHECK_TIMER_CREATE], + [AC_CACHE_CHECK([for a working timer_create(CLOCK_REALTIME)], + [fptools_cv_timer_create_works], + [AC_TRY_RUN([ +#ifdef HAVE_TIME_H +#include +#endif +#ifdef HAVE_SIGNAL_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +int main(int argc, char *argv[]) +{ +#if HAVE_TIMER_CREATE && HAVE_TIMER_SETTIME + struct sigevent ev; + timer_t timer; + ev.sigev_notify = SIGEV_SIGNAL; + ev.sigev_signo = SIGVTALRM; + if (timer_create(CLOCK_REALTIME, &ev, &timer) != 0) { + exit(1); + } +#else + exit(1) +#endif + exit(0); +} + ], + [fptools_cv_timer_create_works=yes], + [fptools_cv_timer_create_works=no]) + ]) +case $fptools_cv_timer_create_works in + yes) AC_DEFINE([USE_TIMER_CREATE], 1, + [Define to 1 if we can use timer_create(CLOCK_REALTIMER,...)]);; +esac +]) + # LocalWords: fi diff --git a/configure.ac b/configure.ac index fbb9d29..5ce9210 100644 --- a/configure.ac +++ b/configure.ac @@ -1197,6 +1197,7 @@ AC_COMPILE_IFELSE( dnl ** check for librt AC_CHECK_LIB(rt, clock_gettime) AC_CHECK_FUNCS(clock_gettime timer_create timer_settime) +FP_CHECK_TIMER_CREATE dnl ** check for Apple's "interesting" long double compatibility scheme AC_MSG_CHECKING(for printf\$LDBLStub) diff --git a/rts/posix/Itimer.c b/rts/posix/Itimer.c index 8600c0a..c4944aa 100644 --- a/rts/posix/Itimer.c +++ b/rts/posix/Itimer.c @@ -67,9 +67,8 @@ * For now, we're using (1), but this needs a better solution. --SDM */ -#if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME) +#if defined(USE_TIMER_CREATE) -# define USE_TIMER_CREATE # define ITIMER_SIGNAL SIGVTALRM # ifdef THREADED_RTS # define TIMER_FLAVOUR CLOCK_REALTIME @@ -79,7 +78,6 @@ #elif defined(HAVE_SETITIMER) -# define USE_ITIMER # ifdef THREADED_RTS // Oh dear, we have to use SIGALRM if there's no timer_create and // we're using the THREADED_RTS. This leads to problems, see bug #850.