libdl: first execute all destructors, then munmap library
[uclibc-ng.git] / libc / unistd / usleep.c
blob8d01703ec219c51bfa62a89b73d3102737c8f40b
1 /*
2 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5 */
7 #include <time.h>
8 #include <sys/time.h>
9 #include <sys/types.h>
10 #include <unistd.h>
12 #if defined __USE_BSD || defined __USE_POSIX98
13 #if defined __UCLIBC_HAS_REALTIME__
15 int usleep (__useconds_t usec)
17 const struct timespec ts = {
18 .tv_sec = (long int) (usec / 1000000),
19 .tv_nsec = (long int) (usec % 1000000) * 1000ul
21 return nanosleep(&ts, NULL);
23 #else /* __UCLIBC_HAS_REALTIME__ */
24 int usleep (__useconds_t usec)
26 struct timeval tv;
28 tv.tv_sec = (long int) (usec / 1000000);
29 tv.tv_usec = (long int) (usec % 1000000);
30 return select(0, NULL, NULL, NULL, &tv);
32 #endif /* __UCLIBC_HAS_REALTIME__ */
33 #endif