[PATCH] Compile and works on OpenSolaris (tested on BeleniX)
authorJens Axboe <axboe@suse.de>
Thu, 8 Jun 2006 11:25:41 +0000 (13:25 +0200)
committerJens Axboe <axboe@suse.de>
Thu, 8 Jun 2006 11:25:41 +0000 (13:25 +0200)
Makefile.solaris [new file with mode: 0644]
fio.c
init.c
os-freebsd.h
os-linux.h
os-solaris.h [new file with mode: 0644]
os.h

diff --git a/Makefile.solaris b/Makefile.solaris
new file mode 100644 (file)
index 0000000..295928c
--- /dev/null
@@ -0,0 +1,28 @@
+CC     = gcc
+CFLAGS = -Wall -O2 -g -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+PROGS  = fio
+SCRIPTS = fio_generate_plots
+
+OBJS = fio.o ioengines.o init.o stat.o log.o time.o md5.o crc32.o
+
+all: depend $(PROGS) $(SCRIPTS)
+
+fio: fio.o ioengines.o init.o stat.o log.o time.o md5.o crc32.o
+       $(CC) $(CFLAGS) -o $@ $(OBJS) -lc -lpthread -lm -laio -lrt
+
+clean:
+       -rm -f *.o .depend cscope.out $(PROGS)
+
+depend:
+       @$(CC) -MM $(ALL_CFLAGS) *.c 1> .depend
+
+cscope:
+       @cscope -b
+
+INSTALL = install
+prefix = /usr/local
+bindir = $(prefix)/bin
+
+install: $(PROGS) $(SCRIPTS)
+       $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
+       $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
diff --git a/fio.c b/fio.c
index 7aef8225ee6e8b07cab164eb505f0d8e94f590ee..1248971aca2a75da0fc32074898312ebe0895696 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -1173,7 +1173,7 @@ static int setup_file(struct thread_data *td)
        }
 
        if (td->odirect)
        }
 
        if (td->odirect)
-               flags |= O_DIRECT;
+               flags |= OS_O_DIRECT;
 
        if (td_write(td) || td_rw(td)) {
                if (td->filetype == FIO_TYPE_FILE) {
 
        if (td_write(td) || td_rw(td)) {
                if (td->filetype == FIO_TYPE_FILE) {
diff --git a/init.c b/init.c
index 0ec8e9d5ddd41f88a5e775d1a19d04ca1d001cea..3117d60e5d68e530fde45fed328b7b6bb4e39108 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1013,7 +1013,7 @@ static void free_shm(void)
        struct shmid_ds sbuf;
 
        if (threads) {
        struct shmid_ds sbuf;
 
        if (threads) {
-               shmdt(threads);
+               shmdt((void *) threads);
                threads = NULL;
                shmctl(shm_id, IPC_RMID, &sbuf);
        }
                threads = NULL;
                shmctl(shm_id, IPC_RMID, &sbuf);
        }
index 41672d4e10231b3be0a8d3be4e92aa8c45478fe1..6a4c11b634aa064ba37335b8e78f7c01858b9d98 100644 (file)
@@ -9,6 +9,7 @@
 #undef FIO_HAVE_CPU_AFFINITY
 #undef FIO_HAVE_DISK_UTIL
 #undef FIO_HAVE_SGIO
 #undef FIO_HAVE_CPU_AFFINITY
 #undef FIO_HAVE_DISK_UTIL
 #undef FIO_HAVE_SGIO
+#define FIO_HAVE_ODIRECT
 
 #define OS_MAP_ANON            (MAP_ANON)
 
 
 #define OS_MAP_ANON            (MAP_ANON)
 
index f9094cb437148929c336ac1cd109ef15300188de..5f0ef8214fcac07a32d629dbaea2fa9a9a209d15 100644 (file)
@@ -16,6 +16,7 @@
 #define FIO_HAVE_IOPRIO
 #define FIO_HAVE_SPLICE
 #define FIO_HAVE_IOSCHED_SWITCH
 #define FIO_HAVE_IOPRIO
 #define FIO_HAVE_SPLICE
 #define FIO_HAVE_IOSCHED_SWITCH
+#define FIO_HAVE_ODIRECT
 
 #define OS_MAP_ANON            (MAP_ANONYMOUS)
 
 
 #define OS_MAP_ANON            (MAP_ANONYMOUS)
 
diff --git a/os-solaris.h b/os-solaris.h
new file mode 100644 (file)
index 0000000..e7f4e4e
--- /dev/null
@@ -0,0 +1,60 @@
+#ifndef FIO_OS_SOLARIS_H
+#define FIO_OS_SOLARIS_H
+
+#undef FIO_HAVE_LIBAIO
+#define FIO_HAVE_POSIXAIO
+#undef FIO_HAVE_FADVISE
+#undef FIO_HAVE_CPU_AFFINITY
+#undef FIO_HAVE_DISK_UTIL
+#undef FIO_HAVE_SGIO
+#undef FIO_HAVE_ODIRECT
+
+#define OS_MAP_ANON            (MAP_ANON)
+
+typedef unsigned long os_cpu_mask_t;
+typedef unsigned int os_random_state_t;
+
+/*
+ * FIXME
+ */
+static inline int blockdev_size(int fd, unsigned long long *bytes)
+{
+       return 1;
+}
+
+static inline unsigned long long os_phys_mem(void)
+{
+#if 0
+       int mib[2] = { CTL_HW, HW_PHYSMEM };
+       unsigned long long mem;
+       size_t len = sizeof(mem);
+
+       sysctl(mib, 2, &mem, &len, NULL, 0);
+       return mem;
+#else
+       return 0;
+#endif
+}
+
+static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
+{
+       srand(seed);
+}
+
+static inline long os_random_long(os_random_state_t *rs)
+{
+       long val;
+
+       val = rand_r(rs);
+       return val;
+}
+
+static inline double os_random_double(os_random_state_t *rs)
+{
+       double val;
+
+       val = (double) rand_r(rs);
+       return val;
+}
+
+#endif
diff --git a/os.h b/os.h
index 093a722ebfce1d80f78a76bd99c58fdb01d1d906..1160f44c435c967625c152829f889b5bcbd5951d 100644 (file)
--- a/os.h
+++ b/os.h
@@ -5,6 +5,8 @@
 #include "os-linux.h"
 #elif defined(__FreeBSD__)
 #include "os-freebsd.h"
 #include "os-linux.h"
 #elif defined(__FreeBSD__)
 #include "os-freebsd.h"
+#elif defined(__sun__)
+#include "os-solaris.h"
 #else
 #error "unsupported os"
 #endif
 #else
 #error "unsupported os"
 #endif
 #define ioprio_set(which, who, prio)   (0)
 #endif
 
 #define ioprio_set(which, who, prio)   (0)
 #endif
 
+#ifndef FIO_HAVE_ODIRECT
+#define OS_O_DIRECT                    (0)
+#endif
+
 struct thread_data;
 extern int fio_libaio_init(struct thread_data *);
 extern int fio_posixaio_init(struct thread_data *);
 struct thread_data;
 extern int fio_libaio_init(struct thread_data *);
 extern int fio_posixaio_init(struct thread_data *);