Commit 8c4a323d authored by Konstantin Khlebnikov's avatar Konstantin Khlebnikov

ioping: no clock_gettime for mac

Signed-off-by: default avatarKonstantin Khlebnikov <koct9i@gmail.com>
parent 967656ec
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#ifdef __linux__ #ifdef __linux__
# include <sys/ioctl.h> # include <sys/ioctl.h>
# include <sys/mount.h> # include <sys/mount.h>
# define HAVE_CLOCK_GETTIME
# define HAVE_POSIX_FADVICE # define HAVE_POSIX_FADVICE
# define HAVE_POSIX_MEMALIGN # define HAVE_POSIX_MEMALIGN
# define HAVE_DIRECT_IO # define HAVE_DIRECT_IO
...@@ -58,6 +59,7 @@ ...@@ -58,6 +59,7 @@
#ifdef __gnu_hurd__ #ifdef __gnu_hurd__
# include <sys/ioctl.h> # include <sys/ioctl.h>
# define HAVE_CLOCK_GETTIME
# define HAVE_POSIX_MEMALIGN # define HAVE_POSIX_MEMALIGN
# define HAVE_ERR_INCLUDE # define HAVE_ERR_INCLUDE
#endif #endif
...@@ -66,12 +68,14 @@ ...@@ -66,12 +68,14 @@
# include <sys/ioctl.h> # include <sys/ioctl.h>
# include <sys/mount.h> # include <sys/mount.h>
# include <sys/disk.h> # include <sys/disk.h>
# define HAVE_CLOCK_GETTIME
# define HAVE_DIRECT_IO # define HAVE_DIRECT_IO
# define HAVE_ERR_INCLUDE # define HAVE_ERR_INCLUDE
#endif #endif
#ifdef __DragonFly__ #ifdef __DragonFly__
# include <sys/diskslice.h> # include <sys/diskslice.h>
# define HAVE_CLOCK_GETTIME
# define HAVE_ERR_INCLUDE # define HAVE_ERR_INCLUDE
#endif #endif
...@@ -81,11 +85,12 @@ ...@@ -81,11 +85,12 @@
# include <sys/dkio.h> # include <sys/dkio.h>
# include <sys/param.h> # include <sys/param.h>
# include <sys/mount.h> # include <sys/mount.h>
# define HAVE_CLOCK_GETTIME
# define HAVE_POSIX_MEMALIGN # define HAVE_POSIX_MEMALIGN
# define HAVE_ERR_INCLUDE # define HAVE_ERR_INCLUDE
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__ /* OS X */
# include <sys/ioctl.h> # include <sys/ioctl.h>
# include <sys/mount.h> # include <sys/mount.h>
# include <sys/disk.h> # include <sys/disk.h>
...@@ -97,6 +102,7 @@ ...@@ -97,6 +102,7 @@
#ifdef __sun__ /* Solaris */ #ifdef __sun__ /* Solaris */
# include <sys/dkio.h> # include <sys/dkio.h>
# include <sys/vtoc.h> # include <sys/vtoc.h>
# define HAVE_CLOCK_GETTIME
# define HAVE_DIRECT_IO # define HAVE_DIRECT_IO
# define O_DIRECT O_DSYNC # define O_DIRECT O_DSYNC
# define HAVE_ERR_INCLUDE # define HAVE_ERR_INCLUDE
...@@ -153,6 +159,34 @@ void warnx(const char *fmt, ...) ...@@ -153,6 +159,34 @@ void warnx(const char *fmt, ...)
#endif /* HAVE_ERR_INCLUDE */ #endif /* HAVE_ERR_INCLUDE */
#define NSEC_PER_SEC 1000000000ll
#ifdef HAVE_CLOCK_GETTIME
static inline long long now(void)
{
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts))
err(3, "clock_gettime failed");
return ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec;
}
#else
static inline long long now(void)
{
struct timeval tv;
if (gettimeofday(&tv, NULL))
err(3, "gettimeofday failed");
return tv.tv_sec * NSEC_PER_SEC + tv.tv_usec * 1000ll;
}
#endif /* HAVE_CLOCK_GETTIME */
int async = 0; int async = 0;
#ifdef __MINGW32__ #ifdef __MINGW32__
...@@ -321,8 +355,6 @@ static struct suffix size_suffix[] = { ...@@ -321,8 +355,6 @@ static struct suffix size_suffix[] = {
{ NULL, 0ll }, { NULL, 0ll },
}; };
#define NSEC_PER_SEC 1000000000ll
static struct suffix time_suffix[] = { static struct suffix time_suffix[] = {
{ "hour", NSEC_PER_SEC * 60 * 60 }, { "hour", NSEC_PER_SEC * 60 * 60 },
{ "min", NSEC_PER_SEC * 60 }, { "min", NSEC_PER_SEC * 60 },
...@@ -861,16 +893,6 @@ void set_signal(void) ...@@ -861,16 +893,6 @@ void set_signal(void)
SetConsoleCtrlHandler(sig_exit, TRUE); SetConsoleCtrlHandler(sig_exit, TRUE);
} }
static inline long long now(void)
{
struct timeval tv;
if (gettimeofday(&tv, NULL))
err(3, "gettimeofday failed");
return tv.tv_sec * NSEC_PER_SEC + tv.tv_usec * 1000ll;
}
#else /* __MINGW32__ */ #else /* __MINGW32__ */
int open_file(const char *path, const char *temp) int open_file(const char *path, const char *temp)
...@@ -939,16 +961,6 @@ void set_signal(void) ...@@ -939,16 +961,6 @@ void set_signal(void)
sigaction(SIGINT, &sa, NULL); sigaction(SIGINT, &sa, NULL);
} }
static inline long long now(void)
{
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts))
err(3, "clock_gettime failed");
return ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec;
}
#endif /* __MINGW32__ */ #endif /* __MINGW32__ */
void random_memory(void *buf, size_t len) void random_memory(void *buf, size_t len)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment