From: Ammar Faizi Date: Tue, 10 Jan 2023 07:24:33 +0000 (+0100) Subject: nolibc/sys: Implement `getpagesize(2)` function X-Git-Tag: v6.3-rc1~132^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7efd762e97c87f07b0a93e428e5ce3436715f538;p=thirdparty%2Flinux.git nolibc/sys: Implement `getpagesize(2)` function This function returns the page size used by the running kernel. The page size value is taken from the auxiliary vector at 'AT_PAGESZ' key. 'getpagesize(2)' is assumed as a syscall becuase the manpage placement of this function is in entry 2 ('man 2 getpagesize') despite there is no real 'getpagesize(2)' syscall in the Linux syscall table. Define this function in 'sys.h'. Signed-off-by: Ammar Faizi Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 47bf67668860a..b5f8cd35c03be 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -19,6 +19,7 @@ #include #include #include +#include #include "arch.h" #include "errno.h" @@ -499,6 +500,26 @@ pid_t gettid(void) return sys_gettid(); } +static unsigned long getauxval(unsigned long key); + +/* + * long getpagesize(void); + */ + +static __attribute__((unused)) +long getpagesize(void) +{ + long ret; + + ret = getauxval(AT_PAGESZ); + if (!ret) { + SET_ERRNO(ENOENT); + return -1; + } + + return ret; +} + /* * int gettimeofday(struct timeval *tv, struct timezone *tz);