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
285d03d6
Commit
285d03d6
authored
Nov 01, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inline seqno arithmetic.
parent
7aaabd62
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
27 deletions
+21
-27
util.c
util.c
+0
-21
util.h
util.h
+21
-6
No files found.
util.c
View file @
285d03d6
...
@@ -35,27 +35,6 @@ THE SOFTWARE.
...
@@ -35,27 +35,6 @@ THE SOFTWARE.
#include "babel.h"
#include "babel.h"
#include "util.h"
#include "util.h"
int
seqno_compare
(
unsigned
short
s1
,
unsigned
short
s2
)
{
if
(
s1
==
s2
)
return
0
;
else
return
((
s2
-
s1
)
&
0x8000
)
?
1
:
-
1
;
}
int
seqno_minus
(
unsigned
short
s1
,
unsigned
short
s2
)
{
return
(
int
)(
short
)((
s1
-
s2
)
&
0xFFFF
);
}
unsigned
short
seqno_plus
(
unsigned
short
s
,
int
plus
)
{
return
((
s
+
plus
)
&
0xFFFF
);
}
unsigned
unsigned
roughly
(
unsigned
value
)
roughly
(
unsigned
value
)
{
{
...
...
util.h
View file @
285d03d6
...
@@ -37,12 +37,27 @@ struct __us { unsigned short x __attribute__((packed)); };
...
@@ -37,12 +37,27 @@ struct __us { unsigned short x __attribute__((packed)); };
memcpy((_d), &(_dd), 2); } while(0)
memcpy((_d), &(_dd), 2); } while(0)
#endif
#endif
int
seqno_compare
(
unsigned
short
s1
,
unsigned
short
s2
)
static
inline
int
ATTRIBUTE
((
const
));
seqno_compare
(
unsigned
short
s1
,
unsigned
short
s2
)
int
seqno_minus
(
unsigned
short
s1
,
unsigned
short
s2
)
{
ATTRIBUTE
((
const
));
if
(
s1
==
s2
)
unsigned
short
seqno_plus
(
unsigned
short
s
,
int
plus
)
return
0
;
ATTRIBUTE
((
const
));
else
return
((
s2
-
s1
)
&
0x8000
)
?
1
:
-
1
;
}
static
inline
int
seqno_minus
(
unsigned
short
s1
,
unsigned
short
s2
)
{
return
(
int
)(
short
)((
s1
-
s2
)
&
0xFFFF
);
}
static
inline
unsigned
short
seqno_plus
(
unsigned
short
s
,
int
plus
)
{
return
((
s
+
plus
)
&
0xFFFF
);
}
unsigned
roughly
(
unsigned
value
);
unsigned
roughly
(
unsigned
value
);
void
timeval_minus
(
struct
timeval
*
d
,
void
timeval_minus
(
struct
timeval
*
d
,
const
struct
timeval
*
s1
,
const
struct
timeval
*
s2
);
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