From 43865a5045a4146e0a8311dd087dd27343c3bc61 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Sat, 19 Sep 2015 14:43:28 +0200 Subject: [PATCH] Fixed BSD check macros --- src/compat/mockfile.c | 12 ++++++------ src/compat/posix.h | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/compat/mockfile.c b/src/compat/mockfile.c index 8687767..edae531 100644 --- a/src/compat/mockfile.c +++ b/src/compat/mockfile.c @@ -30,9 +30,9 @@ #include "internal.h" #include "criterion/redirect.h" -#if defined(BSD) || defined(__unix__) +#if defined(OS_BSD) || defined(__unix__) -# ifdef BSD +# ifdef OS_BSD typedef int cr_count; typedef int cr_retcount; typedef fpos_t cr_off; @@ -71,7 +71,7 @@ static inline size_t off_safe_add(size_t size, size_t cur, cr_off off) { static cr_retcount mock_file_read(void *cookie, char *buf, cr_count count) { struct memfile *mf = cookie; -# ifdef BSD +# ifdef OS_BSD if (count < 0) errno_return(EINVAL, (cr_retcount) -1); # endif @@ -87,7 +87,7 @@ static cr_retcount mock_file_read(void *cookie, char *buf, cr_count count) { static cr_retcount mock_file_write(void *cookie, const char *buf, cr_count count) { struct memfile *mf = cookie; -# ifdef BSD +# ifdef OS_BSD if (count < 0) errno_return(EINVAL, (cr_retcount) -1); # endif @@ -115,7 +115,7 @@ static cr_retcount mock_file_write(void *cookie, const char *buf, cr_count count return count; } -# ifdef BSD +# ifdef OS_BSD static cr_off mock_file_seek(void *cookie, cr_off off, int whence) { struct memfile *mf = cookie; switch (whence) { @@ -149,7 +149,7 @@ static int mock_file_close(void *cookie) { #endif FILE *cr_mock_file_size(size_t max_size) { -#if defined(__unix__) || defined(BSD) +#if defined(__unix__) || defined(OS_BSD) struct memfile *cookie = malloc(sizeof (struct memfile)); *cookie = (struct memfile) { .max_size = max_size, diff --git a/src/compat/posix.h b/src/compat/posix.h index a001bbb..930225a 100644 --- a/src/compat/posix.h +++ b/src/compat/posix.h @@ -28,6 +28,14 @@ # define VANILLA_WIN32 #endif +# if defined(BSD) \ + || defined(__FreeBSD__) \ + || defined(__NetBSD__) \ + || defined(__OpenBSD__) \ + || defined(__DragonFly__) +# define OS_BSD 1 +# endif + # if !defined(_POSIX_SOURCE) # define _POSIX_SOURCE 1 # define TMP_POSIX