Fix compile of t/btrace2fio on RHEL5/CentOS5
authorJens Axboe <axboe@fb.com>
Mon, 29 Sep 2014 22:07:54 +0000 (16:07 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 29 Sep 2014 22:07:54 +0000 (16:07 -0600)
Get these errors:

t/btrace2fio.c:395: undefined reference to `__bswap_32'
t/btrace2fio.c:396: undefined reference to `__bswap_32'
t/btrace2fio.c:397: undefined reference to `__bswap_64'
t/btrace2fio.c:398: undefined reference to `__bswap_64'
t/btrace2fio.c:399: undefined reference to `__bswap_32'
t/btrace2fio.c:400: undefined reference to `__bswap_32'
t/btrace2fio.c:401: undefined reference to `__bswap_32'
t/btrace2fio.c:402: undefined reference to `__bswap_32'
t/btrace2fio.c:403: undefined reference to `__bswap_32'
t/btrace2fio.c:404: undefined reference to `__bswap_16'
t/btrace2fio.c:405: undefined reference to `__bswap_16'

Issue is that os/os-linux.h needs to include byteswap.h.

Signed-off-by: Jens Axboe <axboe@fb.com>
os/os-linux.h

index 81d04027efb9491fde44c783922dc368734d5042..e1936342bd54fceac5b61d765a86adfacfdcf970 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/unistd.h>
 #include <linux/raw.h>
 #include <linux/major.h>
+#include <byteswap.h>
 
 #include "binject.h"
 #include "../file.h"
@@ -208,9 +209,21 @@ static inline int fio_lookup_raw(dev_t dev, int *majdev, int *mindev)
 #define FIO_MADV_FREE  MADV_REMOVE
 #endif
 
+#if defined(__builtin_bswap16)
+#define fio_swap16(x)  __builtin_bswap16(x)
+#else
 #define fio_swap16(x)  __bswap_16(x)
+#endif
+#if defined(__builtin_bswap32)
+#define fio_swap32(x)  __builtin_bswap32(x)
+#else
 #define fio_swap32(x)  __bswap_32(x)
+#endif
+#if defined(__builtin_bswap64)
+#define fio_swap64(x)  __builtin_bswap64(x)
+#else
 #define fio_swap64(x)  __bswap_64(x)
+#endif
 
 #define CACHE_LINE_FILE        \
        "/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size"