From fd94a32468ea7652382d5717b18118fcab08dba3 Mon Sep 17 00:00:00 2001 From: liuhaitao Date: Mon, 31 Aug 2020 16:58:26 +0800 Subject: [PATCH] sysconf: add _SC_PAGESIZE sysconf support Also implement getpagesize() based on sysconf(_SC_PAGESIZE). Change-Id: I812eb8f34ed602f7bc12c4cafafcebc0d98fd136 Signed-off-by: liuhaitao --- include/unistd.h | 1 + libs/libc/unistd/lib_sysconf.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/unistd.h b/include/unistd.h index 0f132f4df0..c4460ebb7f 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -274,6 +274,7 @@ #define link(p1, p2) symlink((p1), (p2)) #define fdatasync(f) fsync(f) #define getdtablesize(f) ((int)sysconf(_SC_OPEN_MAX)) +#define getpagesize(f) ((int)sysconf(_SC_PAGESIZE)) /**************************************************************************** * Public Data diff --git a/libs/libc/unistd/lib_sysconf.c b/libs/libc/unistd/lib_sysconf.c index 6da23940f9..0c3b613818 100644 --- a/libs/libc/unistd/lib_sysconf.c +++ b/libs/libc/unistd/lib_sysconf.c @@ -241,6 +241,13 @@ long sysconf(int name) return 1; #endif + case _SC_PAGESIZE: +#ifdef CONFIG_MM_PGSIZE + return CONFIG_MM_PGSIZE; +#else + return 1; +#endif + default: #if 0 /* Assume valid but not implemented for the time being */ errcode = EINVAL;