Commit 7222ec27 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Fix MacOS compilation (probably)

parent 9ae29b39
...@@ -25,9 +25,6 @@ ...@@ -25,9 +25,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#ifndef WIN32
#include <malloc.h>
static int check_align (size_t align) static int check_align (size_t align)
{ {
for (size_t i = sizeof (void *); i != 0; i *= 2) for (size_t i = sizeof (void *); i != 0; i *= 2)
...@@ -36,6 +33,9 @@ static int check_align (size_t align) ...@@ -36,6 +33,9 @@ static int check_align (size_t align)
return EINVAL; return EINVAL;
} }
#if !defined (WIN32) && !defined (__APPLE__)
#include <malloc.h>
int posix_memalign (void **ptr, size_t align, size_t size) int posix_memalign (void **ptr, size_t align, size_t size)
{ {
if (check_align (align)) if (check_align (align))
...@@ -52,4 +52,16 @@ int posix_memalign (void **ptr, size_t align, size_t size) ...@@ -52,4 +52,16 @@ int posix_memalign (void **ptr, size_t align, size_t size)
*ptr = p; *ptr = p;
return 0; return 0;
} }
#else
int posix_memalign (void **ptr, size_t align, size_t size)
{
if (check_align (align))
return EINVAL;
*ptr = NULL;
return size ? ENOMEM : 0;
}
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment