Fix compile of t/btrace2fio on RHEL5/CentOS5
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>
diff --git a/os/os-linux.h b/os/os-linux.h
index 81d0402..e193634 100644
--- a/os/os-linux.h
+++ b/os/os-linux.h
@@ -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 @@
#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"