From df6fc2a1ce9f3a1778e9c8e14c800cd2ad96e96e Mon Sep 17 00:00:00 2001 From: Saya Sugiura Date: Tue, 8 Jan 2019 16:45:04 +0900 Subject: POSIX: Replace usleep with nanosleep Signed-off-by: Saya Sugiura --- src/examples/dlt-example-user-common-api.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/examples/dlt-example-user-common-api.c') diff --git a/src/examples/dlt-example-user-common-api.c b/src/examples/dlt-example-user-common-api.c index 880ea97..65f3b3c 100644 --- a/src/examples/dlt-example-user-common-api.c +++ b/src/examples/dlt-example-user-common-api.c @@ -112,6 +112,7 @@ int main(int argc, char *argv[]) char *text; int num, maxnum; int delay; + struct timespec ts; int state = -1, newstate; @@ -199,9 +200,9 @@ int main(int argc, char *argv[]) maxnum = 10; if (dvalue) - delay = atoi(dvalue) * 1000; + delay = atoi(dvalue) * 1000000; else - delay = 500 * 1000; + delay = 500 * 1000000; if (gflag) { /* DLT messages to test Fibex non-verbose description: dlt-example-non-verbose.xml */ @@ -258,8 +259,11 @@ int main(int argc, char *argv[]) /* Verbose mode */ DLT_LOG2(mycontext, DLT_LOG_WARN, DLT_INT(num), DLT_STRING(text)); - if (delay > 0) - usleep(delay); + if (delay > 0) { + ts.tv_sec = delay / 1000000000; + ts.tv_nsec = delay % 1000000000; + nanosleep(&ts, NULL); + } } sleep(1); -- cgit v1.2.1