File klibc-2.0.4-usleep.patch of Package klibc

diff -Nurp klibc-2.0.4/usr/include/unistd.h klibc-2.0.4-usleep/usr/include/unistd.h
--- klibc-2.0.4/usr/include/unistd.h	2014-07-26 03:15:06.000000000 +0300
+++ klibc-2.0.4-usleep/usr/include/unistd.h	2014-09-22 06:06:30.415343575 +0300
@@ -126,7 +126,7 @@ __extern int sync_file_range(int, off_t,
 __extern int pause(void);
 __extern unsigned int alarm(unsigned int);
 __extern unsigned int sleep(unsigned int);
-__extern void usleep(unsigned long);
+__extern int usleep(unsigned long);
 
 __extern int gethostname(char *, size_t);
 __extern int sethostname(const char *, size_t);
diff -Nurp klibc-2.0.4/usr/klibc/usleep.c klibc-2.0.4-usleep/usr/klibc/usleep.c
--- klibc-2.0.4/usr/klibc/usleep.c	2014-07-26 03:15:07.000000000 +0300
+++ klibc-2.0.4-usleep/usr/klibc/usleep.c	2014-09-22 06:07:02.396341412 +0300
@@ -3,15 +3,19 @@
  */
 
 #include <errno.h>
-#include <stdlib.h>
 #include <time.h>
-#include <unistd.h>
 
-void usleep(unsigned long usec)
+int usleep(unsigned long usec)
 {
-	struct timespec ts;
+	int r;
+	struct timespec ts = {
+		.tv_sec = usec / 1000000UL,
+		.tv_nsec = (usec % 1000000UL) * 1000
+	};
 
-	ts.tv_sec = usec / 1000000UL;
-	ts.tv_nsec = (usec % 1000000UL) * 1000;
-	while (nanosleep(&ts, &ts) == -1 && errno == EINTR) ;
+	do {
+		r = nanosleep(&ts, &ts);
+	} while (r && errno == EINTR);
+
+	return r;
 }
openSUSE Build Service is sponsored by