Zhaoming Luo, le sam. 03 mai 2025 21:28:08 +0800, a ecrit:
> 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.

Applied, thanks!

Samuel

> ---
>  configure.ac                |  3 +++
>  libshouldbeinlibc/maptime.h | 16 ++++++++++++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/configure.ac b/configure.ac
> index 1f814438..d7e33e56 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -335,6 +335,9 @@ AC_SUBST([libdaemon_CFLAGS])
>  AC_CHECK_MEMBERS([struct thread_sched_info.last_processor],,,
>   [#include <mach/thread_info.h>])
>  
> +AC_CHECK_MEMBERS([struct mapped_time_value.time_value.seconds],,,
> + [#include <mach/time_value.h>])
> +
>  PKG_CHECK_MODULES([libblkid], [blkid],
>    [AC_DEFINE([HAVE_BLKID], [1], [Use libblkid])],
>    [true])
> 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;
> -- 
> 2.49.0
> 
> 

-- 
Samuel
"...[Linux's] capacity to talk via any medium except smoke signals."
(By Dr. Greg Wettstein, Roger Maris Cancer Center)

Reply via email to