#include <unistd.h>
#include <ctype.h>
#include <dirent.h>
-#include <byteswap.h>
+#include <common/compat/endian.h>
#include <inttypes.h>
#include <stdbool.h>
switch (size) {
case 1: return *(uint8_t *) ptr;
case 2: if (layout->reverse_byte_order) {
- return __bswap_16(*(uint16_t *) ptr);
+ return bswap_16(*(uint16_t *) ptr);
} else {
return *(uint16_t *) ptr;
}
case 4: if (layout->reverse_byte_order) {
- return __bswap_32(*(uint32_t *) ptr);
+ return bswap_32(*(uint32_t *) ptr);
} else {
return *(uint32_t *) ptr;
}
case 8: if (layout->reverse_byte_order) {
- return __bswap_64(*(uint64_t *) ptr);
+ return bswap_64(*(uint64_t *) ptr);
} else {
return *(uint64_t *) ptr;
}
subbuf_ptr + layout->offset.packet_size,
layout->length.packet_size);
if (layout->reverse_byte_order) {
- packet_size = __bswap_64(packet_size);
+ packet_size = bswap_64(packet_size);
}
packet_size /= CHAR_BIT;
} else {
*/
patch_size = committed * CHAR_BIT;
if (layout->reverse_byte_order) {
- patch_size = __bswap_64(patch_size);
+ patch_size = bswap_64(patch_size);
}
if (layout->length.content_size) {
memcpy(subbuf_ptr + layout->offset.content_size,
#if defined(__linux__) || defined(__CYGWIN__)
#include <endian.h>
+#include <byteswap.h>
/*
* htobe/betoh are not defined for glibc <2.9, so add them
#endif /* __USE_BSD */
#elif defined(__FreeBSD__)
-#include <machine/endian.h>
+#include <sys/endian.h>
+
+#define bswap_16(x) bswap16(x)
+#define bswap_32(x) bswap32(x)
+#define bswap_64(x) bswap64(x)
#elif defined(__sun__)
#include <sys/byteorder.h>