Will remove guesswork and manual hacking in the OS headers.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
ifdef CONFIG_32BIT
CFLAGS += -DBITS_PER_LONG=32
endif
+ifdef CONFIG_BIG_ENDIAN
+ CFLAGS += -DCONFIG_BIG_ENDIAN
+endif
+ifdef CONFIG_LITTLE_ENDIAN
+ CFLAGS += -DCONFIG_LITTLE_ENDIAN
+endif
ifdef CONFIG_LIBAIO
CFLAGS += -DCONFIG_LIBAIO
SOURCE += engines/libaio.c
cc="${CC-${cross_prefix}gcc}"
+##########################################
+# check endianness
+bigendian="no"
+cat > $TMPC <<EOF
+#include <inttypes.h>
+int main(void)
+{
+ volatile uint32_t i=0x01234567;
+ return (*((uint8_t*)(&i))) == 0x67;
+}
+EOF
+if compile_prog "" "" "endian"; then
+ $TMPE && bigendian="yes"
+fi
+
+
echo "Operating system $targetos"
echo "CPU $cpu"
+echo "Big endian $bigendian"
echo "Compiler $cc"
echo
echo "Unknown wordsize!"
exit 1
fi
+if test "$bigendian" = "yes" ; then
+ echo "CONFIG_BIG_ENDIAN=y" >> $config_host_mak
+else
+ echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
+fi
if test "$libaio" = "yes" ; then
echo "CONFIG_LIBAIO=y" >> $config_host_mak
fi
else if (u.c[0] == 0x12)
le = 1;
-#if defined(FIO_LITTLE_ENDIAN)
+#if defined(CONFIG_LITTLE_ENDIAN)
if (be)
return 1;
-#elif defined(FIO_BIG_ENDIAN)
+#elif defined(CONFIG_BIG_ENDIAN)
if (le)
return 1;
#else
#include <inttypes.h>
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#ifdef CONFIG_LITTLE_ENDIAN
static inline uint32_t __be32_to_cpu(uint32_t val)
{
uint32_t c1, c2, c3, c4;
#define OS_MAP_ANON MAP_ANON
#define OS_MSG_DONTWAIT 0
-#if BYTE_ORDER == BIG_ENDIAN
-#define FIO_BIG_ENDIAN
-#else
-#define FIO_LITTLE_ENDIAN
-#endif
-
#define FIO_USE_GENERIC_SWAP
static inline int blockdev_invalidate_cache(struct fio_file *f)
#include <sched.h>
#include <linux/unistd.h>
#include <linux/major.h>
-#include <endian.h>
#include "binject.h"
#include "../file.h"
#define FIO_O_NOATIME 0
#endif
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define FIO_LITTLE_ENDIAN
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#define FIO_BIG_ENDIAN
-#else
-#error "Unknown endianness"
-#endif
-
#define fio_swap16(x) __bswap_16(x)
#define fio_swap32(x) __bswap_32(x)
#define fio_swap64(x) __bswap_64(x)
#include <sys/sysctl.h>
#include <sys/disk.h>
#include <sys/thr.h>
-#include <sys/endian.h>
#include <sys/socket.h>
#include "../file.h"
#define OS_MAP_ANON MAP_ANON
-#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)
#define MSG_WAITALL 0x40
#endif
-#ifdef LITTLE_ENDIAN
-#define FIO_LITTLE_ENDIAN
-#else
-#define FIO_BIG_ENDIAN
-#endif
-
#define FIO_USE_GENERIC_SWAP
#define FIO_OS_HAVE_AIOCB_TYPEDEF
#include <linux/unistd.h>
#include <linux/raw.h>
#include <linux/major.h>
-#include <endian.h>
#include "binject.h"
#include "../file.h"
#define FIO_MADV_FREE MADV_REMOVE
#endif
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define FIO_LITTLE_ENDIAN
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#define FIO_BIG_ENDIAN
-#else
-#error "Unknown endianness"
-#endif
-
#define fio_swap16(x) __bswap_16(x)
#define fio_swap32(x) __bswap_32(x)
#define fio_swap64(x) __bswap_64(x)
#define OS_MAP_ANON MAP_ANON
-#if defined(__LITTLE_ENDIAN__)
-#define FIO_LITTLE_ENDIAN
-#elif defined(__BIG_ENDIAN__)
-#define FIO_BIG_ENDIAN
-#else
-#error "Undefined byte order"
-#endif
-
#define fio_swap16(x) OSSwapInt16(x)
#define fio_swap32(x) OSSwapInt32(x)
#define fio_swap64(x) OSSwapInt64(x)
#include <errno.h>
#include <lwp.h>
#include <sys/param.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)
#define OS_MAP_ANON MAP_ANON
#define OS_RAND_MAX 2147483648UL
-#if defined(_BIG_ENDIAN)
-#define FIO_BIG_ENDIAN
-#else
-#define FIO_LITTLE_ENDIAN
-#endif
-
#define fio_swap16(x) BSWAP_16(x)
#define fio_swap32(x) BSWAP_32(x)
#define fio_swap64(x) BSWAP_64(x)
#define OS_MAP_ANON MAP_ANON
-#define FIO_LITTLE_ENDIAN
#define fio_swap16(x) _byteswap_ushort(x)
#define fio_swap32(x) _byteswap_ulong(x)
#define fio_swap64(x) _byteswap_uint64(x)
#endif
#ifndef FIO_HAVE_BYTEORDER_FUNCS
-#ifdef FIO_LITTLE_ENDIAN
+#ifdef CONFIG_LITTLE_ENDIAN
#define __le16_to_cpu(x) (x)
#define __le32_to_cpu(x) (x)
#define __le64_to_cpu(x) (x)
memset(&probe, 0, sizeof(probe));
gethostname((char *) probe.hostname, sizeof(probe.hostname));
-#ifdef FIO_BIG_ENDIAN
+#ifdef CONFIG_BIG_ENDIAN
probe.bigendian = 1;
#endif
strncpy((char *) probe.fio_version, fio_version_string, sizeof(probe.fio_version));