[PATCH 01/12] linux: Fix vDSO macros build with time64 interfaces
Adhemerval Zanella
adhemerval.zanella@linaro.org
Fri Dec 13 12:05:00 GMT 2019
On 13/12/2019 08:51, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>> diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
>> index 7e772e05ce..07d38466e2 100644
>> --- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
>> +++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
>> @@ -22,10 +22,6 @@
>>
>> #include <time.h>
>> #include <sysdep.h>
>> -
>> -#ifdef HAVE_GETTIMEOFDAY_VSYSCALL
>> -# define HAVE_VSYSCALL
>> -#endif
>> #include <sysdep-vdso.h>
>>
>> /* Used as a fallback in the ifunc resolver if VDSO is not available
>> @@ -36,7 +32,9 @@ __gettimeofday_vsyscall (struct timeval *restrict tv, void *restrict tz)
>> if (__glibc_unlikely (tz != 0))
>> memset (tz, 0, sizeof *tz);
>>
>> - return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
>> + if (INLINE_VSYSCALL (gettimeofday, 2, tv, tz) == 0)
>> + return 0;
>> + return INLINE_SYSCALL_CALL (gettimeofday, tv, tz);
>> }
>
> Given that this is the fallback function why do we try INLINE_VSYSCALL
> first?
>
> (The static case would need adjusting, of course.)
Because it will be used on static build and the fallback case will be
unlikely. But I can add static only case that uses vDSO plus syscall and
change the shared fallback case that just issues the syscall.
My idea is to eventually consolidate the aarch64/powerpc64/x86_64
gettimeofday implementation, since they are essentially the same.
>
>> diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c b/sysdeps/unix/sysv/linux/clock_gettime.c
>> index 875c4fe905..4ea56c9a4b 100644
>> --- a/sysdeps/unix/sysv/linux/clock_gettime.c
>> +++ b/sysdeps/unix/sysv/linux/clock_gettime.c
>> @@ -21,10 +21,6 @@
>> #include <errno.h>
>> #include <time.h>
>> #include "kernel-posix-cpu-timers.h"
>> -
>> -#ifdef HAVE_CLOCK_GETTIME_VSYSCALL
>> -# define HAVE_VSYSCALL
>> -#endif
>> #include <sysdep-vdso.h>
>>
>> #include <shlib-compat.h>
>> @@ -33,24 +29,39 @@
>> int
>> __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp)
>> {
>> + int r = -1;
>> +
>> #ifdef __ASSUME_TIME64_SYSCALLS
>> + /* 64 bit ABIs or Newer 32-bit ABIs that only support 64-bit time_t. */
>> +# ifdef __NR_clock_gettime64
>> + r = INLINE_SYSCALL_CALL (clock_gettime64, clock_id, tp);
>> +# else
>> +# ifdef HAVE_CLOCK_GETTIME_VSYSCALL
>> + r = INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp);
>> +# endif
>> + if (r == -1)
>> + r = INLINE_SYSCALL_CALL (clock_gettime, clock_id, tp);
>
> Why do you check __NR_clock_gettime64 first? Won't this make the vDSO
> unused?
The vDSO support for clock_gettime64 was added later in this set. I
explicit removed because even if an architecture sets
HAVE_CLOCK_GETTIME64_VSYSCALL, it won't build.
More information about the Libc-alpha
mailing list