#ifndef MEM_H_MODULE
#define MEM_H_MODULE
#if defined (__cplusplus)
extern "C" {
#endif
#include <stddef.h>
#include "compiler.h"
#include "debug.h"
#include "zstd_deps.h"
#if defined(_MSC_VER)
# include <stdlib.h>
# include <intrin.h>
#endif
#if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) ) )
# if defined(_AIX)
# include <inttypes.h>
# else
# include <stdint.h>
# endif
BYTE;
U8;
S8;
U16;
S16;
U32;
S32;
U64;
S64;
#else
# include <limits.h>
#if CHAR_BIT != 8
# error "this implementation requires char to be exactly 8-bit type"
#endif
typedef unsigned char BYTE;
typedef unsigned char U8;
typedef signed char S8;
#if USHRT_MAX != 65535
# error "this implementation requires short to be exactly 16-bit type"
#endif
typedef unsigned short U16;
typedef signed short S16;
#if UINT_MAX != 4294967295
# error "this implementation requires int to be exactly 32-bit type"
#endif
typedef unsigned int U32;
typedef signed int S32;
typedef unsigned long long U64;
typedef signed long long S64;
#endif
MEM_STATIC unsigned MEM_32bits(void);
MEM_STATIC unsigned MEM_64bits(void);
MEM_STATIC unsigned MEM_isLittleEndian(void);
MEM_STATIC U16 MEM_read16(const void* memPtr);
MEM_STATIC U32 MEM_read32(const void* memPtr);
MEM_STATIC U64 MEM_read64(const void* memPtr);
MEM_STATIC size_t MEM_readST(const void* memPtr);
MEM_STATIC void MEM_write16(void* memPtr, U16 value);
MEM_STATIC void MEM_write32(void* memPtr, U32 value);
MEM_STATIC void MEM_write64(void* memPtr, U64 value);
MEM_STATIC U16 MEM_readLE16(const void* memPtr);
MEM_STATIC U32 MEM_readLE24(const void* memPtr);
MEM_STATIC U32 MEM_readLE32(const void* memPtr);
MEM_STATIC U64 MEM_readLE64(const void* memPtr);
MEM_STATIC size_t MEM_readLEST(const void* memPtr);
MEM_STATIC void MEM_writeLE16(void* memPtr, U16 val);
MEM_STATIC void MEM_writeLE24(void* memPtr, U32 val);
MEM_STATIC void MEM_writeLE32(void* memPtr, U32 val32);
MEM_STATIC void MEM_writeLE64(void* memPtr, U64 val64);
MEM_STATIC void MEM_writeLEST(void* memPtr, size_t val);
MEM_STATIC U32 MEM_readBE32(const void* memPtr);
MEM_STATIC U64 MEM_readBE64(const void* memPtr);
MEM_STATIC size_t MEM_readBEST(const void* memPtr);
MEM_STATIC void MEM_writeBE32(void* memPtr, U32 val32);
MEM_STATIC void MEM_writeBE64(void* memPtr, U64 val64);
MEM_STATIC void MEM_writeBEST(void* memPtr, size_t val);
MEM_STATIC U32 MEM_swap32(U32 in);
MEM_STATIC U64 MEM_swap64(U64 in);
MEM_STATIC size_t MEM_swapST(size_t in);
#ifndef MEM_FORCE_MEMORY_ACCESS
# ifdef __GNUC__
#define MEM_FORCE_MEMORY_ACCESS …
# endif
#endif
MEM_STATIC unsigned MEM_32bits(void) { … }
MEM_STATIC unsigned MEM_64bits(void) { … }
MEM_STATIC unsigned MEM_isLittleEndian(void)
{ … }
#if defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==2)
MEM_STATIC U16 MEM_read16(const void* memPtr) { return *(const U16*) memPtr; }
MEM_STATIC U32 MEM_read32(const void* memPtr) { return *(const U32*) memPtr; }
MEM_STATIC U64 MEM_read64(const void* memPtr) { return *(const U64*) memPtr; }
MEM_STATIC size_t MEM_readST(const void* memPtr) { return *(const size_t*) memPtr; }
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; }
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { *(U32*)memPtr = value; }
MEM_STATIC void MEM_write64(void* memPtr, U64 value) { *(U64*)memPtr = value; }
#elif defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==1)
unalign16;
unalign32;
unalign64;
unalignArch;
MEM_STATIC U16 MEM_read16(const void* ptr) { … }
MEM_STATIC U32 MEM_read32(const void* ptr) { … }
MEM_STATIC U64 MEM_read64(const void* ptr) { … }
MEM_STATIC size_t MEM_readST(const void* ptr) { … }
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { … }
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { … }
MEM_STATIC void MEM_write64(void* memPtr, U64 value) { … }
#else
MEM_STATIC U16 MEM_read16(const void* memPtr)
{
U16 val; ZSTD_memcpy(&val, memPtr, sizeof(val)); return val;
}
MEM_STATIC U32 MEM_read32(const void* memPtr)
{
U32 val; ZSTD_memcpy(&val, memPtr, sizeof(val)); return val;
}
MEM_STATIC U64 MEM_read64(const void* memPtr)
{
U64 val; ZSTD_memcpy(&val, memPtr, sizeof(val)); return val;
}
MEM_STATIC size_t MEM_readST(const void* memPtr)
{
size_t val; ZSTD_memcpy(&val, memPtr, sizeof(val)); return val;
}
MEM_STATIC void MEM_write16(void* memPtr, U16 value)
{
ZSTD_memcpy(memPtr, &value, sizeof(value));
}
MEM_STATIC void MEM_write32(void* memPtr, U32 value)
{
ZSTD_memcpy(memPtr, &value, sizeof(value));
}
MEM_STATIC void MEM_write64(void* memPtr, U64 value)
{
ZSTD_memcpy(memPtr, &value, sizeof(value));
}
#endif
MEM_STATIC U32 MEM_swap32_fallback(U32 in)
{ … }
MEM_STATIC U32 MEM_swap32(U32 in)
{ … }
MEM_STATIC U64 MEM_swap64_fallback(U64 in)
{ … }
MEM_STATIC U64 MEM_swap64(U64 in)
{ … }
MEM_STATIC size_t MEM_swapST(size_t in)
{ … }
MEM_STATIC U16 MEM_readLE16(const void* memPtr)
{ … }
MEM_STATIC void MEM_writeLE16(void* memPtr, U16 val)
{ … }
MEM_STATIC U32 MEM_readLE24(const void* memPtr)
{ … }
MEM_STATIC void MEM_writeLE24(void* memPtr, U32 val)
{ … }
MEM_STATIC U32 MEM_readLE32(const void* memPtr)
{ … }
MEM_STATIC void MEM_writeLE32(void* memPtr, U32 val32)
{ … }
MEM_STATIC U64 MEM_readLE64(const void* memPtr)
{ … }
MEM_STATIC void MEM_writeLE64(void* memPtr, U64 val64)
{ … }
MEM_STATIC size_t MEM_readLEST(const void* memPtr)
{ … }
MEM_STATIC void MEM_writeLEST(void* memPtr, size_t val)
{ … }
MEM_STATIC U32 MEM_readBE32(const void* memPtr)
{ … }
MEM_STATIC void MEM_writeBE32(void* memPtr, U32 val32)
{ … }
MEM_STATIC U64 MEM_readBE64(const void* memPtr)
{ … }
MEM_STATIC void MEM_writeBE64(void* memPtr, U64 val64)
{ … }
MEM_STATIC size_t MEM_readBEST(const void* memPtr)
{ … }
MEM_STATIC void MEM_writeBEST(void* memPtr, size_t val)
{ … }
MEM_STATIC void MEM_check(void) { … }
#if defined (__cplusplus)
}
#endif
#endif