Commit df7dc3fa authored by Simon Marlow's avatar Simon Marlow

better autoconfery for timer_create()

parent c559d7b3
......@@ -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
......@@ -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)
......
......@@ -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.
......
Markdown is supported
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