diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2015-11-23 11:32:18 +0100 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2015-11-23 11:32:18 +0100 |
commit | 12d752ef24ab507d249a60098ec98dcf28b70036 (patch) | |
tree | 2b80394586acab9048474a596a269e76cd214a0e /lib/unaligned.h | |
parent | 1e4891e48e7b6f022564e7409d15c3fdb65ec2ad (diff) | |
parent | f312a837e919c660884ceb9c50c106df1e4c0658 (diff) |
Merge commit 'origin/crypto-hash^'
Diffstat (limited to 'lib/unaligned.h')
-rw-r--r-- | lib/unaligned.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/unaligned.h b/lib/unaligned.h index af655204..a2dbae4f 100644 --- a/lib/unaligned.h +++ b/lib/unaligned.h @@ -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 |