X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=contrib%2Fgregbook%2Frpng2-x.c;h=0c8ddeba223930f379fe21f648c68aa8798f6f06;hb=7b7ccdda02217a442f273ef9684706ecdef2acc5;hp=a146ef4173f017c3722df29882e185cd9bc22655;hpb=361fb099aa967c1618d8071268abab395e67e86a;p=platform%2Fupstream%2Flibpng.git diff --git a/contrib/gregbook/rpng2-x.c b/contrib/gregbook/rpng2-x.c index a146ef4..0c8ddeb 100644 --- a/contrib/gregbook/rpng2-x.c +++ b/contrib/gregbook/rpng2-x.c @@ -43,12 +43,10 @@ - 2.03: deleted runtime MMX-enabling/disabling and obsolete -mmx* options - 2.04: Added "void(foo);" statements to quiet pedantic compiler warnings about unused variables (GR-P) - - TO DO: - use nanosleep() instead of usleep(), which is obsolete/deprecated. + - 2.05: Use nanosleep() instead of usleep(), which is deprecated (GR-P). --------------------------------------------------------------------------- - Copyright (c) 1998-2008 Greg Roelofs. All rights reserved. + Copyright (c) 1998-2010, 2014-2015 Greg Roelofs. All rights reserved. This software is provided "as is," without warranty of any kind, express or implied. In no event shall the author or contributors @@ -103,9 +101,6 @@ #define RESNAME "rpng2" /* our X resource application name */ #define RESCLASS "Rpng" /* our X resource class name */ -/* This is temporary until the code is rewritten to use nanosleep(). */ -#define usleep(x) sleep(((x)+499999)/1000000) - #include #include #include @@ -118,6 +113,19 @@ #include #include /* defines XK_* macros */ +#if _POSIX_C_SOURCE >= 199309L /* have nanosleep() */ +# undef usleep +# define usleep(usec) { \ + struct timespec ts; \ + ts.tv_sec = 0; \ + ts.tv_nsec = (usec) * 1000; \ + nanosleep(&ts, NULL); } +# endif + +#ifndef usleep /* have neither nanosleep() nor usleep() */ +# define usleep(x) sleep(((x)+499999)/1000000) +#endif + #ifdef VMS # include #endif @@ -488,12 +496,12 @@ int main(int argc, char **argv) "\t\t transparent images; overrides -bgcolor\n", num_bgpat-1); #ifdef FEATURE_LOOP - fprintf(stderr, + fprintf(stderr, " -loop\tloops through background images after initial display\n" "\t\t is complete (depends on -bgpat)\n" " sec \tseconds to display each background image (default = 2)\n"); #endif - fprintf(stderr, + fprintf(stderr, " dur \tduration in microseconds to wait after displaying each\n" "\t\t row (for demo purposes)\n" " -timing\tenables delay for every block read, to simulate modem\n"