Contributed by Small Tree, adopted to newer fio version by me.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
--- /dev/null
+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
#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"
{
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;
+}
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
--- /dev/null
+#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
#include "os-freebsd.h"
#elif defined(__sun__)
#include "os-solaris.h"
+#elif defined(__APPLE__)
+#include "os-mac.h"
#else
#error "unsupported os"
#endif