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