Make SH port work for packagers that don't differentiate between SH4 and SH4A
[fio.git] / os / os-freebsd.h
1 #ifndef FIO_OS_FREEBSD_H
2 #define FIO_OS_FREEBSD_H
3
4 #include <errno.h>
5 #include <sys/sysctl.h>
6 #include <sys/disk.h>
7 #include <sys/thr.h>
8
9 #include "../file.h"
10
11 #define FIO_HAVE_POSIXAIO
12 #define FIO_HAVE_ODIRECT
13 #define FIO_HAVE_STRSEP
14 #define FIO_USE_GENERIC_RAND
15 #define FIO_HAVE_CHARDEV_SIZE
16 #define FIO_HAVE_CLOCK_MONOTONIC
17 #define FIO_HAVE_GETTID
18
19 #define OS_MAP_ANON             MAP_ANON
20
21 typedef off_t off64_t;
22
23 static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
24 {
25         off_t size;
26
27         if (!ioctl(f->fd, DIOCGMEDIASIZE, &size)) {
28                 *bytes = size;
29                 return 0;
30         }
31
32         *bytes = 0;
33         return errno;
34 }
35
36 static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
37 {
38         return blockdev_size(f, bytes);
39 }
40
41 static inline int blockdev_invalidate_cache(struct fio_file *f)
42 {
43         return EINVAL;
44 }
45
46 static inline unsigned long long os_phys_mem(void)
47 {
48         int mib[2] = { CTL_HW, HW_PHYSMEM };
49         unsigned long long mem;
50         size_t len = sizeof(mem);
51
52         sysctl(mib, 2, &mem, &len, NULL, 0);
53         return mem;
54 }
55
56 static inline int gettid(void)
57 {
58         long lwpid;
59
60         thr_self(&lwpid);
61         return (int) lwpid;
62 }
63
64 #ifdef MADV_FREE
65 #define FIO_MADV_FREE   MADV_FREE
66 #endif
67
68 #endif