mmapped heaps: fix the file descriptor argument to mmap for the BSDs

On the BSDs, the file descriptor passed to mmap when using MAP_ANON
must be -1.  Passing 0 causes mmap to fail.
This commit is contained in:
Kris Katterjohn 2019-10-04 20:39:37 -05:00
parent 650be6adc0
commit 25d4807f50

2
gc.c
View file

@ -501,7 +501,7 @@ sexp_heap sexp_make_heap (size_t size, size_t max_size, size_t chunk_size) {
sexp_heap h; sexp_heap h;
#if SEXP_USE_MMAP_GC #if SEXP_USE_MMAP_GC
h = mmap(NULL, sexp_heap_pad_size(size), PROT_READ|PROT_WRITE|PROT_EXEC, h = mmap(NULL, sexp_heap_pad_size(size), PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_ANON|MAP_PRIVATE, 0, 0); MAP_ANON|MAP_PRIVATE, -1, 0);
if (h == MAP_FAILED) return NULL; if (h == MAP_FAILED) return NULL;
#else #else
h = sexp_malloc(sexp_heap_pad_size(size)); h = sexp_malloc(sexp_heap_pad_size(size));