[libpng16] Use nanosleep() instead of usleep() in contrib/gregbook/rpng2-x.c

because usleep() is deprecated.
This commit is contained in:
Glenn Randers-Pehrson
2014-09-14 16:34:09 -05:00
parent e4489f1db2
commit 996046aed5
3 changed files with 17 additions and 4 deletions

View File

@@ -115,8 +115,15 @@
#include <X11/Xos.h>
#include <X11/keysym.h> /* defines XK_* macros */
/* This is temporary until the code is rewritten to use nanosleep(). */
#ifndef usleep
#if _POSIX_C_SOURCE >= 199309L /* have nanosleep() */
# undef usleep
# define usleep(usec) { \
struct timespec ts; \
ts.tv_nsec = (usec) * 1000; \
nanosleep(&ts, NULL); }
# endif
#ifndef usleep /* have neither nanosleep() nor usleep() */
# define usleep(x) sleep(((x)+499999)/1000000)
#endif