36 #if defined( INC_ALL )
47 #if !defined( UNIT_BITS )
48 # if PLATFORM_BYTE_ORDER == IS_BIG_ENDIAN
50 # elif defined( _WIN64 )
57 #if UNIT_BITS == 64 && !defined( NEED_UINT_64T )
58 # define NEED_UINT_64T
61 #if defined( INC_ALL )
71 #if 1 && !defined( USE_INLINING )
75 #if defined( _MSC_VER )
79 # pragma intrinsic(memset)
80 # pragma intrinsic(memcpy)
83 # define rotl64 _rotl64
84 # define rotr64 _rotl64
85 # define bswap_16(x) _byteswap_ushort(x)
86 # define bswap_32(x) _byteswap_ulong(x)
87 # define bswap_64(x) _byteswap_uint64(x)
89 # define rotl32 _lrotl
90 # define rotr32 _lrotr
94 #if defined( USE_INLINING )
95 # if defined( _MSC_VER )
96 # define mh_decl __inline
97 # elif defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
98 # define mh_decl static inline
100 # define mh_decl static
104 #if defined(__cplusplus)
108 #define UI8_PTR(x) UPTR_CAST(x, 8)
109 #define UI16_PTR(x) UPTR_CAST(x, 16)
110 #define UI32_PTR(x) UPTR_CAST(x, 32)
111 #define UI64_PTR(x) UPTR_CAST(x, 64)
112 #define UNIT_PTR(x) UPTR_CAST(x, UNIT_BITS)
114 #define UI8_VAL(x) UNIT_CAST(x, 8)
115 #define UI16_VAL(x) UNIT_CAST(x, 16)
116 #define UI32_VAL(x) UNIT_CAST(x, 32)
117 #define UI64_VAL(x) UNIT_CAST(x, 64)
118 #define UNIT_VAL(x) UNIT_CAST(x, UNIT_BITS)
120 #define BUF_INC (UNIT_BITS >> 3)
121 #define BUF_ADRMASK ((UNIT_BITS >> 3) - 1)
123 #define rep2_u2(f,r,x) f( 0,r,x); f( 1,r,x)
124 #define rep2_u4(f,r,x) f( 0,r,x); f( 1,r,x); f( 2,r,x); f( 3,r,x)
125 #define rep2_u16(f,r,x) f( 0,r,x); f( 1,r,x); f( 2,r,x); f( 3,r,x); \
126 f( 4,r,x); f( 5,r,x); f( 6,r,x); f( 7,r,x); \
127 f( 8,r,x); f( 9,r,x); f(10,r,x); f(11,r,x); \
128 f(12,r,x); f(13,r,x); f(14,r,x); f(15,r,x)
130 #define rep2_d2(f,r,x) f( 1,r,x); f( 0,r,x)
131 #define rep2_d4(f,r,x) f( 3,r,x); f( 2,r,x); f( 1,r,x); f( 0,r,x)
132 #define rep2_d16(f,r,x) f(15,r,x); f(14,r,x); f(13,r,x); f(12,r,x); \
133 f(11,r,x); f(10,r,x); f( 9,r,x); f( 8,r,x); \
134 f( 7,r,x); f( 6,r,x); f( 5,r,x); f( 4,r,x); \
135 f( 3,r,x); f( 2,r,x); f( 1,r,x); f( 0,r,x)
137 #define rep3_u2(f,r,x,y,c) f( 0,r,x,y,c); f( 1,r,x,y,c)
138 #define rep3_u4(f,r,x,y,c) f( 0,r,x,y,c); f( 1,r,x,y,c); f( 2,r,x,y,c); f( 3,r,x,y,c)
139 #define rep3_u16(f,r,x,y,c) f( 0,r,x,y,c); f( 1,r,x,y,c); f( 2,r,x,y,c); f( 3,r,x,y,c); \
140 f( 4,r,x,y,c); f( 5,r,x,y,c); f( 6,r,x,y,c); f( 7,r,x,y,c); \
141 f( 8,r,x,y,c); f( 9,r,x,y,c); f(10,r,x,y,c); f(11,r,x,y,c); \
142 f(12,r,x,y,c); f(13,r,x,y,c); f(14,r,x,y,c); f(15,r,x,y,c)
144 #define rep3_d2(f,r,x,y,c) f( 1,r,x,y,c); f( 0,r,x,y,c)
145 #define rep3_d4(f,r,x,y,c) f( 3,r,x,y,c); f( 2,r,x,y,c); f( 1,r,x,y,c); f( 0,r,x,y,c)
146 #define rep3_d16(f,r,x,y,c) f(15,r,x,y,c); f(14,r,x,y,c); f(13,r,x,y,c); f(12,r,x,y,c); \
147 f(11,r,x,y,c); f(10,r,x,y,c); f( 9,r,x,y,c); f( 8,r,x,y,c); \
148 f( 7,r,x,y,c); f( 6,r,x,y,c); f( 5,r,x,y,c); f( 4,r,x,y,c); \
149 f( 3,r,x,y,c); f( 2,r,x,y,c); f( 1,r,x,y,c); f( 0,r,x,y,c)
157 #if !defined( rotl32 )
160 return (((x) << n) | ((x) >> (32 - n)));
164 #if !defined( rotr32 )
167 return (((x) >> n) | ((x) << (32 - n)));
171 #if ( UNIT_BITS == 64 ) && !defined( rotl64 )
172 mh_decl uint_64t rotl64(uint_64t x,
int n)
174 return (((x) << n) | ((x) >> (64 - n)));
178 #if ( UNIT_BITS == 64 ) && !defined( rotr64 )
179 mh_decl uint_64t rotr64(uint_64t x,
int n)
181 return (((x) >> n) | ((x) << (64 - n)));
187 #if !defined(bswap_16)
190 return (uint_16t)((x >> 8) | (x << 8));
194 #if !defined(bswap_32)
197 return ((
rotr32((x), 24) & 0x00ff00ff) | (
rotr32((x), 8) & 0xff00ff00));
201 #if ( UNIT_BITS == 64 ) && !defined(bswap_64)
202 mh_decl uint_64t bswap_64(uint_64t x)
204 return bswap_32((uint_32t)(x >> 32)) | ((uint_64t)
bswap_32((uint_32t)x) << 32);
213 #define f_copy(n,p,q) p[n] = q[n]
214 #define f_xor(n,r,p,q,c) r[n] = c(p[n] ^ q[n])
225 #elif UNIT_BITS == 32
241 #elif UNIT_BITS == 32
260 #elif UNIT_BITS == 32
281 #elif UNIT_BITS == 32
302 #elif UNIT_BITS == 32
314 #if PLATFORM_BYTE_ORDER == IS_BIG_ENDIAN
316 # define uint_16t_to_le(x) (x) = bswap_16((x))
317 # define uint_32t_to_le(x) (x) = bswap_32((x))
318 # define uint_64t_to_le(x) (x) = bswap_64((x))
319 # define uint_16t_to_be(x)
320 # define uint_32t_to_be(x)
321 # define uint_64t_to_be(x)
325 # define uint_16t_to_le(x)
326 # define uint_32t_to_le(x)
327 # define uint_64t_to_le(x)
328 # define uint_16t_to_be(x) (x) = bswap_16((x))
329 # define uint_32t_to_be(x) (x) = bswap_32((x))
330 # define uint_64t_to_be(x) (x) = bswap_64((x))
334 #if defined(__cplusplus)