https://gcc.gnu.org/g:8cb4d3dd75c42fdc27cd3df196fe5a65188c9a93
commit r17-4202-g8cb4d3dd75c42fdc27cd3df196fe5a65188c9a93 Author: Iain Sandoe <[email protected]> Date: Thu Sep 10 23:53:37 2026 +0100 libgm2: Provide fallback GetTimeRealtime when clock_getttime is not available. This copies the approach used in libstdc++ if getttimeofday is available and clock_gettime is not, then use the former. libgm2/ChangeLog: * libm2iso/wrapclock.cc (GetTimeRealtime): Provide a fallback when clock_gettime is not available. Signed-off-by: Iain Sandoe <[email protected]> Diff: --- libgm2/libm2iso/wrapclock.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libgm2/libm2iso/wrapclock.cc b/libgm2/libm2iso/wrapclock.cc index 540a8b9ae6d0..3a770e5f8c54 100644 --- a/libgm2/libm2iso/wrapclock.cc +++ b/libgm2/libm2iso/wrapclock.cc @@ -86,7 +86,6 @@ typedef long long int longint_t; extern "C" int EXPORT(GetTimeRealtime) (struct timespec *ts) { - timespec tp; #if defined(_GLIBCXX_USE_CLOCK_GETTIME_SYSCALL) return syscall (SYS_clock_gettime, CLOCK_REALTIME, ts); #else @@ -94,6 +93,18 @@ EXPORT(GetTimeRealtime) (struct timespec *ts) #endif } +#elif defined(HAVE_STRUCT_TIMESPEC) && defined(HAVE_GETTIMEOFDAY) +extern "C" int +EXPORT(GetTimeRealtime) (struct timespec *ts) +{ + struct timeval tv; + if (gettimeofday (&tv, NULL) != 0) + return -1; + ts->tv_sec = tv.tv_sec; + ts->tv_nsec = ((long) tv.tv_usec) * 1000; + return 0; +} + #else extern "C" int
