14#if defined (__cplusplus)
38#if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) ) )
56# error "this implementation requires char to be exactly 8-bit type"
58 typedef unsigned char BYTE;
59 typedef unsigned char U8;
60 typedef signed char S8;
62# error "this implementation requires short to be exactly 16-bit type"
64 typedef unsigned short U16;
65 typedef signed short S16;
66#if UINT_MAX != 4294967295
67# error "this implementation requires int to be exactly 32-bit type"
69 typedef unsigned int U32;
70 typedef signed int S32;
73 typedef unsigned long long U64;
74 typedef signed long long S64;
134#ifndef MEM_FORCE_MEMORY_ACCESS
136# define MEM_FORCE_MEMORY_ACCESS 1
145#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
147#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
149#elif defined(__clang__) && __LITTLE_ENDIAN__
151#elif defined(__clang__) && __BIG_ENDIAN__
153#elif defined(_MSC_VER) && (_M_AMD64 || _M_IX86)
155#elif defined(__DMC__) && defined(_M_IX86)
158 const union {
U32 u;
BYTE c[4]; } one = { 1 };
163#if defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==2)
176#elif defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==1)
178typedef __attribute__((aligned(1)))
U16 unalign16;
179typedef __attribute__((aligned(1)))
U32 unalign32;
180typedef __attribute__((aligned(1)))
U64 unalign64;
181typedef __attribute__((aligned(1)))
size_t unalignArch;
214 size_t val;
ZSTD_memcpy(&val, memPtr,
sizeof(val));
return val;
236 return ((in << 24) & 0xff000000 ) |
237 ((in << 8) & 0x00ff0000 ) |
238 ((in >> 8) & 0x0000ff00 ) |
239 ((in >> 24) & 0x000000ff );
245 return _byteswap_ulong(in);
246#elif (defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)) \
247 || (defined(__clang__) && __has_builtin(__builtin_bswap32))
248 return __builtin_bswap32(in);
256 return ((in << 56) & 0xff00000000000000ULL) |
257 ((in << 40) & 0x00ff000000000000ULL) |
258 ((in << 24) & 0x0000ff0000000000ULL) |
259 ((in << 8) & 0x000000ff00000000ULL) |
260 ((in >> 8) & 0x00000000ff000000ULL) |
261 ((in >> 24) & 0x0000000000ff0000ULL) |
262 ((in >> 40) & 0x000000000000ff00ULL) |
263 ((in >> 56) & 0x00000000000000ffULL);
269 return _byteswap_uint64(in);
270#elif (defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)) \
271 || (defined(__clang__) && __has_builtin(__builtin_bswap64))
272 return __builtin_bswap64(in);
293 const BYTE* p = (
const BYTE*)memPtr;
294 return (
U16)(p[0] + (p[1]<<8));
305 p[1] = (
BYTE)(val>>8);
317 ((
BYTE*)memPtr)[2] = (
BYTE)(val>>16);
422#if defined (__cplusplus)
#define DEBUG_STATIC_ASSERT(c)
MEM_STATIC U32 MEM_readLE24(const void *memPtr)
MEM_STATIC void MEM_write64(void *memPtr, U64 value)
MEM_STATIC unsigned MEM_32bits(void)
MEM_STATIC U64 MEM_swap64(U64 in)
MEM_STATIC U64 MEM_readBE64(const void *memPtr)
MEM_STATIC U32 MEM_read32(const void *memPtr)
MEM_STATIC U32 MEM_swap32(U32 in)
MEM_STATIC U16 MEM_read16(const void *memPtr)
MEM_STATIC void MEM_writeBE32(void *memPtr, U32 val32)
MEM_STATIC size_t MEM_readLEST(const void *memPtr)
MEM_STATIC size_t MEM_readST(const void *memPtr)
MEM_STATIC size_t MEM_readBEST(const void *memPtr)
MEM_STATIC U32 MEM_readBE32(const void *memPtr)
MEM_STATIC void MEM_writeLE16(void *memPtr, U16 val)
MEM_STATIC void MEM_writeBEST(void *memPtr, size_t val)
MEM_STATIC size_t MEM_swapST(size_t in)
MEM_STATIC unsigned MEM_isLittleEndian(void)
MEM_STATIC void MEM_writeLE32(void *memPtr, U32 val32)
MEM_STATIC U16 MEM_readLE16(const void *memPtr)
MEM_STATIC void MEM_check(void)
MEM_STATIC unsigned MEM_64bits(void)
MEM_STATIC U64 MEM_swap64_fallback(U64 in)
MEM_STATIC void MEM_write32(void *memPtr, U32 value)
MEM_STATIC U64 MEM_readLE64(const void *memPtr)
MEM_STATIC void MEM_writeLEST(void *memPtr, size_t val)
MEM_STATIC void MEM_write16(void *memPtr, U16 value)
MEM_STATIC void MEM_writeLE64(void *memPtr, U64 val64)
MEM_STATIC void MEM_writeLE24(void *memPtr, U32 val)
MEM_STATIC U32 MEM_readLE32(const void *memPtr)
MEM_STATIC U64 MEM_read64(const void *memPtr)
MEM_STATIC void MEM_writeBE64(void *memPtr, U64 val64)
MEM_STATIC U32 MEM_swap32_fallback(U32 in)
#define ZSTD_memcpy(d, s, l)