[git commit nptl] call nanosleep directly

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Fri Nov 27 09:03:24 UTC 2009


commit: http://git.uclibc.org/uClibc/commit/?id=557e0c8dd7831473920ad900f5205e0d6987b2aa
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/nptl

usleep is a SUSv3 function.
TODO: nanosleep moved from SUSv3 Timers to SUSv4 Base

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 test/pthread/ex6.c |    7 +++++--
 test/pthread/ex7.c |    7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/test/pthread/ex6.c b/test/pthread/ex6.c
index bb96ca5..ffb6287 100644
--- a/test/pthread/ex6.c
+++ b/test/pthread/ex6.c
@@ -2,7 +2,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <pthread.h>
-#include <unistd.h>
+#include <time.h>
 
 static void *
 test_thread (void *v_param)
@@ -14,6 +14,9 @@ int
 main (void)
 {
   unsigned long count;
+  struct timespec ts;
+  ts.tv_sec = 0;
+  ts.tv_nsec = 10 * 1000;
 
   setvbuf (stdout, NULL, _IONBF, 0);
 
@@ -35,7 +38,7 @@ main (void)
 	}
       /* pthread_detach (thread); */
       pthread_join (thread, NULL);
-      usleep (10);
+      nanosleep (&ts, NULL);
     }
   return 0;
 }
diff --git a/test/pthread/ex7.c b/test/pthread/ex7.c
index 49af18d..8eeb9a2 100644
--- a/test/pthread/ex7.c
+++ b/test/pthread/ex7.c
@@ -8,7 +8,7 @@
 #include <string.h>
 #include <pthread.h>
 #include <sys/time.h>
-#include <unistd.h>
+#include <time.h>
 
 /* Our event variable using a condition variable contruct. */
 typedef struct {
@@ -63,6 +63,9 @@ int
 main (void)
 {
   unsigned long count;
+  struct timespec ts;
+  ts.tv_sec = 0;
+  ts.tv_nsec = 10 * 1000;
 
   setvbuf (stdout, NULL, _IONBF, 0);
 
@@ -96,7 +99,7 @@ main (void)
 	  printf ("count = %lu\n", count);
       }
 
-      usleep (10);
+      nanosleep (&ts, NULL);
   }
 
   return 0;
-- 
1.6.3.3



More information about the uClibc-cvs mailing list