blob: 1b1c95896eec5431584fb89e4ee6b35308ea8da9 [file] [log] [blame]
Jens Axboec00a2282011-07-08 20:56:06 +02001#ifndef FIO_OS_HPUX_H
2#define FIO_OS_HPUX_H
3
4#include <errno.h>
5#include <unistd.h>
6#include <sys/ioctl.h>
7#include <sys/fcntl.h>
8#include <sys/fadvise.h>
9#include <sys/mman.h>
10#include <sys/mpctl.h>
Jens Axboe0ec15d62011-07-11 10:48:51 +020011#include <sys/diskio.h>
Jens Axboe8c9ca2e2011-07-11 10:25:35 +020012#include <sys/param.h>
13#include <sys/pstat.h>
Jens Axboed48a9792011-07-09 08:54:26 +020014#include <time.h>
15#include <aio.h>
Jens Axboec00a2282011-07-08 20:56:06 +020016
17#include "../file.h"
18
19#define FIO_HAVE_POSIXAIO
20#define FIO_HAVE_ODIRECT
21#define FIO_USE_GENERIC_RAND
22#define FIO_HAVE_CLOCK_MONOTONIC
23#define FIO_HAVE_PSHARED_MUTEX
24#define FIO_HAVE_FADVISE
Jens Axboe0ec15d62011-07-11 10:48:51 +020025#define FIO_HAVE_CHARDEV_SIZE
Jens Axboec00a2282011-07-08 20:56:06 +020026
27#define OS_MAP_ANON MAP_ANONYMOUS
28#define OS_MSG_DONTWAIT 0
29
30#define POSIX_MADV_DONTNEED MADV_DONTNEED
31#define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
32#define POSIX_MADV_RANDOM MADV_RANDOM
33#define posix_madvise(ptr, sz, hint) madvise((ptr), (sz), (hint))
34
Jens Axboed48a9792011-07-09 08:54:26 +020035#ifndef CLOCK_MONOTONIC
36#define CLOCK_MONOTONIC CLOCK_REALTIME
37#endif
38
39#ifndef MSG_WAITALL
40#define MSG_WAITALL 0x40
41#endif
42
Jens Axboec00a2282011-07-08 20:56:06 +020043static inline int blockdev_invalidate_cache(struct fio_file *f)
44{
45 return EINVAL;
46}
47
48static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
49{
Jens Axboe0ec15d62011-07-11 10:48:51 +020050 disk_describe_type_ext_t dext;
Jens Axboec00a2282011-07-08 20:56:06 +020051
Jens Axboe0ec15d62011-07-11 10:48:51 +020052 if (!ioctl(f->fd, DIOC_DESCRIBE_EXT, &dext)) {
53 unsigned long long lba;
54
55 lba = ((uint64_t) dext.maxsva_high << 32) | dext.maxsva_low;
56 *bytes = lba * dext.lgblksz;
Jens Axboec00a2282011-07-08 20:56:06 +020057 return 0;
58 }
59
Jens Axboe564e49f2011-07-08 21:10:30 +020060 *bytes = 0;
Jens Axboec00a2282011-07-08 20:56:06 +020061 return errno;
Jens Axboec00a2282011-07-08 20:56:06 +020062}
63
Jens Axboe0ec15d62011-07-11 10:48:51 +020064static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
65{
66 return blockdev_size(f, bytes);
67}
68
Jens Axboec00a2282011-07-08 20:56:06 +020069static inline unsigned long long os_phys_mem(void)
70{
Jens Axboe8c9ca2e2011-07-11 10:25:35 +020071 unsigned long long ret;
72 struct pst_static pst;
73 union pstun pu;
Jens Axboec00a2282011-07-08 20:56:06 +020074
Jens Axboe8c9ca2e2011-07-11 10:25:35 +020075 pu.pst_static = &pst;
76 if (pstat(PSTAT_STATIC, pu, sizeof(pst), 0, 0) == -1)
Jens Axboec00a2282011-07-08 20:56:06 +020077 return 0;
78
Jens Axboe8c9ca2e2011-07-11 10:25:35 +020079 ret = pst.physical_memory;
80 ret *= pst.page_size;
81 return ret;
Jens Axboec00a2282011-07-08 20:56:06 +020082}
83
84#define FIO_HAVE_CPU_ONLINE_SYSCONF
85
86static inline unsigned int cpus_online(void)
87{
88 return mpctl(MPC_GETNUMSPUS, 0, NULL);
89}
90
91#endif