X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmath%2Fm_debug_util.h;h=25ee029cebc1192ec6aa28ac7cdb4fcfc2b33ce2;hb=f0993f81c7fab4ceb99b010d8ee2facbf4fdc737;hp=9df84301f10c7bae207d8136d9d3ab5ab9ea5634;hpb=2cdd699a77f7801b1e37b72108a33fa95354e67a;p=mesa.git diff --git a/src/mesa/math/m_debug_util.h b/src/mesa/math/m_debug_util.h index 9df84301f10..25ee029cebc 100644 --- a/src/mesa/math/m_debug_util.h +++ b/src/mesa/math/m_debug_util.h @@ -1,9 +1,7 @@ - /* * Mesa 3-D graphics library - * Version: 3.5 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2004 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"), @@ -18,9 +16,10 @@ * 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 @@ -30,7 +29,10 @@ #define __M_DEBUG_UTIL_H__ -#ifdef DEBUG /* This code only used for debugging */ +#ifdef DEBUG_MATH /* This code only used for debugging */ + + +#include "c99_math.h" /* Comment this out to deactivate the cycle counter. @@ -62,7 +64,7 @@ extern long counter_overhead; */ extern char *mesa_profile; -/* Modify the the number of tests if you like. +/* Modify the number of tests if you like. * We take the minimum of all results, because every error should be * positive (time used by other processes, task switches etc). * It is assumed that all calculations are done in the cache. @@ -186,6 +188,44 @@ extern char *mesa_profile; #endif +#elif defined(__x86_64__) + +#define rdtscll(val) do { \ + unsigned int a,d; \ + __asm__ volatile("rdtsc" : "=a" (a), "=d" (d)); \ + (val) = ((unsigned long)a) | (((unsigned long)d)<<32); \ +} while(0) + +/* Copied from i386 PIII version */ +#define INIT_COUNTER() \ + do { \ + int cycle_i; \ + counter_overhead = LONG_MAX; \ + for ( cycle_i = 0 ; cycle_i < 16 ; cycle_i++ ) { \ + unsigned long cycle_tmp1, cycle_tmp2; \ + rdtscll(cycle_tmp1); \ + rdtscll(cycle_tmp2); \ + if ( counter_overhead > (cycle_tmp2 - cycle_tmp1) ) { \ + counter_overhead = cycle_tmp2 - cycle_tmp1; \ + } \ + } \ + } while (0) + + +#define BEGIN_RACE(x) \ + x = LONG_MAX; \ + for ( cycle_i = 0 ; cycle_i < 10 ; cycle_i++ ) { \ + unsigned long cycle_tmp1, cycle_tmp2; \ + rdtscll(cycle_tmp1); \ + +#define END_RACE(x) \ + rdtscll(cycle_tmp2); \ + if ( x > (cycle_tmp2 - cycle_tmp1) ) { \ + x = cycle_tmp2 - cycle_tmp1; \ + } \ + } \ + x -= counter_overhead; + #elif defined(__sparc__) #define INIT_COUNTER() \ @@ -194,8 +234,8 @@ extern char *mesa_profile; #define BEGIN_RACE(x) \ x = LONG_MAX; \ for (cycle_i = 0; cycle_i <10; cycle_i++) { \ - register long cycle_tmp1 asm("l0"); \ - register long cycle_tmp2 asm("l1"); \ + register long cycle_tmp1 __asm__("l0"); \ + register long cycle_tmp2 __asm__("l1"); \ /* rd %tick, %l0 */ \ __asm__ __volatile__ (".word 0xa1410000" : "=r" (cycle_tmp1)); /* save timestamp */ @@ -249,9 +289,9 @@ static int significand_match( GLfloat a, GLfloat b ) return 0; } - frexp( a, &a_ex ); - frexp( b, &b_ex ); - frexp( d, &d_ex ); + frexpf( a, &a_ex ); + frexpf( b, &b_ex ); + frexpf( d, &d_ex ); if ( a_ex < b_ex ) { return a_ex - d_ex; @@ -265,17 +305,17 @@ enum { NIL = 0, ONE = 1, NEG = -1, VAR = 2 }; /* Ensure our arrays are correctly aligned. */ #if defined(__GNUC__) -# define ALIGN16 __attribute__ ((aligned (16))) -#elif defined(__MSC__) -# define ALIGN16 __declspec(align(16)) /* GH: Does this work? */ -#elif defined(__WATCOMC__) -# define ALIGN16 /* Watcom does not support this */ +# define ALIGN16(type, array) type array __attribute__ ((aligned (16))) +#elif defined(_MSC_VER) +# define ALIGN16(type, array) type array __declspec(align(16)) /* GH: Does this work? */ +#elif defined(__xlC__) +# define ALIGN16(type, array) type __align (16) array #else # warning "ALIGN16 will not 16-byte align!\n" # define ALIGN16 #endif -#endif /* DEBUG */ +#endif /* DEBUG_MATH */ #endif /* __M_DEBUG_UTIL_H__ */