Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / util / u_cpu_detect.c
index ae553d887010c0f3d5b09ba4022a23c4e54261cd..ab064957382c1fd77c9e64fa49159c8f450d4cee 100644 (file)
@@ -33,6 +33,7 @@
  */
 
 #include "pipe/p_config.h"
  */
 
 #include "pipe/p_config.h"
+#include "pipe/p_compiler.h"
 
 #include "util/u_debug.h"
 #include "u_cpu_detect.h"
 
 #include "util/u_debug.h"
 #include "u_cpu_detect.h"
 #endif
 #endif
 
 #endif
 #endif
 
-#if defined(PIPE_OS_NETBSD) || defined(PIPE_OS_OPENBSD)
+#if defined(PIPE_OS_BSD)
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #include <machine/cpu.h>
 #endif
 
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #include <machine/cpu.h>
 #endif
 
-#if defined(PIPE_OS_FREEBSD) || defined(PIPE_OS_DRAGONFLY)
-#include <sys/types.h>
-#include <sys/sysctl.h>
+#if defined(PIPE_OS_FREEBSD)
 #if __has_include(<sys/auxv.h>)
 #include <sys/auxv.h>
 #define HAVE_ELF_AUX_INFO
 #if __has_include(<sys/auxv.h>)
 #include <sys/auxv.h>
 #define HAVE_ELF_AUX_INFO
@@ -85,7 +84,7 @@
 
 
 #ifdef DEBUG
 
 
 #ifdef DEBUG
-DEBUG_GET_ONCE_BOOL_OPTION(dump_cpu, "GALLIUM_DUMP_CPU", FALSE)
+DEBUG_GET_ONCE_BOOL_OPTION(dump_cpu, "GALLIUM_DUMP_CPU", false)
 #endif
 
 
 #endif
 
 
@@ -96,7 +95,7 @@ static int has_cpuid(void);
 #endif
 
 
 #endif
 
 
-#if defined(PIPE_ARCH_PPC) && !defined(PIPE_OS_APPLE) && !defined(PIPE_OS_LINUX)
+#if defined(PIPE_ARCH_PPC) && !defined(PIPE_OS_APPLE) && !defined(PIPE_OS_BSD) && !defined(PIPE_OS_LINUX)
 static jmp_buf  __lv_powerpc_jmpbuf;
 static volatile sig_atomic_t __lv_powerpc_canjump = 0;
 
 static jmp_buf  __lv_powerpc_jmpbuf;
 static volatile sig_atomic_t __lv_powerpc_canjump = 0;
 
@@ -125,8 +124,12 @@ check_os_altivec_support(void)
 #endif
 #if defined(__ALTIVEC__) && defined(__VSX__)
 /* Do nothing */
 #endif
 #if defined(__ALTIVEC__) && defined(__VSX__)
 /* Do nothing */
-#elif defined(PIPE_OS_APPLE)
+#elif defined(PIPE_OS_APPLE) || defined(PIPE_OS_NETBSD) || defined(PIPE_OS_OPENBSD)
+#ifdef HW_VECTORUNIT
    int sels[2] = {CTL_HW, HW_VECTORUNIT};
    int sels[2] = {CTL_HW, HW_VECTORUNIT};
+#else
+   int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC};
+#endif
    int has_vu = 0;
    int len = sizeof (has_vu);
    int err;
    int has_vu = 0;
    int len = sizeof (has_vu);
    int err;
@@ -138,7 +141,19 @@ check_os_altivec_support(void)
          util_cpu_caps.has_altivec = 1;
       }
    }
          util_cpu_caps.has_altivec = 1;
       }
    }
-#elif defined(PIPE_OS_LINUX) /* !PIPE_OS_APPLE */
+#elif defined(PIPE_OS_FREEBSD) /* !PIPE_OS_APPLE && !PIPE_OS_NETBSD && !PIPE_OS_OPENBSD */
+   unsigned long hwcap = 0;
+#ifdef HAVE_ELF_AUX_INFO
+   elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
+#else
+   size_t len = sizeof(hwcap);
+   sysctlbyname("hw.cpu_features", &hwcap, &len, NULL, 0);
+#endif
+   if (hwcap & PPC_FEATURE_HAS_ALTIVEC)
+      util_cpu_caps.has_altivec = 1;
+   if (hwcap & PPC_FEATURE_HAS_VSX)
+      util_cpu_caps.has_vsx = 1;
+#elif defined(PIPE_OS_LINUX) /* !PIPE_OS_FREEBSD */
 #if defined(PIPE_ARCH_PPC_64)
     Elf64_auxv_t aux;
 #else
 #if defined(PIPE_ARCH_PPC_64)
     Elf64_auxv_t aux;
 #else
@@ -159,7 +174,7 @@ check_os_altivec_support(void)
        }
        close(fd);
     }
        }
        close(fd);
     }
-#else /* !PIPE_OS_APPLE && !PIPE_OS_LINUX */
+#else /* !PIPE_OS_APPLE && !PIPE_OS_BSD && !PIPE_OS_LINUX */
    /* not on Apple/Darwin or Linux, do it the brute-force way */
    /* this is borrowed from the libmpeg2 library */
    signal(SIGILL, sigill_handler);
    /* not on Apple/Darwin or Linux, do it the brute-force way */
    /* this is borrowed from the libmpeg2 library */
    signal(SIGILL, sigill_handler);