Deleted Added
full compact
thr_nanosleep.c (117706) thr_nanosleep.c (119063)
1/*
2 * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
1/*
2 * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * $FreeBSD: head/lib/libkse/thread/thr_nanosleep.c 117706 2003-07-17 23:02:30Z davidxu $
32 * $FreeBSD: head/lib/libkse/thread/thr_nanosleep.c 119063 2003-08-18 03:58:29Z davidxu $
33 */
34#include <stdio.h>
35#include <errno.h>
36#include <pthread.h>
37#include "thr_private.h"
38
39__weak_reference(__nanosleep, nanosleep);
40

--- 9 unchanged lines hidden (view full) ---

50 /* Check if the time to sleep is legal: */
51 if ((time_to_sleep == NULL) || (time_to_sleep->tv_sec < 0) ||
52 (time_to_sleep->tv_nsec < 0) ||
53 (time_to_sleep->tv_nsec >= 1000000000)) {
54 /* Return an EINVAL error : */
55 errno = EINVAL;
56 ret = -1;
57 } else {
33 */
34#include <stdio.h>
35#include <errno.h>
36#include <pthread.h>
37#include "thr_private.h"
38
39__weak_reference(__nanosleep, nanosleep);
40

--- 9 unchanged lines hidden (view full) ---

50 /* Check if the time to sleep is legal: */
51 if ((time_to_sleep == NULL) || (time_to_sleep->tv_sec < 0) ||
52 (time_to_sleep->tv_nsec < 0) ||
53 (time_to_sleep->tv_nsec >= 1000000000)) {
54 /* Return an EINVAL error : */
55 errno = EINVAL;
56 ret = -1;
57 } else {
58 if (!_kse_isthreaded() ||
59 (curthread->attr.flags & PTHREAD_SCOPE_SYSTEM))
58 if (curthread->attr.flags & PTHREAD_SCOPE_SYSTEM)
60 return (__sys_nanosleep(time_to_sleep, time_remaining));
61
62 KSE_GET_TOD(curthread->kse, &ts);
63
64 /* Calculate the time for the current thread to wake up: */
65 TIMESPEC_ADD(&curthread->wakeup_time, &ts, time_to_sleep);
66
67 THR_LOCK_SWITCH(curthread);

--- 63 unchanged lines hidden ---
59 return (__sys_nanosleep(time_to_sleep, time_remaining));
60
61 KSE_GET_TOD(curthread->kse, &ts);
62
63 /* Calculate the time for the current thread to wake up: */
64 TIMESPEC_ADD(&curthread->wakeup_time, &ts, time_to_sleep);
65
66 THR_LOCK_SWITCH(curthread);

--- 63 unchanged lines hidden ---