st/mesa: fix resource leak in try_pbo_readpixels
[mesa.git] / src / mesa / x86 / common_x86.c
index b401c354a33ebd2c20a958ed05155caec4cce1ac..1c8640514ab64563f140cda9a83a1958e90c8ab9 100644 (file)
@@ -42,7 +42,7 @@
 #include <sys/types.h>
 #include <sys/sysctl.h>
 #endif
-#if defined(USE_SSE_ASM) && defined(__OpenBSD__)
+#if defined(USE_SSE_ASM) && (defined(__OpenBSD__) || defined(__NetBSD__))
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #include <machine/cpu.h>
@@ -68,12 +68,12 @@ static int detection_debug = GL_FALSE;
 
 /* No reason for this to be public.
  */
-extern GLuint  _ASMAPI _mesa_x86_has_cpuid(void);
-extern void    _ASMAPI _mesa_x86_cpuid(GLuint op, GLuint *reg_eax, GLuint *reg_ebx, GLuint *reg_ecx, GLuint *reg_edx);
-extern GLuint  _ASMAPI _mesa_x86_cpuid_eax(GLuint op);
-extern GLuint  _ASMAPI _mesa_x86_cpuid_ebx(GLuint op);
-extern GLuint  _ASMAPI _mesa_x86_cpuid_ecx(GLuint op);
-extern GLuint  _ASMAPI _mesa_x86_cpuid_edx(GLuint op);
+extern GLuint _mesa_x86_has_cpuid(void);
+extern void _mesa_x86_cpuid(GLuint op, GLuint *reg_eax, GLuint *reg_ebx, GLuint *reg_ecx, GLuint *reg_edx);
+extern GLuint _mesa_x86_cpuid_eax(GLuint op);
+extern GLuint _mesa_x86_cpuid_ebx(GLuint op);
+extern GLuint _mesa_x86_cpuid_ecx(GLuint op);
+extern GLuint _mesa_x86_cpuid_edx(GLuint op);
 
 
 #if defined(USE_SSE_ASM)
@@ -224,7 +224,7 @@ _mesa_get_x86_features(void)
 #ifdef USE_X86_ASM
    _mesa_x86_cpu_features = 0x0;
 
-   if (_mesa_getenv( "MESA_NO_ASM")) {
+   if (getenv( "MESA_NO_ASM")) {
       return;
    }
 
@@ -307,7 +307,7 @@ _mesa_get_x86_features(void)
 
 #ifdef USE_MMX_ASM
    if ( cpu_has_mmx ) {
-      if ( _mesa_getenv( "MESA_NO_MMX" ) == 0 ) {
+      if ( getenv( "MESA_NO_MMX" ) == 0 ) {
         if (detection_debug)
            _mesa_debug(NULL, "MMX cpu detected.\n");
       } else {
@@ -318,7 +318,7 @@ _mesa_get_x86_features(void)
 
 #ifdef USE_3DNOW_ASM
    if ( cpu_has_3dnow ) {
-      if ( _mesa_getenv( "MESA_NO_3DNOW" ) == 0 ) {
+      if ( getenv( "MESA_NO_3DNOW" ) == 0 ) {
         if (detection_debug)
            _mesa_debug(NULL, "3DNow! cpu detected.\n");
       } else {
@@ -329,10 +329,10 @@ _mesa_get_x86_features(void)
 
 #ifdef USE_SSE_ASM
    if ( cpu_has_xmm ) {
-      if ( _mesa_getenv( "MESA_NO_SSE" ) == 0 ) {
+      if ( getenv( "MESA_NO_SSE" ) == 0 ) {
         if (detection_debug)
            _mesa_debug(NULL, "SSE cpu detected.\n");
-         if ( _mesa_getenv( "MESA_FORCE_SSE" ) == 0 ) {
+         if ( getenv( "MESA_FORCE_SSE" ) == 0 ) {
             _mesa_check_os_sse_support();
          }
       } else {
@@ -343,16 +343,18 @@ _mesa_get_x86_features(void)
 #endif
 
 #elif defined(USE_X86_64_ASM)
-   unsigned int uninitialized_var(eax), uninitialized_var(ebx),
-                uninitialized_var(ecx), uninitialized_var(edx);
+   {
+      unsigned int eax, ebx, ecx, edx;
 
-   /* Always available on x86-64. */
-   _mesa_x86_cpu_features |= X86_FEATURE_XMM | X86_FEATURE_XMM2;
+      /* Always available on x86-64. */
+      _mesa_x86_cpu_features |= X86_FEATURE_XMM | X86_FEATURE_XMM2;
 
-   __get_cpuid(1, &eax, &ebx, &ecx, &edx);
+      if (!__get_cpuid(1, &eax, &ebx, &ecx, &edx))
+         return;
 
-   if (ecx & bit_SSE4_1)
-      _mesa_x86_cpu_features |= X86_FEATURE_SSE4_1;
+      if (ecx & bit_SSE4_1)
+         _mesa_x86_cpu_features |= X86_FEATURE_SSE4_1;
+   }
 #endif /* USE_X86_64_ASM */
 
    (void) detection_debug;