#define STORE_LE16(bUFF,nUM) ( ((bUFF)[1] = (UINT8) ((nUM)>>8)), \
((bUFF)[0] = (UINT8) (nUM)) ) #define STORE_LE32(bUFF,nUM) ( ((bUFF)[3] = (UINT8) ((nUM)>>24)), \ ((bUFF)[2] = (UINT8) ((nUM)>>16)), \ ((bUFF)[1] = (UINT8) ((nUM)>>8)), \ ((bUFF)[0] = (UINT8) (nUM)) ) /* Store value into a bUFFer in Big Endian format */ #define STORE_BE16(bUFF,nUM) ( ((bUFF)[0] = (UINT8) ((nUM)>>8)), \ ((bUFF)[1] = (UINT8) (nUM)) ) #define STORE_BE32(bUFF,nUM) ( ((bUFF)[0] = (UINT8) ((nUM)>>24)), \ ((bUFF)[1] = (UINT8) ((nUM)>>16)), \ ((bUFF)[2] = (UINT8) ((nUM)>>8)), \ ((bUFF)[3] = (UINT8) (nUM)) ) /* Little Endian to Host integer format conversion macros */ #define LEtoHost16(ptr) (U16)( ((U16) *((U8*)(ptr)+1) << 8) | \ ((U16) *((U8*)(ptr))) ) #define LEtoHost32(ptr) (U32)( ((U32) *((U8*)(ptr)+3) << 24) | \ ((U32) *((U8*)(ptr)+2) << 16) | \ ((U32) *((U8*)(ptr)+1) << 8) | \ ((U32) *((U8*)(ptr))) ) /* Big Endian to Host integer format conversion macros */ #define BEtoHost16(ptr) (U16)( ((U16) *((U8*)(ptr)) << 8) | \ ((U16) *((U8*)(ptr)+1)) ) #define BEtoHost32(ptr) (U32)( ((U32) *((U8*)(ptr)) << 24) | \ ((U32) *((U8*)(ptr)+1) << 16) | \ ((U32) *((U8*)(ptr)+2) << 8) | \ ((U32) *((U8*)(ptr)+3)) )
'Language > C&C++' 카테고리의 다른 글
[C/C++] Case study! Bad example about ignoring data-align.. (0) | 2007.07.09 |
---|---|
[C/C++] Case study! Bad example about endianness. (0) | 2007.06.29 |
[C/C++] Avoiding symbol conflict when release library... (0) | 2007.05.19 |
[C/C++] Using 'virtual' and 'inline' keywords simultaneously. (0) | 2007.04.04 |
[C/C++] virtual inheritance (0) | 2007.03.24 |