From 2c0ecd28459b6a1b236c865defb5ef76ce8bfa02 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 8 Jun 2006 13:25:41 +0200 Subject: [PATCH] [PATCH] Compile and works on OpenSolaris (tested on BeleniX) --- Makefile.solaris | 28 ++++++++++++++++++++++ fio.c | 2 +- init.c | 2 +- os-freebsd.h | 1 + os-linux.h | 1 + os-solaris.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ os.h | 6 +++++ 7 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 Makefile.solaris create mode 100644 os-solaris.h diff --git a/Makefile.solaris b/Makefile.solaris new file mode 100644 index 00000000..295928c7 --- /dev/null +++ b/Makefile.solaris @@ -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 7aef8225..1248971a 100644 --- a/fio.c +++ b/fio.c @@ -1173,7 +1173,7 @@ static int setup_file(struct thread_data *td) } if (td->odirect) - flags |= O_DIRECT; + flags |= OS_O_DIRECT; if (td_write(td) || td_rw(td)) { if (td->filetype == FIO_TYPE_FILE) { diff --git a/init.c b/init.c index 0ec8e9d5..3117d60e 100644 --- a/init.c +++ b/init.c @@ -1013,7 +1013,7 @@ static void free_shm(void) struct shmid_ds sbuf; if (threads) { - shmdt(threads); + shmdt((void *) threads); threads = NULL; shmctl(shm_id, IPC_RMID, &sbuf); } diff --git a/os-freebsd.h b/os-freebsd.h index 41672d4e..6a4c11b6 100644 --- a/os-freebsd.h +++ b/os-freebsd.h @@ -9,6 +9,7 @@ #undef FIO_HAVE_CPU_AFFINITY #undef FIO_HAVE_DISK_UTIL #undef FIO_HAVE_SGIO +#define FIO_HAVE_ODIRECT #define OS_MAP_ANON (MAP_ANON) diff --git a/os-linux.h b/os-linux.h index f9094cb4..5f0ef821 100644 --- a/os-linux.h +++ b/os-linux.h @@ -16,6 +16,7 @@ #define FIO_HAVE_IOPRIO #define FIO_HAVE_SPLICE #define FIO_HAVE_IOSCHED_SWITCH +#define FIO_HAVE_ODIRECT #define OS_MAP_ANON (MAP_ANONYMOUS) diff --git a/os-solaris.h b/os-solaris.h new file mode 100644 index 00000000..e7f4e4ee --- /dev/null +++ b/os-solaris.h @@ -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 093a722e..1160f44c 100644 --- a/os.h +++ b/os.h @@ -5,6 +5,8 @@ #include "os-linux.h" #elif defined(__FreeBSD__) #include "os-freebsd.h" +#elif defined(__sun__) +#include "os-solaris.h" #else #error "unsupported os" #endif @@ -39,6 +41,10 @@ #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 *); -- 2.25.1