diff options
author | Austin Seipp <austin@well-typed.com> | 2015-04-14 01:12:09 -0500 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2015-04-14 01:18:54 -0500 |
commit | edc059a425068f9bf4a60520e8d8906bc764e2b5 (patch) | |
tree | 016e37e356489dac6babf1eabfe4ddfe3f7f275e /aclocal.m4 | |
parent | 485dba86d2519cc4855e01db279e127d0221f88a (diff) | |
download | haskell-edc059a425068f9bf4a60520e8d8906bc764e2b5.tar.gz |
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
Diffstat (limited to 'aclocal.m4')
-rw-r--r-- | aclocal.m4 | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/aclocal.m4 b/aclocal.m4 index 226e15aec5..33a51badbb 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 |