sleep.c (30442) | sleep.c (30479) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. 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 --- 21 unchanged lines hidden (view full) --- 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#if defined(LIBC_SCCS) && !defined(lint) 35static char sccsid[] = "@(#)sleep.c 8.1 (Berkeley) 6/4/93"; 36#endif /* LIBC_SCCS and not lint */ 37 | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. 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 --- 21 unchanged lines hidden (view full) --- 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#if defined(LIBC_SCCS) && !defined(lint) 35static char sccsid[] = "@(#)sleep.c 8.1 (Berkeley) 6/4/93"; 36#endif /* LIBC_SCCS and not lint */ 37 |
38#include <sys/time.h> 39#include <signal.h> | 38#include |
40#include <unistd.h> 41 42unsigned int 43sleep(seconds) 44 unsigned int seconds; 45{ 46 struct timespec time_to_sleep; 47 struct timespec time_remaining; 48 49 if (seconds != 0) { 50 time_to_sleep.tv_sec = seconds; 51 time_to_sleep.tv_nsec = 0; 52 (void)nanosleep(&time_to_sleep, &time_remaining); 53 seconds = time_remaining.tv_sec; 54 if (time_remaining.tv_nsec > 0) 55 seconds++; /* round up */ 56 } 57 return (seconds); 58} | 39#include <unistd.h> 40 41unsigned int 42sleep(seconds) 43 unsigned int seconds; 44{ 45 struct timespec time_to_sleep; 46 struct timespec time_remaining; 47 48 if (seconds != 0) { 49 time_to_sleep.tv_sec = seconds; 50 time_to_sleep.tv_nsec = 0; 51 (void)nanosleep(&time_to_sleep, &time_remaining); 52 seconds = time_remaining.tv_sec; 53 if (time_remaining.tv_nsec > 0) 54 seconds++; /* round up */ 55 } 56 return (seconds); 57} |