aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-12-07 16:35:01 -0800
committerH. Peter Anvin <hpa@linux.intel.com>2010-12-07 16:35:01 -0800
commita6f3691938a78833fc1643a5dd6db66dbef81644 (patch)
treeb0f58b37efe6674660ead4ff0029c5a4b96980cb /utils
parentd6fa7f83ac4e4c6498f6a28e5c90ecc3f2f6aa62 (diff)
downloadsyslinux-a6f3691938a78833fc1643a5dd6db66dbef81644.tar.gz
syslinux-a6f3691938a78833fc1643a5dd6db66dbef81644.tar.xz
syslinux-a6f3691938a78833fc1643a5dd6db66dbef81644.zip
memdiskfind: abstract get page size so we can compile against klibc
klibc doesn't have sysconf(), because it involves a hideously inefficient multiplex. Thus, if _SC_PAGESIZE is not defined, invoke getpagesize(). Call the routine get_page_size() so it doesn't conflict on a platform which has both sysconf(_SC_PAGESIZE) and getpagesize(). Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/memdiskfind.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/utils/memdiskfind.c b/utils/memdiskfind.c
index decc788f..815f8bc1 100644
--- a/utils/memdiskfind.c
+++ b/utils/memdiskfind.c
@@ -94,13 +94,23 @@ static size_t memlimit(void)
return maxram;
}
+static inline size_t get_page_size(void)
+{
+#ifdef _SC_PAGESIZE
+ return sysconf(_SC_PAGESIZE);
+#else
+ /* klibc, for one, doesn't have sysconf() due to excessive multiplex */
+ return getpagesize();
+#endif
+}
+
int main(int argc, char *argv[])
{
const char *map;
int memfd;
size_t fbm;
const char *ptr, *end;
- size_t page = sysconf(_SC_PAGESIZE);
+ size_t page = get_page_size();
size_t mapbase, maplen;
int err = 1;