diff options
author | Karel Zak | 2012-10-22 11:03:09 +0200 |
---|---|---|
committer | Karel Zak | 2012-10-22 11:03:09 +0200 |
commit | 2a31396a9cee344fcc3a4d34f5e26954fccc6e16 (patch) | |
tree | 8fa988d37faeb9a1d21703b006b676f7e644cd6b /include/c.h | |
parent | build-sys: remove gethostbyname() check (diff) | |
download | kernel-qcow2-util-linux-2a31396a9cee344fcc3a4d34f5e26954fccc6e16.tar.gz kernel-qcow2-util-linux-2a31396a9cee344fcc3a4d34f5e26954fccc6e16.tar.xz kernel-qcow2-util-linux-2a31396a9cee344fcc3a4d34f5e26954fccc6e16.zip |
include/c: move usleep() fallback to c.h
To make it available everywhere in code.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include/c.h')
-rw-r--r-- | include/c.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/c.h b/include/c.h index e343778b4..110728797 100644 --- a/include/c.h +++ b/include/c.h @@ -241,6 +241,21 @@ static inline size_t get_hostname_max(void) return 64; } +#ifndef HAVE_USLEEP +/* + * This function is marked obsolete in POSIX.1-2001 and removed in + * POSIX.1-2008. It is replaced with nanosleep(). + */ +static inline usleep(useconds_t usec) +{ + struct timespec waittime = { + .tv_sec = usec / 1000000L, + .tv_nsec = (usec % 1000000L) * 1000 + } + nanosleep(&waittime, NULL); +} +#endif + /* * Constant strings for usage() functions. For more info see * Documentation/howto-usage-function.txt and sys-utils/arch.c |