This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v4 3/3] y2038: linux: Provide __clock_settime64 implementation


20.05.2019 в 12:27:23 +0200 Lukasz Majewski написал:
>  /* Set CLOCK to value TP.  */
>  int
> -__clock_settime (clockid_t clock_id, const struct timespec *tp)
> +__clock_settime64 (clockid_t clock_id, const struct __timespec64 *tp)
>  {
>    /* Make sure the time cvalue is OK.  */
>    if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000)
> @@ -32,6 +30,40 @@ __clock_settime (clockid_t clock_id, const struct timespec *tp)
>        return -1;
>      }
>  
> +#if __WORDSIZE == 32
> +# ifdef __NR_clock_settime64
> +  int ret = INLINE_SYSCALL_CALL (clock_settime64, clock_id, tp);
> +#  ifdef __ASSUME_TIME64_SYSCALLS
> +  return ret;
> +#  else
> +  if (ret == 0 || errno != ENOSYS)
> +    return ret;
> +#  endif
> +# endif
> +  /* Fall back to syscall supporting 32bit struct timespec.  */
> +# if (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE != 64)
> +  struct timespec ts32;
> +  valid_timespec64_to_timespec (tp, &ts32);
> +  return INLINE_SYSCALL_CALL (clock_settime, clock_id, &ts32);
> +# endif
> +#endif
>    return INLINE_SYSCALL_CALL (clock_settime, clock_id, tp);
>  }

This still uses __NR_clock_settime even if __ASSUME_TIME64_SYSCALLS is
defined.  This won't even compile on newer 32-bit architectures where
__NR_clock_settime is not defined.  valid_timespec64_to_timespec
won't exist in these cases too.

And in_time_t_range check is missing for the fallback case.

>  weak_alias (__clock_settime, clock_settime)
> +
> +#if __TIMESIZE != 64
> +int
> +__clock_settime (clockid_t clock_id, const struct timespec *tp)
> +{
> +  struct __timespec64 ts64;
> +
> +  if (! in_time_t_range (tp->tv_sec))
> +    {
> +      __set_errno (EOVERFLOW);
> +      return -1;
> +    }

What is this if (false) { … } statement doing here?

> +
> +  valid_timespec_to_timespec64 (tp, &ts64);
> +  return __clock_settime64 (clock_id, &ts64);
> +}
> +#endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]