From fe42a3d0eb4e25a694a8f8c030b00256db87dcb6 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 6 Aug 2025 18:20:44 +0200 Subject: [PATCH] meson/util: properly detect sysconf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's two functions that use sysconf(), and they don't seem to agree on what combination of platforms supports the function. Let's perform proper function detection instead. Acked-by: Lionel Landwerlin Reviewed-by: Eric Engestrom Reviewed-by: Marek Olšák Part-of: --- meson.build | 1 + src/util/os_misc.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 883185fa27d..1b97379e81a 100644 --- a/meson.build +++ b/meson.build @@ -1414,6 +1414,7 @@ functions_to_detect = { 'qsort_s': '', 'posix_fallocate': '', 'secure_getenv': '', + 'sysconf': '#include ', } foreach f, prefix: functions_to_detect diff --git a/src/util/os_misc.c b/src/util/os_misc.c index 0689fec920c..6ec04832288 100644 --- a/src/util/os_misc.c +++ b/src/util/os_misc.c @@ -284,7 +284,7 @@ exit_mutex: bool os_get_total_physical_memory(uint64_t *size) { -#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD || DETECT_OS_MANAGARM +#if HAVE_SYSCONF const long phys_pages = sysconf(_SC_PHYS_PAGES); const long page_size = sysconf(_SC_PAGESIZE); @@ -412,7 +412,7 @@ os_get_available_system_memory(uint64_t *size) bool os_get_page_size(uint64_t *size) { -#if DETECT_OS_POSIX_LITE && !DETECT_OS_APPLE && !DETECT_OS_HAIKU +#if HAVE_SYSCONF const long page_size = sysconf(_SC_PAGESIZE); if (page_size <= 0)