diff options
author | Maciej Borzecki <maciej.borzecki@open-rnd.pl> | 2015-05-12 14:24:05 +0200 |
---|---|---|
committer | Alan Antonuk <alan.antonuk@gmail.com> | 2015-05-14 21:35:40 -0700 |
commit | 3ef3f5fe3180dde40b2716cb10c2143e8b396672 (patch) | |
tree | 363b9a01250dbc403a0819e7acd1f3dac793f485 /examples | |
parent | 112a54de4483c152fcc4ac65681f9f9bb7b55cbc (diff) | |
download | rabbitmq-c-3ef3f5fe3180dde40b2716cb10c2143e8b396672.tar.gz |
examples: replace usleep() with nanosleep()
Accessing usleep() requires _BSD_SOURCE feature test macro to be
set. However, _SVID_SOURCE is set as well, what will cause deprecation
warnings when building with glibc >= 2.20. The patch replaced usleep()
with nanosleep() to avoid these problems.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/unix/platform_utils.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/unix/platform_utils.c b/examples/unix/platform_utils.c index 777d56b..1f3ff43 100644 --- a/examples/unix/platform_utils.c +++ b/examples/unix/platform_utils.c @@ -34,11 +34,8 @@ * ***** END LICENSE BLOCK ***** */ -/* For usleep */ -#define _BSD_SOURCE - #include <stdint.h> - +#include <time.h> #include <sys/time.h> #include <unistd.h> @@ -51,5 +48,8 @@ uint64_t now_microseconds(void) void microsleep(int usec) { - usleep(usec); + struct timespec req; + req.tv_sec = 0; + req.tv_nsec = 1000 * usec; + nanosleep(&req, NULL); } |