Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
d8bd05d0
Commit
d8bd05d0
authored
Jul 30, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move gettime to kernel.c.
parent
454b486f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
35 deletions
+38
-35
kernel.c
kernel.c
+36
-0
kernel.h
kernel.h
+2
-0
util.c
util.c
+0
-34
util.h
util.h
+0
-1
No files found.
kernel.c
View file @
d8bd05d0
#include <sys/time.h>
#include <time.h>
#ifdef __APPLE__
#include "kernel_socket.c"
#else
#include "kernel_netlink.c"
#endif
/* Like gettimeofday, but should return monotonic time. If POSIX clocks
are not available, falls back to gettimeofday. */
int
gettime
(
struct
timeval
*
tv
)
{
#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(CLOCK_MONOTONIC)
static
int
have_posix_clocks
=
-
1
;
if
(
have_posix_clocks
<
0
)
{
struct
timespec
ts
;
int
rc
;
rc
=
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
if
(
rc
<
0
)
{
have_posix_clocks
=
0
;
}
else
{
have_posix_clocks
=
1
;
}
}
if
(
have_posix_clocks
)
{
struct
timespec
ts
;
int
rc
;
rc
=
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
if
(
rc
<
0
)
return
rc
;
tv
->
tv_sec
=
ts
.
tv_sec
;
tv
->
tv_usec
=
ts
.
tv_nsec
/
1000
;
return
rc
;
}
#endif
return
gettimeofday
(
tv
,
NULL
);
}
kernel.h
View file @
d8bd05d0
...
...
@@ -58,3 +58,5 @@ int kernel_route(int operation, const unsigned char *dest, unsigned short plen,
int
kernel_routes
(
struct
kernel_route
*
routes
,
int
maxroutes
);
int
kernel_callback
(
int
(
*
fn
)(
int
,
void
*
),
void
*
closure
);
int
kernel_addresses
(
struct
kernel_route
*
routes
,
int
maxroutes
);
int
gettime
(
struct
timeval
*
tv
);
util.c
View file @
d8bd05d0
...
...
@@ -69,40 +69,6 @@ roughly(int value)
return
value
*
3
/
4
+
random
()
%
(
value
/
2
);
}
/* Like gettimeofday, but should return monotonic time. If POSIX clocks
are not available, falls back to gettimeofday. */
int
gettime
(
struct
timeval
*
tv
)
{
#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(CLOCK_MONOTONIC)
static
int
have_posix_clocks
=
-
1
;
if
(
have_posix_clocks
<
0
)
{
struct
timespec
ts
;
int
rc
;
rc
=
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
if
(
rc
<
0
)
{
have_posix_clocks
=
0
;
}
else
{
have_posix_clocks
=
1
;
}
}
if
(
have_posix_clocks
)
{
struct
timespec
ts
;
int
rc
;
rc
=
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
if
(
rc
<
0
)
return
rc
;
tv
->
tv_sec
=
ts
.
tv_sec
;
tv
->
tv_usec
=
ts
.
tv_nsec
/
1000
;
return
rc
;
}
#endif
return
gettimeofday
(
tv
,
NULL
);
}
void
timeval_minus
(
struct
timeval
*
d
,
const
struct
timeval
*
s1
,
const
struct
timeval
*
s2
)
...
...
util.h
View file @
d8bd05d0
...
...
@@ -27,7 +27,6 @@ int seqno_minus(unsigned short s1, unsigned short s2)
unsigned
short
seqno_plus
(
unsigned
short
s
,
int
plus
)
ATTRIBUTE
((
const
));
int
roughly
(
int
value
);
int
gettime
(
struct
timeval
*
tv
);
void
timeval_minus
(
struct
timeval
*
d
,
const
struct
timeval
*
s1
,
const
struct
timeval
*
s2
);
int
timeval_minus_msec
(
const
struct
timeval
*
s1
,
const
struct
timeval
*
s2
)
...
...
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