mesa: Drop _mesa_getenv() wrapper.
[mesa.git] / src / mesa / math / m_debug_norm.c
index 392e7c6bfd4104fd8b4e8f79840670d99582e6b1..00e72be54e9d432dbd0f6134b55ee3f3fb880b21 100644 (file)
@@ -1,10 +1,8 @@
-/* $Id: m_debug_norm.c,v 1.8 2002/01/05 20:51:12 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  4.1
  *
- * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
  *
  * Authors:
- *    Gareth Hughes <gareth@valinux.com>
+ *    Gareth Hughes
  */
 
-#include "glheader.h"
-#include "context.h"
-#include "macros.h"
-#include "mem.h"
-#include "mmath.h"
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/imports.h"
 
 #include "m_matrix.h"
 #include "m_xform.h"
 #include "m_debug_util.h"
 
 
-#ifdef DEBUG  /* This code only used for debugging */
+#ifdef __UNIXOS2__
+/* The linker doesn't like empty files */
+static char dummy;
+#endif
+
+#ifdef DEBUG_MATH  /* This code only used for debugging */
 
 
 static int m_norm_identity[16] = {
@@ -162,7 +165,7 @@ static void ref_norm_transform_normalize( const GLmatrix *mat,
            /* Hmmm, don't know how we could test the precalculated
             * length case...
             */
-            scale = 1.0 / sqrt( len );
+            scale = INV_SQRTF( len );
            SCALE_SCALAR_3V( out[i], scale, t );
          } else {
             out[i][0] = out[i][1] = out[i][2] = 0;
@@ -181,6 +184,15 @@ static void ref_norm_transform_normalize( const GLmatrix *mat,
  * Normal transformation tests
  */
 
+static void init_matrix( GLfloat *m )
+{
+   m[0] = 63.0; m[4] = 43.0; m[ 8] = 29.0; m[12] = 43.0;
+   m[1] = 55.0; m[5] = 17.0; m[ 9] = 31.0; m[13] =  7.0;
+   m[2] = 44.0; m[6] =  9.0; m[10] =  7.0; m[14] =  3.0;
+   m[3] = 11.0; m[7] = 23.0; m[11] = 91.0; m[15] =  9.0;
+}
+
+
 static int test_norm_function( normal_func func, int mtype, long *cycles )
 {
    GLvector4f source[1], dest[1], dest2[1], ref[1], ref2[1];
@@ -196,7 +208,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
 
    (void) cycles;
 
-   mat->m = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
+   mat->m = _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
    mat->inv = m = mat->m;
 
    init_matrix( m );
@@ -218,7 +230,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
          case VAR:
             break;
          default:
-            abort();
+            exit(1);
          }
       }
    }
@@ -229,7 +241,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
       ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 );
       for ( j = 0 ; j < 3 ; j++ )
          s[i][j] = rnd();
-      length[i] = 1 / sqrt( LEN_SQUARED_3FV( s[i] ) );
+      length[i] = INV_SQRTF( LEN_SQUARED_3FV( s[i] ) );
    }
 
    source->data = (GLfloat(*)[4]) s;
@@ -315,7 +327,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
       }
    }
 
-   ALIGN_FREE( mat->m );
+   _mesa_align_free( mat->m );
    return 1;
 }
 
@@ -350,7 +362,7 @@ void _math_test_all_normal_transform_functions( char *description )
         char buf[100];
         sprintf( buf, "_mesa_normal_tab[0][%s] failed test (%s)",
                  norm_strings[mtype], description );
-        _mesa_problem( NULL, buf );
+        _mesa_problem( NULL, "%s", buf );
       }
 
 #ifdef RUN_DEBUG_BENCHMARK
@@ -363,10 +375,9 @@ void _math_test_all_normal_transform_functions( char *description )
 #ifdef RUN_DEBUG_BENCHMARK
    if ( mesa_profile ) {
       printf( "\n" );
-      fflush( stdout );
    }
 #endif
 }
 
 
-#endif /* DEBUG */
+#endif /* DEBUG_MATH */