summaryrefslogtreecommitdiff
path: root/sysdeps/unix
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix')
-rw-r--r--sysdeps/unix/clock_gettime.c65
-rw-r--r--sysdeps/unix/clock_nanosleep.c30
-rw-r--r--sysdeps/unix/clock_settime.c61
3 files changed, 7 insertions, 149 deletions
diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c
index 33a1f3335c..10a6c96d9d 100644
--- a/sysdeps/unix/clock_gettime.c
+++ b/sysdeps/unix/clock_gettime.c
@@ -24,57 +24,6 @@
#include <ldsodefs.h>
-#if HP_TIMING_AVAIL
-/* Clock frequency of the processor. We make it a 64-bit variable
- because some jokers are already playing with processors with more
- than 4GHz. */
-static hp_timing_t freq;
-
-
-/* This function is defined in the thread library. */
-extern int __pthread_clock_gettime (clockid_t clock_id, hp_timing_t freq,
- struct timespec *tp)
- __attribute__ ((__weak__));
-
-static int
-hp_timing_gettime (clockid_t clock_id, struct timespec *tp)
-{
- hp_timing_t tsc;
-
- if (__glibc_unlikely (freq == 0))
- {
- /* This can only happen if we haven't initialized the `freq'
- variable yet. Do this now. We don't have to protect this
- code against multiple execution since all of them should
- lead to the same result. */
- freq = __get_clockfreq ();
- if (__glibc_unlikely (freq == 0))
- /* Something went wrong. */
- return -1;
- }
-
- if (clock_id != CLOCK_PROCESS_CPUTIME_ID
- && __pthread_clock_gettime != NULL)
- return __pthread_clock_gettime (clock_id, freq, tp);
-
- /* Get the current counter. */
- HP_TIMING_NOW (tsc);
-
- /* Compute the offset since the start time of the process. */
- tsc -= GL(dl_cpuclock_offset);
-
- /* Compute the seconds. */
- tp->tv_sec = tsc / freq;
-
- /* And the nanoseconds. This computation should be stable until
- we get machines with about 16GHz frequency. */
- tp->tv_nsec = ((tsc % freq) * UINT64_C (1000000000)) / freq;
-
- return 0;
-}
-#endif
-
-
static inline int
realtime_gettime (struct timespec *tp)
{
@@ -105,20 +54,8 @@ __clock_gettime (clockid_t clock_id, struct timespec *tp)
break;
default:
-#if HP_TIMING_AVAIL
- if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1))
- == CLOCK_THREAD_CPUTIME_ID)
- retval = hp_timing_gettime (clock_id, tp);
- else
-#endif
- __set_errno (EINVAL);
- break;
-
-#if HP_TIMING_AVAIL
- case CLOCK_PROCESS_CPUTIME_ID:
- retval = hp_timing_gettime (clock_id, tp);
+ __set_errno (EINVAL);
break;
-#endif
}
return retval;
diff --git a/sysdeps/unix/clock_nanosleep.c b/sysdeps/unix/clock_nanosleep.c
index 7722d1111c..b27608570c 100644
--- a/sysdeps/unix/clock_nanosleep.c
+++ b/sysdeps/unix/clock_nanosleep.c
@@ -19,23 +19,8 @@
#include <assert.h>
#include <errno.h>
#include <time.h>
-#include <hp-timing.h>
#include <sysdep-cancel.h>
-#if HP_TIMING_AVAIL
-# define CPUCLOCK_P(clock) \
- ((clock) == CLOCK_PROCESS_CPUTIME_ID \
- || ((clock) & ((1 << CLOCK_IDFIELD_SIZE) - 1)) == CLOCK_THREAD_CPUTIME_ID)
-#else
-# define CPUCLOCK_P(clock) 0
-#endif
-
-#ifndef INVALID_CLOCK_P
-# define INVALID_CLOCK_P(cl) \
- ((cl) < CLOCK_REALTIME || (cl) > CLOCK_THREAD_CPUTIME_ID)
-#endif
-
-
/* This implementation assumes that these is only a `nanosleep' system
call. So we have to remap all other activities. */
int
@@ -51,14 +36,7 @@ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
if (clock_id == CLOCK_THREAD_CPUTIME_ID)
return EINVAL; /* POSIX specifies EINVAL for this case. */
-#ifdef SYSDEP_NANOSLEEP
- SYSDEP_NANOSLEEP;
-#endif
-
- if (CPUCLOCK_P (clock_id))
- return ENOTSUP;
-
- if (INVALID_CLOCK_P (clock_id))
+ if (clock_id < CLOCK_REALTIME || clock_id > CLOCK_THREAD_CPUTIME_ID)
return EINVAL;
/* If we got an absolute time, remap it. */
@@ -71,7 +49,7 @@ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
assert (sizeof (sec) >= sizeof (now.tv_sec));
/* Get the current time for this clock. */
- if (__builtin_expect (__clock_gettime (clock_id, &now), 0) != 0)
+ if (__clock_gettime (clock_id, &now) != 0)
return errno;
/* Compute the difference. */
@@ -90,12 +68,12 @@ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
/* Make sure we are not modifying the struct pointed to by REM. */
rem = NULL;
}
- else if (__builtin_expect (flags, 0) != 0)
+ else if (flags != 0)
return EINVAL;
else if (clock_id != CLOCK_REALTIME)
/* Not supported. */
return ENOTSUP;
- return __builtin_expect (__nanosleep (req, rem), 0) ? errno : 0;
+ return __nanosleep (req, rem), 0 ? errno : 0;
}
weak_alias (__clock_nanosleep, clock_nanosleep)
diff --git a/sysdeps/unix/clock_settime.c b/sysdeps/unix/clock_settime.c
index dcf9ff660a..109a1ad872 100644
--- a/sysdeps/unix/clock_settime.c
+++ b/sysdeps/unix/clock_settime.c
@@ -21,59 +21,11 @@
#include <ldsodefs.h>
-#if HP_TIMING_AVAIL
-/* Clock frequency of the processor. We make it a 64-bit variable
- because some jokers are already playing with processors with more
- than 4GHz. */
-static hp_timing_t freq;
-
-
-/* This function is defined in the thread library. */
-extern void __pthread_clock_settime (clockid_t clock_id, hp_timing_t offset)
- __attribute__ ((__weak__));
-
-
-static int
-hp_timing_settime (clockid_t clock_id, const struct timespec *tp)
-{
- hp_timing_t tsc;
- hp_timing_t usertime;
-
- /* First thing is to get the current time. */
- HP_TIMING_NOW (tsc);
-
- if (__glibc_unlikely (freq == 0))
- {
- /* This can only happen if we haven't initialized the `freq'
- variable yet. Do this now. We don't have to protect this
- code against multiple execution since all of them should lead
- to the same result. */
- freq = __get_clockfreq ();
- if (__glibc_unlikely (freq == 0))
- /* Something went wrong. */
- return -1;
- }
-
- /* Convert the user-provided time into CPU ticks. */
- usertime = tp->tv_sec * freq + (tp->tv_nsec * freq) / 1000000000ull;
-
- /* Determine the offset and use it as the new base value. */
- if (clock_id == CLOCK_PROCESS_CPUTIME_ID
- || __pthread_clock_settime == NULL)
- GL(dl_cpuclock_offset) = tsc - usertime;
- else
- __pthread_clock_settime (clock_id, tsc - usertime);
-
- return 0;
-}
-#endif
-
-
/* Set CLOCK to value TP. */
int
__clock_settime (clockid_t clock_id, const struct timespec *tp)
{
- int retval;
+ int retval = -1;
/* Make sure the time cvalue is OK. */
if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000)
@@ -93,16 +45,7 @@ __clock_settime (clockid_t clock_id, const struct timespec *tp)
break;
default:
-# if HP_TIMING_AVAIL
- if (CPUCLOCK_WHICH (clock_id) == CLOCK_PROCESS_CPUTIME_ID
- || CPUCLOCK_WHICH (clock_id) == CLOCK_THREAD_CPUTIME_ID)
- retval = hp_timing_settime (clock_id, tp);
- else
-# endif
- {
- __set_errno (EINVAL);
- retval = -1;
- }
+ __set_errno (EINVAL);
break;
}