| 9120e874 Andy McCall |
1 |
#pragma once |
| 2 |
|
| 3 |
|
| 4 |
#if defined(_MSC_VER) && !defined(__BYTE_ORDER__) |
| 5 |
#define __BYTE_ORDER__ 1234 |
| 6 |
#define __ORDER_LITTLE_ENDIAN__ 1234 |
| 7 |
#define __ORDER_BIG_ENDIAN__ 4321 |
| 8 |
#endif |
| 9 |
|
| 10 |
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
| 11 |
#define LOW_HIGH_UNION(name, low, high) \ |
| 12 |
union { \ |
| 13 |
struct { \ |
| 14 |
uint8_t low; \ |
| 15 |
uint8_t high; \ |
| 16 |
}; \ |
| 17 |
uint16_t name; \ |
| 18 |
} |
| 19 |
#define ENDIAN_STRUCT_MEMBERS(low, high) \ |
| 20 |
low; \ |
| 21 |
high |
| 22 |
#else |
| 23 |
#define LOW_HIGH_UNION(name, low, high) \ |
| 24 |
union { \ |
| 25 |
struct { \ |
| 26 |
uint8_t high; \ |
| 27 |
uint8_t low; \ |
| 28 |
}; \ |
| 29 |
uint16_t name; \ |
| 30 |
} |
| 31 |
#define ENDIAN_STRUCT_MEMBERS(low, high) \ |
| 32 |
high; \ |
| 33 |
low |
| 34 |
#endif |