From 2134dcc5ecba232a1eabfbda39d347e89f8cf9d5 Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 15 Oct 2023 13:09:56 +0200 Subject: [PATCH] libc: Add madvise stub --- libc/include/sys/mman.h | 6 ++++++ libc/src/sys/mman.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/libc/include/sys/mman.h b/libc/include/sys/mman.h index 1b605f79..d2c3b3ee 100644 --- a/libc/include/sys/mman.h +++ b/libc/include/sys/mman.h @@ -14,6 +14,9 @@ #define MS_ASYNC 2 #define MS_INVALIDATE 4 +#define MADV_NORMAL 0 +#define MADV_RANDOM 1 + #ifdef __cplusplus extern "C" { @@ -28,6 +31,9 @@ extern "C" /* Write modified shared memory back to its associated file. */ int msync(void* addr, size_t len, int flags); + /* Give advice about the use of memory. */ + int madvise(void* addr, size_t length, int advice); + /* Create a new POSIX shared memory object. */ int shm_open(const char* name, int oflag, mode_t mode); diff --git a/libc/src/sys/mman.cpp b/libc/src/sys/mman.cpp index 6f321dc9..2481dbd7 100644 --- a/libc/src/sys/mman.cpp +++ b/libc/src/sys/mman.cpp @@ -28,6 +28,12 @@ extern "C" __errno_return(rc, int); } + int madvise(void*, size_t, int) + { + // FIXME: Use this information to improve performance. + return 0; + } + int shm_open(const char* name, int oflag, mode_t mode) { char buf[BUFSIZ];