X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Funaligned.h;h=6da60d4ddad3112200274b36d271403c2486caf6;hb=b4d79987a979bcbf749294c706fdc8c4ae8f9304;hp=835931453f24ae4aa58dcf67fdfb098c3972a139;hpb=79eebb222ecee1db69c22fe97e359cbcbb12fa8e;p=libucw.git diff --git a/lib/unaligned.h b/lib/unaligned.h index 83593145..6da60d4d 100644 --- a/lib/unaligned.h +++ b/lib/unaligned.h @@ -1,15 +1,19 @@ /* - * Sherlock Library -- Fast Access to Unaligned Data + * UCW Library -- Fast Access to Unaligned Data * - * (c) 1997--2001 Martin Mares + * (c) 1997--2003 Martin Mares + * + * This software may be freely distributed and used according to the terms + * of the GNU Lesser General Public License. */ -#ifndef _SHERLOCK_UNALIGNED_H -#define _SHERLOCK_UNALIGNED_H +#ifndef _UCW_UNALIGNED_H +#define _UCW_UNALIGNED_H #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) @@ -30,6 +34,8 @@ #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) @@ -38,4 +44,9 @@ #define PUT_U40(p,x) do { (p)[4] = ((x) >> 32); PUT_U32(p, x); } while(0) #endif +/* Just for completeness */ + +#define GET_U8(p) (*(byte *)(p)) +#define PUT_U8(p,x) *((byte *)(p)) = (x) + #endif