[02/12] example: odp_generator: fix c99 implicit declaration

Message ID 1424468661-967-4-git-send-email-mike.holmes@linaro.org
State New
Headers show

Commit Message

Mike Holmes Feb. 20, 2015, 9:44 p.m.
odp_generator.c:391:4: error: implicit declaration of function ‘usleep’
[-Werror=implicit-function-declaration]
    usleep(args->appl.interval * 1000);

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 example/generator/odp_generator.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch

diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index 2d5eb26..853a9f0 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -12,6 +12,8 @@ 
 
 /* enable strtok */
 #define _POSIX_C_SOURCE 200112L
+
+#include <time.h>
 #include <stdlib.h>
 #include <string.h>
 #include <getopt.h>
@@ -390,7 +392,10 @@  static void *gen_send_thread(void *arg)
 			       odp_atomic_load_u64(&counters.seq),
 			       odp_atomic_load_u64(&counters.seq)%0xffff);
 			/* TODO use odp timer */
-			usleep(args->appl.interval * 1000);
+			struct timespec ts;
+			ts.tv_sec = 0;
+			ts.tv_nsec = args->appl.interval;
+			nanosleep(&ts, NULL);
 		}
 		if (args->appl.number != -1 &&
 		    odp_atomic_load_u64(&counters.seq)