* lib/readutmp.c (get_boot_time): Initialize 'cached' after 'boot_time',
not before. Also declare both as volatile.
+2023-08-04 Bruno Haible <bruno@clisp.org>
+
+ readutmp: Ensure multithread-safety.
+ * lib/readutmp.c (get_boot_time): Initialize 'cached' after 'boot_time',
+ not before. Also declare both as volatile.
+
2023-08-04 Bruno Haible <bruno@clisp.org>
readutmp tests: Fix gcc warning (regression from yesterday).
static struct timespec
get_boot_time (void)
{
- static bool cached;
- static struct timespec boot_time;
+ static bool volatile cached;
+ static struct timespec volatile boot_time;
if (!cached)
{
- cached = true;
boot_time = get_boot_time_uncached ();
+ cached = true;
}
return boot_time;
}