From c031b6c5d911e6bdeedcd3ea25e89bd82749337b Mon Sep 17 00:00:00 2001 From: slaren Date: Sat, 2 Sep 2023 23:42:54 +0200 Subject: [PATCH] compatibility fixes for MAP_ANONYMOUS --- ggml-alloc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ggml-alloc.c b/ggml-alloc.c index d744282f5eb4c..3265f62ec3cb4 100644 --- a/ggml-alloc.c +++ b/ggml-alloc.c @@ -1,3 +1,8 @@ +// defines MAP_ANONYMOUS +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + #include "ggml-alloc.h" #include "ggml.h" #include @@ -9,11 +14,9 @@ #if __has_include() #include #if defined(_POSIX_MAPPED_FILES) + #include #include #endif - #if defined(_POSIX_MEMLOCK_RANGE) - #include - #endif #endif #endif @@ -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 }