[commit: ghc] master: Fix autoconf's check for create_timer() (edc059a)
git at git.haskell.org
git at git.haskell.org
Tue Apr 14 06:20:08 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/edc059a425068f9bf4a60520e8d8906bc764e2b5/ghc
>---------------------------------------------------------------
commit edc059a425068f9bf4a60520e8d8906bc764e2b5
Author: Austin Seipp <austin at well-typed.com>
Date: Tue Apr 14 01:12:09 2015 -0500
Fix autoconf's check for create_timer()
GHC build system have custom autoconf check for `create_timer()`
function from librt. Check description says that it checks for
`CLOCK_REALTIME` timer, but checking code also checks for
`CLOCK_PROCESS_CPUTIME_ID` timer, which is not commonly present (for
example, FreeBSD doesn't have it). This makes whole check fail despite
the fact that FreeBSD have `create_timer()` call and supports
`CLOCK_REALTIME`. As a consequence, GHC RTS falls back to using SIGALRM
for its timing machinery. Not only it's very ancient codepath, it also
break some FFI bindings to C code that isn't prepared for syscall
interruption caused by SIGALRM delivery.
Grepping through ghc source code reveals that `USE_TIMER_CREATE`
defininition in the config.h doesn't imply having
`CLOCK_PROCESS_CPUTIME_ID`. The only place where
`CLOCK_PROCESS_CPUTIME_ID` is used is rts/posix/GetTime.c and this code
handles the absence of `CLOCK_PROCESS_CPUTIME_ID` gracefully.
This patch makes autoconf checking code to check only for
`timer_create(CLOCK_REALTIME, ...)` and fixes check description.
Reviewed By: austin
Differential Revision: https://phabricator.haskell.org/D831
>---------------------------------------------------------------
edc059a425068f9bf4a60520e8d8906bc764e2b5
aclocal.m4 | 34 ++--------------------------------
1 file changed, 2 insertions(+), 32 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index 226e15a..33a51ba 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1654,7 +1654,7 @@ then
then
# We can't test timer_create when we're cross-compiling, so we
# optimistiaclly assume that it actually works properly.
- AC_DEFINE([USE_TIMER_CREATE], 1, [Define to 1 if we can use timer_create(CLOCK_PROCESS_CPUTIME_ID,...)])
+ AC_DEFINE([USE_TIMER_CREATE], 1, [Define to 1 if we can use timer_create(CLOCK_REALTIME,...)])
else
AC_CACHE_CHECK([for a working timer_create(CLOCK_REALTIME)],
[fptools_cv_timer_create_works],
@@ -1715,36 +1715,6 @@ int main(int argc, char *argv[])
}
alarm(1);
- if (timer_create(CLOCK_PROCESS_CPUTIME_ID, &ev, &timer) != 0) {
- fprintf(stderr,"No CLOCK_PROCESS_CPUTIME_ID timer\n");
- exit(1);
- }
-
- it.it_value.tv_sec = 0;
- it.it_value.tv_nsec = 1;
- it.it_interval = it.it_value;
- if (timer_settime(timer, 0, &it, NULL) != 0) {
- fprintf(stderr,"settime problem\n");
- exit(4);
- }
-
- tock = 0;
-
- for(n = 3; n < 20000; n++){
- for(m = 2; m <= n/2; m++){
- if (!(n%m)) count++;
- if (tock) goto out;
- }
- }
-out:
-
- if (!tock) {
- fprintf(stderr,"no CLOCK_PROCESS_CPUTIME_ID signal\n");
- exit(5);
- }
-
- timer_delete(timer);
-
if (timer_create(CLOCK_REALTIME, &ev, &timer) != 0) {
fprintf(stderr,"No CLOCK_REALTIME timer\n");
exit(2);
@@ -1777,7 +1747,7 @@ out:
])
case $fptools_cv_timer_create_works in
yes) AC_DEFINE([USE_TIMER_CREATE], 1,
- [Define to 1 if we can use timer_create(CLOCK_PROCESS_CPUTIME_ID,...)]);;
+ [Define to 1 if we can use timer_create(CLOCK_REALTIME,...)]);;
esac
fi
fi
More information about the ghc-commits
mailing list