This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2 2/7] y2038: Introduce __ASSUME_64BIT_TIME define
- From: Stepan Golosunov <stepan at golosunov dot pp dot ru>
- To: Lukasz Majewski <lukma at denx dot de>
- Cc: Joseph Myers <joseph at codesourcery dot com>, libc-alpha at sourceware dot org, Arnd Bergmann <arnd at arndb dot de>, Paul Eggert <eggert at cs dot ucla dot edu>
- Date: Wed, 8 May 2019 00:03:58 +0400
- Subject: Re: [PATCH v2 2/7] y2038: Introduce __ASSUME_64BIT_TIME define
- References: <alpine.DEB.2.21.1904292138430.21580@digraph.polyomino.org.uk> <20190430110505.2a0c7d1a@jawa> <20190430214748.rzjlcu3f3hdyqnhw@sghpc.golosunov.pp.ru> <20190502105108.541fe118@jawa> <20190502115459.d3qwvhvmzl6c5kmo@sghpc.golosunov.pp.ru> <20190502155549.2f7bf82d@jawa> <20190506153844.77cad546@jawa> <20190506162659.6d7e4a59@jawa> <20190506193617.nd44jtdt4tty5few@sghpc.golosunov.pp.ru> <20190506231444.088274fc@jawa>
06.05.2019 в 23:14:44 +0200 Lukasz Majewski написал:
> For ARM, x86 there shall be call to clock_settime64 syscall
>
> For x32 there shall be call to clock_settime syscall (which is
> supporting 64 bit anyway - despite the ignoring possible padding
> clearing issue).
> I rather thought about something like:
>
> __clock_settime64 (clockid_t clock_id, const struct __timespec64 *tp)
> {
> <overflow check>
>
> #ifdef __ASSUME_TIME64_SYSCALLS
> # ifdef __NR_clock_settime64
> int ret = INLINE_SYSCALL_CALL (clock_settime64, clock_id, tp);
> if (ret == 0 || errno != ENOSYS)
> return ret;
> # endif
> /* Fall back to syscall supporting 32bit struct timespec. */
> struct timespec ts32;
> valid_timespec64_to_timespec (tp, &ts32);
> return INLINE_SYSCALL_CALL (clock_settime, clock_id, &ts32);
> #else
> /* 64 bit machines + x32 */
> return INLINE_SYSCALL_CALL (clock_settime, clock_id, tp);
> #endif
> }
>
> In the above pseudo code we assume that __ASSUME_TIME64_SYSCALLS is
> #undef'ed for x32 (so it is treated as a 'special case' - in the same
> way as x86_64).
Usually the point of __ASSUME_* macros is to avoid compiling old
compatibility code when it's not needed. That means there should be
no fallback to 32-bit clock_settime when __ASSUME_TIME64_SYSCALLS is
defined. Even when it's defined on 32-bit arm or x86.
And with your current use of __ASSUME_TIME64_SYSCALLS
__NR_clock_settime64 won't be used on any existing architecture.
Because __ASSUME_TIME64_SYSCALLS won't be defined until Linux 5.0 is
no longer supported.
If you replace
#ifdef __ASSUME_TIME64_SYSCALLS
with
#ifdef __NR_clock_settime64
result would make more sense than what you have now.