From: Ivan Maidanski Date: Tue, 7 Mar 2017 16:03:00 +0000 (+0300) Subject: Workaround 'obsolescent usleep called' cppcheck warning (POSIX) X-Git-Tag: v7.6.2~211 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=815cf960910e61f7cbc4444f511d491bea36d4b9;p=gc 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. --- diff --git a/pthread_stop_world.c b/pthread_stop_world.c index 2cb9b76c..72efbf07 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -44,6 +44,7 @@ #include #include #include +#include /* for nanosleep() */ #include #include "atomic_ops.h" @@ -769,7 +770,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; } }