diff options
author | Rickard Green <rickard@erlang.org> | 2022-03-26 15:36:49 +0100 |
---|---|---|
committer | Rickard Green <rickard@erlang.org> | 2022-03-26 15:36:49 +0100 |
commit | f894d88125ce577c100f96270ba06e2728b530d5 (patch) | |
tree | 88163c66210677c16dcf4b6f6362a16e3bad2fe4 | |
parent | 6d5a5f31c36bbdaad21585d25974177bd1b75e66 (diff) | |
download | erlang-f894d88125ce577c100f96270ba06e2728b530d5.tar.gz |
Do not use the on MacOS buggy CLOCK_MONOTONIC clock id
-rw-r--r-- | erts/aclocal.m4 | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/erts/aclocal.m4 b/erts/aclocal.m4 index 085fe76918..19827984a4 100644 --- a/erts/aclocal.m4 +++ b/erts/aclocal.m4 @@ -712,14 +712,30 @@ esac AC_DEFUN(ERL_MONOTONIC_CLOCK, [ + # CLOCK_MONOTONIC is buggy on MacOS (darwin), or at least on Big Sur + # and Monterey, since it may step backwards. if test "$3" = "yes"; then - default_resolution_clock_gettime_monotonic="CLOCK_HIGHRES CLOCK_BOOTTIME CLOCK_MONOTONIC" - low_resolution_clock_gettime_monotonic="CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST" - high_resolution_clock_gettime_monotonic="CLOCK_MONOTONIC_PRECISE" + case $host_os in + darwin*) + default_resolution_clock_gettime_monotonic="CLOCK_MONOTONIC_RAW" + low_resolution_clock_gettime_monotonic="CLOCK_MONOTONIC_RAW_APPROX" + high_resolution_clock_gettime_monotonic="CLOCK_MONOTONIC_RAW";; + *) + default_resolution_clock_gettime_monotonic="CLOCK_HIGHRES CLOCK_BOOTTIME CLOCK_MONOTONIC" + low_resolution_clock_gettime_monotonic="CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST" + high_resolution_clock_gettime_monotonic="CLOCK_MONOTONIC_PRECISE";; + esac else - default_resolution_clock_gettime_monotonic="CLOCK_HIGHRES CLOCK_UPTIME CLOCK_MONOTONIC" - low_resolution_clock_gettime_monotonic="CLOCK_MONOTONIC_COARSE CLOCK_UPTIME_FAST" - high_resolution_clock_gettime_monotonic="CLOCK_UPTIME_PRECISE" + case $host_os in + darwin*) + default_resolution_clock_gettime_monotonic="CLOCK_UPTIME_RAW" + low_resolution_clock_gettime_monotonic="CLOCK_UPTIME_RAW_APPROX" + high_resolution_clock_gettime_monotonic="CLOCK_UPTIME_RAW";; + *) + default_resolution_clock_gettime_monotonic="CLOCK_HIGHRES CLOCK_UPTIME CLOCK_MONOTONIC" + low_resolution_clock_gettime_monotonic="CLOCK_MONOTONIC_COARSE CLOCK_UPTIME_FAST" + high_resolution_clock_gettime_monotonic="CLOCK_UPTIME_PRECISE";; + esac fi case "$1" in @@ -1496,7 +1512,7 @@ AC_ARG_WITH(with_sparc_memory_order, LM_CHECK_THR_LIB ERL_INTERNAL_LIBS -ERL_MONOTONIC_CLOCK(try_find_pthread_compatible, CLOCK_HIGHRES CLOCK_MONOTONIC, no) +ERL_MONOTONIC_CLOCK(try_find_pthread_compatible, CLOCK_HIGHRES CLOCK_UPTIME_RAW CLOCK_MONOTONIC, no) case $erl_monotonic_clock_func in clock_gettime) @@ -2458,6 +2474,15 @@ case "$with_clock_gettime_monotonic_id" in CLOCK_REALTIME*|CLOCK_TAI*) AC_MSG_ERROR([Invalid clock_gettime() monotonic clock id: Refusing to use the realtime clock id $with_clock_gettime_monotonic_id as monotonic clock id]) ;; + CLOCK_MONOTONIC) + case $host_os in + darwin*) + # CLOCK_MONOTONIC is buggy on MacOS (darwin), or at least on Big Sur + # and Monterey, since it may step backwards. + AC_MSG_ERROR([Invalid clock_gettime() monotonic clock id: Refusing to use $with_clock_gettime_monotonic_id as monotonic clock id since it is buggy on MacOS]);; + *) + ;; + esac;; CLOCK_*) ;; *) @@ -2529,7 +2554,7 @@ fi ERL_MONOTONIC_CLOCK(high_resolution, undefined, no) -case $$erl_monotonic_clock_low_resolution-$erl_monotonic_clock_func in +case $erl_monotonic_clock_low_resolution-$erl_monotonic_clock_func in no-mach_clock_get_time) monotonic_hrtime=yes AC_DEFINE(SYS_HRTIME_USING_MACH_CLOCK_GET_TIME, [1], [Define if you want to implement erts_os_hrtime() using mach clock_get_time()]) |