From 77b6f5534778b5403c87fa5415625aeb4c3cbf44 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Wed, 16 Jan 2019 17:30:07 +0000 Subject: linux: Assume clock_getres CLOCK_{PROCESS,THREAD}_CPUTIME_ID The Linux 3.2 clock_getres kernel code (kernel/posix-cpu-timers.c) issued for clock_getres CLOCK_PROCESS_CPUTIME_ID (process_cpu_clock_getres) and CLOCK_THREAD_CPUTIME_ID (thread_cpu_clock_getres) call posix_cpu_clock_getres. And it fails on check_clock only if an invalid clock is used (not the case) or if we pass an invalid the pid/tid in 29 msb of clock_id (not the case either). This patch assumes that clock_getres syscall always support CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID, so there is no need to fallback to hp-timing support for _SC_MONOTONIC_CLOCK neither to issue the syscall to certify the clock_id is supported bt the kernel. This allows simplify the sysconf support to always use the syscall. it also removes ia64 itc drift check and assume kernel handles it correctly. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. * sysdeps/unix/sysv/linux/ia64/has_cpuclock.c: Remove file. * sysdeps/unix/sysv/linux/ia64/sysconf.c: Likewise. * sysdeps/unix/sysv/linux/sysconf.c (has_cpuclock): Remove function. (__sysconf): Assume kernel support for _SC_MONOTONIC_CLOCK, _SC_CPUTIME, and _SC_THREAD_CPUTIME. --- sysdeps/unix/sysv/linux/ia64/has_cpuclock.c | 51 ----------------------------- sysdeps/unix/sysv/linux/ia64/sysconf.c | 30 ----------------- 2 files changed, 81 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/ia64/has_cpuclock.c delete mode 100644 sysdeps/unix/sysv/linux/ia64/sysconf.c (limited to 'sysdeps/unix/sysv/linux/ia64') diff --git a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c deleted file mode 100644 index b3afb37f8b..0000000000 --- a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2000-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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; if not, see - . */ - -#include -#include -#include -#include -#include -#include - -static int itc_usable; - -static int -has_cpuclock (void) -{ - if (__builtin_expect (itc_usable == 0, 0)) - { - int newval = 1; - int fd = __open_nocancel ("/proc/sal/itc_drift", O_RDONLY); - if (__builtin_expect (fd != -1, 1)) - { - char buf[16]; - /* We expect the file to contain a single digit followed by - a newline. If the format changes we better not rely on - the file content. */ - if (__read_nocancel (fd, buf, sizeof buf) != 2 - || buf[0] != '0' || buf[1] != '\n') - newval = -1; - - __close_nocancel_nostatus (fd); - } - - itc_usable = newval; - } - - return itc_usable; -} diff --git a/sysdeps/unix/sysv/linux/ia64/sysconf.c b/sysdeps/unix/sysv/linux/ia64/sysconf.c deleted file mode 100644 index ef75322f1f..0000000000 --- a/sysdeps/unix/sysv/linux/ia64/sysconf.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Get file-specific information about a file. Linux/ia64 version. - Copyright (C) 2003-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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; if not, see - . */ - -#include -#include -#include -#include - - -#include "has_cpuclock.c" -#define HAS_CPUCLOCK(name) (has_cpuclock () ? _POSIX_VERSION : -1) - - -/* Now the generic Linux version. */ -#include -- cgit 1.4.1