From 7452440e1efb40680fdc951eebc7499a95a62f86 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 12 May 2010 15:06:46 +0200 Subject: [PATCH] fio netbsd support Preliminary NetBSD support. Signed-off-by: YAMAMOTO Takashi Signed-off-by: Jens Axboe --- Makefile.NetBSD | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ mutex.c | 4 +++ os/os-freebsd.h | 2 -- os/os-mac.h | 1 - os/os.h | 3 ++ 5 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 Makefile.NetBSD diff --git a/Makefile.NetBSD b/Makefile.NetBSD new file mode 100644 index 00000000..2fb089ef --- /dev/null +++ b/Makefile.NetBSD @@ -0,0 +1,75 @@ +CC = gcc +DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG +OPTFLAGS= -O2 -g $(EXTFLAGS) +CFLAGS = -Wwrite-strings -Wall -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(OPTFLAGS) $(DEBUGFLAGS) -rdynamic +PROGS = fio +SCRIPTS = fio_generate_plots +OBJS = gettime.o fio.o ioengines.o init.o stat.o log.o time.o filesetup.o \ + eta.o verify.o memory.o io_u.o parse.o mutex.o options.o \ + rbtree.o smalloc.o filehash.o helpers.o profile.o debug.o + +OBJS += crc/crc7.o +OBJS += crc/crc16.o +OBJS += crc/crc32.o +OBJS += crc/crc32c.o +OBJS += crc/crc32c-intel.o +OBJS += crc/crc64.o +OBJS += crc/sha1.o +OBJS += crc/sha256.o +OBJS += crc/sha512.o +OBJS += crc/md5.o + +OBJS += engines/cpu.o +OBJS += engines/mmap.o +OBJS += engines/posixaio.o +OBJS += engines/sync.o +OBJS += engines/null.o +OBJS += engines/net.o + +SOURCE = eta.c filehash.c filesetup.c fio.c gettime.c init.c ioengines.c \ + io_u.c log.c memory.c mutex.c options.c parse.c rbtree.c smalloc.c \ + stat.c parse.c crc/*.c engines/cpu.c engines/mmap.c \ + engines/posixaio.c engines/sync.c engines/null.c engines/net.c \ + *.h arch/*.h compiler/*.h crc/*.h lib/*.h \ + os/indirect.h os/kcompat.h os/os-freebsd.h os/os.h os/syslet.h + +ifneq ($(findstring $(MAKEFLAGS),s),s) +ifndef V + QUIET_CC = @echo ' ' CC $@; + QUIET_DEP = @echo ' ' DEP $@; +endif +endif + +INSTALL = install +prefix = /usr/local +bindir = $(prefix)/bin +mandir = $(prefix)/man + +%.o: %.c + $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $< +fio: $(OBJS) + $(QUIET_CC)$(CC) $(CFLAGS) -o $@ $(filter %.o,$^) $(EXTLIBS) -lpthread -lm -lrt + +depend: + $(QUIET_DEP)$(CC) -MM $(ALL_CFLAGS) $(SOURCE) 1> .depend + +$(PROGS): depend + +all: depend $(PROGS) $(SCRIPTS) + +clean: + -rm -f .depend cscope.out $(OBJS) $(PROGS) core.* core + +cscope: + @cscope -b + +install: $(PROGS) $(SCRIPTS) + $(INSTALL) -m755 -d $(DESTDIR)$(bindir) + $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir) + $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1 + +ifneq ($(wildcard .depend),) +include .depend +endif diff --git a/mutex.c b/mutex.c index e148430b..abe073f4 100644 --- a/mutex.c +++ b/mutex.c @@ -65,14 +65,18 @@ struct fio_mutex *fio_mutex_init(int value) log_err("pthread_mutexattr_init: %s\n", strerror(ret)); goto err; } +#ifdef FIO_HAVE_PSHARED_MUTEX ret = pthread_mutexattr_setpshared(&attr, mflag); if (ret) { log_err("pthread_mutexattr_setpshared: %s\n", strerror(ret)); goto err; } +#endif pthread_condattr_init(&cond); +#ifdef FIO_HAVE_PSHARED_MUTEX pthread_condattr_setpshared(&cond, mflag); +#endif pthread_cond_init(&mutex->cond, &cond); ret = pthread_mutex_init(&mutex->lock, &attr); diff --git a/os/os-freebsd.h b/os/os-freebsd.h index 8d965aad..d1313e8c 100644 --- a/os/os-freebsd.h +++ b/os/os-freebsd.h @@ -11,8 +11,6 @@ #define OS_MAP_ANON MAP_ANON -typedef unsigned long os_cpu_mask_t; - static inline int blockdev_invalidate_cache(int fd) { return EINVAL; diff --git a/os/os-mac.h b/os/os-mac.h index be25458f..1b786f83 100644 --- a/os/os-mac.h +++ b/os/os-mac.h @@ -18,7 +18,6 @@ #define OS_MAP_ANON MAP_ANON -typedef unsigned long os_cpu_mask_t; typedef unsigned int clockid_t; typedef off_t off64_t; diff --git a/os/os.h b/os/os.h index d128f027..b7fce80c 100644 --- a/os/os.h +++ b/os/os.h @@ -8,6 +8,8 @@ #include "os-linux.h" #elif defined(__FreeBSD__) #include "os-freebsd.h" +#elif defined(__NetBSD__) +#include "os-netbsd.h" #elif defined(__sun__) #include "os-solaris.h" #elif defined(__APPLE__) @@ -48,6 +50,7 @@ #define fio_getaffinity(pid, mask) do { } while (0) #define fio_cpu_clear(mask, cpu) do { } while (0) #define fio_cpuset_exit(mask) (-1) +typedef unsigned long os_cpu_mask_t; #endif #ifndef FIO_HAVE_IOPRIO -- 2.25.1