From 059572b400b4689058294837b837c4abc9774827 Mon Sep 17 00:00:00 2001 From: Nathan Moinvaziri Date: Fri, 19 Mar 2021 20:45:13 -0700 Subject: [PATCH] Support for posix_memalign in FreeBSD 11. #873 Co-authored-by: Hans Kristian Rosbach Co-authored-by: concatime --- zutil_p.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zutil_p.h b/zutil_p.h index a5f2e525..7dc2e3d3 100644 --- a/zutil_p.h +++ b/zutil_p.h @@ -7,13 +7,19 @@ #ifdef __APPLE__ # include +#elif defined(__FreeBSD__) +# include +# include #else # include #endif /* Function to allocate 16 or 64-byte aligned memory */ static inline void *zng_alloc(size_t size) { -#if defined(_WIN32) +#if defined(__FreeBSD__) + void *ptr; + return posix_memalign(&ptr, 64, size) ? NULL : ptr; +#elif defined(_WIN32) return (void *)_aligned_malloc(size, 64); #elif defined(__APPLE__) return (void *)malloc(size); /* MacOS always aligns to 16 bytes */ -- 2.47.2