util/os_misc: use detect_os.h to start uncoupling from gallium
authorEric Engestrom <eric.engestrom@intel.com>
Thu, 1 Aug 2019 21:33:05 +0000 (22:33 +0100)
committerEric Engestrom <eric.engestrom@intel.com>
Fri, 2 Aug 2019 17:38:52 +0000 (18:38 +0100)
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/util/os_misc.c
src/util/os_misc.h

index b6359ed195ca847ecd9eb14ac8e967bde0d84ed4..755970430b00ace5111a7c8bce05f5128308f98a 100644 (file)
 #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 <unistd.h>
-#elif defined(PIPE_OS_APPLE) || defined(PIPE_OS_BSD)
+#elif DETECT_OS_APPLE || DETECT_OS_BSD
 #  include <sys/sysctl.h>
-#elif defined(PIPE_OS_HAIKU)
+#elif DETECT_OS_HAIKU
 #  include <kernel/OS.h>
-#elif defined(PIPE_OS_WINDOWS)
+#elif DETECT_OS_WINDOWS
 #  include <windows.h>
 #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;
 
index 403c8ee6ec5c345669f810649fe89486e3507072..8ac3eeff3773aa4941c97abd16917c01815819aa 100644 (file)
 #define _OS_MISC_H_
 
 
+#include "detect_os.h"
 #include "pipe/p_compiler.h"
 
 
-#if defined(PIPE_OS_UNIX)
+#if DETECT_OS_UNIX
 #  include <signal.h> /* for kill() */
 #  include <unistd.h> /* 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()