From ad0bcf317b7661807696e15c0e0b43581b18702b Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 7 Mar 2017 19:03:00 +0300 Subject: [PATCH] Workaround 'obsolescent usleep called' cppcheck warning (POSIX) * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]: Include time.h. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world): Use nanosleep() instead of usleep() if CPPCHECK. --- pthread_stop_world.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pthread_stop_world.c b/pthread_stop_world.c index 2c027bc..2be887b 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -44,6 +44,7 @@ #include #include #include +#include /* for nanosleep() */ #include #include "private/gc_atomic_ops.h" @@ -770,7 +771,18 @@ GC_INNER void GC_stop_world(void) } wait_usecs = 0; } - usleep(WAIT_UNIT); + +# if defined(CPPCHECK) /* || _POSIX_C_SOURCE >= 199309L */ + { + struct timespec ts; + + ts.tv_sec = 0; + ts.tv_nsec = WAIT_UNIT * 1000; + (void)nanosleep(&ts, NULL); + } +# else + usleep(WAIT_UNIT); +# endif wait_usecs += WAIT_UNIT; } } -- 2.7.4