Support for Mac OS 10.6.2
authorJens Axboe <jens.axboe@oracle.com>
Mon, 14 Dec 2009 22:08:42 +0000 (23:08 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 14 Dec 2009 22:08:42 +0000 (23:08 +0100)
Contributed by Small Tree, adopted to newer fio version by me.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Makefile.mac [new file with mode: 0644]
arch/arch.h
helpers.c
helpers.h
os/os-mac.h [new file with mode: 0644]
os/os.h

diff --git a/Makefile.mac b/Makefile.mac
new file mode 100644 (file)
index 0000000..7574f00
--- /dev/null
@@ -0,0 +1,73 @@
+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 -arch i386 -arch x86_64 -arch ppc
+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
+
+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/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 */*.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
+
+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
index 64593748302c2fbddd15e2243780a40679ee0ba0..9f2a566ebfe3dfdb6305bcd97bf569e2872a8c86 100644 (file)
@@ -23,7 +23,7 @@ enum {
 #include "arch-x86.h"
 #elif defined(__x86_64__)
 #include "arch-x86_64.h"
 #include "arch-x86.h"
 #elif defined(__x86_64__)
 #include "arch-x86_64.h"
-#elif defined(__powerpc__) || defined(__powerpc64__)
+#elif defined(__powerpc__) || defined(__powerpc64__) || defined(__ppc__)
 #include "arch-ppc.h"
 #elif defined(__ia64__)
 #include "arch-ia64.h"
 #include "arch-ppc.h"
 #elif defined(__ia64__)
 #include "arch-ia64.h"
index f314ebb96ce7aa4c43302ad5f0e03dbd46ae83fb..9c76d305ba51ba6b35fdd8a6bfd6816b417464c7 100644 (file)
--- a/helpers.c
+++ b/helpers.c
@@ -24,3 +24,16 @@ int __weak inet_aton(const char *cp, struct in_addr *inp)
 {
        return 0;
 }
 {
        return 0;
 }
+
+int __weak clock_gettime(clockid_t clk_id, struct timespec *ts)
+{
+       struct timeval tv;
+       int ret;
+
+       ret = gettimeofday(&tv, NULL);
+
+       ts->ts_sec = tv.tv_sec;
+       ts->ts_nsec = tv.tv_usec * 1000;
+
+       return ret;
+}
index a3a773bc098fe0edd762ed99c449dcf0ae8c3801..61a3f2b2be1fd4edce64f0c603479418d11927b1 100644 (file)
--- a/helpers.h
+++ b/helpers.h
@@ -6,5 +6,6 @@ struct in_addr;
 extern int __weak posix_memalign(void **ptr, size_t align, size_t size);
 extern int __weak posix_fallocate(int fd, off_t offset, off_t len);
 extern int __weak inet_aton(const char *cp, struct in_addr *inp);
 extern int __weak posix_memalign(void **ptr, size_t align, size_t size);
 extern int __weak posix_fallocate(int fd, off_t offset, off_t len);
 extern int __weak inet_aton(const char *cp, struct in_addr *inp);
+extern int __weak clock_gettime(clockid_t clk_id, struct timespec *ts);
 
 #endif
 
 #endif
diff --git a/os/os-mac.h b/os/os-mac.h
new file mode 100644 (file)
index 0000000..77c2165
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef FIO_OS_APPLE_H
+#define FIO_OS_APPLE_H
+
+#include <errno.h>
+#include <sys/sysctl.h>
+
+#ifndef CLOCK_MONOTONIC
+#define CLOCK_MONOTONIC 1
+#endif
+
+#ifndef CLOCK_REALTIME
+#define CLOCK_REALTIME 1
+#endif
+
+#define FIO_HAVE_POSIXAIO
+#define FIO_USE_GENERIC_BDEV_SIZE
+
+#define OS_MAP_ANON            MAP_ANON
+
+typedef unsigned long os_cpu_mask_t;
+typedef unsigned int os_random_state_t;
+typedef unsigned int clockid_t;
+
+static inline int blockdev_invalidate_cache(int fd)
+{
+       return EINVAL;
+}
+
+static inline unsigned long long os_phys_mem(void)
+{
+       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;
+}
+
+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;
+}
+
+#endif
diff --git a/os/os.h b/os/os.h
index 1afb4b227521e3846b087d401b7297201d45cbbb..bed12814ffd26021590e5054e1b0be560b8e088d 100644 (file)
--- a/os/os.h
+++ b/os/os.h
@@ -7,6 +7,8 @@
 #include "os-freebsd.h"
 #elif defined(__sun__)
 #include "os-solaris.h"
 #include "os-freebsd.h"
 #elif defined(__sun__)
 #include "os-solaris.h"
+#elif defined(__APPLE__)
+#include "os-mac.h"
 #else
 #error "unsupported os"
 #endif
 #else
 #error "unsupported os"
 #endif