From 0a8e088d1b3f9f199d41bb04616cf6fbaec91b83 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Mon, 7 Apr 2014 13:39:03 +0200 Subject: [PATCH] Fix build on OS X * There is no direct equivalent of O_DIRECT, just warn. * error(3) is glibc-specific. * There were a couple missing includes. --- file/file.c | 1 + fork/fork.c | 1 + io/io.c | 6 ++++++ lib/copy.c | 4 +++- mmap/mmap.c | 1 + mutsem/mutsem.c | 1 + thread/thread.c | 1 + 7 files changed, 14 insertions(+), 1 deletion(-) diff --git a/file/file.c b/file/file.c index 179d933..22092ec 100644 --- a/file/file.c +++ b/file/file.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "benchmark.h" diff --git a/fork/fork.c b/fork/fork.c index bca935c..900c2a8 100644 --- a/fork/fork.c +++ b/fork/fork.c @@ -1,5 +1,6 @@ #include #include +#include // mesure copy-on-write, also with pthread diff --git a/io/io.c b/io/io.c index 9a9be73..a093b3c 100644 --- a/io/io.c +++ b/io/io.c @@ -11,8 +11,14 @@ #define _GNU_SOURCE #include #include +#include #include +#ifndef O_DIRECT +#warning O_DIRECT not defined on this platform +#define O_DIRECT 0 +#endif + #include "benchmark.h" #include "copy.h" diff --git a/lib/copy.c b/lib/copy.c index 657ffbe..240302f 100644 --- a/lib/copy.c +++ b/lib/copy.c @@ -118,7 +118,9 @@ void read_write (timer *t, recorder *rec, char *in, char *out, char *s = NULL; err = posix_memalign((void **) &s, 512, len); if (err != 0) { - error(0, err, "posix_memalign"); + // The value of errno is indeterminate after a call to posix_memalign() + errno = err; // so set it to use perror() + perror("posix_memalign"); exit(EXIT_FAILURE); } diff --git a/mmap/mmap.c b/mmap/mmap.c index 7f3a5a9..c79b5c5 100644 --- a/mmap/mmap.c +++ b/mmap/mmap.c @@ -5,6 +5,7 @@ #include #include +#include #include "benchmark.h" #include "copy.h" diff --git a/mutsem/mutsem.c b/mutsem/mutsem.c index f85bac4..4def923 100644 --- a/mutsem/mutsem.c +++ b/mutsem/mutsem.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "benchmark.h" diff --git a/thread/thread.c b/thread/thread.c index a8549eb..3cedef1 100644 --- a/thread/thread.c +++ b/thread/thread.c @@ -1,5 +1,6 @@ #include #include +#include #include #include "benchmark.h"