Initial HP-UX port
authorJens Axboe <jaxboe@fusionio.com>
Fri, 8 Jul 2011 18:56:06 +0000 (20:56 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Fri, 8 Jul 2011 18:56:06 +0000 (20:56 +0200)
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Makefile
lib/getopt.h
options.c
os/os-hpux.h [new file with mode: 0644]
os/os.h

index b609deb3d2b57a8ba7191fffc83bca8e39a10897..dade0ae6649f60ac2dec83d742e07b95dbe10bbc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -13,45 +13,49 @@ SOURCE = gettime.c fio.c ioengines.c init.c stat.c log.c time.c filesetup.c \
                eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
                rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
                lib/num2str.c $(wildcard crc/*.c) engines/cpu.c \
-               engines/mmap.c engines/sync.c engines/null.c engines/net.c \
-               memalign.c
+               engines/mmap.c engines/sync.c engines/null.c memalign.c
 
 ifeq ($(UNAME), Linux)
   SOURCE += diskutil.c fifo.c blktrace.c helpers.c cgroup.c trim.c \
                engines/libaio.c engines/posixaio.c engines/sg.c \
                engines/splice.c engines/syslet-rw.c engines/guasi.c \
-               engines/binject.c profiles/tiobench.c
+               engines/binject.c profiles/tiobench.c engines/net.c
   LIBS += -lpthread -ldl -lrt -laio
   CFLAGS += -rdynamic
 endif
 ifeq ($(UNAME), SunOS)
   SOURCE += fifo.c lib/strsep.c helpers.c engines/posixaio.c \
-               engines/solarisaio.c
+               engines/solarisaio.c engines/net.c
   LIBS  += -lpthread -ldl -laio -lrt -lnsl -lsocket
   CPPFLAGS += -D__EXTENSIONS__
 endif
 ifeq ($(UNAME), FreeBSD)
-  SOURCE += helpers.c engines/posixaio.c
+  SOURCE += helpers.c engines/posixaio.c engines/net.c
   LIBS  += -lpthread -lrt
   CFLAGS += -rdynamic
 endif
 ifeq ($(UNAME), NetBSD)
-  SOURCE += helpers.c engines/posixaio.c
+  SOURCE += helpers.c engines/posixaio.c engines/net.c
   LIBS  += -lpthread -lrt
   CFLAGS += -rdynamic
 endif
 ifeq ($(UNAME), AIX)
-  SOURCE += fifo.c helpers.c lib/getopt_long.c engines/posixaio.c
+  SOURCE += fifo.c helpers.c lib/getopt_long.c engines/posixaio.c engines/net.c
   LIBS  += -lpthread -ldl -lrt
   CFLAGS += -rdynamic
   CPPFLAGS += -D_LARGE_FILES -D__ppc__
 endif
+ifeq ($(UNAME), HP-UX)
+  SOURCE += fifo.c helpers.c lib/getopt_long.c lib/strsep.c
+  LIBS   += -lpthread -dl -lrt
+  CPPFLAGS += -D_LARGE_FILES
+endif
 ifeq ($(UNAME), Darwin)
-  SOURCE += helpers.c engines/posixaio.c
+  SOURCE += helpers.c engines/posixaio.c engines/net.c
   LIBS  += -lpthread -ldl
 endif
 ifneq (,$(findstring CYGWIN,$(UNAME)))
-  SOURCE += engines/windowsaio.c
+  SOURCE += engines/windowsaio.c engines/net.c
   LIBS  += -lpthread -lrt
 endif
 
index 56fe3bf481f9b5b128443fbeb06a1c17e6b3b66f..0dd4608cd8a6bbd671631db8cb6e7a4a0c721d23 100644 (file)
@@ -1,4 +1,5 @@
 #ifndef _AIX
+#ifndef __hpux
 
 #include <getopt.h>
 
@@ -23,4 +24,5 @@ enum {
 int getopt_long_only(int, char *const *, const char *, const struct option *, int *);
 
 #endif /* _GETOPT_H */
+#endif /* __hpux */
 #endif /* _AIX */
index bd7dc99fddeffa7c74c3d51fa945fa62fe1763e1..f1c0ea788ddf0db28fce608ea05ec3962c92237a 100644 (file)
--- a/options.c
+++ b/options.c
@@ -329,7 +329,7 @@ static int str_cpumask_cb(void *data, unsigned long long *val)
                return 1;
        }
 
-       max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
+       max_cpu = cpus_online();
 
        for (i = 0; i < sizeof(int) * 8; i++) {
                if ((1 << i) & *val) {
@@ -366,7 +366,7 @@ static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
        strip_blank_front(&str);
        strip_blank_end(str);
 
-       max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
+       max_cpu = cpus_online();
 
        while ((cpu = strsep(&str, ",")) != NULL) {
                char *str2, *cpu2;
@@ -2095,7 +2095,7 @@ void fio_keywords_init(void)
        sprintf(buf, "%llu", mb_memory);
        fio_keywords[1].replace = strdup(buf);
 
-       l = sysconf(_SC_NPROCESSORS_ONLN);
+       l = cpus_online();
        sprintf(buf, "%lu", l);
        fio_keywords[2].replace = strdup(buf);
 }
diff --git a/os/os-hpux.h b/os/os-hpux.h
new file mode 100644 (file)
index 0000000..a36cb70
--- /dev/null
@@ -0,0 +1,72 @@
+#ifndef FIO_OS_HPUX_H
+#define FIO_OS_HPUX_H
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/fcntl.h>
+#include <sys/fadvise.h>
+#include <sys/mman.h>
+#include <sys/mpctl.h>
+
+#include "../file.h"
+
+#define FIO_HAVE_POSIXAIO
+#define FIO_HAVE_ODIRECT
+#define FIO_USE_GENERIC_RAND
+#define FIO_HAVE_CLOCK_MONOTONIC
+#define FIO_HAVE_PSHARED_MUTEX
+#define FIO_HAVE_FADVISE
+
+#define OS_MAP_ANON            MAP_ANONYMOUS
+#define OS_MSG_DONTWAIT                0
+
+#define POSIX_MADV_DONTNEED    MADV_DONTNEED
+#define POSIX_MADV_SEQUENTIAL  MADV_SEQUENTIAL
+#define POSIX_MADV_RANDOM      MADV_RANDOM
+#define posix_madvise(ptr, sz, hint)   madvise((ptr), (sz), (hint))
+
+static inline int blockdev_invalidate_cache(struct fio_file *f)
+{
+       return EINVAL;
+}
+
+static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
+{
+#if 0
+       struct devinfo info;
+
+       if (!ioctl(f->fd, IOCINFO, &info)) {
+               *bytes = (unsigned long long)info.un.scdk.numblks *
+                               info.un.scdk.blksize;
+               return 0;
+       }
+
+       return errno;
+#else
+       return 0;
+#endif
+}
+
+static inline unsigned long long os_phys_mem(void)
+{
+#if 0
+       long mem = sysconf(_SC_AIX_REALMEM);
+
+       if (mem == -1)
+               return 0;
+
+       return (unsigned long long) mem * 1024;
+#else
+       return 0;
+#endif
+}
+
+#define FIO_HAVE_CPU_ONLINE_SYSCONF
+
+static inline unsigned int cpus_online(void)
+{
+       return mpctl(MPC_GETNUMSPUS, 0, NULL);
+}
+
+#endif
diff --git a/os/os.h b/os/os.h
index 4bbdd623a987c174122b2577b2899332605a0a0c..3df7b41be4b6447c73783abf03808b38ca2ee586 100644 (file)
--- a/os/os.h
+++ b/os/os.h
@@ -18,6 +18,8 @@
 #include "os-mac.h"
 #elif defined(_AIX)
 #include "os-aix.h"
+#elif defined(__hpux)
+#include "os-hpux.h"
 #elif defined(__CYGWIN__)
 #include "os-windows.h"
 #else
@@ -178,4 +180,11 @@ static inline unsigned long long get_fs_size(const char *path)
 }
 #endif
 
+#ifndef FIO_HAVE_CPU_ONLINE_SYSCONF
+static inline unsigned int cpus_online(void)
+{
+       return sysconf(_SC_NPROCESSORS_ONLN);
+}
+#endif
+
 #endif