From: Eric Engestrom Date: Thu, 1 Aug 2019 21:33:05 +0000 (+0100) Subject: util/os_misc: use detect_os.h to start uncoupling from gallium X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7f12a66ad5be2ec190000622dddff58600bc9053;p=mesa.git util/os_misc: use detect_os.h to start uncoupling from gallium Signed-off-by: Eric Engestrom Reviewed-by: Matt Turner --- diff --git a/src/util/os_misc.c b/src/util/os_misc.c index b6359ed195c..755970430b0 100644 --- a/src/util/os_misc.c +++ b/src/util/os_misc.c @@ -47,13 +47,13 @@ #endif -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_CYGWIN) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HURD) +#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD # include -#elif defined(PIPE_OS_APPLE) || defined(PIPE_OS_BSD) +#elif DETECT_OS_APPLE || DETECT_OS_BSD # include -#elif defined(PIPE_OS_HAIKU) +#elif DETECT_OS_HAIKU # include -#elif defined(PIPE_OS_WINDOWS) +#elif DETECT_OS_WINDOWS # include #else #error unexpected platform in os_sysinfo.c @@ -124,7 +124,7 @@ os_get_option(const char *name) bool os_get_total_physical_memory(uint64_t *size) { -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_CYGWIN) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HURD) +#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD const long phys_pages = sysconf(_SC_PHYS_PAGES); const long page_size = sysconf(_SC_PAGE_SIZE); @@ -133,25 +133,25 @@ os_get_total_physical_memory(uint64_t *size) *size = (uint64_t)phys_pages * (uint64_t)page_size; return true; -#elif defined(PIPE_OS_APPLE) || defined(PIPE_OS_BSD) +#elif DETECT_OS_APPLE || DETECT_OS_BSD size_t len = sizeof(*size); int mib[2]; mib[0] = CTL_HW; -#if defined(PIPE_OS_APPLE) +#if DETECT_OS_APPLE mib[1] = HW_MEMSIZE; -#elif defined(PIPE_OS_NETBSD) || defined(PIPE_OS_OPENBSD) +#elif DETECT_OS_NETBSD || DETECT_OS_OPENBSD mib[1] = HW_PHYSMEM64; -#elif defined(PIPE_OS_FREEBSD) +#elif DETECT_OS_FREEBSD mib[1] = HW_REALMEM; -#elif defined(PIPE_OS_DRAGONFLY) +#elif DETECT_OS_DRAGONFLY mib[1] = HW_PHYSMEM; #else #error Unsupported *BSD #endif return (sysctl(mib, 2, size, &len, NULL, 0) == 0); -#elif defined(PIPE_OS_HAIKU) +#elif DETECT_OS_HAIKU system_info info; status_t ret; @@ -161,7 +161,7 @@ os_get_total_physical_memory(uint64_t *size) *size = (uint64_t)info.max_pages * (uint64_t)B_PAGE_SIZE; return true; -#elif defined(PIPE_OS_WINDOWS) +#elif DETECT_OS_WINDOWS MEMORYSTATUSEX status; BOOL ret; diff --git a/src/util/os_misc.h b/src/util/os_misc.h index 403c8ee6ec5..8ac3eeff377 100644 --- a/src/util/os_misc.h +++ b/src/util/os_misc.h @@ -35,10 +35,11 @@ #define _OS_MISC_H_ +#include "detect_os.h" #include "pipe/p_compiler.h" -#if defined(PIPE_OS_UNIX) +#if DETECT_OS_UNIX # include /* for kill() */ # include /* getpid() */ #endif @@ -56,7 +57,7 @@ extern "C" { # define os_break() __asm("int3") #elif defined(PIPE_CC_MSVC) # define os_break() __debugbreak() -#elif defined(PIPE_OS_UNIX) +#elif DETECT_OS_UNIX # define os_break() kill(getpid(), SIGTRAP) #else # define os_break() abort()