Merge branch 'master' of https://github.com/celestinechen/fio
[fio.git] / os / os-hpux.h
1 #ifndef FIO_OS_HPUX_H
2 #define FIO_OS_HPUX_H
3
4 #define FIO_OS  os_hpux
5
6 #include <errno.h>
7 #include <unistd.h>
8 #include <sys/ioctl.h>
9 #include <fcntl.h>
10 #include <sys/fadvise.h>
11 #include <sys/mman.h>
12 #include <sys/mpctl.h>
13 #include <sys/diskio.h>
14 #include <sys/param.h>
15 #include <sys/pstat.h>
16 #include <time.h>
17 #include <aio.h>
18 #include <arm.h>
19
20 #include "../file.h"
21
22 #define FIO_HAVE_ODIRECT
23 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
24 #define FIO_HAVE_CHARDEV_SIZE
25
26 #define OS_MAP_ANON             MAP_ANONYMOUS
27 #define OS_MSG_DONTWAIT         0
28
29 #define POSIX_MADV_DONTNEED     MADV_DONTNEED
30 #define POSIX_MADV_SEQUENTIAL   MADV_SEQUENTIAL
31 #define POSIX_MADV_RANDOM       MADV_RANDOM
32 #define posix_madvise(ptr, sz, hint)    madvise((ptr), (sz), (hint))
33
34 #ifndef MSG_WAITALL
35 #define MSG_WAITALL     0x40
36 #endif
37
38 #define FIO_USE_GENERIC_SWAP
39
40 #define FIO_OS_HAVE_AIOCB_TYPEDEF
41
42 #ifdef CONFIG_PTHREAD_GETAFFINITY
43 #define FIO_HAVE_GET_THREAD_AFFINITY
44 #define fio_get_thread_affinity(mask)   \
45         pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
46 #endif
47
48 typedef struct aiocb64 os_aiocb_t;
49
50 static inline int blockdev_invalidate_cache(struct fio_file *f)
51 {
52         return ENOTSUP;
53 }
54
55 static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
56 {
57         disk_describe_type_ext_t dext;
58
59         if (!ioctl(f->fd, DIOC_DESCRIBE_EXT, &dext)) {
60                 unsigned long long lba;
61
62                 lba = ((uint64_t) dext.maxsva_high << 32) | dext.maxsva_low;
63                 *bytes = lba * dext.lgblksz;
64                 return 0;
65         }
66
67         *bytes = 0;
68         return errno;
69 }
70
71 static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
72 {
73         return blockdev_size(f, bytes);
74 }
75
76 static inline unsigned long long os_phys_mem(void)
77 {
78         unsigned long long ret;
79         struct pst_static pst;
80         union pstun pu;
81
82         pu.pst_static = &pst;
83         if (pstat(PSTAT_STATIC, pu, sizeof(pst), 0, 0) == -1)
84                 return 0;
85
86         ret = pst.physical_memory;
87         ret *= pst.page_size;
88         return ret;
89 }
90
91 #define FIO_HAVE_CPU_ONLINE_SYSCONF
92
93 static inline unsigned int cpus_online(void)
94 {
95         return mpctl(MPC_GETNUMSPUS, 0, NULL);
96 }
97
98 #endif