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 | |
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>
-rw-r--r-- | include/Makemodule.am | 1 | ||||
-rw-r--r-- | include/all-io.h | 2 | ||||
-rw-r--r-- | include/c.h | 15 | ||||
-rw-r--r-- | include/usleep.h | 18 | ||||
-rw-r--r-- | mount-deprecated/fstab.c | 2 | ||||
-rw-r--r-- | sys-utils/hwclock-kd.c | 4 | ||||
-rw-r--r-- | sys-utils/rtcwake.c | 1 | ||||
-rw-r--r-- | text-utils/tailf.c | 1 |
8 files changed, 19 insertions, 25 deletions
diff --git a/include/Makemodule.am b/include/Makemodule.am index 9f9b78e3b..bef118f44 100644 --- a/include/Makemodule.am +++ b/include/Makemodule.am @@ -38,7 +38,6 @@ dist_noinst_HEADERS += \ include/sysfs.h \ include/tt.h \ include/ttyutils.h \ - include/usleep.h \ include/wholedisk.h \ include/widechar.h \ include/xalloc.h \ diff --git a/include/all-io.h b/include/all-io.h index 38a760ff6..248759908 100644 --- a/include/all-io.h +++ b/include/all-io.h @@ -5,6 +5,8 @@ #include <unistd.h> #include <errno.h> +#include "c.h" + static inline int write_all(int fd, const void *buf, size_t count) { while (count) { 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 diff --git a/include/usleep.h b/include/usleep.h deleted file mode 100644 index f64477c99..000000000 --- a/include/usleep.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef UTIL_LINUX_USLEEP_H -#define UTIL_LINUX_USLEEP_H - -#ifndef HAVE_USLEEP -/* - * This function is marked obsolete in POSIX.1-2001 and removed in - * POSIX.1-2008. It is replaced with nanosleep(). - */ -# define usleep(x) \ - do { \ - struct timespec xsleep; \ - xsleep.tv_sec = x / 1000 / 1000; \ - xsleep.tv_nsec = (x - xsleep.tv_sec * 1000 * 1000) * 1000; \ - nanosleep(&xsleep, NULL); \ - } while (0) -#endif - -#endif /* UTIL_LINUX_USLEEP_H */ diff --git a/mount-deprecated/fstab.c b/mount-deprecated/fstab.c index 47159a3a9..803a700fc 100644 --- a/mount-deprecated/fstab.c +++ b/mount-deprecated/fstab.c @@ -19,8 +19,8 @@ #include "fsprobe.h" #include "pathnames.h" #include "nls.h" -#include "usleep.h" #include "strutils.h" +#include "c.h" #define streq(s, t) (strcmp ((s), (t)) == 0) diff --git a/sys-utils/hwclock-kd.c b/sys-utils/hwclock-kd.c index bfe50dc15..9ed83436a 100644 --- a/sys-utils/hwclock-kd.c +++ b/sys-utils/hwclock-kd.c @@ -1,8 +1,7 @@ /* * kd.c - KDGHWCLK stuff, possibly m68k only, likely to be deprecated */ - -# include "hwclock.h" +#include "hwclock.h" #ifdef __m68k__ @@ -12,7 +11,6 @@ # include <unistd.h> # include "nls.h" -# include "usleep.h" /* Get defines for KDGHWCLK and KDSHWCLK (m68k) */ # include <linux/kd.h> diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c index a1fd6dc45..7a757ad66 100644 --- a/sys-utils/rtcwake.c +++ b/sys-utils/rtcwake.c @@ -38,7 +38,6 @@ #include "nls.h" #include "xalloc.h" #include "pathnames.h" -#include "usleep.h" #include "strutils.h" #include "c.h" #include "closestream.h" diff --git a/text-utils/tailf.c b/text-utils/tailf.c index 9571645d5..a8630fb6c 100644 --- a/text-utils/tailf.c +++ b/text-utils/tailf.c @@ -42,7 +42,6 @@ #include "nls.h" #include "xalloc.h" -#include "usleep.h" #include "strutils.h" #include "c.h" #include "closestream.h" |