summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authornate <nate@FreeBSD.org>1996-09-20 06:33:54 +0000
committernate <nate@FreeBSD.org>1996-09-20 06:33:54 +0000
commitc19924b40999e4c8f0a8c7772bb76abf312ba197 (patch)
tree935487cdfab28e511c09b2f7b1f8bc5a2ca8c5ff /lib
parent934efd0502462dcd9fa380eaee3b55c8c91a0cdc (diff)
downloadFreeBSD-src-c19924b40999e4c8f0a8c7772bb76abf312ba197.zip
FreeBSD-src-c19924b40999e4c8f0a8c7772bb76abf312ba197.tar.gz
Remove now un-necessary FreeBSD specific code since our timespec
structure now has the correct member names. Pointed out by: Peter Wemm
Diffstat (limited to 'lib')
-rw-r--r--lib/libc_r/uthread/uthread_cond.c5
-rw-r--r--lib/libc_r/uthread/uthread_kern.c112
-rw-r--r--lib/libc_r/uthread/uthread_nanosleep.c59
-rw-r--r--lib/libkse/thread/thr_cond.c5
-rw-r--r--lib/libkse/thread/thr_kern.c112
-rw-r--r--lib/libkse/thread/thr_nanosleep.c59
-rw-r--r--lib/libpthread/thread/thr_cond.c5
-rw-r--r--lib/libpthread/thread/thr_kern.c112
-rw-r--r--lib/libpthread/thread/thr_nanosleep.c59
9 files changed, 0 insertions, 528 deletions
diff --git a/lib/libc_r/uthread/uthread_cond.c b/lib/libc_r/uthread/uthread_cond.c
index 0f9f302..4395380 100644
--- a/lib/libc_r/uthread/uthread_cond.c
+++ b/lib/libc_r/uthread/uthread_cond.c
@@ -200,13 +200,8 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
/* Fast condition variable: */
case COND_TYPE_FAST:
/* Set the wakeup time: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = abstime->ts_sec;
- _thread_run->wakeup_time.ts_nsec = abstime->ts_nsec;
-#else
_thread_run->wakeup_time.tv_sec = abstime->tv_sec;
_thread_run->wakeup_time.tv_nsec = abstime->tv_nsec;
-#endif
/* Reset the timeout flag: */
_thread_run->timeout = 0;
diff --git a/lib/libc_r/uthread/uthread_kern.c b/lib/libc_r/uthread/uthread_kern.c
index c6759cf..1db4da6 100644
--- a/lib/libc_r/uthread/uthread_kern.c
+++ b/lib/libc_r/uthread/uthread_kern.c
@@ -250,30 +250,18 @@ __asm__("fnsave %0": :"m"(*fdata));
pthread->state == PS_FDW_WAIT ||
pthread->state == PS_SELECT_WAIT) {
/* Check if this thread is to wait forever: */
-#if defined(__FreeBSD__)
- if (pthread->wakeup_time.ts_sec == -1) {
-#else
if (pthread->wakeup_time.tv_sec == -1) {
-#endif
}
/*
* Check if this thread is to wakeup
* immediately or if it is past its wakeup
* time:
*/
-#if defined(__FreeBSD__)
- else if ((pthread->wakeup_time.ts_sec == 0 &&
- pthread->wakeup_time.ts_nsec == 0) ||
- (ts.ts_sec > pthread->wakeup_time.ts_sec) ||
- ((ts.ts_sec == pthread->wakeup_time.ts_sec) &&
- (ts.ts_nsec >= pthread->wakeup_time.ts_nsec))) {
-#else
else if ((pthread->wakeup_time.tv_sec == 0 &&
pthread->wakeup_time.tv_nsec == 0) ||
(ts.tv_sec > pthread->wakeup_time.tv_sec) ||
((ts.tv_sec == pthread->wakeup_time.tv_sec) &&
(ts.tv_nsec >= pthread->wakeup_time.tv_nsec))) {
-#endif
/*
* Check if this thread is waiting on
* select:
@@ -694,37 +682,22 @@ __asm__("fnsave %0": :"m"(*fdata));
* Check if this thread is to
* wait forever:
*/
-#if defined(__FreeBSD__)
- if (pthread->wakeup_time.ts_sec == -1) {
-#else
if (pthread->wakeup_time.tv_sec == -1) {
-#endif
}
/*
* Check if this thread is to
* wakeup immediately:
*/
-#if defined(__FreeBSD__)
- else if (pthread->wakeup_time.ts_sec == 0 &&
- pthread->wakeup_time.ts_nsec == 0) {
-#else
else if (pthread->wakeup_time.tv_sec == 0 &&
pthread->wakeup_time.tv_nsec == 0) {
-#endif
}
/*
* Check if the current time
* is after the wakeup time:
*/
-#if defined(__FreeBSD__)
- else if ((ts.ts_sec > pthread->wakeup_time.ts_sec) ||
- ((ts.ts_sec == pthread->wakeup_time.ts_sec) &&
- (ts.ts_nsec > pthread->wakeup_time.ts_nsec))) {
-#else
else if ((ts.tv_sec > pthread->wakeup_time.tv_sec) ||
((ts.tv_sec == pthread->wakeup_time.tv_sec) &&
(ts.tv_nsec > pthread->wakeup_time.tv_nsec))) {
-#endif
} else {
/*
* Calculate the time
@@ -733,26 +706,16 @@ __asm__("fnsave %0": :"m"(*fdata));
* for the clock
* resolution:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec = pthread->wakeup_time.ts_sec - ts.ts_sec;
- ts1.ts_nsec = pthread->wakeup_time.ts_nsec - ts.ts_nsec +
- CLOCK_RES_NSEC;
-#else
ts1.tv_sec = pthread->wakeup_time.tv_sec - ts.tv_sec;
ts1.tv_nsec = pthread->wakeup_time.tv_nsec - ts.tv_nsec +
CLOCK_RES_NSEC;
-#endif
/*
* Check for
* underflow of the
* nanosecond field:
*/
-#if defined(__FreeBSD__)
- if (ts1.ts_nsec < 0) {
-#else
if (ts1.tv_nsec < 0) {
-#endif
/*
* Allow for
* the
@@ -761,24 +724,15 @@ __asm__("fnsave %0": :"m"(*fdata));
* nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec--;
- ts1.ts_nsec += 1000000000;
-#else
ts1.tv_sec--;
ts1.tv_nsec += 1000000000;
-#endif
}
/*
* Check for overflow
* of the nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- if (ts1.ts_nsec >= 1000000000) {
-#else
if (ts1.tv_nsec >= 1000000000) {
-#endif
/*
* Allow for
* the
@@ -787,13 +741,8 @@ __asm__("fnsave %0": :"m"(*fdata));
* nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec++;
- ts1.ts_nsec -= 1000000000;
-#else
ts1.tv_sec++;
ts1.tv_nsec -= 1000000000;
-#endif
}
/*
* Convert the
@@ -1268,20 +1217,11 @@ _thread_kern_select(int wait_reqd)
*/
if (wait_reqd && settimeout) {
/* Check if this thread wants to wait forever: */
-#if defined(__FreeBSD__)
- if (pthread->wakeup_time.ts_sec == -1) {
-#else
if (pthread->wakeup_time.tv_sec == -1) {
-#endif
}
/* Check if this thread doesn't want to wait at all: */
-#if defined(__FreeBSD__)
- else if (pthread->wakeup_time.ts_sec == 0 &&
- pthread->wakeup_time.ts_nsec == 0) {
-#else
else if (pthread->wakeup_time.tv_sec == 0 &&
pthread->wakeup_time.tv_nsec == 0) {
-#endif
/* Override the caller's request to wait: */
wait_reqd = 0;
} else {
@@ -1289,57 +1229,33 @@ _thread_kern_select(int wait_reqd)
* Calculate the time until this thread is
* ready, allowing for the clock resolution:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec = pthread->wakeup_time.ts_sec - ts.ts_sec;
- ts1.ts_nsec = pthread->wakeup_time.ts_nsec - ts.ts_nsec +
- CLOCK_RES_NSEC;
-#else
ts1.tv_sec = pthread->wakeup_time.tv_sec - ts.tv_sec;
ts1.tv_nsec = pthread->wakeup_time.tv_nsec - ts.tv_nsec +
CLOCK_RES_NSEC;
-#endif
/*
* Check for underflow of the nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- if (ts1.ts_nsec < 0) {
-#else
if (ts1.tv_nsec < 0) {
-#endif
/*
* Allow for the underflow of the
* nanosecond field:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec--;
- ts1.ts_nsec += 1000000000;
-#else
ts1.tv_sec--;
ts1.tv_nsec += 1000000000;
-#endif
}
/*
* Check for overflow of the nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- if (ts1.ts_nsec >= 1000000000) {
-#else
if (ts1.tv_nsec >= 1000000000) {
-#endif
/*
* Allow for the overflow of the
* nanosecond field:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec++;
- ts1.ts_nsec -= 1000000000;
-#else
ts1.tv_sec++;
ts1.tv_nsec -= 1000000000;
-#endif
}
/*
* Convert the timespec structure to a
@@ -1753,56 +1669,28 @@ _thread_kern_set_timeout(struct timespec * timeout)
* Set the wakeup time to something that can be recognised as
* different to an actual time of day:
*/
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = -1;
- _thread_run->wakeup_time.ts_nsec = -1;
-#else
_thread_run->wakeup_time.tv_sec = -1;
_thread_run->wakeup_time.tv_nsec = -1;
-#endif
}
/* Check if no waiting is required: */
-#if defined(__FreeBSD__)
- else if (timeout->ts_sec == 0 && timeout->ts_nsec == 0) {
-#else
else if (timeout->tv_sec == 0 && timeout->tv_nsec == 0) {
-#endif
/* Set the wake up time to 'immediately': */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = 0;
- _thread_run->wakeup_time.ts_nsec = 0;
-#else
_thread_run->wakeup_time.tv_sec = 0;
_thread_run->wakeup_time.tv_nsec = 0;
-#endif
} else {
/* Get the current time: */
gettimeofday(&tv, NULL);
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = current_time.ts_sec + timeout->ts_sec;
- _thread_run->wakeup_time.ts_nsec = current_time.ts_nsec + timeout->ts_nsec;
-#else
_thread_run->wakeup_time.tv_sec = current_time.tv_sec + timeout->tv_sec;
_thread_run->wakeup_time.tv_nsec = current_time.tv_nsec + timeout->tv_nsec;
-#endif
/* Check if the nanosecond field needs to wrap: */
-#if defined(__FreeBSD__)
- if (_thread_run->wakeup_time.ts_nsec >= 1000000000) {
-#else
if (_thread_run->wakeup_time.tv_nsec >= 1000000000) {
-#endif
/* Wrap the nanosecond field: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec += 1;
- _thread_run->wakeup_time.ts_nsec -= 1000000000;
-#else
_thread_run->wakeup_time.tv_sec += 1;
_thread_run->wakeup_time.tv_nsec -= 1000000000;
-#endif
}
}
return;
diff --git a/lib/libc_r/uthread/uthread_nanosleep.c b/lib/libc_r/uthread/uthread_nanosleep.c
index 58ade98..46ec14b 100644
--- a/lib/libc_r/uthread/uthread_nanosleep.c
+++ b/lib/libc_r/uthread/uthread_nanosleep.c
@@ -46,11 +46,7 @@ nanosleep(struct timespec * time_to_sleep, struct timespec * time_remaining)
struct timeval tv;
/* Check if the time to sleep is legal: */
-#if defined(__FreeBSD__)
- if (time_to_sleep == NULL || time_to_sleep->ts_nsec < 0 || time_to_sleep->ts_nsec > 1000000000) {
-#else
if (time_to_sleep == NULL || time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec > 1000000000) {
-#endif
/* Return an EINVAL error : */
errno = EINVAL;
ret = -1;
@@ -60,28 +56,14 @@ nanosleep(struct timespec * time_to_sleep, struct timespec * time_remaining)
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = current_time.ts_sec + time_to_sleep->ts_sec;
- _thread_run->wakeup_time.ts_nsec = current_time.ts_nsec + time_to_sleep->ts_nsec;
-#else
_thread_run->wakeup_time.tv_sec = current_time.tv_sec + time_to_sleep->tv_sec;
_thread_run->wakeup_time.tv_nsec = current_time.tv_nsec + time_to_sleep->tv_nsec;
-#endif
/* Check if the nanosecond field has overflowed: */
-#if defined(__FreeBSD__)
- if (_thread_run->wakeup_time.ts_nsec >= 1000000000) {
-#else
if (_thread_run->wakeup_time.tv_nsec >= 1000000000) {
-#endif
/* Wrap the nanosecond field: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec += 1;
- _thread_run->wakeup_time.ts_nsec -= 1000000000;
-#else
_thread_run->wakeup_time.tv_sec += 1;
_thread_run->wakeup_time.tv_nsec -= 1000000000;
-#endif
}
/* Reschedule the current thread to sleep: */
@@ -92,80 +74,39 @@ nanosleep(struct timespec * time_to_sleep, struct timespec * time_remaining)
TIMEVAL_TO_TIMESPEC(&tv, &current_time1);
/* Calculate the remaining time to sleep: */
-#if defined(__FreeBSD__)
- remaining_time.ts_sec = time_to_sleep->ts_sec + current_time.ts_sec - current_time1.ts_sec;
- remaining_time.ts_nsec = time_to_sleep->ts_nsec + current_time.ts_nsec - current_time1.ts_nsec;
-#else
remaining_time.tv_sec = time_to_sleep->tv_sec + current_time.tv_sec - current_time1.tv_sec;
remaining_time.tv_nsec = time_to_sleep->tv_nsec + current_time.tv_nsec - current_time1.tv_nsec;
-#endif
/* Check if the nanosecond field has underflowed: */
-#if defined(__FreeBSD__)
- if (remaining_time.ts_nsec < 0) {
-#else
if (remaining_time.tv_nsec < 0) {
-#endif
/* Handle the underflow: */
-#if defined(__FreeBSD__)
- remaining_time.ts_sec -= 1;
- remaining_time.ts_nsec += 1000000000;
-#else
remaining_time.tv_sec -= 1;
remaining_time.tv_nsec += 1000000000;
-#endif
}
/* Check if the nanosecond field has overflowed: */
-#if defined(__FreeBSD__)
- if (remaining_time.ts_nsec >= 1000000000) {
-#else
if (remaining_time.tv_nsec >= 1000000000) {
-#endif
/* Handle the overflow: */
-#if defined(__FreeBSD__)
- remaining_time.ts_sec += 1;
- remaining_time.ts_nsec -= 1000000000;
-#else
remaining_time.tv_sec += 1;
remaining_time.tv_nsec -= 1000000000;
-#endif
}
/* Check if the sleep was longer than the required time: */
-#if defined(__FreeBSD__)
- if (remaining_time.ts_sec < 0) {
-#else
if (remaining_time.tv_sec < 0) {
-#endif
/* Reset the time left: */
-#if defined(__FreeBSD__)
- remaining_time.ts_sec = 0;
- remaining_time.ts_nsec = 0;
-#else
remaining_time.tv_sec = 0;
remaining_time.tv_nsec = 0;
-#endif
}
/* Check if the time remaining is to be returned: */
if (time_remaining != NULL) {
/* Return the actual time slept: */
-#if defined(__FreeBSD__)
- time_remaining->ts_sec = remaining_time.ts_sec;
- time_remaining->ts_nsec = remaining_time.ts_nsec;
-#else
time_remaining->tv_sec = remaining_time.tv_sec;
time_remaining->tv_nsec = remaining_time.tv_nsec;
-#endif
}
/* Check if the entire sleep was not completed: */
-#if defined(__FreeBSD__)
- if (remaining_time.ts_nsec != 0 || remaining_time.ts_sec != 0) {
-#else
if (remaining_time.tv_nsec != 0 || remaining_time.tv_sec != 0) {
-#endif
/* Return an EINTR error : */
errno = EINTR;
ret = -1;
diff --git a/lib/libkse/thread/thr_cond.c b/lib/libkse/thread/thr_cond.c
index 0f9f302..4395380 100644
--- a/lib/libkse/thread/thr_cond.c
+++ b/lib/libkse/thread/thr_cond.c
@@ -200,13 +200,8 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
/* Fast condition variable: */
case COND_TYPE_FAST:
/* Set the wakeup time: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = abstime->ts_sec;
- _thread_run->wakeup_time.ts_nsec = abstime->ts_nsec;
-#else
_thread_run->wakeup_time.tv_sec = abstime->tv_sec;
_thread_run->wakeup_time.tv_nsec = abstime->tv_nsec;
-#endif
/* Reset the timeout flag: */
_thread_run->timeout = 0;
diff --git a/lib/libkse/thread/thr_kern.c b/lib/libkse/thread/thr_kern.c
index c6759cf..1db4da6 100644
--- a/lib/libkse/thread/thr_kern.c
+++ b/lib/libkse/thread/thr_kern.c
@@ -250,30 +250,18 @@ __asm__("fnsave %0": :"m"(*fdata));
pthread->state == PS_FDW_WAIT ||
pthread->state == PS_SELECT_WAIT) {
/* Check if this thread is to wait forever: */
-#if defined(__FreeBSD__)
- if (pthread->wakeup_time.ts_sec == -1) {
-#else
if (pthread->wakeup_time.tv_sec == -1) {
-#endif
}
/*
* Check if this thread is to wakeup
* immediately or if it is past its wakeup
* time:
*/
-#if defined(__FreeBSD__)
- else if ((pthread->wakeup_time.ts_sec == 0 &&
- pthread->wakeup_time.ts_nsec == 0) ||
- (ts.ts_sec > pthread->wakeup_time.ts_sec) ||
- ((ts.ts_sec == pthread->wakeup_time.ts_sec) &&
- (ts.ts_nsec >= pthread->wakeup_time.ts_nsec))) {
-#else
else if ((pthread->wakeup_time.tv_sec == 0 &&
pthread->wakeup_time.tv_nsec == 0) ||
(ts.tv_sec > pthread->wakeup_time.tv_sec) ||
((ts.tv_sec == pthread->wakeup_time.tv_sec) &&
(ts.tv_nsec >= pthread->wakeup_time.tv_nsec))) {
-#endif
/*
* Check if this thread is waiting on
* select:
@@ -694,37 +682,22 @@ __asm__("fnsave %0": :"m"(*fdata));
* Check if this thread is to
* wait forever:
*/
-#if defined(__FreeBSD__)
- if (pthread->wakeup_time.ts_sec == -1) {
-#else
if (pthread->wakeup_time.tv_sec == -1) {
-#endif
}
/*
* Check if this thread is to
* wakeup immediately:
*/
-#if defined(__FreeBSD__)
- else if (pthread->wakeup_time.ts_sec == 0 &&
- pthread->wakeup_time.ts_nsec == 0) {
-#else
else if (pthread->wakeup_time.tv_sec == 0 &&
pthread->wakeup_time.tv_nsec == 0) {
-#endif
}
/*
* Check if the current time
* is after the wakeup time:
*/
-#if defined(__FreeBSD__)
- else if ((ts.ts_sec > pthread->wakeup_time.ts_sec) ||
- ((ts.ts_sec == pthread->wakeup_time.ts_sec) &&
- (ts.ts_nsec > pthread->wakeup_time.ts_nsec))) {
-#else
else if ((ts.tv_sec > pthread->wakeup_time.tv_sec) ||
((ts.tv_sec == pthread->wakeup_time.tv_sec) &&
(ts.tv_nsec > pthread->wakeup_time.tv_nsec))) {
-#endif
} else {
/*
* Calculate the time
@@ -733,26 +706,16 @@ __asm__("fnsave %0": :"m"(*fdata));
* for the clock
* resolution:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec = pthread->wakeup_time.ts_sec - ts.ts_sec;
- ts1.ts_nsec = pthread->wakeup_time.ts_nsec - ts.ts_nsec +
- CLOCK_RES_NSEC;
-#else
ts1.tv_sec = pthread->wakeup_time.tv_sec - ts.tv_sec;
ts1.tv_nsec = pthread->wakeup_time.tv_nsec - ts.tv_nsec +
CLOCK_RES_NSEC;
-#endif
/*
* Check for
* underflow of the
* nanosecond field:
*/
-#if defined(__FreeBSD__)
- if (ts1.ts_nsec < 0) {
-#else
if (ts1.tv_nsec < 0) {
-#endif
/*
* Allow for
* the
@@ -761,24 +724,15 @@ __asm__("fnsave %0": :"m"(*fdata));
* nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec--;
- ts1.ts_nsec += 1000000000;
-#else
ts1.tv_sec--;
ts1.tv_nsec += 1000000000;
-#endif
}
/*
* Check for overflow
* of the nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- if (ts1.ts_nsec >= 1000000000) {
-#else
if (ts1.tv_nsec >= 1000000000) {
-#endif
/*
* Allow for
* the
@@ -787,13 +741,8 @@ __asm__("fnsave %0": :"m"(*fdata));
* nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec++;
- ts1.ts_nsec -= 1000000000;
-#else
ts1.tv_sec++;
ts1.tv_nsec -= 1000000000;
-#endif
}
/*
* Convert the
@@ -1268,20 +1217,11 @@ _thread_kern_select(int wait_reqd)
*/
if (wait_reqd && settimeout) {
/* Check if this thread wants to wait forever: */
-#if defined(__FreeBSD__)
- if (pthread->wakeup_time.ts_sec == -1) {
-#else
if (pthread->wakeup_time.tv_sec == -1) {
-#endif
}
/* Check if this thread doesn't want to wait at all: */
-#if defined(__FreeBSD__)
- else if (pthread->wakeup_time.ts_sec == 0 &&
- pthread->wakeup_time.ts_nsec == 0) {
-#else
else if (pthread->wakeup_time.tv_sec == 0 &&
pthread->wakeup_time.tv_nsec == 0) {
-#endif
/* Override the caller's request to wait: */
wait_reqd = 0;
} else {
@@ -1289,57 +1229,33 @@ _thread_kern_select(int wait_reqd)
* Calculate the time until this thread is
* ready, allowing for the clock resolution:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec = pthread->wakeup_time.ts_sec - ts.ts_sec;
- ts1.ts_nsec = pthread->wakeup_time.ts_nsec - ts.ts_nsec +
- CLOCK_RES_NSEC;
-#else
ts1.tv_sec = pthread->wakeup_time.tv_sec - ts.tv_sec;
ts1.tv_nsec = pthread->wakeup_time.tv_nsec - ts.tv_nsec +
CLOCK_RES_NSEC;
-#endif
/*
* Check for underflow of the nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- if (ts1.ts_nsec < 0) {
-#else
if (ts1.tv_nsec < 0) {
-#endif
/*
* Allow for the underflow of the
* nanosecond field:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec--;
- ts1.ts_nsec += 1000000000;
-#else
ts1.tv_sec--;
ts1.tv_nsec += 1000000000;
-#endif
}
/*
* Check for overflow of the nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- if (ts1.ts_nsec >= 1000000000) {
-#else
if (ts1.tv_nsec >= 1000000000) {
-#endif
/*
* Allow for the overflow of the
* nanosecond field:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec++;
- ts1.ts_nsec -= 1000000000;
-#else
ts1.tv_sec++;
ts1.tv_nsec -= 1000000000;
-#endif
}
/*
* Convert the timespec structure to a
@@ -1753,56 +1669,28 @@ _thread_kern_set_timeout(struct timespec * timeout)
* Set the wakeup time to something that can be recognised as
* different to an actual time of day:
*/
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = -1;
- _thread_run->wakeup_time.ts_nsec = -1;
-#else
_thread_run->wakeup_time.tv_sec = -1;
_thread_run->wakeup_time.tv_nsec = -1;
-#endif
}
/* Check if no waiting is required: */
-#if defined(__FreeBSD__)
- else if (timeout->ts_sec == 0 && timeout->ts_nsec == 0) {
-#else
else if (timeout->tv_sec == 0 && timeout->tv_nsec == 0) {
-#endif
/* Set the wake up time to 'immediately': */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = 0;
- _thread_run->wakeup_time.ts_nsec = 0;
-#else
_thread_run->wakeup_time.tv_sec = 0;
_thread_run->wakeup_time.tv_nsec = 0;
-#endif
} else {
/* Get the current time: */
gettimeofday(&tv, NULL);
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = current_time.ts_sec + timeout->ts_sec;
- _thread_run->wakeup_time.ts_nsec = current_time.ts_nsec + timeout->ts_nsec;
-#else
_thread_run->wakeup_time.tv_sec = current_time.tv_sec + timeout->tv_sec;
_thread_run->wakeup_time.tv_nsec = current_time.tv_nsec + timeout->tv_nsec;
-#endif
/* Check if the nanosecond field needs to wrap: */
-#if defined(__FreeBSD__)
- if (_thread_run->wakeup_time.ts_nsec >= 1000000000) {
-#else
if (_thread_run->wakeup_time.tv_nsec >= 1000000000) {
-#endif
/* Wrap the nanosecond field: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec += 1;
- _thread_run->wakeup_time.ts_nsec -= 1000000000;
-#else
_thread_run->wakeup_time.tv_sec += 1;
_thread_run->wakeup_time.tv_nsec -= 1000000000;
-#endif
}
}
return;
diff --git a/lib/libkse/thread/thr_nanosleep.c b/lib/libkse/thread/thr_nanosleep.c
index 58ade98..46ec14b 100644
--- a/lib/libkse/thread/thr_nanosleep.c
+++ b/lib/libkse/thread/thr_nanosleep.c
@@ -46,11 +46,7 @@ nanosleep(struct timespec * time_to_sleep, struct timespec * time_remaining)
struct timeval tv;
/* Check if the time to sleep is legal: */
-#if defined(__FreeBSD__)
- if (time_to_sleep == NULL || time_to_sleep->ts_nsec < 0 || time_to_sleep->ts_nsec > 1000000000) {
-#else
if (time_to_sleep == NULL || time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec > 1000000000) {
-#endif
/* Return an EINVAL error : */
errno = EINVAL;
ret = -1;
@@ -60,28 +56,14 @@ nanosleep(struct timespec * time_to_sleep, struct timespec * time_remaining)
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = current_time.ts_sec + time_to_sleep->ts_sec;
- _thread_run->wakeup_time.ts_nsec = current_time.ts_nsec + time_to_sleep->ts_nsec;
-#else
_thread_run->wakeup_time.tv_sec = current_time.tv_sec + time_to_sleep->tv_sec;
_thread_run->wakeup_time.tv_nsec = current_time.tv_nsec + time_to_sleep->tv_nsec;
-#endif
/* Check if the nanosecond field has overflowed: */
-#if defined(__FreeBSD__)
- if (_thread_run->wakeup_time.ts_nsec >= 1000000000) {
-#else
if (_thread_run->wakeup_time.tv_nsec >= 1000000000) {
-#endif
/* Wrap the nanosecond field: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec += 1;
- _thread_run->wakeup_time.ts_nsec -= 1000000000;
-#else
_thread_run->wakeup_time.tv_sec += 1;
_thread_run->wakeup_time.tv_nsec -= 1000000000;
-#endif
}
/* Reschedule the current thread to sleep: */
@@ -92,80 +74,39 @@ nanosleep(struct timespec * time_to_sleep, struct timespec * time_remaining)
TIMEVAL_TO_TIMESPEC(&tv, &current_time1);
/* Calculate the remaining time to sleep: */
-#if defined(__FreeBSD__)
- remaining_time.ts_sec = time_to_sleep->ts_sec + current_time.ts_sec - current_time1.ts_sec;
- remaining_time.ts_nsec = time_to_sleep->ts_nsec + current_time.ts_nsec - current_time1.ts_nsec;
-#else
remaining_time.tv_sec = time_to_sleep->tv_sec + current_time.tv_sec - current_time1.tv_sec;
remaining_time.tv_nsec = time_to_sleep->tv_nsec + current_time.tv_nsec - current_time1.tv_nsec;
-#endif
/* Check if the nanosecond field has underflowed: */
-#if defined(__FreeBSD__)
- if (remaining_time.ts_nsec < 0) {
-#else
if (remaining_time.tv_nsec < 0) {
-#endif
/* Handle the underflow: */
-#if defined(__FreeBSD__)
- remaining_time.ts_sec -= 1;
- remaining_time.ts_nsec += 1000000000;
-#else
remaining_time.tv_sec -= 1;
remaining_time.tv_nsec += 1000000000;
-#endif
}
/* Check if the nanosecond field has overflowed: */
-#if defined(__FreeBSD__)
- if (remaining_time.ts_nsec >= 1000000000) {
-#else
if (remaining_time.tv_nsec >= 1000000000) {
-#endif
/* Handle the overflow: */
-#if defined(__FreeBSD__)
- remaining_time.ts_sec += 1;
- remaining_time.ts_nsec -= 1000000000;
-#else
remaining_time.tv_sec += 1;
remaining_time.tv_nsec -= 1000000000;
-#endif
}
/* Check if the sleep was longer than the required time: */
-#if defined(__FreeBSD__)
- if (remaining_time.ts_sec < 0) {
-#else
if (remaining_time.tv_sec < 0) {
-#endif
/* Reset the time left: */
-#if defined(__FreeBSD__)
- remaining_time.ts_sec = 0;
- remaining_time.ts_nsec = 0;
-#else
remaining_time.tv_sec = 0;
remaining_time.tv_nsec = 0;
-#endif
}
/* Check if the time remaining is to be returned: */
if (time_remaining != NULL) {
/* Return the actual time slept: */
-#if defined(__FreeBSD__)
- time_remaining->ts_sec = remaining_time.ts_sec;
- time_remaining->ts_nsec = remaining_time.ts_nsec;
-#else
time_remaining->tv_sec = remaining_time.tv_sec;
time_remaining->tv_nsec = remaining_time.tv_nsec;
-#endif
}
/* Check if the entire sleep was not completed: */
-#if defined(__FreeBSD__)
- if (remaining_time.ts_nsec != 0 || remaining_time.ts_sec != 0) {
-#else
if (remaining_time.tv_nsec != 0 || remaining_time.tv_sec != 0) {
-#endif
/* Return an EINTR error : */
errno = EINTR;
ret = -1;
diff --git a/lib/libpthread/thread/thr_cond.c b/lib/libpthread/thread/thr_cond.c
index 0f9f302..4395380 100644
--- a/lib/libpthread/thread/thr_cond.c
+++ b/lib/libpthread/thread/thr_cond.c
@@ -200,13 +200,8 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
/* Fast condition variable: */
case COND_TYPE_FAST:
/* Set the wakeup time: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = abstime->ts_sec;
- _thread_run->wakeup_time.ts_nsec = abstime->ts_nsec;
-#else
_thread_run->wakeup_time.tv_sec = abstime->tv_sec;
_thread_run->wakeup_time.tv_nsec = abstime->tv_nsec;
-#endif
/* Reset the timeout flag: */
_thread_run->timeout = 0;
diff --git a/lib/libpthread/thread/thr_kern.c b/lib/libpthread/thread/thr_kern.c
index c6759cf..1db4da6 100644
--- a/lib/libpthread/thread/thr_kern.c
+++ b/lib/libpthread/thread/thr_kern.c
@@ -250,30 +250,18 @@ __asm__("fnsave %0": :"m"(*fdata));
pthread->state == PS_FDW_WAIT ||
pthread->state == PS_SELECT_WAIT) {
/* Check if this thread is to wait forever: */
-#if defined(__FreeBSD__)
- if (pthread->wakeup_time.ts_sec == -1) {
-#else
if (pthread->wakeup_time.tv_sec == -1) {
-#endif
}
/*
* Check if this thread is to wakeup
* immediately or if it is past its wakeup
* time:
*/
-#if defined(__FreeBSD__)
- else if ((pthread->wakeup_time.ts_sec == 0 &&
- pthread->wakeup_time.ts_nsec == 0) ||
- (ts.ts_sec > pthread->wakeup_time.ts_sec) ||
- ((ts.ts_sec == pthread->wakeup_time.ts_sec) &&
- (ts.ts_nsec >= pthread->wakeup_time.ts_nsec))) {
-#else
else if ((pthread->wakeup_time.tv_sec == 0 &&
pthread->wakeup_time.tv_nsec == 0) ||
(ts.tv_sec > pthread->wakeup_time.tv_sec) ||
((ts.tv_sec == pthread->wakeup_time.tv_sec) &&
(ts.tv_nsec >= pthread->wakeup_time.tv_nsec))) {
-#endif
/*
* Check if this thread is waiting on
* select:
@@ -694,37 +682,22 @@ __asm__("fnsave %0": :"m"(*fdata));
* Check if this thread is to
* wait forever:
*/
-#if defined(__FreeBSD__)
- if (pthread->wakeup_time.ts_sec == -1) {
-#else
if (pthread->wakeup_time.tv_sec == -1) {
-#endif
}
/*
* Check if this thread is to
* wakeup immediately:
*/
-#if defined(__FreeBSD__)
- else if (pthread->wakeup_time.ts_sec == 0 &&
- pthread->wakeup_time.ts_nsec == 0) {
-#else
else if (pthread->wakeup_time.tv_sec == 0 &&
pthread->wakeup_time.tv_nsec == 0) {
-#endif
}
/*
* Check if the current time
* is after the wakeup time:
*/
-#if defined(__FreeBSD__)
- else if ((ts.ts_sec > pthread->wakeup_time.ts_sec) ||
- ((ts.ts_sec == pthread->wakeup_time.ts_sec) &&
- (ts.ts_nsec > pthread->wakeup_time.ts_nsec))) {
-#else
else if ((ts.tv_sec > pthread->wakeup_time.tv_sec) ||
((ts.tv_sec == pthread->wakeup_time.tv_sec) &&
(ts.tv_nsec > pthread->wakeup_time.tv_nsec))) {
-#endif
} else {
/*
* Calculate the time
@@ -733,26 +706,16 @@ __asm__("fnsave %0": :"m"(*fdata));
* for the clock
* resolution:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec = pthread->wakeup_time.ts_sec - ts.ts_sec;
- ts1.ts_nsec = pthread->wakeup_time.ts_nsec - ts.ts_nsec +
- CLOCK_RES_NSEC;
-#else
ts1.tv_sec = pthread->wakeup_time.tv_sec - ts.tv_sec;
ts1.tv_nsec = pthread->wakeup_time.tv_nsec - ts.tv_nsec +
CLOCK_RES_NSEC;
-#endif
/*
* Check for
* underflow of the
* nanosecond field:
*/
-#if defined(__FreeBSD__)
- if (ts1.ts_nsec < 0) {
-#else
if (ts1.tv_nsec < 0) {
-#endif
/*
* Allow for
* the
@@ -761,24 +724,15 @@ __asm__("fnsave %0": :"m"(*fdata));
* nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec--;
- ts1.ts_nsec += 1000000000;
-#else
ts1.tv_sec--;
ts1.tv_nsec += 1000000000;
-#endif
}
/*
* Check for overflow
* of the nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- if (ts1.ts_nsec >= 1000000000) {
-#else
if (ts1.tv_nsec >= 1000000000) {
-#endif
/*
* Allow for
* the
@@ -787,13 +741,8 @@ __asm__("fnsave %0": :"m"(*fdata));
* nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec++;
- ts1.ts_nsec -= 1000000000;
-#else
ts1.tv_sec++;
ts1.tv_nsec -= 1000000000;
-#endif
}
/*
* Convert the
@@ -1268,20 +1217,11 @@ _thread_kern_select(int wait_reqd)
*/
if (wait_reqd && settimeout) {
/* Check if this thread wants to wait forever: */
-#if defined(__FreeBSD__)
- if (pthread->wakeup_time.ts_sec == -1) {
-#else
if (pthread->wakeup_time.tv_sec == -1) {
-#endif
}
/* Check if this thread doesn't want to wait at all: */
-#if defined(__FreeBSD__)
- else if (pthread->wakeup_time.ts_sec == 0 &&
- pthread->wakeup_time.ts_nsec == 0) {
-#else
else if (pthread->wakeup_time.tv_sec == 0 &&
pthread->wakeup_time.tv_nsec == 0) {
-#endif
/* Override the caller's request to wait: */
wait_reqd = 0;
} else {
@@ -1289,57 +1229,33 @@ _thread_kern_select(int wait_reqd)
* Calculate the time until this thread is
* ready, allowing for the clock resolution:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec = pthread->wakeup_time.ts_sec - ts.ts_sec;
- ts1.ts_nsec = pthread->wakeup_time.ts_nsec - ts.ts_nsec +
- CLOCK_RES_NSEC;
-#else
ts1.tv_sec = pthread->wakeup_time.tv_sec - ts.tv_sec;
ts1.tv_nsec = pthread->wakeup_time.tv_nsec - ts.tv_nsec +
CLOCK_RES_NSEC;
-#endif
/*
* Check for underflow of the nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- if (ts1.ts_nsec < 0) {
-#else
if (ts1.tv_nsec < 0) {
-#endif
/*
* Allow for the underflow of the
* nanosecond field:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec--;
- ts1.ts_nsec += 1000000000;
-#else
ts1.tv_sec--;
ts1.tv_nsec += 1000000000;
-#endif
}
/*
* Check for overflow of the nanosecond
* field:
*/
-#if defined(__FreeBSD__)
- if (ts1.ts_nsec >= 1000000000) {
-#else
if (ts1.tv_nsec >= 1000000000) {
-#endif
/*
* Allow for the overflow of the
* nanosecond field:
*/
-#if defined(__FreeBSD__)
- ts1.ts_sec++;
- ts1.ts_nsec -= 1000000000;
-#else
ts1.tv_sec++;
ts1.tv_nsec -= 1000000000;
-#endif
}
/*
* Convert the timespec structure to a
@@ -1753,56 +1669,28 @@ _thread_kern_set_timeout(struct timespec * timeout)
* Set the wakeup time to something that can be recognised as
* different to an actual time of day:
*/
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = -1;
- _thread_run->wakeup_time.ts_nsec = -1;
-#else
_thread_run->wakeup_time.tv_sec = -1;
_thread_run->wakeup_time.tv_nsec = -1;
-#endif
}
/* Check if no waiting is required: */
-#if defined(__FreeBSD__)
- else if (timeout->ts_sec == 0 && timeout->ts_nsec == 0) {
-#else
else if (timeout->tv_sec == 0 && timeout->tv_nsec == 0) {
-#endif
/* Set the wake up time to 'immediately': */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = 0;
- _thread_run->wakeup_time.ts_nsec = 0;
-#else
_thread_run->wakeup_time.tv_sec = 0;
_thread_run->wakeup_time.tv_nsec = 0;
-#endif
} else {
/* Get the current time: */
gettimeofday(&tv, NULL);
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = current_time.ts_sec + timeout->ts_sec;
- _thread_run->wakeup_time.ts_nsec = current_time.ts_nsec + timeout->ts_nsec;
-#else
_thread_run->wakeup_time.tv_sec = current_time.tv_sec + timeout->tv_sec;
_thread_run->wakeup_time.tv_nsec = current_time.tv_nsec + timeout->tv_nsec;
-#endif
/* Check if the nanosecond field needs to wrap: */
-#if defined(__FreeBSD__)
- if (_thread_run->wakeup_time.ts_nsec >= 1000000000) {
-#else
if (_thread_run->wakeup_time.tv_nsec >= 1000000000) {
-#endif
/* Wrap the nanosecond field: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec += 1;
- _thread_run->wakeup_time.ts_nsec -= 1000000000;
-#else
_thread_run->wakeup_time.tv_sec += 1;
_thread_run->wakeup_time.tv_nsec -= 1000000000;
-#endif
}
}
return;
diff --git a/lib/libpthread/thread/thr_nanosleep.c b/lib/libpthread/thread/thr_nanosleep.c
index 58ade98..46ec14b 100644
--- a/lib/libpthread/thread/thr_nanosleep.c
+++ b/lib/libpthread/thread/thr_nanosleep.c
@@ -46,11 +46,7 @@ nanosleep(struct timespec * time_to_sleep, struct timespec * time_remaining)
struct timeval tv;
/* Check if the time to sleep is legal: */
-#if defined(__FreeBSD__)
- if (time_to_sleep == NULL || time_to_sleep->ts_nsec < 0 || time_to_sleep->ts_nsec > 1000000000) {
-#else
if (time_to_sleep == NULL || time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec > 1000000000) {
-#endif
/* Return an EINVAL error : */
errno = EINVAL;
ret = -1;
@@ -60,28 +56,14 @@ nanosleep(struct timespec * time_to_sleep, struct timespec * time_remaining)
TIMEVAL_TO_TIMESPEC(&tv, &current_time);
/* Calculate the time for the current thread to wake up: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec = current_time.ts_sec + time_to_sleep->ts_sec;
- _thread_run->wakeup_time.ts_nsec = current_time.ts_nsec + time_to_sleep->ts_nsec;
-#else
_thread_run->wakeup_time.tv_sec = current_time.tv_sec + time_to_sleep->tv_sec;
_thread_run->wakeup_time.tv_nsec = current_time.tv_nsec + time_to_sleep->tv_nsec;
-#endif
/* Check if the nanosecond field has overflowed: */
-#if defined(__FreeBSD__)
- if (_thread_run->wakeup_time.ts_nsec >= 1000000000) {
-#else
if (_thread_run->wakeup_time.tv_nsec >= 1000000000) {
-#endif
/* Wrap the nanosecond field: */
-#if defined(__FreeBSD__)
- _thread_run->wakeup_time.ts_sec += 1;
- _thread_run->wakeup_time.ts_nsec -= 1000000000;
-#else
_thread_run->wakeup_time.tv_sec += 1;
_thread_run->wakeup_time.tv_nsec -= 1000000000;
-#endif
}
/* Reschedule the current thread to sleep: */
@@ -92,80 +74,39 @@ nanosleep(struct timespec * time_to_sleep, struct timespec * time_remaining)
TIMEVAL_TO_TIMESPEC(&tv, &current_time1);
/* Calculate the remaining time to sleep: */
-#if defined(__FreeBSD__)
- remaining_time.ts_sec = time_to_sleep->ts_sec + current_time.ts_sec - current_time1.ts_sec;
- remaining_time.ts_nsec = time_to_sleep->ts_nsec + current_time.ts_nsec - current_time1.ts_nsec;
-#else
remaining_time.tv_sec = time_to_sleep->tv_sec + current_time.tv_sec - current_time1.tv_sec;
remaining_time.tv_nsec = time_to_sleep->tv_nsec + current_time.tv_nsec - current_time1.tv_nsec;
-#endif
/* Check if the nanosecond field has underflowed: */
-#if defined(__FreeBSD__)
- if (remaining_time.ts_nsec < 0) {
-#else
if (remaining_time.tv_nsec < 0) {
-#endif
/* Handle the underflow: */
-#if defined(__FreeBSD__)
- remaining_time.ts_sec -= 1;
- remaining_time.ts_nsec += 1000000000;
-#else
remaining_time.tv_sec -= 1;
remaining_time.tv_nsec += 1000000000;
-#endif
}
/* Check if the nanosecond field has overflowed: */
-#if defined(__FreeBSD__)
- if (remaining_time.ts_nsec >= 1000000000) {
-#else
if (remaining_time.tv_nsec >= 1000000000) {
-#endif
/* Handle the overflow: */
-#if defined(__FreeBSD__)
- remaining_time.ts_sec += 1;
- remaining_time.ts_nsec -= 1000000000;
-#else
remaining_time.tv_sec += 1;
remaining_time.tv_nsec -= 1000000000;
-#endif
}
/* Check if the sleep was longer than the required time: */
-#if defined(__FreeBSD__)
- if (remaining_time.ts_sec < 0) {
-#else
if (remaining_time.tv_sec < 0) {
-#endif
/* Reset the time left: */
-#if defined(__FreeBSD__)
- remaining_time.ts_sec = 0;
- remaining_time.ts_nsec = 0;
-#else
remaining_time.tv_sec = 0;
remaining_time.tv_nsec = 0;
-#endif
}
/* Check if the time remaining is to be returned: */
if (time_remaining != NULL) {
/* Return the actual time slept: */
-#if defined(__FreeBSD__)
- time_remaining->ts_sec = remaining_time.ts_sec;
- time_remaining->ts_nsec = remaining_time.ts_nsec;
-#else
time_remaining->tv_sec = remaining_time.tv_sec;
time_remaining->tv_nsec = remaining_time.tv_nsec;
-#endif
}
/* Check if the entire sleep was not completed: */
-#if defined(__FreeBSD__)
- if (remaining_time.ts_nsec != 0 || remaining_time.ts_sec != 0) {
-#else
if (remaining_time.tv_nsec != 0 || remaining_time.tv_sec != 0) {
-#endif
/* Return an EINTR error : */
errno = EINTR;
ret = -1;
OpenPOWER on IntegriCloud