From: Michael Jeanson Date: Tue, 13 Oct 2020 21:32:00 +0000 (-0400) Subject: port: fix compat/endian.h on FreeBSD X-Git-Tag: v2.13.0-rc1~454 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=4ff128af76f44cc4e0aff55f00be3e57abf6ac00;p=lttng-tools.git port: fix compat/endian.h on FreeBSD Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau Change-Id: If591ed8d1cf50c1914a613976e9e285c3647906c --- diff --git a/src/bin/lttng-crash/lttng-crash.c b/src/bin/lttng-crash/lttng-crash.c index 8f94544ba..7f1f52803 100644 --- a/src/bin/lttng-crash/lttng-crash.c +++ b/src/bin/lttng-crash/lttng-crash.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include @@ -373,19 +373,19 @@ uint64_t _crash_get_field(const struct lttng_crash_layout *layout, 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; } @@ -720,7 +720,7 @@ int copy_crash_subbuf(const struct lttng_crash_layout *layout, 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 { @@ -736,7 +736,7 @@ int copy_crash_subbuf(const struct lttng_crash_layout *layout, */ 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, diff --git a/src/common/compat/endian.h b/src/common/compat/endian.h index 42c7fab31..d808b40e4 100644 --- a/src/common/compat/endian.h +++ b/src/common/compat/endian.h @@ -10,6 +10,7 @@ #if defined(__linux__) || defined(__CYGWIN__) #include +#include /* * htobe/betoh are not defined for glibc <2.9, so add them @@ -103,7 +104,11 @@ #endif /* __USE_BSD */ #elif defined(__FreeBSD__) -#include +#include + +#define bswap_16(x) bswap16(x) +#define bswap_32(x) bswap32(x) +#define bswap_64(x) bswap64(x) #elif defined(__sun__) #include