]> mj.ucw.cz Git - libucw.git/commitdiff
Added macro for fetching of u32's aligned on 2-byte boundary.
authorMartin Mares <mj@ucw.cz>
Sat, 10 Mar 2001 16:09:13 +0000 (16:09 +0000)
committerMartin Mares <mj@ucw.cz>
Sat, 10 Mar 2001 16:09:13 +0000 (16:09 +0000)
lib/unaligned.h

index 835931453f24ae4aa58dcf67fdfb098c3972a139..2d4541a77cd111d9d0947534b6d61f7d4fea3635 100644 (file)
@@ -10,6 +10,7 @@
 #ifdef CPU_ALLOW_UNALIGNED
 #define GET_U16(p) (*((u16 *)(p)))
 #define GET_U32(p) (*((u32 *)(p)))
+#define GET_U32_16(p) (*((u32 *)(p)))
 #define GET_U64(p) (*((u64 *)(p)))
 #define PUT_U16(p,x) *((u16 *)(p)) = (x)
 #define PUT_U32(p,x) *((u32 *)(p)) = (x)
 #ifdef CPU_BIG_ENDIAN
 #define GET_U16(p) (((p)[0] << 8) | (p)[1])
 #define GET_U32(p) (((p)[0] << 24) | ((p)[1] << 16) | ((p)[2] << 8) | (p)[3])
+#define GET_U32_16(p) (((p)[0] << 16) | (p)[1])
 #define PUT_U16(p,x) (void)(((p)[0] = ((x) >> 8)), (((p)[1]) = (x)))
 #define PUT_U32(p,x) (void)(((p)[0] = ((x) >> 24)), (((p)[1]) = ((x) >> 16)), (((p)[2]) = ((x) >> 8)), (((p)[3]) = (x)))
 #else
 #define GET_U16(p) (((p)[1] << 8) | (p)[0])
 #define GET_U32(p) (((p)[3] << 24) | ((p)[2] << 16) | ((p)[1] << 8) | (p)[0])
+#define GET_U32_16(p) (((p)[1] << 16) | (p)[0])
 #define PUT_U16(p,x) (void)(((p)[1] = ((x) >> 8)), (((p)[0]) = (x)))
 #define PUT_U32(p,x) (void)(((p)[3] = ((x) >> 24)), (((p)[2]) = ((x) >> 16)), (((p)[1]) = ((x) >> 8)), (((p)[0]) = (x)))
 #endif