os-hpux.h revision e97c14423a5688d7adfb342c16363c263cb741f9
1c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#ifndef FIO_OS_HPUX_H
2c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#define FIO_OS_HPUX_H
3c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
4c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#include <errno.h>
5c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#include <unistd.h>
6c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#include <sys/ioctl.h>
7c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#include <sys/fcntl.h>
8c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#include <sys/fadvise.h>
9c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#include <sys/mman.h>
10c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#include <sys/mpctl.h>
110ec15d6ca9fee3c2b0f19b3520f5b77fb2378d51Jens Axboe#include <sys/diskio.h>
128c9ca2e6fe5a400fcba3a7dd45a33effea8298e0Jens Axboe#include <sys/param.h>
138c9ca2e6fe5a400fcba3a7dd45a33effea8298e0Jens Axboe#include <sys/pstat.h>
14d48a9799a3d3cbe3c41658d6e41d6791b33e926cJens Axboe#include <time.h>
15d48a9799a3d3cbe3c41658d6e41d6791b33e926cJens Axboe#include <aio.h>
16c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
17c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#include "../file.h"
18c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
19c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#define FIO_HAVE_POSIXAIO
20c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#define FIO_HAVE_ODIRECT
21c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#define FIO_USE_GENERIC_RAND
22c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#define FIO_HAVE_CLOCK_MONOTONIC
23c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#define FIO_HAVE_PSHARED_MUTEX
24c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#define FIO_HAVE_FADVISE
250ec15d6ca9fee3c2b0f19b3520f5b77fb2378d51Jens Axboe#define FIO_HAVE_CHARDEV_SIZE
26baa6677be0054fa1dab3000881098f7e943bfc5dJens Axboe#define FIO_HAVE_FALLOCATE
27baa6677be0054fa1dab3000881098f7e943bfc5dJens Axboe#define FIO_HAVE_POSIXAIO_FSYNC
28893b37c668638714f8240a1dcf8548836fe51233Jens Axboe#define FIO_HAVE_FDATASYNC
29c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
30c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#define OS_MAP_ANON		MAP_ANONYMOUS
31c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#define OS_MSG_DONTWAIT		0
32c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
33c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#define POSIX_MADV_DONTNEED	MADV_DONTNEED
34c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#define POSIX_MADV_SEQUENTIAL	MADV_SEQUENTIAL
35c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#define POSIX_MADV_RANDOM	MADV_RANDOM
36c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#define posix_madvise(ptr, sz, hint)	madvise((ptr), (sz), (hint))
37c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
38d48a9799a3d3cbe3c41658d6e41d6791b33e926cJens Axboe#ifndef CLOCK_MONOTONIC
39d48a9799a3d3cbe3c41658d6e41d6791b33e926cJens Axboe#define CLOCK_MONOTONIC		CLOCK_REALTIME
40d48a9799a3d3cbe3c41658d6e41d6791b33e926cJens Axboe#endif
41d48a9799a3d3cbe3c41658d6e41d6791b33e926cJens Axboe
42d48a9799a3d3cbe3c41658d6e41d6791b33e926cJens Axboe#ifndef MSG_WAITALL
43d48a9799a3d3cbe3c41658d6e41d6791b33e926cJens Axboe#define MSG_WAITALL	0x40
44d48a9799a3d3cbe3c41658d6e41d6791b33e926cJens Axboe#endif
45d48a9799a3d3cbe3c41658d6e41d6791b33e926cJens Axboe
46e97c14423a5688d7adfb342c16363c263cb741f9Jens Axboe#define FIO_OS_HAVE_AIOCB_TYPEDEF
47e97c14423a5688d7adfb342c16363c263cb741f9Jens Axboetypedef struct aiocb64 os_aiocb_t;
48e97c14423a5688d7adfb342c16363c263cb741f9Jens Axboe
49c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboestatic inline int blockdev_invalidate_cache(struct fio_file *f)
50c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe{
51c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe	return EINVAL;
52c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe}
53c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
54c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboestatic inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
55c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe{
560ec15d6ca9fee3c2b0f19b3520f5b77fb2378d51Jens Axboe	disk_describe_type_ext_t dext;
57c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
580ec15d6ca9fee3c2b0f19b3520f5b77fb2378d51Jens Axboe	if (!ioctl(f->fd, DIOC_DESCRIBE_EXT, &dext)) {
590ec15d6ca9fee3c2b0f19b3520f5b77fb2378d51Jens Axboe		unsigned long long lba;
600ec15d6ca9fee3c2b0f19b3520f5b77fb2378d51Jens Axboe
610ec15d6ca9fee3c2b0f19b3520f5b77fb2378d51Jens Axboe		lba = ((uint64_t) dext.maxsva_high << 32) | dext.maxsva_low;
620ec15d6ca9fee3c2b0f19b3520f5b77fb2378d51Jens Axboe		*bytes = lba * dext.lgblksz;
63c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe		return 0;
64c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe	}
65c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
66564e49f329dd526842a29f4086fff727bc4d0ba0Jens Axboe	*bytes = 0;
67c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe	return errno;
68c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe}
69c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
700ec15d6ca9fee3c2b0f19b3520f5b77fb2378d51Jens Axboestatic inline int chardev_size(struct fio_file *f, unsigned long long *bytes)
710ec15d6ca9fee3c2b0f19b3520f5b77fb2378d51Jens Axboe{
720ec15d6ca9fee3c2b0f19b3520f5b77fb2378d51Jens Axboe	return blockdev_size(f, bytes);
730ec15d6ca9fee3c2b0f19b3520f5b77fb2378d51Jens Axboe}
740ec15d6ca9fee3c2b0f19b3520f5b77fb2378d51Jens Axboe
75c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboestatic inline unsigned long long os_phys_mem(void)
76c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe{
778c9ca2e6fe5a400fcba3a7dd45a33effea8298e0Jens Axboe	unsigned long long ret;
788c9ca2e6fe5a400fcba3a7dd45a33effea8298e0Jens Axboe	struct pst_static pst;
798c9ca2e6fe5a400fcba3a7dd45a33effea8298e0Jens Axboe	union pstun pu;
80c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
818c9ca2e6fe5a400fcba3a7dd45a33effea8298e0Jens Axboe	pu.pst_static = &pst;
828c9ca2e6fe5a400fcba3a7dd45a33effea8298e0Jens Axboe	if (pstat(PSTAT_STATIC, pu, sizeof(pst), 0, 0) == -1)
83c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe		return 0;
84c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
858c9ca2e6fe5a400fcba3a7dd45a33effea8298e0Jens Axboe	ret = pst.physical_memory;
868c9ca2e6fe5a400fcba3a7dd45a33effea8298e0Jens Axboe	ret *= pst.page_size;
878c9ca2e6fe5a400fcba3a7dd45a33effea8298e0Jens Axboe	return ret;
88c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe}
89c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
90c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#define FIO_HAVE_CPU_ONLINE_SYSCONF
91c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
92c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboestatic inline unsigned int cpus_online(void)
93c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe{
94c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe	return mpctl(MPC_GETNUMSPUS, 0, NULL);
95c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe}
96c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe
97c00a22894b82ff53b42c1e741a7b4828199a1388Jens Axboe#endif
98