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
ef8a9fa3
Commit
ef8a9fa3
authored
Dec 11, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More time paranoia.
parent
8abdd950
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
kernel.c
kernel.c
+15
-4
No files found.
kernel.c
View file @
ef8a9fa3
...
...
@@ -60,17 +60,19 @@ kernel_ll_addresses(char *ifname, int ifindex,
return
j
;
}
/* Like gettimeofday, but
should return monotonic time. If POSIX clocks
a
re not available, falls back to gettimeofda
y. */
/* Like gettimeofday, but
returns monotonic time. If POSIX clocks are not
a
vailable, falls back to gettimeofday but enforces monotonicit
y. */
int
gettime
(
struct
timeval
*
tv
)
{
int
rc
;
static
time_t
offset
=
0
,
previous
=
0
;
#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(CLOCK_MONOTONIC)
static
int
have_posix_clocks
=
-
1
;
if
(
UNLIKELY
(
have_posix_clocks
<
0
))
{
struct
timespec
ts
;
int
rc
;
rc
=
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
if
(
rc
<
0
)
{
have_posix_clocks
=
0
;
...
...
@@ -91,5 +93,14 @@ gettime(struct timeval *tv)
}
#endif
return
gettimeofday
(
tv
,
NULL
);
rc
=
gettimeofday
(
tv
,
NULL
);
if
(
rc
<
0
)
return
rc
;
tv
->
tv_sec
+=
offset
;
if
(
UNLIKELY
(
previous
>
tv
->
tv_sec
))
{
offset
+=
previous
-
tv
->
tv_sec
;
tv
->
tv_sec
=
previous
;
}
previous
=
tv
->
tv_sec
;
return
rc
;
}
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