| 1 |
/* |
| 2 |
* Common Reader/Writer Helpers |
| 3 |
* |
| 4 |
* XXX |
| 5 |
*/ |
| 6 |
|
| 7 |
#include <assert.h> |
| 8 |
#include <byteswap.h> |
| 9 |
#include <c-stdaux.h> |
| 10 |
#include <endian.h> |
| 11 |
#include <errno.h> |
| 12 |
#include <inttypes.h> |
| 13 |
#include <stdarg.h> |
| 14 |
#include <stdbool.h> |
| 15 |
#include <stdlib.h> |
| 16 |
#include "c-dvar.h" |
| 17 |
#include "c-dvar-private.h" |
| 18 |
|
| 19 |
uint16_t c_dvar_bswap16(CDVar *var, uint16_t v) { |
| 20 |
return _c_likely_(!!var->big_endian == !!(__BYTE_ORDER == __BIG_ENDIAN)) ? v : bswap_16(v); |
| 21 |
} |
| 22 |
|
| 23 |
uint32_t c_dvar_bswap32(CDVar *var, uint32_t v) { |
| 24 |
return _c_likely_(!!var->big_endian == !!(__BYTE_ORDER == __BIG_ENDIAN)) ? v : bswap_32(v); |
| 25 |
} |
| 26 |
|
| 27 |
uint64_t c_dvar_bswap64(CDVar *var, uint64_t v) { |
| 28 |
return _c_likely_(!!var->big_endian == !!(__BYTE_ORDER == __BIG_ENDIAN)) ? v : bswap_64(v); |
| 29 |
} |