replace usleep() for systems that don't have them
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>
This commit is contained in:
parent
102f5d89d9
commit
437fa54f05
|
@ -140,6 +140,7 @@ AC_CHECK_FUNCS(
|
|||
fsync \
|
||||
getdomainname \
|
||||
get_current_dir_name \
|
||||
usleep \
|
||||
nanosleep \
|
||||
personality \
|
||||
updwtmp \
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -16,6 +16,7 @@ dist_noinst_HEADERS = \
|
|||
pttype.h \
|
||||
setproctitle.h \
|
||||
swapheader.h \
|
||||
usleep.h \
|
||||
wholedisk.h \
|
||||
widechar.h \
|
||||
xstrncpy.h
|
||||
|
|
|
@ -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 */
|
|
@ -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);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "fsprobe.h"
|
||||
#include "pathnames.h"
|
||||
#include "nls.h"
|
||||
#include "usleep.h"
|
||||
|
||||
#define streq(s, t) (strcmp ((s), (t)) == 0)
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <linux/rtc.h>
|
||||
|
||||
#include "nls.h"
|
||||
#include "usleep.h"
|
||||
|
||||
/* constants from legacy PC/AT hardware */
|
||||
#define RTC_PF 0x40
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <sys/inotify.h>
|
||||
#endif
|
||||
#include "nls.h"
|
||||
#include "usleep.h"
|
||||
|
||||
#define DEFAULT_LINES 10
|
||||
|
||||
|
|
Loading…
Reference in New Issue