diff --git a/Makefile b/Makefile index c7b05a9a..a9ae2e7a 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,13 @@ LDFLAGS = CFLAGS += -D_XOPEN_SOURCE=600 CXXFLAGS += -D_XOPEN_SOURCE=600 +# RLIMIT_MEMLOCK came in BSD, is not specified in POSIX.1, +# and on macOS its availability depends on enabling Darwin extensions +ifeq ($(UNAME_S),Darwin) + CFLAGS += -D_DARWIN_C_SOURCE + CXXFLAGS += -D_DARWIN_C_SOURCE +endif + # OS specific # TODO: support Windows ifeq ($(UNAME_S),Linux) diff --git a/examples/talk-llama/llama-util.h b/examples/talk-llama/llama-util.h index 3cac9f68..4d510063 100644 --- a/examples/talk-llama/llama-util.h +++ b/examples/talk-llama/llama-util.h @@ -186,8 +186,8 @@ struct llama_mmap { if (prefetch > 0) { // Advise the kernel to preload the mapped memory - if (madvise(addr, std::min(file->size, prefetch), MADV_WILLNEED)) { - fprintf(stderr, "warning: madvise(.., MADV_WILLNEED) failed: %s\n", + if (posix_madvise(addr, std::min(file->size, prefetch), POSIX_MADV_WILLNEED)) { + fprintf(stderr, "warning: posix_madvise(.., POSIX_MADV_WILLNEED) failed: %s\n", strerror(errno)); } }