]>
git.ipfire.org Git - thirdparty/bird.git/blob - lib/unaligned.h
2 * Unaligned Data Accesses -- Generic Version, Network Order
4 * (c) 2000 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
9 #ifndef _BIRD_UNALIGNED_H_
10 #define _BIRD_UNALIGNED_H_
13 * We don't do any clever tricks with unaligned accesses since it's
14 * virtually impossible to figure out what alignment does the CPU want
15 * (unaligned accesses can be emulated by the OS which makes them work,
16 * but unusably slow). We use memcpy and hope GCC will optimize it out
20 #include "lib/string.h"
23 get_u16(const void *p
)
31 get_u32(const void *p
)
39 get_u64(const void *p
)
44 return (((u64
) ntohl(xh
)) << 32) | ntohl(xl
);
54 put_u16(void *p
, u16 x
)
61 put_u32(void *p
, u32 x
)
68 put_u64(void *p
, u64 x
)