summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRickard Green <rickard@erlang.org>2022-03-26 17:06:04 +0100
committerRickard Green <rickard@erlang.org>2022-03-26 17:06:04 +0100
commit6bac5ba903c5ed4b49c5259ba1444a9856baf206 (patch)
tree181c156acb35eb73cf1be66c9ddfef0f1b3ba014
parenta53ff4ad87a6c4db1f7302290779db205723bb32 (diff)
parentf894d88125ce577c100f96270ba06e2728b530d5 (diff)
downloaderlang-6bac5ba903c5ed4b49c5259ba1444a9856baf206.tar.gz
Merge branch 'rickard/macos-os-monotonic-fix/OTP-17998' into rickard/macos-os-monotonic-fix/22/OTP-17998
* rickard/macos-os-monotonic-fix/OTP-17998: Do not use the on MacOS buggy CLOCK_MONOTONIC clock id
-rw-r--r--erts/aclocal.m439
1 files changed, 32 insertions, 7 deletions
diff --git a/erts/aclocal.m4 b/erts/aclocal.m4
index 2a991b3a33..c2edf77cf1 100644
--- a/erts/aclocal.m4
+++ b/erts/aclocal.m4
@@ -714,14 +714,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
@@ -1498,7 +1514,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)
@@ -2460,6 +2476,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_*)
;;
*)