From: Jens Axboe Date: Tue, 4 Oct 2011 21:31:00 +0000 (+0200) Subject: Finalize (?) byte swap/endian stuff X-Git-Tag: fio-1.99~15 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=901ebe18bdca90032e2fe107a1410385da80d18b Finalize (?) byte swap/endian stuff Signed-off-by: Jens Axboe --- diff --git a/os/os-hpux.h b/os/os-hpux.h index ae3d6f28..43098ad7 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 e03866df..5d8258bd 100644 --- a/os/os-netbsd.h +++ b/os/os-netbsd.h @@ -4,6 +4,7 @@ #include #include #include +#include /* XXX hack to avoid confilcts between rbtree.h and */ #define rb_node _rb_node #include @@ -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 c6c91a04..a24004b5 100644 --- 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);