]> err.no Git - util-linux/commitdiff
replace usleep() for systems that don't have them
authorDaniel Mierswa <impulze@impulze.org>
Mon, 17 Aug 2009 19:22:02 +0000 (21:22 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 21 Aug 2009 07:58:17 +0000 (09:58 +0200)
This function is marked obsolete in POSIX.1-2001 and removed in
POSIX.1-2008.

Conditionally replaced with nanosleep().

Signed-off-by: Daniel Mierswa <impulze@impulze.org>
configure.ac
hwclock/kd.c
include/Makefile.am
include/usleep.h [new file with mode: 0644]
login-utils/shutdown.c
mount/fstab.c
sys-utils/rtcwake.c
text-utils/tailf.c

index 8999826afd86365d4e216bbcd8efe6e01dc3a885..7e13a61ebe8a23e75289144d880b76a1215f14f9 100644 (file)
@@ -140,6 +140,7 @@ AC_CHECK_FUNCS(
        fsync \
        getdomainname \
        get_current_dir_name \
+       usleep \
        nanosleep \
        personality \
        updwtmp \
index b0e55d1c51bb24800fc3e24aeaa5cfdd640b9222..3da87cafde7e18df2849208504df629d682e6b42 100644 (file)
@@ -17,6 +17,7 @@ probe_for_kd_clock() {
 #include <sys/ioctl.h>
 
 #include "nls.h"
+#include "usleep.h"
 
 static int con_fd = -1;                /* opened by probe_for_kd_clock() */
                                /* never closed */
index f959659a2f7b01e04891b82a620891ef7b397067..5669421ba045dfbd31e8db8912b32ab84e0dcc64 100644 (file)
@@ -16,6 +16,7 @@ dist_noinst_HEADERS = \
        pttype.h \
        setproctitle.h \
        swapheader.h \
+       usleep.h \
        wholedisk.h \
        widechar.h \
        xstrncpy.h
diff --git a/include/usleep.h b/include/usleep.h
new file mode 100644 (file)
index 0000000..f64477c
--- /dev/null
@@ -0,0 +1,18 @@
+#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 58600b9d8bfaddefb379505b26cfab154ac3c76f..f7bc0005aafa7752e07b4083cde6bb7b9a482320 100644 (file)
@@ -76,6 +76,7 @@
 #include "pathnames.h"
 #include "xstrncpy.h"
 #include "nls.h"
+#include "usleep.h"
 
 static void usage(void), int_handler(int), write_user(struct utmp *);
 static void wall(void), write_wtmp(void), unmount_disks(void);
index 82e90f3a9ca7b59f934fc77492978062b424eae1..8cd35d64cd3ab3e1e3718dc2c828e66b60d4d5d2 100644 (file)
@@ -19,6 +19,7 @@
 #include "fsprobe.h"
 #include "pathnames.h"
 #include "nls.h"
+#include "usleep.h"
 
 #define streq(s, t)    (strcmp ((s), (t)) == 0)
 
index 4b843736d33df2f18da064b6437d63746a963e80..d75a69f3caa69153c5b8f5888616977fdd4bde43 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/rtc.h>
 
 #include "nls.h"
+#include "usleep.h"
 
 /* constants from legacy PC/AT hardware */
 #define        RTC_PF  0x40
index 6a76ef4539cb7dd939b7177faf6aaa5f398e4cc1..ec6e1c46c4b938c3cba5619ea18e0f61baf1000f 100644 (file)
@@ -41,6 +41,7 @@
 #include <sys/inotify.h>
 #endif
 #include "nls.h"
+#include "usleep.h"
 
 #define DEFAULT_LINES  10