port: fix compat/endian.h on FreeBSD
authorMichael Jeanson <mjeanson@efficios.com>
Tue, 13 Oct 2020 21:32:00 +0000 (17:32 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 28 Oct 2020 20:31:10 +0000 (16:31 -0400)
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If591ed8d1cf50c1914a613976e9e285c3647906c

src/bin/lttng-crash/lttng-crash.c
src/common/compat/endian.h

index 8f94544ba54794f1dbbed0fecca70cc5e44b2028..7f1f52803f9f5c5102ebcdbc5b8f5cd1281fa3d0 100644 (file)
@@ -20,7 +20,7 @@
 #include <unistd.h>
 #include <ctype.h>
 #include <dirent.h>
-#include <byteswap.h>
+#include <common/compat/endian.h>
 #include <inttypes.h>
 #include <stdbool.h>
 
@@ -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,
index 42c7fab31af9e53d67ac9eacf82bcc897f79e0b5..d808b40e4e42e829b8383c8f120b0cefbe2b06e8 100644 (file)
@@ -10,6 +10,7 @@
 
 #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>
This page took 0.029011 seconds and 5 git commands to generate.