diff options
Diffstat (limited to 'src/common/endianness.h')
-rwxr-xr-x | src/common/endianness.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/common/endianness.h b/src/common/endianness.h index 2af6493..5ceb2ee 100755 --- a/src/common/endianness.h +++ b/src/common/endianness.h @@ -43,6 +43,33 @@ typedef enum _SourceEndian } SourceEndian; +/* --------------------------- CONVERSION ENTRE BOUTISMES --------------------------- */ + + +/* Adapte un nombre sur 16 bits à un boutisme donné. */ +uint16_t swap_u16(const uint16_t *, SourceEndian); + +/* Adapte un nombre sur 16 bits à un boutisme donné. */ +uint32_t swap_u32(const uint32_t *, SourceEndian); + +/* Adapte un nombre sur 16 bits à un boutisme donné. */ +uint64_t swap_u64(const uint64_t *, SourceEndian); + + +#define from_u16(v, e) swap_u16(v, e) +#define from_u32(v, e) swap_u32(v, e) +#define from_u64(v, e) swap_u64(v, e) + + +#define to_u16(v, e) swap_u16(v, e) +#define to_u32(v, e) swap_u32(v, e) +#define to_u64(v, e) swap_u64(v, e) + + + +/* ------------------------- BOUTISME DES ENTREES / SORTIES ------------------------- */ + + /* Lit un nombre non signé sur 4 bits. */ bool read_u4(uint8_t *, const bin_t *, phys_t *, phys_t, bool *); |