GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libgm2

libgm2: Add fallback for GetTimeRealtime when clock_getttime is unavailable.

libgm2 now uses getttimeofday as a fallback for GetTimeRealtime if clock_getttime is not available.

This commit provides a fallback mechanism in libgm2 for the GetTimeRealtime function. If the clock_getttime function is not available on a system, the library will now attempt to use getttimeofday instead, mirroring the approach taken by libstdc++.

This change ensures that time-related functionality remains available on a wider range of systems by providing a compatible alternative when the preferred POSIX API is missing.

In Details

The libgm2 library's time-handling routines now include a fallback for GetTimeRealtime. This function, previously relying solely on clock_gettime, will now attempt to use getttimeofday if clock_gettime is not supported by the system, ensuring broader compatibility for time retrieval. This mirrors a similar strategy employed within libstdc++.

For Context
libgm2
A library within GCC, likely for the GNU Modula-2 language, that includes runtime and configuration components.
clock_gettime
A POSIX function that provides a high-resolution timestamp from a specified clock, such as the system's real-time clock or a monotonic clock.
getttimeofday
A non-standard function that retrieves the current system time and timezone information. It is generally less preferred than clock_gettime for high-resolution timing.
Filed Under: libgm2compatibilitytime