Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
labs
BIRD Internet Routing Daemon
Commits
75ff0802
Commit
75ff0802
authored
Nov 13, 2015
by
Pavel Tvrdík
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add get_u64() and put_u64() into lib/unaligned.h
parent
fce764f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
lib/unaligned.h
lib/unaligned.h
+19
-0
No files found.
lib/unaligned.h
View file @
75ff0802
...
...
@@ -35,6 +35,15 @@ get_u32(void *p)
return
ntohl
(
x
);
}
static
inline
u64
get_u64
(
const
void
*
p
)
{
u32
xh
,
xl
;
memcpy
(
&
xh
,
p
,
4
);
memcpy
(
&
xl
,
p
+
4
,
4
);
return
(((
u64
)
ntohl
(
xh
))
<<
32
)
|
ntohl
(
xl
);
}
static
inline
void
put_u16
(
void
*
p
,
u16
x
)
{
...
...
@@ -49,4 +58,14 @@ put_u32(void *p, u32 x)
memcpy
(
p
,
&
x
,
4
);
}
static
inline
void
put_u64
(
void
*
p
,
u64
x
)
{
u32
xh
,
xl
;
xh
=
htonl
(
x
>>
32
);
xl
=
htonl
((
u32
)
x
);
memcpy
(
p
,
&
xh
,
4
);
memcpy
(
p
+
4
,
&
xl
,
4
);
}
#endif
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