]> mj.ucw.cz Git - libucw.git/blobdiff - lib/unaligned.h
Oops, the card array was reversed!
[libucw.git] / lib / unaligned.h
index 835931453f24ae4aa58dcf67fdfb098c3972a139..7f8c417a0937a61745e20cf1a1ada82db2d78f81 100644 (file)
@@ -2,6 +2,9 @@
  *     Sherlock Library -- Fast Access to Unaligned Data
  *
  *     (c) 1997--2001 Martin Mares <mj@ucw.cz>
  *     Sherlock Library -- Fast Access to Unaligned Data
  *
  *     (c) 1997--2001 Martin Mares <mj@ucw.cz>
+ *
+ *     This software may be freely distributed and used according to the terms
+ *     of the GNU Lesser General Public License.
  */
 
 #ifndef _SHERLOCK_UNALIGNED_H
  */
 
 #ifndef _SHERLOCK_UNALIGNED_H
@@ -10,6 +13,7 @@
 #ifdef CPU_ALLOW_UNALIGNED
 #define GET_U16(p) (*((u16 *)(p)))
 #define GET_U32(p) (*((u32 *)(p)))
 #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)
 #define GET_U64(p) (*((u64 *)(p)))
 #define PUT_U16(p,x) *((u16 *)(p)) = (x)
 #define PUT_U32(p,x) *((u32 *)(p)) = (x)
@@ -30,6 +34,8 @@
 #endif
 #endif
 
 #endif
 #endif
 
+#define GET_U32_BE16(p) (((p)[0] << 16) | (p)[1])
+
 #ifdef CPU_BIG_ENDIAN
 #define GET_U40(p) (((u64) (p)[0] << 32) | GET_U32((p)+1))
 #define PUT_U40(p,x) do { (p)[0] = ((x) >> 32); PUT_U32(((p)+1), x); } while(0)
 #ifdef CPU_BIG_ENDIAN
 #define GET_U40(p) (((u64) (p)[0] << 32) | GET_U32((p)+1))
 #define PUT_U40(p,x) do { (p)[0] = ((x) >> 32); PUT_U32(((p)+1), x); } while(0)