Finalize (?) byte swap/endian stuff
authorJens Axboe <axboe@kernel.dk>
Tue, 4 Oct 2011 21:31:00 +0000 (23:31 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 4 Oct 2011 21:32:29 +0000 (23:32 +0200)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
os/os-hpux.h
os/os-netbsd.h
os/os.h

index ae3d6f2864c770879447abc71f33e5e72450dd00..43098ad72d86fcc40d6d8c2860d7fa62722d3b6d 100644 (file)
@@ -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;
 
index e03866dfc86c131ea6fa9cf32f4786b45042baf8..5d8258bd9460e2e6edaf14f441b291b1acb91fbb 100644 (file)
@@ -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>
 #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 c6c91a045d9a7e14ea902ce275ec064646c20e14..a24004b584e749ea2d830481e3ea3e8a5584e1f7 100644 (file)
--- a/os/os.h
+++ b/os/os.h
@@ -115,20 +115,20 @@ typedef unsigned long os_cpu_mask_t;
 #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);