From: Jens Axboe Date: Mon, 2 Apr 2007 19:36:44 +0000 (+0200) Subject: Move os/arch/compiler headers into directories X-Git-Tag: fio-1.15.2~11 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=317b95d07d4921d2594a1be6e014c9c2d062fe75 Move os/arch/compiler headers into directories Signed-off-by: Jens Axboe --- diff --git a/arch-alpha.h b/arch-alpha.h deleted file mode 100644 index 09293bd3..00000000 --- a/arch-alpha.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ARCH_ALPHA_H -#define ARCH_ALPHA_H - -#define ARCH (arch_alpha) - -#ifndef __NR_ioprio_set -#define __NR_ioprio_set 442 -#define __NR_ioprio_get 443 -#endif - -#ifndef __NR_fadvise64 -#define __NR_fadvise64 413 -#endif - -#define nop do { } while (0) -#define ffz(v) generic_ffz((v)) - -#endif diff --git a/arch-ia64.h b/arch-ia64.h deleted file mode 100644 index b3ee0c38..00000000 --- a/arch-ia64.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef ARCH_IA64_H -#define ARCH_IA64_H - -#define ARCH (arch_ia64) - -#ifndef __NR_ioprio_set -#define __NR_ioprio_set 1274 -#define __NR_ioprio_get 1275 -#endif - -#ifndef __NR_fadvise64 -#define __NR_fadvise64 1234 -#endif - -#ifndef __NR_sys_splice -#define __NR_sys_splice 1297 -#define __NR_sys_tee 1301 -#define __NR_sys_vmsplice 1302 -#endif - -#define nop asm volatile ("hint @pause" ::: "memory"); - -#define ia64_popcnt(x) \ -({ \ - unsigned long ia64_intri_res; \ - asm ("popcnt %0=%1" : "=r" (ia64_intri_res) : "r" (x)); \ - ia64_intri_res; \ -}) - -static inline unsigned long ffz(unsigned long bitmask) -{ - return ia64_popcnt(bitmask & (~bitmask - 1)); -} - -#endif diff --git a/arch-ppc.h b/arch-ppc.h deleted file mode 100644 index 8bfed597..00000000 --- a/arch-ppc.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef ARCH_PPC_H -#define ARCH_PPH_H - -#define ARCH (arch_ppc) - -#ifndef __NR_ioprio_set -#define __NR_ioprio_set 273 -#define __NR_ioprio_get 274 -#endif - -#ifndef __NR_fadvise64 -#define __NR_fadvise64 233 -#endif - -#ifndef __NR_sys_splice -#define __NR_sys_splice 283 -#define __NR_sys_tee 284 -#define __NR_sys_vmsplice 285 -#endif - -#define nop do { } while (0) - -static inline int __ilog2(unsigned long bitmask) -{ - int lz; - - asm ("cntlzw %0,%1" : "=r" (lz) : "r" (bitmask)); - return 31 - lz; -} - -static inline int ffz(unsigned long bitmask) -{ - if ((bitmask = ~bitmask) == 0) - return 32; - return __ilog2(bitmask & -bitmask); -} - -#endif diff --git a/arch-s390.h b/arch-s390.h deleted file mode 100644 index b7048ad6..00000000 --- a/arch-s390.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ARCH_S390_H -#define ARCH_S390_H - -#define ARCH (arch_s390) - -#ifndef __NR_ioprio_set -#define __NR_ioprio_set 282 -#define __NR_ioprio_get 283 -#endif - -#ifndef __NR_fadvise64 -#define __NR_fadvise64 253 -#endif - -#define nop asm volatile ("diag 0,0,68" : : : "memory") -#define ffz(v) generic_ffz((v)) - -#endif diff --git a/arch-x86.h b/arch-x86.h deleted file mode 100644 index aa106920..00000000 --- a/arch-x86.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef ARCH_X86_H -#define ARCH_X86_H - -#define ARCH (arch_i386) - -#ifndef __NR_ioprio_set -#define __NR_ioprio_set 289 -#define __NR_ioprio_get 290 -#endif - -#ifndef __NR_fadvise64 -#define __NR_fadvise64 250 -#endif - -#ifndef __NR_sys_splice -#define __NR_sys_splice 313 -#define __NR_sys_tee 315 -#define __NR_sys_vmsplice 316 -#endif - -#ifndef __NR_async_exec -#define __NR_async_exec 320 -#define __NR_async_wait 321 -#define __NR_umem_add 322 -#define __NR_async_thread 323 -#endif - -#define FIO_HUGE_PAGE 4194304 - -#define FIO_HAVE_SYSLET - -#define nop __asm__ __volatile__("rep;nop": : :"memory") - -static inline unsigned long ffz(unsigned long bitmask) -{ - __asm__("bsfl %1,%0" :"=r" (bitmask) :"r" (~bitmask)); - return bitmask; -} - -#endif diff --git a/arch-x86_64.h b/arch-x86_64.h deleted file mode 100644 index 4e0ad5f6..00000000 --- a/arch-x86_64.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef ARCH_X86_64_h -#define ARCH_X86_64_h - -#define ARCH (arch_x86_64) - -#ifndef __NR_ioprio_set -#define __NR_ioprio_set 251 -#define __NR_ioprio_get 252 -#endif - -#ifndef __NR_fadvise64 -#define __NR_fadvise64 221 -#endif - -#ifndef __NR_sys_splice -#define __NR_sys_splice 275 -#define __NR_sys_tee 276 -#define __NR_sys_vmsplice 278 -#endif - -#ifndef __NR_async_exec -#define __NR_async_exec 280 -#define __NR_async_wait 281 -#define __NR_umem_add 282 -#define __NR_async_thread 283 -#endif - -#define FIO_HUGE_PAGE 2097152 - -#define FIO_HAVE_SYSLET - -#define nop __asm__ __volatile__("rep;nop": : :"memory") - -static inline unsigned long ffz(unsigned long bitmask) -{ - __asm__("bsfq %1,%0" :"=r" (bitmask) :"r" (~bitmask)); - return bitmask; -} - - -#endif diff --git a/arch.h b/arch.h deleted file mode 100644 index 745bf3a4..00000000 --- a/arch.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef ARCH_H -#define ARCH_H - -enum { - arch_x86_64, - arch_i386, - arch_ppc, - arch_ia64, - arch_s390, - arch_alpha, -}; - -static inline unsigned long generic_ffz(unsigned long word) -{ - unsigned int i; - - for (i = 0; i < sizeof(word) * 8; i++) - if ((word & (1UL << i)) == 0) - return i; - - return -1; -} - -#if defined(__i386__) -#include "arch-x86.h" -#elif defined(__x86_64__) -#include "arch-x86_64.h" -#elif defined(__powerpc__) || defined(__powerpc64__) -#include "arch-ppc.h" -#elif defined(__ia64__) -#include "arch-ia64.h" -#elif defined(__alpha__) -#include "arch-alpha.h" -#elif defined(__s390x__) || defined(__s390__) -#include "arch-s390.h" -#else -#error "Unsupported arch" -#endif - -#define BITS_PER_LONG (__WORDSIZE) - -#endif diff --git a/arch/arch-alpha.h b/arch/arch-alpha.h new file mode 100644 index 00000000..09293bd3 --- /dev/null +++ b/arch/arch-alpha.h @@ -0,0 +1,18 @@ +#ifndef ARCH_ALPHA_H +#define ARCH_ALPHA_H + +#define ARCH (arch_alpha) + +#ifndef __NR_ioprio_set +#define __NR_ioprio_set 442 +#define __NR_ioprio_get 443 +#endif + +#ifndef __NR_fadvise64 +#define __NR_fadvise64 413 +#endif + +#define nop do { } while (0) +#define ffz(v) generic_ffz((v)) + +#endif diff --git a/arch/arch-ia64.h b/arch/arch-ia64.h new file mode 100644 index 00000000..b3ee0c38 --- /dev/null +++ b/arch/arch-ia64.h @@ -0,0 +1,35 @@ +#ifndef ARCH_IA64_H +#define ARCH_IA64_H + +#define ARCH (arch_ia64) + +#ifndef __NR_ioprio_set +#define __NR_ioprio_set 1274 +#define __NR_ioprio_get 1275 +#endif + +#ifndef __NR_fadvise64 +#define __NR_fadvise64 1234 +#endif + +#ifndef __NR_sys_splice +#define __NR_sys_splice 1297 +#define __NR_sys_tee 1301 +#define __NR_sys_vmsplice 1302 +#endif + +#define nop asm volatile ("hint @pause" ::: "memory"); + +#define ia64_popcnt(x) \ +({ \ + unsigned long ia64_intri_res; \ + asm ("popcnt %0=%1" : "=r" (ia64_intri_res) : "r" (x)); \ + ia64_intri_res; \ +}) + +static inline unsigned long ffz(unsigned long bitmask) +{ + return ia64_popcnt(bitmask & (~bitmask - 1)); +} + +#endif diff --git a/arch/arch-ppc.h b/arch/arch-ppc.h new file mode 100644 index 00000000..8bfed597 --- /dev/null +++ b/arch/arch-ppc.h @@ -0,0 +1,38 @@ +#ifndef ARCH_PPC_H +#define ARCH_PPH_H + +#define ARCH (arch_ppc) + +#ifndef __NR_ioprio_set +#define __NR_ioprio_set 273 +#define __NR_ioprio_get 274 +#endif + +#ifndef __NR_fadvise64 +#define __NR_fadvise64 233 +#endif + +#ifndef __NR_sys_splice +#define __NR_sys_splice 283 +#define __NR_sys_tee 284 +#define __NR_sys_vmsplice 285 +#endif + +#define nop do { } while (0) + +static inline int __ilog2(unsigned long bitmask) +{ + int lz; + + asm ("cntlzw %0,%1" : "=r" (lz) : "r" (bitmask)); + return 31 - lz; +} + +static inline int ffz(unsigned long bitmask) +{ + if ((bitmask = ~bitmask) == 0) + return 32; + return __ilog2(bitmask & -bitmask); +} + +#endif diff --git a/arch/arch-s390.h b/arch/arch-s390.h new file mode 100644 index 00000000..b7048ad6 --- /dev/null +++ b/arch/arch-s390.h @@ -0,0 +1,18 @@ +#ifndef ARCH_S390_H +#define ARCH_S390_H + +#define ARCH (arch_s390) + +#ifndef __NR_ioprio_set +#define __NR_ioprio_set 282 +#define __NR_ioprio_get 283 +#endif + +#ifndef __NR_fadvise64 +#define __NR_fadvise64 253 +#endif + +#define nop asm volatile ("diag 0,0,68" : : : "memory") +#define ffz(v) generic_ffz((v)) + +#endif diff --git a/arch/arch-x86.h b/arch/arch-x86.h new file mode 100644 index 00000000..aa106920 --- /dev/null +++ b/arch/arch-x86.h @@ -0,0 +1,40 @@ +#ifndef ARCH_X86_H +#define ARCH_X86_H + +#define ARCH (arch_i386) + +#ifndef __NR_ioprio_set +#define __NR_ioprio_set 289 +#define __NR_ioprio_get 290 +#endif + +#ifndef __NR_fadvise64 +#define __NR_fadvise64 250 +#endif + +#ifndef __NR_sys_splice +#define __NR_sys_splice 313 +#define __NR_sys_tee 315 +#define __NR_sys_vmsplice 316 +#endif + +#ifndef __NR_async_exec +#define __NR_async_exec 320 +#define __NR_async_wait 321 +#define __NR_umem_add 322 +#define __NR_async_thread 323 +#endif + +#define FIO_HUGE_PAGE 4194304 + +#define FIO_HAVE_SYSLET + +#define nop __asm__ __volatile__("rep;nop": : :"memory") + +static inline unsigned long ffz(unsigned long bitmask) +{ + __asm__("bsfl %1,%0" :"=r" (bitmask) :"r" (~bitmask)); + return bitmask; +} + +#endif diff --git a/arch/arch-x86_64.h b/arch/arch-x86_64.h new file mode 100644 index 00000000..4e0ad5f6 --- /dev/null +++ b/arch/arch-x86_64.h @@ -0,0 +1,41 @@ +#ifndef ARCH_X86_64_h +#define ARCH_X86_64_h + +#define ARCH (arch_x86_64) + +#ifndef __NR_ioprio_set +#define __NR_ioprio_set 251 +#define __NR_ioprio_get 252 +#endif + +#ifndef __NR_fadvise64 +#define __NR_fadvise64 221 +#endif + +#ifndef __NR_sys_splice +#define __NR_sys_splice 275 +#define __NR_sys_tee 276 +#define __NR_sys_vmsplice 278 +#endif + +#ifndef __NR_async_exec +#define __NR_async_exec 280 +#define __NR_async_wait 281 +#define __NR_umem_add 282 +#define __NR_async_thread 283 +#endif + +#define FIO_HUGE_PAGE 2097152 + +#define FIO_HAVE_SYSLET + +#define nop __asm__ __volatile__("rep;nop": : :"memory") + +static inline unsigned long ffz(unsigned long bitmask) +{ + __asm__("bsfq %1,%0" :"=r" (bitmask) :"r" (~bitmask)); + return bitmask; +} + + +#endif diff --git a/arch/arch.h b/arch/arch.h new file mode 100644 index 00000000..745bf3a4 --- /dev/null +++ b/arch/arch.h @@ -0,0 +1,42 @@ +#ifndef ARCH_H +#define ARCH_H + +enum { + arch_x86_64, + arch_i386, + arch_ppc, + arch_ia64, + arch_s390, + arch_alpha, +}; + +static inline unsigned long generic_ffz(unsigned long word) +{ + unsigned int i; + + for (i = 0; i < sizeof(word) * 8; i++) + if ((word & (1UL << i)) == 0) + return i; + + return -1; +} + +#if defined(__i386__) +#include "arch-x86.h" +#elif defined(__x86_64__) +#include "arch-x86_64.h" +#elif defined(__powerpc__) || defined(__powerpc64__) +#include "arch-ppc.h" +#elif defined(__ia64__) +#include "arch-ia64.h" +#elif defined(__alpha__) +#include "arch-alpha.h" +#elif defined(__s390x__) || defined(__s390__) +#include "arch-s390.h" +#else +#error "Unsupported arch" +#endif + +#define BITS_PER_LONG (__WORDSIZE) + +#endif diff --git a/compiler-gcc3.h b/compiler-gcc3.h deleted file mode 100644 index ab8ccc4f..00000000 --- a/compiler-gcc3.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef FIO_COMPILER_GCC3_H -#define FIO_COMPILER_GCC3_H - -#if __GNUC_MINOR__ >= 4 -#define __must_check __attribute__((warn_unused_result)) -#endif - -#endif diff --git a/compiler-gcc4.h b/compiler-gcc4.h deleted file mode 100644 index bb9cc7c5..00000000 --- a/compiler-gcc4.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef FIO_COMPILER_GCC4_H -#define FIO_COMPILER_GCC4_H - -#define __must_check __attribute__((warn_unused_result)) - -#endif diff --git a/compiler.h b/compiler.h deleted file mode 100644 index 72e84197..00000000 --- a/compiler.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef FIO_COMPILER_H -#define FIO_COMPILER_H - -#if __GNUC__ >= 4 -#include "compiler-gcc4.h" -#elif __GNUC__ == 3 -#include "compiler-gcc3.h" -#else -#error Compiler too old, need gcc at least gcc 3.x -#endif - -#ifndef __must_check -#define __must_check -#endif - -#endif diff --git a/compiler/compiler-gcc3.h b/compiler/compiler-gcc3.h new file mode 100644 index 00000000..ab8ccc4f --- /dev/null +++ b/compiler/compiler-gcc3.h @@ -0,0 +1,8 @@ +#ifndef FIO_COMPILER_GCC3_H +#define FIO_COMPILER_GCC3_H + +#if __GNUC_MINOR__ >= 4 +#define __must_check __attribute__((warn_unused_result)) +#endif + +#endif diff --git a/compiler/compiler-gcc4.h b/compiler/compiler-gcc4.h new file mode 100644 index 00000000..bb9cc7c5 --- /dev/null +++ b/compiler/compiler-gcc4.h @@ -0,0 +1,6 @@ +#ifndef FIO_COMPILER_GCC4_H +#define FIO_COMPILER_GCC4_H + +#define __must_check __attribute__((warn_unused_result)) + +#endif diff --git a/compiler/compiler.h b/compiler/compiler.h new file mode 100644 index 00000000..72e84197 --- /dev/null +++ b/compiler/compiler.h @@ -0,0 +1,16 @@ +#ifndef FIO_COMPILER_H +#define FIO_COMPILER_H + +#if __GNUC__ >= 4 +#include "compiler-gcc4.h" +#elif __GNUC__ == 3 +#include "compiler-gcc3.h" +#else +#error Compiler too old, need gcc at least gcc 3.x +#endif + +#ifndef __must_check +#define __must_check +#endif + +#endif diff --git a/engines/cpu.c b/engines/cpu.c index 9fac418b..cfdf281d 100644 --- a/engines/cpu.c +++ b/engines/cpu.c @@ -6,7 +6,6 @@ * */ #include "../fio.h" -#include "../os.h" static int fio_cpuio_queue(struct thread_data *td, struct io_u fio_unused *io_u) { diff --git a/engines/guasi.c b/engines/guasi.c index d67699af..1d3c77f6 100644 --- a/engines/guasi.c +++ b/engines/guasi.c @@ -20,7 +20,6 @@ #include #include "../fio.h" -#include "../os.h" #ifdef FIO_HAVE_GUASI diff --git a/engines/libaio.c b/engines/libaio.c index 7c44927a..871c5a47 100644 --- a/engines/libaio.c +++ b/engines/libaio.c @@ -11,7 +11,6 @@ #include #include "../fio.h" -#include "../os.h" #ifdef FIO_HAVE_LIBAIO diff --git a/engines/mmap.c b/engines/mmap.c index da690694..95ad1d84 100644 --- a/engines/mmap.c +++ b/engines/mmap.c @@ -13,7 +13,6 @@ #include #include "../fio.h" -#include "../os.h" static int fio_mmapio_queue(struct thread_data *td, struct io_u *io_u) { diff --git a/engines/net.c b/engines/net.c index 66f1e607..4de86c12 100644 --- a/engines/net.c +++ b/engines/net.c @@ -15,7 +15,6 @@ #include #include "../fio.h" -#include "../os.h" struct netio_data { int listenfd; diff --git a/engines/null.c b/engines/null.c index 724feca7..70d1fa78 100644 --- a/engines/null.c +++ b/engines/null.c @@ -12,7 +12,6 @@ #include #include "../fio.h" -#include "../os.h" struct null_data { struct io_u **io_us; diff --git a/engines/posixaio.c b/engines/posixaio.c index 4aa7420c..88ed4026 100644 --- a/engines/posixaio.c +++ b/engines/posixaio.c @@ -11,7 +11,6 @@ #include #include "../fio.h" -#include "../os.h" #ifdef FIO_HAVE_POSIXAIO diff --git a/engines/sg.c b/engines/sg.c index 8856c6f9..cc50d6b9 100644 --- a/engines/sg.c +++ b/engines/sg.c @@ -12,7 +12,6 @@ #include #include "../fio.h" -#include "../os.h" #ifdef FIO_HAVE_SGIO diff --git a/engines/skeleton_external.c b/engines/skeleton_external.c index 4c0c926c..9000accf 100644 --- a/engines/skeleton_external.c +++ b/engines/skeleton_external.c @@ -13,7 +13,6 @@ #include #include "../fio.h" -#include "../os.h" /* * The core of the module is identical to the ones included with fio, diff --git a/engines/splice.c b/engines/splice.c index 6d843538..b92da4a8 100644 --- a/engines/splice.c +++ b/engines/splice.c @@ -13,7 +13,6 @@ #include #include "../fio.h" -#include "../os.h" #ifdef FIO_HAVE_SPLICE diff --git a/engines/sync.c b/engines/sync.c index a1372827..ee8e3c36 100644 --- a/engines/sync.c +++ b/engines/sync.c @@ -12,7 +12,6 @@ #include #include "../fio.h" -#include "../os.h" static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u) { diff --git a/engines/syslet-rw.c b/engines/syslet-rw.c index d225cc41..7e407d78 100644 --- a/engines/syslet-rw.c +++ b/engines/syslet-rw.c @@ -13,7 +13,6 @@ #include #include "../fio.h" -#include "../os.h" #ifdef FIO_HAVE_SYSLET diff --git a/eta.c b/eta.c index a48cadae..31028dd8 100644 --- a/eta.c +++ b/eta.c @@ -6,7 +6,6 @@ #include #include "fio.h" -#include "os.h" static char run_str[MAX_JOBS + 1]; diff --git a/filesetup.c b/filesetup.c index 78264d3d..c99d5b36 100644 --- a/filesetup.c +++ b/filesetup.c @@ -8,7 +8,6 @@ #include #include "fio.h" -#include "os.h" static int extend_file(struct thread_data *td, struct fio_file *f) { diff --git a/fio.c b/fio.c index 125cf6fb..a945b856 100644 --- a/fio.c +++ b/fio.c @@ -35,7 +35,6 @@ #include #include "fio.h" -#include "os.h" unsigned long page_mask; unsigned long page_size; diff --git a/fio.h b/fio.h index a62971d1..6b708059 100644 --- a/fio.h +++ b/fio.h @@ -13,13 +13,13 @@ #include #include -#include "compiler.h" +#include "compiler/compiler.h" #include "list.h" #include "rbtree.h" #include "md5.h" #include "crc32.h" -#include "arch.h" -#include "os.h" +#include "arch/arch.h" +#include "os/os.h" #include "mutex.h" #ifdef FIO_HAVE_SYSLET diff --git a/gettime.c b/gettime.c index 4f6ec955..136c02c1 100644 --- a/gettime.c +++ b/gettime.c @@ -6,7 +6,6 @@ #include #include "fio.h" -#include "os.h" #include "hash.h" diff --git a/io_u.c b/io_u.c index b48c99da..1ae63789 100644 --- a/io_u.c +++ b/io_u.c @@ -6,7 +6,6 @@ #include #include "fio.h" -#include "os.h" /* * Change this define to play with the timeout handling diff --git a/ioengines.c b/ioengines.c index 3cfa773a..998c13ee 100644 --- a/ioengines.c +++ b/ioengines.c @@ -17,7 +17,6 @@ #include #include "fio.h" -#include "os.h" static LIST_HEAD(engine_list); diff --git a/memory.c b/memory.c index 8d6f9557..b5a71d53 100644 --- a/memory.c +++ b/memory.c @@ -6,7 +6,6 @@ #include #include "fio.h" -#include "os.h" static void *pinned_mem; diff --git a/os-freebsd.h b/os-freebsd.h deleted file mode 100644 index 01c5ce91..00000000 --- a/os-freebsd.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef FIO_OS_FREEBSD_H -#define FIO_OS_FREEBSD_H - -#include - -#undef FIO_HAVE_LIBAIO -#define FIO_HAVE_POSIXAIO -#undef FIO_HAVE_FADVISE -#undef FIO_HAVE_CPU_AFFINITY -#undef FIO_HAVE_DISK_UTIL -#undef FIO_HAVE_SGIO -#define FIO_HAVE_ODIRECT - -#define OS_MAP_ANON (MAP_ANON) - -typedef unsigned long os_cpu_mask_t; -typedef unsigned int os_random_state_t; - -/* - * FIXME - */ -static inline int blockdev_size(int fd, unsigned long long *bytes) -{ - return EINVAL; -} - -static inline int blockdev_invalidate_cache(int fd) -{ - return EINVAL; -} - -static inline unsigned long long os_phys_mem(void) -{ - int mib[2] = { CTL_HW, HW_PHYSMEM }; - unsigned long long mem; - size_t len = sizeof(mem); - - sysctl(mib, 2, &mem, &len, NULL, 0); - return mem; -} - -static inline void os_random_seed(unsigned long seed, os_random_state_t *rs) -{ - srand(seed); -} - -static inline long os_random_long(os_random_state_t *rs) -{ - long val; - - val = rand_r(rs); - return val; -} - -static inline double os_random_double(os_random_state_t *rs) -{ - double val; - - val = (double) rand_r(rs); - return val; -} -#endif diff --git a/os-linux.h b/os-linux.h deleted file mode 100644 index 561b273d..00000000 --- a/os-linux.h +++ /dev/null @@ -1,203 +0,0 @@ -#ifndef FIO_OS_LINUX_H -#define FIO_OS_LINUX_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#define FIO_HAVE_LIBAIO -#define FIO_HAVE_POSIXAIO -#define FIO_HAVE_FADVISE -#define FIO_HAVE_CPU_AFFINITY -#define FIO_HAVE_DISK_UTIL -#define FIO_HAVE_SGIO -#define FIO_HAVE_IOPRIO -#define FIO_HAVE_SPLICE -#define FIO_HAVE_IOSCHED_SWITCH -#define FIO_HAVE_ODIRECT -#define FIO_HAVE_HUGETLB -#define FIO_HAVE_RAWBIND - -#define OS_MAP_ANON (MAP_ANONYMOUS) - -typedef cpu_set_t os_cpu_mask_t; -typedef struct drand48_data os_random_state_t; - -/* - * we want fadvise64 really, but it's so tangled... later - */ -#define fadvise(fd, off, len, advice) \ - posix_fadvise((fd), (off_t)(off), (len), (advice)) - -#define fio_setaffinity(td) \ - sched_setaffinity((td)->pid, sizeof((td)->o.cpumask), &(td)->o.cpumask) -#define fio_getaffinity(pid, ptr) \ - sched_getaffinity((pid), sizeof(cpu_set_t), (ptr)) - -static inline int ioprio_set(int which, int who, int ioprio) -{ - return syscall(__NR_ioprio_set, which, who, ioprio); -} - -/* - * Just check for SPLICE_F_MOVE, if that isn't there, assume the others - * aren't either. - */ -#ifndef SPLICE_F_MOVE -#define SPLICE_F_MOVE (0x01) /* move pages instead of copying */ -#define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */ - /* we may still block on the fd we splice */ - /* from/to, of course */ -#define SPLICE_F_MORE (0x04) /* expect more data */ -#define SPLICE_F_GIFT (0x08) /* pages passed in are a gift */ - -static inline int splice(int fdin, loff_t *off_in, int fdout, loff_t *off_out, - size_t len, unsigned long flags) -{ - return syscall(__NR_sys_splice, fdin, off_in, fdout, off_out, len, flags); -} - -static inline int tee(int fdin, int fdout, size_t len, unsigned int flags) -{ - return syscall(__NR_sys_tee, fdin, fdout, len, flags); -} - -static inline int vmsplice(int fd, const struct iovec *iov, - unsigned long nr_segs, unsigned int flags) -{ - return syscall(__NR_sys_vmsplice, fd, iov, nr_segs, flags); -} -#endif - -#define SPLICE_DEF_SIZE (64*1024) - -#ifdef FIO_HAVE_SYSLET - -struct syslet_uatom; -struct async_head_user; - -/* - * syslet stuff - */ -static inline struct syslet_uatom * -async_exec(struct syslet_uatom *atom, struct async_head_user *ahu) -{ - return (void *) syscall(__NR_async_exec, atom, ahu); -} - -static inline long -async_wait(unsigned long min_wait_events, unsigned long user_ring_idx, - struct async_head_user *ahu) -{ - return syscall(__NR_async_wait, min_wait_events, - user_ring_idx, ahu); -} - -static inline long async_thread(void *event, struct async_head_user *ahu) -{ - return syscall(__NR_async_thread, event, ahu); -} - -static inline long umem_add(unsigned long *uptr, unsigned long inc) -{ - return syscall(__NR_umem_add, uptr, inc); -} -#endif /* FIO_HAVE_SYSLET */ - -enum { - IOPRIO_WHO_PROCESS = 1, - IOPRIO_WHO_PGRP, - IOPRIO_WHO_USER, -}; - -#define IOPRIO_CLASS_SHIFT 13 - -#ifndef BLKGETSIZE64 -#define BLKGETSIZE64 _IOR(0x12,114,size_t) -#endif - -#ifndef BLKFLSBUF -#define BLKFLSBUF _IO(0x12,97) -#endif - -static inline int blockdev_invalidate_cache(int fd) -{ - return ioctl(fd, BLKFLSBUF); -} - -static inline int blockdev_size(int fd, unsigned long long *bytes) -{ - if (!ioctl(fd, BLKGETSIZE64, bytes)) - return 0; - - return errno; -} - -static inline unsigned long long os_phys_mem(void) -{ - long pagesize, pages; - - pagesize = sysconf(_SC_PAGESIZE); - pages = sysconf(_SC_PHYS_PAGES); - if (pages == -1 || pagesize == -1) - return 0; - - return (unsigned long long) pages * (unsigned long long) pagesize; -} - -static inline void os_random_seed(unsigned long seed, os_random_state_t *rs) -{ - srand48_r(seed, rs); -} - -static inline long os_random_long(os_random_state_t *rs) -{ - long val; - - lrand48_r(rs, &val); - return val; -} - -static inline double os_random_double(os_random_state_t *rs) -{ - double val; - - drand48_r(rs, &val); - return val; -} - -static inline void fio_lookup_raw(dev_t dev, int *majdev, int *mindev) -{ - struct raw_config_request rq; - int fd; - - if (major(dev) != RAW_MAJOR) - return; - - /* - * we should be able to find /dev/rawctl or /dev/raw/rawctl - */ - fd = open("/dev/rawctl", O_RDONLY); - if (fd < 0) { - fd = open("/dev/raw/rawctl", O_RDONLY); - if (fd < 0) - return; - } - - rq.raw_minor = minor(dev); - if (ioctl(fd, RAW_GETBIND, &rq) < 0) { - close(fd); - return; - } - - close(fd); - *majdev = rq.block_major; - *mindev = rq.block_minor; -} - -#endif diff --git a/os-solaris.h b/os-solaris.h deleted file mode 100644 index 898da18e..00000000 --- a/os-solaris.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef FIO_OS_SOLARIS_H -#define FIO_OS_SOLARIS_H - -#undef FIO_HAVE_LIBAIO -#define FIO_HAVE_POSIXAIO -#undef FIO_HAVE_FADVISE -#undef FIO_HAVE_CPU_AFFINITY -#undef FIO_HAVE_DISK_UTIL -#undef FIO_HAVE_SGIO -#undef FIO_HAVE_ODIRECT - -#define OS_MAP_ANON (MAP_ANON) - -typedef unsigned long os_cpu_mask_t; -typedef unsigned int os_random_state_t; - -/* - * FIXME - */ -static inline int blockdev_size(int fd, unsigned long long *bytes) -{ - return EINVAL; -} - -static inline int blockdev_invalidate_cache(int fd) -{ - return EINVAL; -} - -static inline unsigned long long os_phys_mem(void) -{ -#if 0 - int mib[2] = { CTL_HW, HW_PHYSMEM }; - unsigned long long mem; - size_t len = sizeof(mem); - - sysctl(mib, 2, &mem, &len, NULL, 0); - return mem; -#else - return 0; -#endif -} - -static inline void os_random_seed(unsigned long seed, os_random_state_t *rs) -{ - srand(seed); -} - -static inline long os_random_long(os_random_state_t *rs) -{ - long val; - - val = rand_r(rs); - return val; -} - -static inline double os_random_double(os_random_state_t *rs) -{ - double val; - - val = (double) rand_r(rs); - return val; -} - -#endif diff --git a/os.h b/os.h deleted file mode 100644 index 104f4a81..00000000 --- a/os.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef FIO_OS_H -#define FIO_OS_H - -#if defined(__linux__) -#include "os-linux.h" -#elif defined(__FreeBSD__) -#include "os-freebsd.h" -#elif defined(__sun__) -#include "os-solaris.h" -#else -#error "unsupported os" -#endif - -#ifdef FIO_HAVE_LIBAIO -#include -#endif - -#ifdef FIO_HAVE_POSIXAIO -#include -#endif - -#ifdef FIO_HAVE_SGIO -#include -#include -#endif - -#ifndef FIO_HAVE_FADVISE -#define fadvise(fd, off, len, advice) (0) - -#define POSIX_FADV_DONTNEED (0) -#define POSIX_FADV_SEQUENTIAL (0) -#define POSIX_FADV_RANDOM (0) -#endif /* FIO_HAVE_FADVISE */ - -#ifndef FIO_HAVE_CPU_AFFINITY -#define fio_setaffinity(td) (0) -#define fio_getaffinity(pid, mask) (0) -#endif - -#ifndef FIO_HAVE_IOPRIO -#define ioprio_set(which, who, prio) (0) -#endif - -#ifndef FIO_HAVE_ODIRECT -#define OS_O_DIRECT 0 -#else -#define OS_O_DIRECT O_DIRECT -#endif - -#ifndef FIO_HAVE_HUGETLB -#define SHM_HUGETLB 0 -#define FIO_HUGE_PAGE 0 -#else -#ifndef FIO_HUGE_PAGE -#define FIO_HUGE_PAGE 4194304 -#endif -#endif - -#ifndef FIO_HAVE_RAWBIND -#define fio_lookup_raw(dev, majdev, mindev) -#endif - -#endif diff --git a/os/os-freebsd.h b/os/os-freebsd.h new file mode 100644 index 00000000..01c5ce91 --- /dev/null +++ b/os/os-freebsd.h @@ -0,0 +1,62 @@ +#ifndef FIO_OS_FREEBSD_H +#define FIO_OS_FREEBSD_H + +#include + +#undef FIO_HAVE_LIBAIO +#define FIO_HAVE_POSIXAIO +#undef FIO_HAVE_FADVISE +#undef FIO_HAVE_CPU_AFFINITY +#undef FIO_HAVE_DISK_UTIL +#undef FIO_HAVE_SGIO +#define FIO_HAVE_ODIRECT + +#define OS_MAP_ANON (MAP_ANON) + +typedef unsigned long os_cpu_mask_t; +typedef unsigned int os_random_state_t; + +/* + * FIXME + */ +static inline int blockdev_size(int fd, unsigned long long *bytes) +{ + return EINVAL; +} + +static inline int blockdev_invalidate_cache(int fd) +{ + return EINVAL; +} + +static inline unsigned long long os_phys_mem(void) +{ + int mib[2] = { CTL_HW, HW_PHYSMEM }; + unsigned long long mem; + size_t len = sizeof(mem); + + sysctl(mib, 2, &mem, &len, NULL, 0); + return mem; +} + +static inline void os_random_seed(unsigned long seed, os_random_state_t *rs) +{ + srand(seed); +} + +static inline long os_random_long(os_random_state_t *rs) +{ + long val; + + val = rand_r(rs); + return val; +} + +static inline double os_random_double(os_random_state_t *rs) +{ + double val; + + val = (double) rand_r(rs); + return val; +} +#endif diff --git a/os/os-linux.h b/os/os-linux.h new file mode 100644 index 00000000..561b273d --- /dev/null +++ b/os/os-linux.h @@ -0,0 +1,203 @@ +#ifndef FIO_OS_LINUX_H +#define FIO_OS_LINUX_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#define FIO_HAVE_LIBAIO +#define FIO_HAVE_POSIXAIO +#define FIO_HAVE_FADVISE +#define FIO_HAVE_CPU_AFFINITY +#define FIO_HAVE_DISK_UTIL +#define FIO_HAVE_SGIO +#define FIO_HAVE_IOPRIO +#define FIO_HAVE_SPLICE +#define FIO_HAVE_IOSCHED_SWITCH +#define FIO_HAVE_ODIRECT +#define FIO_HAVE_HUGETLB +#define FIO_HAVE_RAWBIND + +#define OS_MAP_ANON (MAP_ANONYMOUS) + +typedef cpu_set_t os_cpu_mask_t; +typedef struct drand48_data os_random_state_t; + +/* + * we want fadvise64 really, but it's so tangled... later + */ +#define fadvise(fd, off, len, advice) \ + posix_fadvise((fd), (off_t)(off), (len), (advice)) + +#define fio_setaffinity(td) \ + sched_setaffinity((td)->pid, sizeof((td)->o.cpumask), &(td)->o.cpumask) +#define fio_getaffinity(pid, ptr) \ + sched_getaffinity((pid), sizeof(cpu_set_t), (ptr)) + +static inline int ioprio_set(int which, int who, int ioprio) +{ + return syscall(__NR_ioprio_set, which, who, ioprio); +} + +/* + * Just check for SPLICE_F_MOVE, if that isn't there, assume the others + * aren't either. + */ +#ifndef SPLICE_F_MOVE +#define SPLICE_F_MOVE (0x01) /* move pages instead of copying */ +#define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */ + /* we may still block on the fd we splice */ + /* from/to, of course */ +#define SPLICE_F_MORE (0x04) /* expect more data */ +#define SPLICE_F_GIFT (0x08) /* pages passed in are a gift */ + +static inline int splice(int fdin, loff_t *off_in, int fdout, loff_t *off_out, + size_t len, unsigned long flags) +{ + return syscall(__NR_sys_splice, fdin, off_in, fdout, off_out, len, flags); +} + +static inline int tee(int fdin, int fdout, size_t len, unsigned int flags) +{ + return syscall(__NR_sys_tee, fdin, fdout, len, flags); +} + +static inline int vmsplice(int fd, const struct iovec *iov, + unsigned long nr_segs, unsigned int flags) +{ + return syscall(__NR_sys_vmsplice, fd, iov, nr_segs, flags); +} +#endif + +#define SPLICE_DEF_SIZE (64*1024) + +#ifdef FIO_HAVE_SYSLET + +struct syslet_uatom; +struct async_head_user; + +/* + * syslet stuff + */ +static inline struct syslet_uatom * +async_exec(struct syslet_uatom *atom, struct async_head_user *ahu) +{ + return (void *) syscall(__NR_async_exec, atom, ahu); +} + +static inline long +async_wait(unsigned long min_wait_events, unsigned long user_ring_idx, + struct async_head_user *ahu) +{ + return syscall(__NR_async_wait, min_wait_events, + user_ring_idx, ahu); +} + +static inline long async_thread(void *event, struct async_head_user *ahu) +{ + return syscall(__NR_async_thread, event, ahu); +} + +static inline long umem_add(unsigned long *uptr, unsigned long inc) +{ + return syscall(__NR_umem_add, uptr, inc); +} +#endif /* FIO_HAVE_SYSLET */ + +enum { + IOPRIO_WHO_PROCESS = 1, + IOPRIO_WHO_PGRP, + IOPRIO_WHO_USER, +}; + +#define IOPRIO_CLASS_SHIFT 13 + +#ifndef BLKGETSIZE64 +#define BLKGETSIZE64 _IOR(0x12,114,size_t) +#endif + +#ifndef BLKFLSBUF +#define BLKFLSBUF _IO(0x12,97) +#endif + +static inline int blockdev_invalidate_cache(int fd) +{ + return ioctl(fd, BLKFLSBUF); +} + +static inline int blockdev_size(int fd, unsigned long long *bytes) +{ + if (!ioctl(fd, BLKGETSIZE64, bytes)) + return 0; + + return errno; +} + +static inline unsigned long long os_phys_mem(void) +{ + long pagesize, pages; + + pagesize = sysconf(_SC_PAGESIZE); + pages = sysconf(_SC_PHYS_PAGES); + if (pages == -1 || pagesize == -1) + return 0; + + return (unsigned long long) pages * (unsigned long long) pagesize; +} + +static inline void os_random_seed(unsigned long seed, os_random_state_t *rs) +{ + srand48_r(seed, rs); +} + +static inline long os_random_long(os_random_state_t *rs) +{ + long val; + + lrand48_r(rs, &val); + return val; +} + +static inline double os_random_double(os_random_state_t *rs) +{ + double val; + + drand48_r(rs, &val); + return val; +} + +static inline void fio_lookup_raw(dev_t dev, int *majdev, int *mindev) +{ + struct raw_config_request rq; + int fd; + + if (major(dev) != RAW_MAJOR) + return; + + /* + * we should be able to find /dev/rawctl or /dev/raw/rawctl + */ + fd = open("/dev/rawctl", O_RDONLY); + if (fd < 0) { + fd = open("/dev/raw/rawctl", O_RDONLY); + if (fd < 0) + return; + } + + rq.raw_minor = minor(dev); + if (ioctl(fd, RAW_GETBIND, &rq) < 0) { + close(fd); + return; + } + + close(fd); + *majdev = rq.block_major; + *mindev = rq.block_minor; +} + +#endif diff --git a/os/os-solaris.h b/os/os-solaris.h new file mode 100644 index 00000000..898da18e --- /dev/null +++ b/os/os-solaris.h @@ -0,0 +1,65 @@ +#ifndef FIO_OS_SOLARIS_H +#define FIO_OS_SOLARIS_H + +#undef FIO_HAVE_LIBAIO +#define FIO_HAVE_POSIXAIO +#undef FIO_HAVE_FADVISE +#undef FIO_HAVE_CPU_AFFINITY +#undef FIO_HAVE_DISK_UTIL +#undef FIO_HAVE_SGIO +#undef FIO_HAVE_ODIRECT + +#define OS_MAP_ANON (MAP_ANON) + +typedef unsigned long os_cpu_mask_t; +typedef unsigned int os_random_state_t; + +/* + * FIXME + */ +static inline int blockdev_size(int fd, unsigned long long *bytes) +{ + return EINVAL; +} + +static inline int blockdev_invalidate_cache(int fd) +{ + return EINVAL; +} + +static inline unsigned long long os_phys_mem(void) +{ +#if 0 + int mib[2] = { CTL_HW, HW_PHYSMEM }; + unsigned long long mem; + size_t len = sizeof(mem); + + sysctl(mib, 2, &mem, &len, NULL, 0); + return mem; +#else + return 0; +#endif +} + +static inline void os_random_seed(unsigned long seed, os_random_state_t *rs) +{ + srand(seed); +} + +static inline long os_random_long(os_random_state_t *rs) +{ + long val; + + val = rand_r(rs); + return val; +} + +static inline double os_random_double(os_random_state_t *rs) +{ + double val; + + val = (double) rand_r(rs); + return val; +} + +#endif diff --git a/os/os.h b/os/os.h new file mode 100644 index 00000000..104f4a81 --- /dev/null +++ b/os/os.h @@ -0,0 +1,63 @@ +#ifndef FIO_OS_H +#define FIO_OS_H + +#if defined(__linux__) +#include "os-linux.h" +#elif defined(__FreeBSD__) +#include "os-freebsd.h" +#elif defined(__sun__) +#include "os-solaris.h" +#else +#error "unsupported os" +#endif + +#ifdef FIO_HAVE_LIBAIO +#include +#endif + +#ifdef FIO_HAVE_POSIXAIO +#include +#endif + +#ifdef FIO_HAVE_SGIO +#include +#include +#endif + +#ifndef FIO_HAVE_FADVISE +#define fadvise(fd, off, len, advice) (0) + +#define POSIX_FADV_DONTNEED (0) +#define POSIX_FADV_SEQUENTIAL (0) +#define POSIX_FADV_RANDOM (0) +#endif /* FIO_HAVE_FADVISE */ + +#ifndef FIO_HAVE_CPU_AFFINITY +#define fio_setaffinity(td) (0) +#define fio_getaffinity(pid, mask) (0) +#endif + +#ifndef FIO_HAVE_IOPRIO +#define ioprio_set(which, who, prio) (0) +#endif + +#ifndef FIO_HAVE_ODIRECT +#define OS_O_DIRECT 0 +#else +#define OS_O_DIRECT O_DIRECT +#endif + +#ifndef FIO_HAVE_HUGETLB +#define SHM_HUGETLB 0 +#define FIO_HUGE_PAGE 0 +#else +#ifndef FIO_HUGE_PAGE +#define FIO_HUGE_PAGE 4194304 +#endif +#endif + +#ifndef FIO_HAVE_RAWBIND +#define fio_lookup_raw(dev, majdev, mindev) +#endif + +#endif diff --git a/verify.c b/verify.c index 47335107..46e610d7 100644 --- a/verify.c +++ b/verify.c @@ -6,7 +6,6 @@ #include #include "fio.h" -#include "os.h" static void fill_random_bytes(struct thread_data *td, unsigned char *p, unsigned int len)