From 4ff128af76f44cc4e0aff55f00be3e57abf6ac00 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Tue, 13 Oct 2020 17:32:00 -0400 Subject: [PATCH 1/1] port: fix compat/endian.h on FreeBSD MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau Change-Id: If591ed8d1cf50c1914a613976e9e285c3647906c --- src/bin/lttng-crash/lttng-crash.c | 12 ++++++------ src/common/compat/endian.h | 7 ++++++- 2 files changed, 12 insertions(+), 7 deletions(-) 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 -- 2.34.1