https://gcc.gnu.org/g:f361709b3d7cd4151568485da7c5bab67a81b7e8
commit r17-4201-gf361709b3d7cd4151568485da7c5bab67a81b7e8 Author: Iain Sandoe <[email protected]> Date: Thu Sep 10 20:31:51 2026 +0100 libgm2, configure: Update clock_gettime config to match libstdc++. When _POSIX_TIMERS (and _POSIX_MONOTONIC_CLOCK) are set to -1 that indicates the implementation is not claiming POSIX compliance; it does not indicate that either timespec or any specific APIs are actually absent. We have been gating the configure tests on _POSIX_TIMERS/_POSIX_MONOTONIC_CLOCK which is preventing the discovery of nanosleep/clock_gettime on Darwin where these have been present for quite some time (nanosleep since at least Darwin8 and clock_gettime since Darwin12). This follows libstdc++ by carrying out the configure probes even when the platform does not claim strict POSIX compliance. libgm2/ChangeLog: * acinclude.m4: Do not gate the use of 'timespec' with _POSIX_TIMERS > 0. For the auto case, set ac_has_clock_monotonic and ac_has_clock_realtime for Darwin versions that implement them. * configure: Regenerate. Signed-off-by: Iain Sandoe <[email protected]> Diff: --- libgm2/acinclude.m4 | 19 +++++++++++-------- libgm2/configure | 23 +++++++++++++---------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/libgm2/acinclude.m4 b/libgm2/acinclude.m4 index d46d474e52ac..c243cecfdeb9 100644 --- a/libgm2/acinclude.m4 +++ b/libgm2/acinclude.m4 @@ -216,6 +216,13 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ darwin*) ac_has_nanosleep=yes ac_has_sched_yield=yes + case "${target_os}" in + darwin1[[6-9]]* | darwin2*) + # clock_gettime() is available from Darwin12. + ac_has_clock_monotonic=yes + ac_has_clock_realtime=yes + ;; + esac ;; # VxWorks has nanosleep as soon as the kernel is configured with # INCLUDE_POSIX_TIMERS, which is normally/most-often the case. @@ -298,9 +305,8 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ [[#include <unistd.h> #include <time.h> ]], - [[#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK) + [[ timespec tp; - #endif clock_gettime(CLOCK_MONOTONIC, &tp); ]])], [ac_has_clock_monotonic=yes], [ac_has_clock_monotonic=no]) @@ -311,9 +317,8 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ [[#include <unistd.h> #include <time.h> ]], - [[#if _POSIX_TIMERS > 0 + [[ timespec tp; - #endif clock_gettime(CLOCK_REALTIME, &tp); ]])], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no]) @@ -324,9 +329,8 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ [[#include <unistd.h> #include <time.h> ]], - [[#if _POSIX_TIMERS > 0 + [[ timespec tp; - #endif nanosleep(&tp, 0); ]])], [ac_has_nanosleep=yes], [ac_has_nanosleep=no]) @@ -343,9 +347,8 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ #include <time.h> #include <sys/syscall.h> ]], - [[#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK) + [[ timespec tp; - #endif syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &tp); syscall(SYS_clock_gettime, CLOCK_REALTIME, &tp); ]])], [ac_has_clock_gettime_syscall=yes], [ac_has_clock_gettime_syscall=no]) diff --git a/libgm2/configure b/libgm2/configure index 0b53b2099ecf..283b44f8d9b3 100755 --- a/libgm2/configure +++ b/libgm2/configure @@ -5245,6 +5245,13 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu darwin*) ac_has_nanosleep=yes ac_has_sched_yield=yes + case "${target_os}" in + darwin1[6-9]* | darwin2*) + # clock_gettime() is available from Darwin12. + ac_has_clock_monotonic=yes + ac_has_clock_realtime=yes + ;; + esac ;; # VxWorks has nanosleep as soon as the kernel is configured with # INCLUDE_POSIX_TIMERS, which is normally/most-often the case. @@ -5588,9 +5595,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext int main () { -#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK) + timespec tp; - #endif clock_gettime(CLOCK_MONOTONIC, &tp); ; @@ -5621,9 +5627,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext int main () { -#if _POSIX_TIMERS > 0 + timespec tp; - #endif clock_gettime(CLOCK_REALTIME, &tp); ; @@ -5654,9 +5659,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext int main () { -#if _POSIX_TIMERS > 0 + timespec tp; - #endif nanosleep(&tp, 0); ; @@ -5690,9 +5694,8 @@ $as_echo_n "checking for clock_gettime syscall... " >&6; } int main () { -#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK) + timespec tp; - #endif syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &tp); syscall(SYS_clock_gettime, CLOCK_REALTIME, &tp); @@ -15252,7 +15255,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 15255 "configure" +#line 15258 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15358,7 +15361,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 15361 "configure" +#line 15364 "configure" #include "confdefs.h" #if HAVE_DLFCN_H
