mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-23 05:20:06 +00:00
562cdc19c7
This patch provides new __timer_gettime64 explicit 64 bit function for reading status of specified timer. To be more precise - the remaining time and interval set with timer_settime. Moreover, a 32 bit version - __timer_gettime has been refactored to internally use __timer_gettime64. The __timer_gettime is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion from 64 bit struct __timespec64 to struct timespec. The new __timer_gettime64 syscall available from Linux 5.1+ has been used, when applicable. The original INLINE_SYSCALL() macro has been replaced with INLINE_SYSCALL_CALL() to avoid explicit passing the number of arguments. Build tests: - The code has been tested on x86_64/x86 (native compilation): make PARALLELMFLAGS="-j8" && make check PARALLELMFLAGS="-j8" && \\ make xcheck PARALLELMFLAGS="-j8" - The glibc has been build tested (make PARALLELMFLAGS="-j8") for x86 (i386), x86_64-x32, and armv7 Run-time tests: - Run specific tests on ARM/x86 32bit systems (qemu): https://github.com/lmajewski/meta-y2038 and run tests: https://github.com/lmajewski/y2038-tests/commits/master - Use of cross-test-ssh.sh for ARM (armv7): make PARALLELMFLAGS="-j8" test-wrapper='./cross-test-ssh.sh root@192.168.7.2' xcheck Linux kernel, headers and minimal kernel version for glibc build test matrix: - Linux v5.1 (with timer_gettime64) and glibc build with v5.1 as minimal kernel version (--enable-kernel="5.1.0") The __ASSUME_TIME64_SYSCALLS flag defined. - Linux v5.1 and default minimal kernel version The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports timer_gettime64 syscall. - Linux v4.19 (no timer_gettime64 support) with default minimal kernel version for contemporary glibc (3.2.0) This kernel doesn't support timer_gettime64 syscall, so the fallback to timer_gettime is tested. Above tests were performed with Y2038 redirection applied as well as without (so the __TIMESIZE != 64 execution path is checked as well). No regressions were observed. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
71 lines
2.2 KiB
C
71 lines
2.2 KiB
C
/* Copyright (C) 2003-2019 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public License as
|
|
published by the Free Software Foundation; either version 2.1 of the
|
|
License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
|
not, see <https://www.gnu.org/licenses/>. */
|
|
|
|
#include <errno.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
#include <sysdep.h>
|
|
#include <kernel-features.h>
|
|
#include "kernel-posix-timers.h"
|
|
|
|
int
|
|
__timer_gettime64 (timer_t timerid, struct __itimerspec64 *value)
|
|
{
|
|
struct timer *kt = (struct timer *) timerid;
|
|
|
|
#ifdef __ASSUME_TIME64_SYSCALLS
|
|
# ifndef __NR_timer_gettime64
|
|
# define __NR_timer_gettime64 __NR_timer_gettime
|
|
# endif
|
|
return INLINE_SYSCALL_CALL (timer_gettime64, kt->ktimerid, value);
|
|
#else
|
|
# ifdef __NR_timer_gettime64
|
|
int ret = INLINE_SYSCALL_CALL (timer_gettime64, kt->ktimerid, value);
|
|
if (ret == 0 || errno != ENOSYS)
|
|
return ret;
|
|
# endif
|
|
struct itimerspec its32;
|
|
int retval = INLINE_SYSCALL_CALL (timer_gettime, kt->ktimerid, &its32);
|
|
if (retval == 0)
|
|
{
|
|
value->it_interval = valid_timespec_to_timespec64 (its32.it_interval);
|
|
value->it_value = valid_timespec_to_timespec64 (its32.it_value);
|
|
}
|
|
|
|
return retval;
|
|
#endif
|
|
}
|
|
|
|
#if __TIMESIZE != 64
|
|
int
|
|
__timer_gettime (timer_t timerid, struct itimerspec *value)
|
|
{
|
|
struct __itimerspec64 its64;
|
|
int retval = __timer_gettime64 (timerid, &its64);
|
|
if (retval == 0)
|
|
{
|
|
value->it_interval = valid_timespec64_to_timespec (its64.it_interval);
|
|
value->it_value = valid_timespec64_to_timespec (its64.it_value);
|
|
}
|
|
|
|
return retval;
|
|
}
|
|
#endif
|
|
weak_alias (__timer_gettime, timer_gettime)
|
|
libc_hidden_def (timer_gettime)
|