[PATCH] Include ETA for job(s) to finish
[fio.git] / os-linux.h
1 #ifndef FIO_OS_LINUX_H
2 #define FIO_OS_LINUX_H
3
4 #include <sys/ioctl.h>
5
6 #define FIO_HAVE_LIBAIO
7 #define FIO_HAVE_POSIXAIO
8 #define FIO_HAVE_FADVISE
9 #define FIO_HAVE_CPU_AFFINITY
10 #define FIO_HAVE_DISK_UTIL
11 #define FIO_HAVE_SGIO
12
13 #define OS_MAP_ANON             (MAP_ANONYMOUS)
14
15 typedef cpu_set_t os_cpu_mask_t;
16
17 /*
18  * we want fadvise64 really, but it's so tangled... later
19  */
20 #define fadvise(fd, off, len, advice)   \
21         posix_fadvise((fd), (off_t)(off), (len), (advice))
22
23 #define fio_setaffinity(td)             \
24         sched_setaffinity((td)->pid, sizeof((td)->cpumask), &(td)->cpumask)
25 #define fio_getaffinity(pid, ptr)       \
26         sched_getaffinity((pid), sizeof(cpu_set_t), (ptr))
27
28 static inline int ioprio_set(int which, int who, int ioprio)
29 {
30         return syscall(__NR_ioprio_set, which, who, ioprio);
31 }
32
33 enum {
34         IOPRIO_WHO_PROCESS = 1,
35         IOPRIO_WHO_PGRP,
36         IOPRIO_WHO_USER,
37 };
38
39 #define IOPRIO_CLASS_SHIFT      13
40
41 #ifndef BLKGETSIZE64
42 #define BLKGETSIZE64    _IOR(0x12,114,size_t)
43 #endif
44
45 static inline int blockdev_size(int fd, size_t *bytes)
46 {
47         if (!ioctl(fd, BLKGETSIZE64, bytes))
48                 return 0;
49
50         return errno;
51 }
52
53 #endif