Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioping
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ioping
Commits
8c4a323d
Commit
8c4a323d
authored
Oct 24, 2015
by
Konstantin Khlebnikov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ioping: no clock_gettime for mac
Signed-off-by:
Konstantin Khlebnikov
<
koct9i@gmail.com
>
parent
967656ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
23 deletions
+35
-23
ioping.c
ioping.c
+35
-23
No files found.
ioping.c
View file @
8c4a323d
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment