X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=os%2Fos.h;h=df706ab7be4150d8589b2130e96e5c4ef1b09bb6;hp=03d1e9a14565f8481dd93db480e1896dfde184ec;hb=ff8039b745d59ede0ce9245ed24da14ecf2d3f38;hpb=3cd4c66f35fad0df64e4e6dfeddc5bdfd5206e0c diff --git a/os/os.h b/os/os.h index 03d1e9a1..df706ab7 100644 --- a/os/os.h +++ b/os/os.h @@ -80,7 +80,10 @@ typedef struct aiocb os_aiocb_t; #define fio_getaffinity(pid, mask) do { } while (0) #define fio_cpu_clear(mask, cpu) do { } while (0) #define fio_cpuset_exit(mask) (-1) +#define fio_cpus_split(mask, cpu) (0) typedef unsigned long os_cpu_mask_t; +#else +extern int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu); #endif #ifndef FIO_HAVE_IOPRIO @@ -197,29 +200,32 @@ static inline uint64_t fio_swap64(uint64_t val) #endif #endif /* FIO_HAVE_BYTEORDER_FUNCS */ +#ifdef FIO_INTERNAL #define le16_to_cpu(val) ({ \ - uint16_t *__val = &(val); \ - __le16_to_cpu(*__val); \ + typecheck(uint16_t, val); \ + __le16_to_cpu(val); \ }) #define le32_to_cpu(val) ({ \ - uint32_t *__val = &(val); \ - __le32_to_cpu(*__val); \ + typecheck(uint32_t, val); \ + __le32_to_cpu(val); \ }) #define le64_to_cpu(val) ({ \ - uint64_t *__val = &(val); \ - __le64_to_cpu(*__val); \ + typecheck(uint64_t, val); \ + __le64_to_cpu(val); \ }) +#endif + #define cpu_to_le16(val) ({ \ - uint16_t *__val = &(val); \ - __cpu_to_le16(*__val); \ + typecheck(uint16_t, val); \ + __cpu_to_le16(val); \ }) #define cpu_to_le32(val) ({ \ - uint32_t *__val = &(val); \ - __cpu_to_le32(*__val); \ + typecheck(uint32_t, val); \ + __cpu_to_le32(val); \ }) #define cpu_to_le64(val) ({ \ - uint64_t *__val = &(val); \ - __cpu_to_le64(*__val); \ + typecheck(uint64_t, val); \ + __cpu_to_le64(val); \ }) #ifndef FIO_HAVE_BLKTRACE @@ -324,6 +330,22 @@ static inline unsigned int cpus_online(void) } #endif +#ifndef CPU_COUNT +#ifdef FIO_HAVE_CPU_AFFINITY +static inline int CPU_COUNT(os_cpu_mask_t *mask) +{ + int max_cpus = cpus_online(); + int nr_cpus, i; + + for (i = 0, nr_cpus = 0; i < max_cpus; i++) + if (fio_cpu_isset(mask, i)) + nr_cpus++; + + return nr_cpus; +} +#endif +#endif + #ifndef FIO_HAVE_GETTID static inline int gettid(void) {