|
|
dfa500 |
commit b06f4c0094d3c68be39ada0ed26ae99d51f48013
|
|
|
dfa500 |
Author: Wilco Dijkstra <wdijkstr@arm.com>
|
|
|
dfa500 |
Date: Fri Feb 1 12:19:42 2019 +0000
|
|
|
dfa500 |
|
|
|
dfa500 |
Cleanup clock_*time includes
|
|
|
dfa500 |
|
|
|
dfa500 |
Clock_gettime, settime and getres implementations are unncessarily
|
|
|
dfa500 |
complex due to using defines and C file inclusion. Simplify the
|
|
|
dfa500 |
code by replacing the redundant defines and removing the inclusion,
|
|
|
dfa500 |
making it much easier to understand. No functional changes.
|
|
|
dfa500 |
|
|
|
dfa500 |
* sysdeps/posix/clock_getres.c (__clock_getres): Cleanup.
|
|
|
dfa500 |
* sysdeps/unix/clock_gettime.c (__clock_gettime): Cleanup.
|
|
|
dfa500 |
* sysdeps/unix/clock_settime.c (__clock_settime): Cleanup.
|
|
|
dfa500 |
* sysdeps/unix/sysv/linux/clock_getres.c (__clock_getres): Cleanup.
|
|
|
dfa500 |
* sysdeps/unix/sysv/linux/clock_gettime.c (__clock_gettime): Cleanup.
|
|
|
dfa500 |
* sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime): Cleanup.
|
|
|
dfa500 |
|
|
|
dfa500 |
diff --git a/sysdeps/posix/clock_getres.c b/sysdeps/posix/clock_getres.c
|
|
|
dfa500 |
index e7924e0891b0a476..43228c381e6a73f1 100644
|
|
|
dfa500 |
--- a/sysdeps/posix/clock_getres.c
|
|
|
dfa500 |
+++ b/sysdeps/posix/clock_getres.c
|
|
|
dfa500 |
@@ -82,20 +82,11 @@ __clock_getres (clockid_t clock_id, struct timespec *res)
|
|
|
dfa500 |
|
|
|
dfa500 |
switch (clock_id)
|
|
|
dfa500 |
{
|
|
|
dfa500 |
-#ifdef SYSDEP_GETRES
|
|
|
dfa500 |
- SYSDEP_GETRES;
|
|
|
dfa500 |
-#endif
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-#ifndef HANDLED_REALTIME
|
|
|
dfa500 |
case CLOCK_REALTIME:
|
|
|
dfa500 |
retval = realtime_getres (res);
|
|
|
dfa500 |
break;
|
|
|
dfa500 |
-#endif /* handled REALTIME */
|
|
|
dfa500 |
|
|
|
dfa500 |
default:
|
|
|
dfa500 |
-#ifdef SYSDEP_GETRES_CPU
|
|
|
dfa500 |
- SYSDEP_GETRES_CPU;
|
|
|
dfa500 |
-#endif
|
|
|
dfa500 |
#if HP_TIMING_AVAIL
|
|
|
dfa500 |
if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1))
|
|
|
dfa500 |
== CLOCK_THREAD_CPUTIME_ID)
|
|
|
dfa500 |
@@ -105,7 +96,7 @@ __clock_getres (clockid_t clock_id, struct timespec *res)
|
|
|
dfa500 |
__set_errno (EINVAL);
|
|
|
dfa500 |
break;
|
|
|
dfa500 |
|
|
|
dfa500 |
-#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME
|
|
|
dfa500 |
+#if HP_TIMING_AVAIL
|
|
|
dfa500 |
case CLOCK_PROCESS_CPUTIME_ID:
|
|
|
dfa500 |
case CLOCK_THREAD_CPUTIME_ID:
|
|
|
dfa500 |
retval = hp_timing_getres (res);
|
|
|
dfa500 |
diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c
|
|
|
dfa500 |
index 96df78ab1ed09c04..f19fdf7e5f310973 100644
|
|
|
dfa500 |
--- a/sysdeps/unix/clock_gettime.c
|
|
|
dfa500 |
+++ b/sysdeps/unix/clock_gettime.c
|
|
|
dfa500 |
@@ -95,11 +95,6 @@ __clock_gettime (clockid_t clock_id, struct timespec *tp)
|
|
|
dfa500 |
|
|
|
dfa500 |
switch (clock_id)
|
|
|
dfa500 |
{
|
|
|
dfa500 |
-#ifdef SYSDEP_GETTIME
|
|
|
dfa500 |
- SYSDEP_GETTIME;
|
|
|
dfa500 |
-#endif
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-#ifndef HANDLED_REALTIME
|
|
|
dfa500 |
case CLOCK_REALTIME:
|
|
|
dfa500 |
{
|
|
|
dfa500 |
struct timeval tv;
|
|
|
dfa500 |
@@ -108,12 +103,8 @@ __clock_gettime (clockid_t clock_id, struct timespec *tp)
|
|
|
dfa500 |
TIMEVAL_TO_TIMESPEC (&tv, tp);
|
|
|
dfa500 |
}
|
|
|
dfa500 |
break;
|
|
|
dfa500 |
-#endif
|
|
|
dfa500 |
|
|
|
dfa500 |
default:
|
|
|
dfa500 |
-#ifdef SYSDEP_GETTIME_CPU
|
|
|
dfa500 |
- SYSDEP_GETTIME_CPU (clock_id, tp);
|
|
|
dfa500 |
-#endif
|
|
|
dfa500 |
#if HP_TIMING_AVAIL
|
|
|
dfa500 |
if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1))
|
|
|
dfa500 |
== CLOCK_THREAD_CPUTIME_ID)
|
|
|
dfa500 |
@@ -123,7 +114,7 @@ __clock_gettime (clockid_t clock_id, struct timespec *tp)
|
|
|
dfa500 |
__set_errno (EINVAL);
|
|
|
dfa500 |
break;
|
|
|
dfa500 |
|
|
|
dfa500 |
-#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME
|
|
|
dfa500 |
+#if HP_TIMING_AVAIL
|
|
|
dfa500 |
case CLOCK_PROCESS_CPUTIME_ID:
|
|
|
dfa500 |
retval = hp_timing_gettime (clock_id, tp);
|
|
|
dfa500 |
break;
|
|
|
dfa500 |
diff --git a/sysdeps/unix/clock_settime.c b/sysdeps/unix/clock_settime.c
|
|
|
dfa500 |
index 38813eddf7b66ca1..9d5857e61b966b44 100644
|
|
|
dfa500 |
--- a/sysdeps/unix/clock_settime.c
|
|
|
dfa500 |
+++ b/sysdeps/unix/clock_settime.c
|
|
|
dfa500 |
@@ -21,7 +21,7 @@
|
|
|
dfa500 |
#include <ldsodefs.h>
|
|
|
dfa500 |
|
|
|
dfa500 |
|
|
|
dfa500 |
-#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME
|
|
|
dfa500 |
+#if HP_TIMING_AVAIL
|
|
|
dfa500 |
/* Clock frequency of the processor. We make it a 64-bit variable
|
|
|
dfa500 |
because some jokers are already playing with processors with more
|
|
|
dfa500 |
than 4GHz. */
|
|
|
dfa500 |
@@ -84,29 +84,15 @@ __clock_settime (clockid_t clock_id, const struct timespec *tp)
|
|
|
dfa500 |
|
|
|
dfa500 |
switch (clock_id)
|
|
|
dfa500 |
{
|
|
|
dfa500 |
-#define HANDLE_REALTIME \
|
|
|
dfa500 |
- do { \
|
|
|
dfa500 |
- struct timeval tv; \
|
|
|
dfa500 |
- TIMESPEC_TO_TIMEVAL (&tv, tp); \
|
|
|
dfa500 |
- \
|
|
|
dfa500 |
- retval = __settimeofday (&tv, NULL); \
|
|
|
dfa500 |
- } while (0)
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-#ifdef SYSDEP_SETTIME
|
|
|
dfa500 |
- SYSDEP_SETTIME;
|
|
|
dfa500 |
-#endif
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-#ifndef HANDLED_REALTIME
|
|
|
dfa500 |
case CLOCK_REALTIME:
|
|
|
dfa500 |
- HANDLE_REALTIME;
|
|
|
dfa500 |
+ {
|
|
|
dfa500 |
+ struct timeval tv;
|
|
|
dfa500 |
+ TIMESPEC_TO_TIMEVAL (&tv, tp);
|
|
|
dfa500 |
+ retval = __settimeofday (&tv, NULL);
|
|
|
dfa500 |
+ }
|
|
|
dfa500 |
break;
|
|
|
dfa500 |
-#endif
|
|
|
dfa500 |
|
|
|
dfa500 |
default:
|
|
|
dfa500 |
-#ifdef SYSDEP_SETTIME_CPU
|
|
|
dfa500 |
- SYSDEP_SETTIME_CPU;
|
|
|
dfa500 |
-#endif
|
|
|
dfa500 |
-#ifndef HANDLED_CPUTIME
|
|
|
dfa500 |
# if HP_TIMING_AVAIL
|
|
|
dfa500 |
if (CPUCLOCK_WHICH (clock_id) == CLOCK_PROCESS_CPUTIME_ID
|
|
|
dfa500 |
|| CPUCLOCK_WHICH (clock_id) == CLOCK_THREAD_CPUTIME_ID)
|
|
|
dfa500 |
@@ -117,7 +103,6 @@ __clock_settime (clockid_t clock_id, const struct timespec *tp)
|
|
|
dfa500 |
__set_errno (EINVAL);
|
|
|
dfa500 |
retval = -1;
|
|
|
dfa500 |
}
|
|
|
dfa500 |
-#endif
|
|
|
dfa500 |
break;
|
|
|
dfa500 |
}
|
|
|
dfa500 |
|
|
|
dfa500 |
diff --git a/sysdeps/unix/sysv/linux/clock_getres.c b/sysdeps/unix/sysv/linux/clock_getres.c
|
|
|
dfa500 |
index 5d94f59afee80fa9..2517e66910a79d93 100644
|
|
|
dfa500 |
--- a/sysdeps/unix/sysv/linux/clock_getres.c
|
|
|
dfa500 |
+++ b/sysdeps/unix/sysv/linux/clock_getres.c
|
|
|
dfa500 |
@@ -26,26 +26,10 @@
|
|
|
dfa500 |
#endif
|
|
|
dfa500 |
#include <sysdep-vdso.h>
|
|
|
dfa500 |
|
|
|
dfa500 |
-#define SYSCALL_GETRES \
|
|
|
dfa500 |
- retval = INLINE_VSYSCALL (clock_getres, 2, clock_id, res); \
|
|
|
dfa500 |
- break
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-/* The REALTIME and MONOTONIC clock are definitely supported in the
|
|
|
dfa500 |
- kernel. */
|
|
|
dfa500 |
-#define SYSDEP_GETRES \
|
|
|
dfa500 |
- SYSDEP_GETRES_CPUTIME \
|
|
|
dfa500 |
- case CLOCK_REALTIME: \
|
|
|
dfa500 |
- case CLOCK_MONOTONIC: \
|
|
|
dfa500 |
- case CLOCK_MONOTONIC_RAW: \
|
|
|
dfa500 |
- case CLOCK_REALTIME_COARSE: \
|
|
|
dfa500 |
- case CLOCK_MONOTONIC_COARSE: \
|
|
|
dfa500 |
- SYSCALL_GETRES
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-/* We handled the REALTIME clock here. */
|
|
|
dfa500 |
-#define HANDLED_REALTIME 1
|
|
|
dfa500 |
-#define HANDLED_CPUTIME 1
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-#define SYSDEP_GETRES_CPU SYSCALL_GETRES
|
|
|
dfa500 |
-#define SYSDEP_GETRES_CPUTIME /* Default catches them too. */
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-#include <sysdeps/posix/clock_getres.c>
|
|
|
dfa500 |
+/* Get resolution of clock. */
|
|
|
dfa500 |
+int
|
|
|
dfa500 |
+__clock_getres (clockid_t clock_id, struct timespec *res)
|
|
|
dfa500 |
+{
|
|
|
dfa500 |
+ return INLINE_VSYSCALL (clock_getres, 2, clock_id, res);
|
|
|
dfa500 |
+}
|
|
|
dfa500 |
+weak_alias (__clock_getres, clock_getres)
|
|
|
dfa500 |
diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c b/sysdeps/unix/sysv/linux/clock_gettime.c
|
|
|
dfa500 |
index d837fa36b1b901e5..dadfc518b74baea0 100644
|
|
|
dfa500 |
--- a/sysdeps/unix/sysv/linux/clock_gettime.c
|
|
|
dfa500 |
+++ b/sysdeps/unix/sysv/linux/clock_gettime.c
|
|
|
dfa500 |
@@ -26,22 +26,11 @@
|
|
|
dfa500 |
#endif
|
|
|
dfa500 |
#include <sysdep-vdso.h>
|
|
|
dfa500 |
|
|
|
dfa500 |
-/* The REALTIME and MONOTONIC clock are definitely supported in the
|
|
|
dfa500 |
- kernel. */
|
|
|
dfa500 |
-#define SYSDEP_GETTIME \
|
|
|
dfa500 |
- SYSDEP_GETTIME_CPUTIME; \
|
|
|
dfa500 |
- case CLOCK_REALTIME: \
|
|
|
dfa500 |
- case CLOCK_MONOTONIC: \
|
|
|
dfa500 |
- retval = INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); \
|
|
|
dfa500 |
- break
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-/* We handled the REALTIME clock here. */
|
|
|
dfa500 |
-#define HANDLED_REALTIME 1
|
|
|
dfa500 |
-#define HANDLED_CPUTIME 1
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-#define SYSDEP_GETTIME_CPU(clock_id, tp) \
|
|
|
dfa500 |
- retval = INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); \
|
|
|
dfa500 |
- break
|
|
|
dfa500 |
-#define SYSDEP_GETTIME_CPUTIME /* Default catches them too. */
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-#include <sysdeps/unix/clock_gettime.c>
|
|
|
dfa500 |
+/* Get current value of CLOCK and store it in TP. */
|
|
|
dfa500 |
+int
|
|
|
dfa500 |
+__clock_gettime (clockid_t clock_id, struct timespec *tp)
|
|
|
dfa500 |
+{
|
|
|
dfa500 |
+ return INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp);
|
|
|
dfa500 |
+}
|
|
|
dfa500 |
+weak_alias (__clock_gettime, clock_gettime)
|
|
|
dfa500 |
+libc_hidden_def (__clock_gettime)
|
|
|
dfa500 |
diff --git a/sysdeps/unix/sysv/linux/clock_settime.c b/sysdeps/unix/sysv/linux/clock_settime.c
|
|
|
dfa500 |
index 5f3f22f74b3e745c..c71461a4f6deac5a 100644
|
|
|
dfa500 |
--- a/sysdeps/unix/sysv/linux/clock_settime.c
|
|
|
dfa500 |
+++ b/sysdeps/unix/sysv/linux/clock_settime.c
|
|
|
dfa500 |
@@ -21,18 +21,17 @@
|
|
|
dfa500 |
|
|
|
dfa500 |
#include "kernel-posix-cpu-timers.h"
|
|
|
dfa500 |
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-/* The REALTIME clock is definitely supported in the kernel. */
|
|
|
dfa500 |
-#define SYSDEP_SETTIME \
|
|
|
dfa500 |
- case CLOCK_REALTIME: \
|
|
|
dfa500 |
- retval = INLINE_SYSCALL (clock_settime, 2, clock_id, tp); \
|
|
|
dfa500 |
- break
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-/* We handled the REALTIME clock here. */
|
|
|
dfa500 |
-#define HANDLED_REALTIME 1
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-#define HANDLED_CPUTIME 1
|
|
|
dfa500 |
-#define SYSDEP_SETTIME_CPU \
|
|
|
dfa500 |
- retval = INLINE_SYSCALL (clock_settime, 2, clock_id, tp)
|
|
|
dfa500 |
-
|
|
|
dfa500 |
-#include <sysdeps/unix/clock_settime.c>
|
|
|
dfa500 |
+/* Set CLOCK to value TP. */
|
|
|
dfa500 |
+int
|
|
|
dfa500 |
+__clock_settime (clockid_t clock_id, const struct timespec *tp)
|
|
|
dfa500 |
+{
|
|
|
dfa500 |
+ /* Make sure the time cvalue is OK. */
|
|
|
dfa500 |
+ if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000)
|
|
|
dfa500 |
+ {
|
|
|
dfa500 |
+ __set_errno (EINVAL);
|
|
|
dfa500 |
+ return -1;
|
|
|
dfa500 |
+ }
|
|
|
dfa500 |
+
|
|
|
dfa500 |
+ return INLINE_SYSCALL_CALL (clock_settime, clock_id, tp);
|
|
|
dfa500 |
+}
|
|
|
dfa500 |
+weak_alias (__clock_settime, clock_settime)
|