|
|
e354a5 |
commit 77b6f5534778b5403c87fa5415625aeb4c3cbf44
|
|
|
e354a5 |
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
e354a5 |
Date: Wed Jan 16 17:30:07 2019 +0000
|
|
|
e354a5 |
|
|
|
e354a5 |
linux: Assume clock_getres CLOCK_{PROCESS,THREAD}_CPUTIME_ID
|
|
|
e354a5 |
|
|
|
e354a5 |
The Linux 3.2 clock_getres kernel code (kernel/posix-cpu-timers.c)
|
|
|
e354a5 |
issued for clock_getres CLOCK_PROCESS_CPUTIME_ID (process_cpu_clock_getres)
|
|
|
e354a5 |
and CLOCK_THREAD_CPUTIME_ID (thread_cpu_clock_getres) call
|
|
|
e354a5 |
posix_cpu_clock_getres. And it fails on check_clock only if an invalid
|
|
|
e354a5 |
clock is used (not the case) or if we pass an invalid the pid/tid in
|
|
|
e354a5 |
29 msb of clock_id (not the case either).
|
|
|
e354a5 |
|
|
|
e354a5 |
This patch assumes that clock_getres syscall always support
|
|
|
e354a5 |
CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID, so there is no need
|
|
|
e354a5 |
to fallback to hp-timing support for _SC_MONOTONIC_CLOCK neither to issue
|
|
|
e354a5 |
the syscall to certify the clock_id is supported bt the kernel. This
|
|
|
e354a5 |
allows simplify the sysconf support to always use the syscall.
|
|
|
e354a5 |
|
|
|
e354a5 |
it also removes ia64 itc drift check and assume kernel handles it correctly.
|
|
|
e354a5 |
|
|
|
e354a5 |
Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu.
|
|
|
e354a5 |
|
|
|
e354a5 |
* sysdeps/unix/sysv/linux/ia64/has_cpuclock.c: Remove file.
|
|
|
e354a5 |
* sysdeps/unix/sysv/linux/ia64/sysconf.c: Likewise.
|
|
|
e354a5 |
* sysdeps/unix/sysv/linux/sysconf.c (has_cpuclock): Remove function.
|
|
|
e354a5 |
(__sysconf): Assume kernel support for _SC_MONOTONIC_CLOCK,
|
|
|
e354a5 |
_SC_CPUTIME, and _SC_THREAD_CPUTIME.
|
|
|
e354a5 |
|
|
|
e354a5 |
Conflicts:
|
|
|
e354a5 |
sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
|
|
|
e354a5 |
sysdeps/unix/sysv/linux/ia64/sysconf.c
|
|
|
e354a5 |
(Removal after copyright year update.)
|
|
|
e354a5 |
|
|
|
e354a5 |
diff --git a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
|
|
|
e354a5 |
deleted file mode 100644
|
|
|
e354a5 |
index 75f3ef9f4d1366fb..0000000000000000
|
|
|
e354a5 |
--- a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
|
|
|
e354a5 |
+++ /dev/null
|
|
|
e354a5 |
@@ -1,51 +0,0 @@
|
|
|
e354a5 |
-/* Copyright (C) 2000-2018 Free Software Foundation, Inc.
|
|
|
e354a5 |
- This file is part of the GNU C Library.
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
e354a5 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
e354a5 |
- License as published by the Free Software Foundation; either
|
|
|
e354a5 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
e354a5 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
e354a5 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
e354a5 |
- Lesser General Public License for more details.
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
e354a5 |
- License along with the GNU C Library; if not, see
|
|
|
e354a5 |
- <http://www.gnu.org/licenses/>. */
|
|
|
e354a5 |
-
|
|
|
e354a5 |
-#include <errno.h>
|
|
|
e354a5 |
-#include <fcntl.h>
|
|
|
e354a5 |
-#include <unistd.h>
|
|
|
e354a5 |
-#include <sys/stat.h>
|
|
|
e354a5 |
-#include <sys/types.h>
|
|
|
e354a5 |
-#include <not-cancel.h>
|
|
|
e354a5 |
-
|
|
|
e354a5 |
-static int itc_usable;
|
|
|
e354a5 |
-
|
|
|
e354a5 |
-static int
|
|
|
e354a5 |
-has_cpuclock (void)
|
|
|
e354a5 |
-{
|
|
|
e354a5 |
- if (__builtin_expect (itc_usable == 0, 0))
|
|
|
e354a5 |
- {
|
|
|
e354a5 |
- int newval = 1;
|
|
|
e354a5 |
- int fd = __open_nocancel ("/proc/sal/itc_drift", O_RDONLY);
|
|
|
e354a5 |
- if (__builtin_expect (fd != -1, 1))
|
|
|
e354a5 |
- {
|
|
|
e354a5 |
- char buf[16];
|
|
|
e354a5 |
- /* We expect the file to contain a single digit followed by
|
|
|
e354a5 |
- a newline. If the format changes we better not rely on
|
|
|
e354a5 |
- the file content. */
|
|
|
e354a5 |
- if (__read_nocancel (fd, buf, sizeof buf) != 2
|
|
|
e354a5 |
- || buf[0] != '0' || buf[1] != '\n')
|
|
|
e354a5 |
- newval = -1;
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- __close_nocancel_nostatus (fd);
|
|
|
e354a5 |
- }
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- itc_usable = newval;
|
|
|
e354a5 |
- }
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- return itc_usable;
|
|
|
e354a5 |
-}
|
|
|
e354a5 |
diff --git a/sysdeps/unix/sysv/linux/ia64/sysconf.c b/sysdeps/unix/sysv/linux/ia64/sysconf.c
|
|
|
e354a5 |
deleted file mode 100644
|
|
|
e354a5 |
index 6c39db5a4af3e15a..0000000000000000
|
|
|
e354a5 |
--- a/sysdeps/unix/sysv/linux/ia64/sysconf.c
|
|
|
e354a5 |
+++ /dev/null
|
|
|
e354a5 |
@@ -1,30 +0,0 @@
|
|
|
e354a5 |
-/* Get file-specific information about a file. Linux/ia64 version.
|
|
|
e354a5 |
- Copyright (C) 2003-2018 Free Software Foundation, Inc.
|
|
|
e354a5 |
- This file is part of the GNU C Library.
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
e354a5 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
e354a5 |
- License as published by the Free Software Foundation; either
|
|
|
e354a5 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
e354a5 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
e354a5 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
e354a5 |
- Lesser General Public License for more details.
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
e354a5 |
- License along with the GNU C Library; if not, see
|
|
|
e354a5 |
- <http://www.gnu.org/licenses/>. */
|
|
|
e354a5 |
-
|
|
|
e354a5 |
-#include <assert.h>
|
|
|
e354a5 |
-#include <stdbool.h>
|
|
|
e354a5 |
-#include <stdlib.h>
|
|
|
e354a5 |
-#include <unistd.h>
|
|
|
e354a5 |
-
|
|
|
e354a5 |
-
|
|
|
e354a5 |
-#include "has_cpuclock.c"
|
|
|
e354a5 |
-#define HAS_CPUCLOCK(name) (has_cpuclock () ? _POSIX_VERSION : -1)
|
|
|
e354a5 |
-
|
|
|
e354a5 |
-
|
|
|
e354a5 |
-/* Now the generic Linux version. */
|
|
|
e354a5 |
-#include <sysdeps/unix/sysv/linux/sysconf.c>
|
|
|
e354a5 |
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
|
|
|
e354a5 |
index 4e49ebaa7a25748c..6fab1601034e4724 100644
|
|
|
e354a5 |
--- a/sysdeps/unix/sysv/linux/sysconf.c
|
|
|
e354a5 |
+++ b/sysdeps/unix/sysv/linux/sysconf.c
|
|
|
e354a5 |
@@ -35,34 +35,6 @@
|
|
|
e354a5 |
static long int posix_sysconf (int name);
|
|
|
e354a5 |
|
|
|
e354a5 |
|
|
|
e354a5 |
-#ifndef HAS_CPUCLOCK
|
|
|
e354a5 |
-static long int
|
|
|
e354a5 |
-has_cpuclock (int name)
|
|
|
e354a5 |
-{
|
|
|
e354a5 |
-# if defined __NR_clock_getres || HP_TIMING_AVAIL
|
|
|
e354a5 |
- /* If we have HP_TIMING, we will fall back on that if the system
|
|
|
e354a5 |
- call does not work, so we support it either way. */
|
|
|
e354a5 |
-# if !HP_TIMING_AVAIL
|
|
|
e354a5 |
- /* Check using the clock_getres system call. */
|
|
|
e354a5 |
- struct timespec ts;
|
|
|
e354a5 |
- INTERNAL_SYSCALL_DECL (err);
|
|
|
e354a5 |
- int r = INTERNAL_SYSCALL (clock_getres, err, 2,
|
|
|
e354a5 |
- (name == _SC_CPUTIME
|
|
|
e354a5 |
- ? CLOCK_PROCESS_CPUTIME_ID
|
|
|
e354a5 |
- : CLOCK_THREAD_CPUTIME_ID),
|
|
|
e354a5 |
- &ts);
|
|
|
e354a5 |
- if (INTERNAL_SYSCALL_ERROR_P (r, err))
|
|
|
e354a5 |
- return -1;
|
|
|
e354a5 |
-# endif
|
|
|
e354a5 |
- return _POSIX_VERSION;
|
|
|
e354a5 |
-# else
|
|
|
e354a5 |
- return -1;
|
|
|
e354a5 |
-# endif
|
|
|
e354a5 |
-}
|
|
|
e354a5 |
-# define HAS_CPUCLOCK(name) has_cpuclock (name)
|
|
|
e354a5 |
-#endif
|
|
|
e354a5 |
-
|
|
|
e354a5 |
-
|
|
|
e354a5 |
/* Get the value of the system variable NAME. */
|
|
|
e354a5 |
long int
|
|
|
e354a5 |
__sysconf (int name)
|
|
|
e354a5 |
@@ -71,29 +43,20 @@ __sysconf (int name)
|
|
|
e354a5 |
|
|
|
e354a5 |
switch (name)
|
|
|
e354a5 |
{
|
|
|
e354a5 |
- struct rlimit rlimit;
|
|
|
e354a5 |
-#ifdef __NR_clock_getres
|
|
|
e354a5 |
case _SC_MONOTONIC_CLOCK:
|
|
|
e354a5 |
- /* Check using the clock_getres system call. */
|
|
|
e354a5 |
- {
|
|
|
e354a5 |
- struct timespec ts;
|
|
|
e354a5 |
- INTERNAL_SYSCALL_DECL (err);
|
|
|
e354a5 |
- int r;
|
|
|
e354a5 |
- r = INTERNAL_SYSCALL (clock_getres, err, 2, CLOCK_MONOTONIC, &ts);
|
|
|
e354a5 |
- return INTERNAL_SYSCALL_ERROR_P (r, err) ? -1 : _POSIX_VERSION;
|
|
|
e354a5 |
- }
|
|
|
e354a5 |
-#endif
|
|
|
e354a5 |
-
|
|
|
e354a5 |
case _SC_CPUTIME:
|
|
|
e354a5 |
case _SC_THREAD_CPUTIME:
|
|
|
e354a5 |
- return HAS_CPUCLOCK (name);
|
|
|
e354a5 |
+ return _POSIX_VERSION;
|
|
|
e354a5 |
|
|
|
e354a5 |
case _SC_ARG_MAX:
|
|
|
e354a5 |
- /* Use getrlimit to get the stack limit. */
|
|
|
e354a5 |
- if (__getrlimit (RLIMIT_STACK, &rlimit) == 0)
|
|
|
e354a5 |
- return MAX (legacy_ARG_MAX, rlimit.rlim_cur / 4);
|
|
|
e354a5 |
+ {
|
|
|
e354a5 |
+ struct rlimit rlimit;
|
|
|
e354a5 |
+ /* Use getrlimit to get the stack limit. */
|
|
|
e354a5 |
+ if (__getrlimit (RLIMIT_STACK, &rlimit) == 0)
|
|
|
e354a5 |
+ return MAX (legacy_ARG_MAX, rlimit.rlim_cur / 4);
|
|
|
e354a5 |
|
|
|
e354a5 |
- return legacy_ARG_MAX;
|
|
|
e354a5 |
+ return legacy_ARG_MAX;
|
|
|
e354a5 |
+ }
|
|
|
e354a5 |
|
|
|
e354a5 |
case _SC_NGROUPS_MAX:
|
|
|
e354a5 |
/* Try to read the information from the /proc/sys/kernel/ngroups_max
|
|
|
e354a5 |
@@ -102,11 +65,14 @@ __sysconf (int name)
|
|
|
e354a5 |
break;
|
|
|
e354a5 |
|
|
|
e354a5 |
case _SC_SIGQUEUE_MAX:
|
|
|
e354a5 |
- if (__getrlimit (RLIMIT_SIGPENDING, &rlimit) == 0)
|
|
|
e354a5 |
- return rlimit.rlim_cur;
|
|
|
e354a5 |
+ {
|
|
|
e354a5 |
+ struct rlimit rlimit;
|
|
|
e354a5 |
+ if (__getrlimit (RLIMIT_SIGPENDING, &rlimit) == 0)
|
|
|
e354a5 |
+ return rlimit.rlim_cur;
|
|
|
e354a5 |
|
|
|
e354a5 |
- /* The /proc/sys/kernel/rtsig-max file contains the answer. */
|
|
|
e354a5 |
- procfname = "/proc/sys/kernel/rtsig-max";
|
|
|
e354a5 |
+ /* The /proc/sys/kernel/rtsig-max file contains the answer. */
|
|
|
e354a5 |
+ procfname = "/proc/sys/kernel/rtsig-max";
|
|
|
e354a5 |
+ }
|
|
|
e354a5 |
break;
|
|
|
e354a5 |
|
|
|
e354a5 |
default:
|