Align io units to processor cache line size
[fio.git] / os / os.h
CommitLineData
ebac4655
JA
1#ifndef FIO_OS_H
2#define FIO_OS_H
3
4#if defined(__linux__)
5#include "os-linux.h"
6#elif defined(__FreeBSD__)
7#include "os-freebsd.h"
2c0ecd28
JA
8#elif defined(__sun__)
9#include "os-solaris.h"
ebac4655
JA
10#else
11#error "unsupported os"
12#endif
13
14#ifdef FIO_HAVE_LIBAIO
15#include <libaio.h>
16#endif
17
18#ifdef FIO_HAVE_POSIXAIO
19#include <aio.h>
20#endif
21
22#ifdef FIO_HAVE_SGIO
23#include <linux/fs.h>
24#include <scsi/sg.h>
25#endif
26
5921e80c 27#ifndef FIO_HAVE_STRSEP
00fb3c8d 28#include "../lib/strsep.h"
5921e80c
JA
29#endif
30
ebac4655
JA
31#ifndef FIO_HAVE_FADVISE
32#define fadvise(fd, off, len, advice) (0)
33
4d8947de 34#ifndef POSIX_FADV_DONTNEED
ebac4655
JA
35#define POSIX_FADV_DONTNEED (0)
36#define POSIX_FADV_SEQUENTIAL (0)
37#define POSIX_FADV_RANDOM (0)
4d8947de 38#endif
ebac4655
JA
39#endif /* FIO_HAVE_FADVISE */
40
41#ifndef FIO_HAVE_CPU_AFFINITY
42#define fio_setaffinity(td) (0)
be4ecfdf
JA
43#define fio_getaffinity(pid, mask) do { } while (0)
44#define fio_cpu_clear(mask, cpu) do { } while (0)
85daf2c1 45#define fio_cpuset_exit(mask) (-1)
ebac4655
JA
46#endif
47
48#ifndef FIO_HAVE_IOPRIO
49#define ioprio_set(which, who, prio) (0)
50#endif
51
2c0ecd28 52#ifndef FIO_HAVE_ODIRECT
7d424763
JA
53#define OS_O_DIRECT 0
54#else
55#define OS_O_DIRECT O_DIRECT
2c0ecd28
JA
56#endif
57
74b025b0
JA
58#ifndef FIO_HAVE_HUGETLB
59#define SHM_HUGETLB 0
4d8947de 60#ifndef FIO_HUGE_PAGE
74b025b0 61#define FIO_HUGE_PAGE 0
4d8947de 62#endif
74b025b0 63#else
cb25df61 64#ifndef FIO_HUGE_PAGE
ee0e0a71 65#define FIO_HUGE_PAGE 4194304
74b025b0 66#endif
cb25df61 67#endif
74b025b0 68
5921e80c
JA
69#ifndef FIO_O_NOATIME
70#define FIO_O_NOATIME 0
71#endif
72
dc873b6f
JA
73#ifndef OS_RAND_MAX
74#define OS_RAND_MAX RAND_MAX
75#endif
76
07e5b264 77#ifndef FIO_HAVE_RAWBIND
8cc7afa9 78#define fio_lookup_raw(dev, majdev, mindev) 1
07e5b264
JA
79#endif
80
5e62c22a
JA
81#ifndef FIO_HAVE_BLKTRACE
82static inline int is_blktrace(const char *fname)
83{
84 return 0;
85}
5921e80c 86struct thread_data;
5e62c22a
JA
87static inline int load_blktrace(struct thread_data *td, const char *fname)
88{
89 return 1;
90}
91#endif
92
eb7ccf38
JA
93#define FIO_DEF_CL_SIZE 128
94
95static inline int os_cache_line_size(void)
96{
97#ifdef FIO_HAVE_CL_SIZE
98 int ret = arch_cache_line_size();
99
100 if (ret <= 0)
101 return FIO_DEF_CL_SIZE;
102
103 return ret;
104#else
105 return FIO_DEF_CL_SIZE;
106#endif
107}
108
ebac4655 109#endif