libclamav/7z/CpuArch.h
569bdeeb
 /* CpuArch.h -- CPU specific code
 2010-10-26: Igor Pavlov : Public domain */
700cc7f7
 
569bdeeb
 #ifndef __CPU_ARCH_H
 #define __CPU_ARCH_H
700cc7f7
 
569bdeeb
 #include "Types.h"
 #include "others.h"
700cc7f7
 
569bdeeb
 EXTERN_C_BEGIN
700cc7f7
 
569bdeeb
 /*
 MY_CPU_LE means that CPU is LITTLE ENDIAN.
 If MY_CPU_LE is not defined, we don't know about that property of platform (it can be LITTLE ENDIAN).
700cc7f7
 
569bdeeb
 MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses.
 If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of platform.
 */
700cc7f7
 
569bdeeb
 #define GetUi16(p) (cli_readint16(p))
 #define GetUi32(p) (cli_readint32(p))
700cc7f7
 
 #define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32))
 
569bdeeb
 #define SetUi16(p, d) { UInt32 _x_ = (d); \
700cc7f7
     ((Byte *)(p))[0] = (Byte)_x_; \
569bdeeb
     ((Byte *)(p))[1] = (Byte)(_x_ >> 8); }
700cc7f7
 
569bdeeb
 #define SetUi32(p, d) (cli_writeint32(p, d))
700cc7f7
 
569bdeeb
 #define SetUi64(p, d) { UInt64 _x64_ = (d); \
     SetUi32(p, (UInt32)_x64_); \
     SetUi32(((Byte *)(p)) + 4, (UInt32)(_x64_ >> 32)); }
700cc7f7
 
569bdeeb
 EXTERN_C_END
700cc7f7
 
 #endif