added FREXPF() macro (bug 4060)

This commit is contained in:
Brian Paul
2005-08-12 18:56:56 +00:00
parent f2876d1ee3
commit 6fe7a0dc01
3 changed files with 10 additions and 9 deletions

View File

@@ -331,23 +331,28 @@ static INLINE int GET_FLOAT_BITS( float x )
*** CEILF: ceiling of float *** CEILF: ceiling of float
*** FLOORF: floor of float *** FLOORF: floor of float
*** FABSF: absolute value of float *** FABSF: absolute value of float
*** LDEXPF: multiply value by an integral power of two
*** FREXPF: extract mantissa and exponent from value
***/ ***/
#if defined(XFree86LOADER) && defined(IN_MODULE) #if defined(XFree86LOADER) && defined(IN_MODULE)
#define CEILF(x) ((GLfloat) xf86ceil(x)) #define CEILF(x) ((GLfloat) xf86ceil(x))
#define FLOORF(x) ((GLfloat) xf86floor(x)) #define FLOORF(x) ((GLfloat) xf86floor(x))
#define FABSF(x) ((GLfloat) xf86fabs(x)) #define FABSF(x) ((GLfloat) xf86fabs(x))
#define LDEXPF(x,y) ((GLfloat) xf86ldexp(x,y)) #define LDEXPF(x,y) ((GLfloat) xf86ldexp(x,y))
#define FREXPF(x,y) ((GLfloat) xf86frexp(x,y))
#elif defined(__gnu_linux__) #elif defined(__gnu_linux__)
/* C99 functions */ /* C99 functions */
#define CEILF(x) ceilf(x) #define CEILF(x) ceilf(x)
#define FLOORF(x) floorf(x) #define FLOORF(x) floorf(x)
#define FABSF(x) fabsf(x) #define FABSF(x) fabsf(x)
#define LDEXPF(x,y) ldexpf(x,y) #define LDEXPF(x,y) ldexpf(x,y)
#define FREXPF(x,y) frexpf(x,y)
#else #else
#define CEILF(x) ((GLfloat) ceil(x)) #define CEILF(x) ((GLfloat) ceil(x))
#define FLOORF(x) ((GLfloat) floor(x)) #define FLOORF(x) ((GLfloat) floor(x))
#define FABSF(x) ((GLfloat) fabs(x)) #define FABSF(x) ((GLfloat) fabs(x))
#define LDEXPF(x,y) ((GLfloat) ldexp(x,y)) #define LDEXPF(x,y) ((GLfloat) ldexp(x,y))
#define FREXPF(x,y) ((GLfloat) frexp(x,y))
#endif #endif

View File

@@ -286,9 +286,9 @@ static int significand_match( GLfloat a, GLfloat b )
return 0; return 0;
} }
frexp( a, &a_ex ); FREXPF( a, &a_ex );
frexp( b, &b_ex ); FREXPF( b, &b_ex );
frexp( d, &d_ex ); FREXPF( d, &d_ex );
if ( a_ex < b_ex ) { if ( a_ex < b_ex ) {
return a_ex - d_ex; return a_ex - d_ex;

View File

@@ -2,7 +2,7 @@
* Mesa 3-D graphics library * Mesa 3-D graphics library
* Version: 6.3 * Version: 6.3
* *
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -351,11 +351,7 @@ static void do_LOG( struct arb_vp_machine *m, union instruction op )
const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0]; const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
GLfloat tmp = FABSF(arg0[0]); GLfloat tmp = FABSF(arg0[0]);
int exponent; int exponent;
#ifdef _WIN32 GLfloat mantissa = FREXPF(tmp, &exponent);
GLfloat mantissa = (GLfloat) frexp((double)tmp, &exponent);
#else
GLfloat mantissa = frexpf(tmp, &exponent);
#endif
result[0] = (GLfloat) (exponent - 1); result[0] = (GLfloat) (exponent - 1);
result[1] = 2.0 * mantissa; /* map [.5, 1) -> [1, 2) */ result[1] = 2.0 * mantissa; /* map [.5, 1) -> [1, 2) */