fio netbsd support
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>
Wed, 12 May 2010 13:06:46 +0000 (15:06 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 12 May 2010 13:06:46 +0000 (15:06 +0200)
Preliminary NetBSD support.

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Makefile.NetBSD [new file with mode: 0644]
mutex.c
os/os-freebsd.h
os/os-mac.h
os/os.h

diff --git a/Makefile.NetBSD b/Makefile.NetBSD
new file mode 100644 (file)
index 0000000..2fb089e
--- /dev/null
@@ -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 e148430b618e5cae1c1fd93c1134f47910198ec6..abe073f4ffdf7d49ee92500db8d89e254def2852 100644 (file)
--- 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);
index 8d965aadf87ec84372f83bd07029f2e414c35992..d1313e8ccb868ccdf8bdc11974cd8b384bb684f8 100644 (file)
@@ -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;
index be25458f0165d0a7c590f500c3c9051cd35505f4..1b786f832f0911f7844774343cc4b70ab30171e7 100644 (file)
@@ -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 d128f027e81c79e6bcdef2b32d75c8e5c49be74e..b7fce80c6f7ce0070146a2f3986e15891108f045 100644 (file)
--- 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