+2024-03-26 Bruno Haible <bruno@clisp.org>
+
+ gettime-res: Fix test failure on Solaris 11.4/SPARC.
+ * lib/gettime-res.c (gettime_res): On Solaris/SPARC, just return 1 ns.
+
2024-03-10 Collin Funk <collin.funk1@gmail.com>
gnulib-tool: Don't remove comments referencing @NMD@, part 2.
/* Get the system clock resolution.
- Copyright 2021-2023 Free Software Foundation, Inc.
+ Copyright 2021-2024 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
long int
gettime_res (void)
{
+#if defined __sun && defined __sparc
+ /* On Solaris 11.4/SPARC (with a SPARC-M8 CPU)
+ clock_getres (CLOCK_REALTIME, ...) returns a resolution of 1000000 ns,
+ and clock_gettime (CLOCK_REALTIME) returns a multiple of 5 ns with a
+ probability of ca. 1 - 1/300000. Thus the heuristic below with the
+ 32 samples guesses a resolution of 5 ns with a probability of ca.
+ 1 - 1/10000. But occasionally clock_gettime (CLOCK_REALTIME) returns
+ only a multiple of 1 ns.
+ Simple guesswork is not enough to cope with this irregular behaviour.
+ Therefore, here is an override. */
+ return 1;
+#else
struct timespec res;
-#if defined CLOCK_REALTIME && HAVE_CLOCK_GETRES
+# if defined CLOCK_REALTIME && HAVE_CLOCK_GETRES
clock_getres (CLOCK_REALTIME, &res);
-#elif defined HAVE_TIMESPEC_GETRES
+# elif defined HAVE_TIMESPEC_GETRES
timespec_getres (&res, TIME_UTC);
-#else
+# else
/* Guess high and let the later code deduce better. */
res.tv_sec = 1;
res.tv_nsec = 0;
-#endif
+# endif
/* On all Gnulib platforms the following calculations do not overflow. */
}
return r;
+#endif
}
/*