]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include/c: move usleep() fallback to c.h
authorKarel Zak <kzak@redhat.com>
Mon, 22 Oct 2012 09:03:09 +0000 (11:03 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 22 Oct 2012 09:03:09 +0000 (11:03 +0200)
To make it available everywhere in code.

Signed-off-by: Karel Zak <kzak@redhat.com>
include/Makemodule.am
include/all-io.h
include/c.h
include/usleep.h [deleted file]
mount-deprecated/fstab.c
sys-utils/hwclock-kd.c
sys-utils/rtcwake.c
text-utils/tailf.c

index 9f9b78e3bf1c2f06de42a48356da637786c87b80..bef118f448c93a4e76a6ef8ef5698d661eb1bd40 100644 (file)
@@ -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 \
index 38a760ff6b42052e15e6c76ce764f74cbe02b095..248759908b457da3f9a1c243279caa0211cfed7b 100644 (file)
@@ -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) {
index e343778b48aae6149681d7f644d8ba8517d924e6..110728797f552073b24d8b227b61d05460513842 100644 (file)
@@ -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 (file)
index f64477c..0000000
+++ /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 */
index 47159a3a9e8e55608f0984397e3f5d9f88ad7d1d..803a700fc6d23e585766340ac8fb24fe0be9eaa7 100644 (file)
@@ -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)
 
index bfe50dc15f0467cfeb7f4f406746fadcfb19221f..9ed83436a60391daadf6625080970fd64d3411f5 100644 (file)
@@ -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>
index a1fd6dc458d107402cbb684498bf2e46ce5d0918..7a757ad6605e814c57cf6788a05cd45865264238 100644 (file)
@@ -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"
index 9571645d5c44873d615b75de350f12a925ab79ee..a8630fb6cba460d368fe8970ceeaaedf823878cb 100644 (file)
@@ -42,7 +42,6 @@
 
 #include "nls.h"
 #include "xalloc.h"
-#include "usleep.h"
 #include "strutils.h"
 #include "c.h"
 #include "closestream.h"