Skip to content

Commit

Permalink
compatibility fixes for MAP_ANONYMOUS
Browse files Browse the repository at this point in the history
  • Loading branch information
slaren committed Sep 2, 2023
1 parent 96f3662 commit c031b6c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ggml-alloc.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// defines MAP_ANONYMOUS
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include "ggml-alloc.h"
#include "ggml.h"
#include <assert.h>
Expand All @@ -9,11 +14,9 @@
#if __has_include(<unistd.h>)
#include <unistd.h>
#if defined(_POSIX_MAPPED_FILES)
#include <sys/types.h>
#include <sys/mman.h>
#endif
#if defined(_POSIX_MEMLOCK_RANGE)
#include <sys/resource.h>
#endif
#endif
#endif

Expand Down Expand Up @@ -313,7 +316,7 @@ static void * alloc_vmem(size_t size) {
#ifdef _WIN32
return VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS);
#else
return mmap(NULL, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
return mmap(NULL, size, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0);
#endif
}

Expand Down

0 comments on commit c031b6c

Please sign in to comment.