bits inverter and endianness utils.

This commit is contained in:
Jean-François DEL NERO
2026-05-23 09:55:51 +02:00
parent 6730fa68c2
commit 4a359adeaf
2 changed files with 73 additions and 0 deletions
+29
View File
@@ -28,3 +28,32 @@ void get_filename(char * path,char * filename);
void printbuf(unsigned char * buf,int size);
int is_printable_char(unsigned char c);
#ifdef BIGENDIAN_HOST
// big endian
#define BIGENDIAN_WORD(wValue) (wValue)
#define BIGENDIAN_DWORD(dwValue) (dwValue)
// little endian
#define LITTLEENDIAN_WORD(wValue) ( (((wValue&0xFF)<<8)) | (((wValue)>>8)&0xFF) )
#define LITTLEENDIAN_DWORD(dwValue) ( (((dwValue&0xFF)<<24)) | (((dwValue&0xFF00)<<8)) | (((dwValue)>>8)&0xFF00) | (((dwValue)>>24)&0xFF) )
#else
//LITTLE ENDIAN HOST
// big endian
#define BIGENDIAN_WORD(wValue) ( (((wValue)<<8)&0xFF00) | (((wValue)>>8)&0xFF) )
#define BIGENDIAN_DWORD(dwValue) ( (((dwValue&0xFF)<<24)) | (((dwValue&0xFF00)<<8)) | (((dwValue)>>8)&0xFF00) | (((dwValue)>>24)&0xFF) )
// little endian
#define LITTLEENDIAN_WORD(wValue) (wValue)
#define LITTLEENDIAN_DWORD(dwValue) (dwValue)
#endif
extern const unsigned char LUT_ByteBitsInverter[];
extern const unsigned char LUT_QuartetBitsInverter[];