summaryrefslogtreecommitdiff
path: root/lib/unaligned.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/unaligned.h')
-rw-r--r--lib/unaligned.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/unaligned.h b/lib/unaligned.h
index 4e841f3a..0da1fdb4 100644
--- a/lib/unaligned.h
+++ b/lib/unaligned.h
@@ -29,6 +29,13 @@ get_u16(const void *p)
}
static inline u32
+get_u24(const void *P)
+{
+ const byte *p = P;
+ return (p[0] << 16) + (p[1] << 8) + p[2];
+}
+
+static inline u32
get_u32(const void *p)
{
u32 x;
@@ -53,6 +60,13 @@ put_u16(void *p, u16 x)
}
static inline void
+put_u24(void *p, u32 x)
+{
+ x = htonl(x);
+ memcpy(p, ((char *) &x) + 1, 3);
+}
+
+static inline void
put_u32(void *p, u32 x)
{
x = htonl(x);