summaryrefslogtreecommitdiffstats
path: root/include/c.h
diff options
context:
space:
mode:
authorKarel Zak2012-10-22 11:03:09 +0200
committerKarel Zak2012-10-22 11:03:09 +0200
commit2a31396a9cee344fcc3a4d34f5e26954fccc6e16 (patch)
tree8fa988d37faeb9a1d21703b006b676f7e644cd6b /include/c.h
parentbuild-sys: remove gethostbyname() check (diff)
downloadkernel-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.h15
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