blob: 821c91690b12c8165488c5d2e99170d98a77e1af [file] [log] [blame]
Jens Axboec00a2282011-07-08 20:56:06 +02001#ifndef FIO_OS_HPUX_H
2#define FIO_OS_HPUX_H
3
Jens Axboecca84642011-10-07 12:47:57 +02004#define FIO_OS os_hpux
5
Jens Axboec00a2282011-07-08 20:56:06 +02006#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>
Jens Axboe0ec15d62011-07-11 10:48:51 +020013#include <sys/diskio.h>
Jens Axboe8c9ca2e2011-07-11 10:25:35 +020014#include <sys/param.h>
15#include <sys/pstat.h>
Jens Axboed48a9792011-07-09 08:54:26 +020016#include <time.h>
17#include <aio.h>
Jens Axboe6e675fc2011-10-04 13:56:06 +020018#include <arm.h>
Jens Axboec00a2282011-07-08 20:56:06 +020019
20#include "../file.h"
21
22#define FIO_HAVE_POSIXAIO
23#define FIO_HAVE_ODIRECT
24#define FIO_USE_GENERIC_RAND
Bruce Cran93bcfd22012-02-20 20:18:19 +010025#define FIO_USE_GENERIC_INIT_RANDOM_STATE
Jens Axboec00a2282011-07-08 20:56:06 +020026#define FIO_HAVE_CLOCK_MONOTONIC
27#define FIO_HAVE_PSHARED_MUTEX
28#define FIO_HAVE_FADVISE
Jens Axboe0ec15d62011-07-11 10:48:51 +020029#define FIO_HAVE_CHARDEV_SIZE
Jens Axboebaa66772011-07-11 10:56:32 +020030#define FIO_HAVE_FALLOCATE
31#define FIO_HAVE_POSIXAIO_FSYNC
Jens Axboe893b37c2011-07-11 14:43:26 +020032#define FIO_HAVE_FDATASYNC
Jens Axboec00a2282011-07-08 20:56:06 +020033
34#define OS_MAP_ANON MAP_ANONYMOUS
35#define OS_MSG_DONTWAIT 0
36
37#define POSIX_MADV_DONTNEED MADV_DONTNEED
38#define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
39#define POSIX_MADV_RANDOM MADV_RANDOM
40#define posix_madvise(ptr, sz, hint) madvise((ptr), (sz), (hint))
41
Jens Axboed48a9792011-07-09 08:54:26 +020042#ifndef CLOCK_MONOTONIC
43#define CLOCK_MONOTONIC CLOCK_REALTIME
44#endif
45
46#ifndef MSG_WAITALL
47#define MSG_WAITALL 0x40
48#endif
49
Jens Axboe6e675fc2011-10-04 13:56:06 +020050#ifdef LITTLE_ENDIAN
51#define FIO_LITTLE_ENDIAN
52#else
53#define FIO_BIG_ENDIAN
54#endif
55
Jens Axboe901ebe12011-10-04 23:31:00 +020056#define FIO_USE_GENERIC_SWAP
57
Jens Axboee97c1442011-09-21 09:38:01 +020058#define FIO_OS_HAVE_AIOCB_TYPEDEF
59typedef struct aiocb64 os_aiocb_t;
60
Jens Axboe5ba13ea2011-10-04 23:50:28 +020061#define FIO_OS_HAVE_SOCKLEN_T
62typedef int fio_socklen_t;
63
Jens Axboec00a2282011-07-08 20:56:06 +020064static inline int blockdev_invalidate_cache(struct fio_file *f)
65{
66 return EINVAL;
67}
68
69static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
70{
Jens Axboe0ec15d62011-07-11 10:48:51 +020071 disk_describe_type_ext_t dext;
Jens Axboec00a2282011-07-08 20:56:06 +020072
Jens Axboe0ec15d62011-07-11 10:48:51 +020073 if (!ioctl(f->fd, DIOC_DESCRIBE_EXT, &dext)) {
74 unsigned long long lba;
75
76 lba = ((uint64_t) dext.maxsva_high << 32) | dext.maxsva_low;
77 *bytes = lba * dext.lgblksz;
Jens Axboec00a2282011-07-08 20:56:06 +020078 return 0;
79 }
80
Jens Axboe564e49f2011-07-08 21:10:30 +020081 *bytes = 0;
Jens Axboec00a2282011-07-08 20:56:06 +020082 return errno;
Jens Axboec00a2282011-07-08 20:56:06 +020083}
84
Jens Axboe0ec15d62011-07-11 10:48:51 +020085static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
86{
87 return blockdev_size(f, bytes);
88}
89
Jens Axboec00a2282011-07-08 20:56:06 +020090static inline unsigned long long os_phys_mem(void)
91{
Jens Axboe8c9ca2e2011-07-11 10:25:35 +020092 unsigned long long ret;
93 struct pst_static pst;
94 union pstun pu;
Jens Axboec00a2282011-07-08 20:56:06 +020095
Jens Axboe8c9ca2e2011-07-11 10:25:35 +020096 pu.pst_static = &pst;
97 if (pstat(PSTAT_STATIC, pu, sizeof(pst), 0, 0) == -1)
Jens Axboec00a2282011-07-08 20:56:06 +020098 return 0;
99
Jens Axboe8c9ca2e2011-07-11 10:25:35 +0200100 ret = pst.physical_memory;
101 ret *= pst.page_size;
102 return ret;
Jens Axboec00a2282011-07-08 20:56:06 +0200103}
104
105#define FIO_HAVE_CPU_ONLINE_SYSCONF
106
107static inline unsigned int cpus_online(void)
108{
109 return mpctl(MPC_GETNUMSPUS, 0, NULL);
110}
111
112#endif