From 685bacfc48e05fab8be172f5659f7df4874d9834 Mon Sep 17 00:00:00 2001 From: Zhaoming Luo Date: Sat, 3 May 2025 21:28:08 +0800 Subject: libshouldbeinlibc: Use 64bit mapped time values in maptime_read when possible Use 64bit mapped time values in maptime_read when the kernel and the mapped_time_value structure in header file time_value.h support it. Otherwise step back to use the 32bit time. Message-ID: <20250503132808.15359-1-zhmingluo@163.com> --- libshouldbeinlibc/maptime.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libshouldbeinlibc') diff --git a/libshouldbeinlibc/maptime.h b/libshouldbeinlibc/maptime.h index 04ce0353..3a595ae5 100644 --- a/libshouldbeinlibc/maptime.h +++ b/libshouldbeinlibc/maptime.h @@ -48,6 +48,22 @@ extern void maptime_read (volatile struct mapped_time_value *mtime, struct timev MAPTIME_EI void maptime_read (volatile struct mapped_time_value *mtime, struct timeval *tv) { +#ifdef HAVE_STRUCT_MAPPED_TIME_VALUE_TIME_VALUE_SECONDS + /* Use the 64bit time if it is supported in the kernel. Otherwise step + back to the 32bit time. */ + if (mtime->time_value.seconds != 0) + { + do + { + tv->tv_sec = mtime->time_value.seconds; + __sync_synchronize (); + tv->tv_usec = mtime->time_value.nanoseconds / 1000; + __sync_synchronize (); + } + while (tv->tv_sec != mtime->check_seconds64); + return; + } +#endif do { tv->tv_sec = mtime->seconds; -- cgit v1.2.3