summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libc_r/uthread/uthread_nanosleep.c16
-rw-r--r--lib/libkse/thread/thr_nanosleep.c16
-rw-r--r--lib/libpthread/thread/thr_nanosleep.c16
3 files changed, 36 insertions, 12 deletions
diff --git a/lib/libc_r/uthread/uthread_nanosleep.c b/lib/libc_r/uthread/uthread_nanosleep.c
index 3bbc9a6..67dd08d 100644
--- a/lib/libc_r/uthread/uthread_nanosleep.c
+++ b/lib/libc_r/uthread/uthread_nanosleep.c
@@ -54,8 +54,12 @@ _nanosleep(const struct timespec * time_to_sleep,
errno = EINVAL;
ret = -1;
} else {
- /* Get the current time: */
- gettimeofday(&tv, NULL);
+ /*
+ * As long as we're going to get the time of day, we
+ * might as well store it in the global time of day:
+ */
+ gettimeofday((struct timeval *) &_sched_tod, NULL);
+ GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
@@ -73,8 +77,12 @@ _nanosleep(const struct timespec * time_to_sleep,
/* Reschedule the current thread to sleep: */
_thread_kern_sched_state(PS_SLEEP_WAIT, __FILE__, __LINE__);
- /* Get the current time: */
- gettimeofday(&tv, NULL);
+ /*
+ * As long as we're going to get the time of day, we
+ * might as well store it in the global time of day:
+ */
+ gettimeofday((struct timeval *) &_sched_tod, NULL);
+ GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time1);
/* Calculate the remaining time to sleep: */
diff --git a/lib/libkse/thread/thr_nanosleep.c b/lib/libkse/thread/thr_nanosleep.c
index 3bbc9a6..67dd08d 100644
--- a/lib/libkse/thread/thr_nanosleep.c
+++ b/lib/libkse/thread/thr_nanosleep.c
@@ -54,8 +54,12 @@ _nanosleep(const struct timespec * time_to_sleep,
errno = EINVAL;
ret = -1;
} else {
- /* Get the current time: */
- gettimeofday(&tv, NULL);
+ /*
+ * As long as we're going to get the time of day, we
+ * might as well store it in the global time of day:
+ */
+ gettimeofday((struct timeval *) &_sched_tod, NULL);
+ GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
@@ -73,8 +77,12 @@ _nanosleep(const struct timespec * time_to_sleep,
/* Reschedule the current thread to sleep: */
_thread_kern_sched_state(PS_SLEEP_WAIT, __FILE__, __LINE__);
- /* Get the current time: */
- gettimeofday(&tv, NULL);
+ /*
+ * As long as we're going to get the time of day, we
+ * might as well store it in the global time of day:
+ */
+ gettimeofday((struct timeval *) &_sched_tod, NULL);
+ GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time1);
/* Calculate the remaining time to sleep: */
diff --git a/lib/libpthread/thread/thr_nanosleep.c b/lib/libpthread/thread/thr_nanosleep.c
index 3bbc9a6..67dd08d 100644
--- a/lib/libpthread/thread/thr_nanosleep.c
+++ b/lib/libpthread/thread/thr_nanosleep.c
@@ -54,8 +54,12 @@ _nanosleep(const struct timespec * time_to_sleep,
errno = EINVAL;
ret = -1;
} else {
- /* Get the current time: */
- gettimeofday(&tv, NULL);
+ /*
+ * As long as we're going to get the time of day, we
+ * might as well store it in the global time of day:
+ */
+ gettimeofday((struct timeval *) &_sched_tod, NULL);
+ GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
@@ -73,8 +77,12 @@ _nanosleep(const struct timespec * time_to_sleep,
/* Reschedule the current thread to sleep: */
_thread_kern_sched_state(PS_SLEEP_WAIT, __FILE__, __LINE__);
- /* Get the current time: */
- gettimeofday(&tv, NULL);
+ /*
+ * As long as we're going to get the time of day, we
+ * might as well store it in the global time of day:
+ */
+ gettimeofday((struct timeval *) &_sched_tod, NULL);
+ GET_CURRENT_TOD(tv);
TIMEVAL_TO_TIMESPEC(&tv, &current_time1);
/* Calculate the remaining time to sleep: */
OpenPOWER on IntegriCloud