From 996046aed5d88a939cd52a36d08e4b0d929f8cbe Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Sun, 14 Sep 2014 16:34:09 -0500 Subject: [PATCH] [libpng16] Use nanosleep() instead of usleep() in contrib/gregbook/rpng2-x.c because usleep() is deprecated. --- ANNOUNCE | 5 ++++- CHANGES | 5 ++++- contrib/gregbook/rpng2-x.c | 11 +++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 769069eea..d6c9cd442 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -33,8 +33,11 @@ Version 1.6.14beta01 [September 14, 2014] Add "#include " to contrib/tools/pngfix.c (John Bowler) Version 1.6.14beta02 [September 14, 2014] + Use nanosleep() instead of usleep() in contrib/gregbook/rpng2-x.c + because usleep() is deprecated. Define usleep() in contrib/gregbook/rpng2-x.c if not already defined - in unistd.h; fixes error introduced in libpng-1.6.13. + in unistd.h and nanosleep() is not available; fixes error introduced + in libpng-1.6.13. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index ab508b8ec..712bc9781 100644 --- a/CHANGES +++ b/CHANGES @@ -4986,8 +4986,11 @@ Version 1.6.14beta01 [September 14, 2014] Add "#include " to contrib/tools/pngfix.c (John Bowler) Version 1.6.14beta02 [September 14, 2014] + Use nanosleep() instead of usleep() in contrib/gregbook/rpng2-x.c + because usleep() is deprecated. Define usleep() in contrib/gregbook/rpng2-x.c if not already defined - in unistd.h; fixes error introduced in libpng-1.6.13. + in unistd.h and nanosleep() is not available; fixes error introduced + in libpng-1.6.13. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/contrib/gregbook/rpng2-x.c b/contrib/gregbook/rpng2-x.c index 6e02c890d..cf371014c 100644 --- a/contrib/gregbook/rpng2-x.c +++ b/contrib/gregbook/rpng2-x.c @@ -115,8 +115,15 @@ #include #include /* 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