To make it available everywhere in code.
Signed-off-by: Karel Zak <kzak@redhat.com>
include/sysfs.h \
include/tt.h \
include/ttyutils.h \
- include/usleep.h \
include/wholedisk.h \
include/widechar.h \
include/xalloc.h \
#include <unistd.h>
#include <errno.h>
+#include "c.h"
+
static inline int write_all(int fd, const void *buf, size_t count)
{
while (count) {
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
+++ /dev/null
-#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 */
#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)
/*
* kd.c - KDGHWCLK stuff, possibly m68k only, likely to be deprecated
*/
-
-# include "hwclock.h"
+#include "hwclock.h"
#ifdef __m68k__
# include <unistd.h>
# include "nls.h"
-# include "usleep.h"
/* Get defines for KDGHWCLK and KDSHWCLK (m68k) */
# include <linux/kd.h>
#include "nls.h"
#include "xalloc.h"
#include "pathnames.h"
-#include "usleep.h"
#include "strutils.h"
#include "c.h"
#include "closestream.h"
#include "nls.h"
#include "xalloc.h"
-#include "usleep.h"
#include "strutils.h"
#include "c.h"
#include "closestream.h"