From c403e32526bc99e886d58a09e11a4f3043af8040 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 21 Oct 2010 18:19:35 +0200 Subject: sleep: code shrink Use less stack by using same "sigset_t set" object for new and saved signal set, remove redundant clearing of set, and do not save/restore errno around sigprocmask(SIG_SETMASK) - it never changes it. While at it, improve comments and make code style consistent across sleep.c file. text data bss dec hex filename - 242 0 0 242 f2 libc/unistd/sleep.o + 197 0 0 197 c5 libc/unistd/sleep.o Signed-off-by: Denys Vlasenko --- libc/unistd/usleep.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'libc/unistd/usleep.c') diff --git a/libc/unistd/usleep.c b/libc/unistd/usleep.c index 61ddb900a..8d01703ec 100644 --- a/libc/unistd/usleep.c +++ b/libc/unistd/usleep.c @@ -14,19 +14,19 @@ int usleep (__useconds_t usec) { - const struct timespec ts = { - .tv_sec = (long int) (usec / 1000000), - .tv_nsec = (long int) (usec % 1000000) * 1000ul - }; - return(nanosleep(&ts, NULL)); + const struct timespec ts = { + .tv_sec = (long int) (usec / 1000000), + .tv_nsec = (long int) (usec % 1000000) * 1000ul + }; + return nanosleep(&ts, NULL); } #else /* __UCLIBC_HAS_REALTIME__ */ int usleep (__useconds_t usec) { struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = usec; + tv.tv_sec = (long int) (usec / 1000000); + tv.tv_usec = (long int) (usec % 1000000); return select(0, NULL, NULL, NULL, &tv); } #endif /* __UCLIBC_HAS_REALTIME__ */ -- cgit v1.2.3