Skip to content

Commit

Permalink
Fix anonymous mmap for Darwin/BSD
Browse files Browse the repository at this point in the history
OS X (and probably all BSDs) spell the flag for anonymous mmap
MAP_ANON instead of Linux's MAP_ANONYMOUS.  Until someone else has a
more clever idea of how to abstract out this particular platform
gotcha, simply #define MAP_ANONYMOUS as MAP_ANON when the latter is
available and the former isn't.
  • Loading branch information
Benabik committed Aug 19, 2013
1 parent 98efde5 commit 2b5207c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/platform/posix/mmap.c
Expand Up @@ -2,6 +2,11 @@
#include <sys/mman.h>
#include "platform/mmap.h"

/* MAP_ANONYMOUS is Linux, MAP_ANON is BSD */
#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
#define MAP_ANONYMOUS MAP_ANON
#endif

void *MVM_platform_alloc_pages(size_t size, int executable)
{
void *block = mmap(NULL, size,
Expand Down

0 comments on commit 2b5207c

Please sign in to comment.