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
faa3b899
Commit
faa3b899
authored
Jun 11, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use POSIX timers if available.
This protects against clock stepping if CLOCK_MONOTONIC is implemented.
parent
41eaf51c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
Makefile
Makefile
+2
-0
util.c
util.c
+26
-0
No files found.
Makefile
View file @
faa3b899
...
@@ -6,6 +6,8 @@ DEFINES = $(PLATFORM_DEFINES)
...
@@ -6,6 +6,8 @@ DEFINES = $(PLATFORM_DEFINES)
CFLAGS
=
$(CDEBUGFLAGS)
$(DEFINES)
$(EXTRA_DEFINES)
CFLAGS
=
$(CDEBUGFLAGS)
$(DEFINES)
$(EXTRA_DEFINES)
LDLIBS
=
-lrt
SRCS
=
babel.c net.c kernel.c util.c network.c source.c neighbour.c
\
SRCS
=
babel.c net.c kernel.c util.c network.c source.c neighbour.c
\
route.c xroute.c message.c resend.c filter.c
route.c xroute.c message.c resend.c filter.c
...
...
util.c
View file @
faa3b899
...
@@ -68,6 +68,32 @@ seqno_plus(unsigned short s, int plus)
...
@@ -68,6 +68,32 @@ seqno_plus(unsigned short s, int plus)
int
int
gettime
(
struct
timeval
*
tv
)
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
);
return
gettimeofday
(
tv
,
NULL
);
}
}
...
...
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