b4d677a4cf28d63bea693d7dc1b5add509b7724e
[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 <sys/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_RAND
24 #define FIO_USE_GENERIC_INIT_RANDOM_STATE
25 #define FIO_HAVE_PSHARED_MUTEX
26 #define FIO_HAVE_CHARDEV_SIZE
27
28 #define OS_MAP_ANON             MAP_ANONYMOUS
29 #define OS_MSG_DONTWAIT         0
30
31 #define POSIX_MADV_DONTNEED     MADV_DONTNEED
32 #define POSIX_MADV_SEQUENTIAL   MADV_SEQUENTIAL
33 #define POSIX_MADV_RANDOM       MADV_RANDOM
34 #define posix_madvise(ptr, sz, hint)    madvise((ptr), (sz), (hint))
35
36 #ifndef CLOCK_MONOTONIC
37 #define CLOCK_MONOTONIC         CLOCK_REALTIME
38 #endif
39
40 #ifndef MSG_WAITALL
41 #define MSG_WAITALL     0x40
42 #endif
43
44 #ifdef LITTLE_ENDIAN
45 #define FIO_LITTLE_ENDIAN
46 #else
47 #define FIO_BIG_ENDIAN
48 #endif
49
50 #define FIO_USE_GENERIC_SWAP
51
52 #define FIO_OS_HAVE_AIOCB_TYPEDEF
53 typedef struct aiocb64 os_aiocb_t;
54
55 static inline int blockdev_invalidate_cache(struct fio_file *f)
56 {
57         return EINVAL;
58 }
59
60 static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
61 {
62         disk_describe_type_ext_t dext;
63
64         if (!ioctl(f->fd, DIOC_DESCRIBE_EXT, &dext)) {
65                 unsigned long long lba;
66
67                 lba = ((uint64_t) dext.maxsva_high << 32) | dext.maxsva_low;
68                 *bytes = lba * dext.lgblksz;
69                 return 0;
70         }
71
72         *bytes = 0;
73         return errno;
74 }
75
76 static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
77 {
78         return blockdev_size(f, bytes);
79 }
80
81 static inline unsigned long long os_phys_mem(void)
82 {
83         unsigned long long ret;
84         struct pst_static pst;
85         union pstun pu;
86
87         pu.pst_static = &pst;
88         if (pstat(PSTAT_STATIC, pu, sizeof(pst), 0, 0) == -1)
89                 return 0;
90
91         ret = pst.physical_memory;
92         ret *= pst.page_size;
93         return ret;
94 }
95
96 #define FIO_HAVE_CPU_ONLINE_SYSCONF
97
98 static inline unsigned int cpus_online(void)
99 {
100         return mpctl(MPC_GETNUMSPUS, 0, NULL);
101 }
102
103 #endif