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
7e04f06d
Commit
7e04f06d
authored
Oct 19, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make timeval_minus_msec work with unsigned values.
parent
2b208fd0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
util.c
util.c
+13
-6
util.h
util.h
+1
-1
No files found.
util.c
View file @
7e04f06d
...
...
@@ -82,17 +82,24 @@ timeval_minus(struct timeval *d,
}
}
int
unsigned
timeval_minus_msec
(
const
struct
timeval
*
s1
,
const
struct
timeval
*
s2
)
{
/* Avoid overflow. This may happen if the clock is changed */
if
(
s1
->
tv_sec
<
s2
->
tv_sec
)
return
0
;
/* Avoid overflow. */
if
(
s1
->
tv_sec
-
s2
->
tv_sec
>
2000000
)
return
2000000000
;
else
if
(
s1
->
tv_sec
-
s2
->
tv_sec
<
-
2000000
)
return
-
2000000000
;
return
(
s1
->
tv_sec
-
s2
->
tv_sec
)
*
1000
+
(
s1
->
tv_usec
-
s2
->
tv_usec
)
/
1000
;
if
(
s1
->
tv_sec
>
s2
->
tv_sec
)
return
(
unsigned
)(
s1
->
tv_sec
-
s2
->
tv_sec
)
*
1000u
+
(
unsigned
)(
s1
->
tv_usec
-
s2
->
tv_usec
)
/
1000u
;
if
(
s1
->
tv_usec
<=
s2
->
tv_usec
)
return
0
;
return
(
unsigned
)(
s1
->
tv_usec
-
s2
->
tv_usec
)
/
1000u
;
}
void
...
...
util.h
View file @
7e04f06d
...
...
@@ -46,7 +46,7 @@ unsigned short seqno_plus(unsigned short s, int plus)
unsigned
roughly
(
unsigned
value
);
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
)
unsigned
timeval_minus_msec
(
const
struct
timeval
*
s1
,
const
struct
timeval
*
s2
)
ATTRIBUTE
((
pure
));
void
timeval_plus_msec
(
struct
timeval
*
d
,
const
struct
timeval
*
s
,
int
msecs
);
...
...
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