better autoconfery for timer_create()
authorSimon Marlow <simonmar@microsoft.com>
Mon, 5 Mar 2007 14:36:43 +0000 (14:36 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Mon, 5 Mar 2007 14:36:43 +0000 (14:36 +0000)
aclocal.m4
configure.ac
rts/posix/Itimer.c

index f908e9f..d7bed9a 100644 (file)
@@ -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 <time.h>
+#endif
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#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
index fbb9d29..5ce9210 100644 (file)
@@ -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)
index 8600c0a..c4944aa 100644 (file)
@@ -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.