Finalize (?) byte swap/endian stuff
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/os/os-hpux.h b/os/os-hpux.h
index ae3d6f2..43098ad 100644
--- a/os/os-hpux.h
+++ b/os/os-hpux.h
@@ -50,6 +50,8 @@
#define FIO_BIG_ENDIAN
#endif
+#define FIO_USE_GENERIC_SWAP
+
#define FIO_OS_HAVE_AIOCB_TYPEDEF
typedef struct aiocb64 os_aiocb_t;
diff --git a/os/os-netbsd.h b/os/os-netbsd.h
index e03866d..5d8258b 100644
--- a/os/os-netbsd.h
+++ b/os/os-netbsd.h
@@ -4,6 +4,7 @@
#include <errno.h>
#include <sys/param.h>
#include <sys/thr.h>
+#include <sys/endian.h>
/* XXX hack to avoid confilcts between rbtree.h and <sys/rb.h> */
#define rb_node _rb_node
#include <sys/sysctl.h>
@@ -30,6 +31,16 @@
#define PTHREAD_STACK_MIN 4096
#endif
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define FIO_LITTLE_ENDIAN
+#else
+#define FIO_BIG_ENDIAN
+#endif
+
+#define fio_swap16(x) bswap16(x)
+#define fio_swap32(x) bswap32(x)
+#define fio_swap64(x) bswap64(x)
+
typedef off_t off64_t;
static inline int blockdev_invalidate_cache(struct fio_file *f)
diff --git a/os/os.h b/os/os.h
index c6c91a0..a24004b 100644
--- a/os/os.h
+++ b/os/os.h
@@ -115,20 +115,20 @@
#define FIO_MAX_JOBS 2048
#endif
-#if 0
+#ifdef FIO_USE_GENERIC_SWAP
static inline uint16_t fio_swap16(uint16_t val)
{
return (val << 8) | (val >> 8);
}
-static inline uint32_t bswap_32(uint32_t val)
+static inline uint32_t fio_swap32(uint32_t val)
{
val = ((val & 0xff00ff00UL) >> 8) | ((val & 0x00ff00ffUL) << 8);
return (val >> 16) | (val << 16);
}
-static inline uint64_t bswap_64(uint64_t val)
+static inline uint64_t fio_swap64(uint64_t val)
{
val = ((val & 0xff00ff00ff00ff00ULL) >> 8) |
((val & 0x00ff00ff00ff00ffULL) << 8);