mesa: replace FREXPF, LDEXPF with frexpf, ldexpf

Start getting rid of some imports.h macros.  Use the c99 functions instead.

Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
Brian Paul 2015-02-24 08:57:17 -07:00
parent e6eddbb96a
commit e25f7772ca
4 changed files with 20 additions and 11 deletions

View File

@ -82,6 +82,17 @@ static inline float logf( float f )
return (float) log( (double) f );
}
static inline float frexpf(float x, int *exp)
{
return (float) frexp(x, exp);
}
static inline float ldexpf(float x, int exp)
{
return (float) ldexp(x, exp);
}
#else
/* Work-around an extra semi-colon in VS 2005 logf definition */
#ifdef logf

View File

@ -209,8 +209,6 @@ static inline GLfloat LOG2(GLfloat x)
*** FABSF: absolute value of float
*** LOGF: the natural logarithm (base e) of the value
*** EXPF: raise e to the value
*** LDEXPF: multiply value by an integral power of two
*** FREXPF: extract mantissa and exponent from value
***/
#if defined(__gnu_linux__)
/* C99 functions */
@ -219,16 +217,12 @@ static inline GLfloat LOG2(GLfloat x)
#define FABSF(x) fabsf(x)
#define LOGF(x) logf(x)
#define EXPF(x) expf(x)
#define LDEXPF(x,y) ldexpf(x,y)
#define FREXPF(x,y) frexpf(x,y)
#else
#define CEILF(x) ((GLfloat) ceil(x))
#define FLOORF(x) ((GLfloat) floor(x))
#define FABSF(x) ((GLfloat) fabs(x))
#define LOGF(x) ((GLfloat) log(x))
#define EXPF(x) ((GLfloat) exp(x))
#define LDEXPF(x,y) ((GLfloat) ldexp(x,y))
#define FREXPF(x,y) ((GLfloat) frexp(x,y))
#endif

View File

@ -32,6 +32,9 @@
#ifdef DEBUG_MATH /* This code only used for debugging */
#include "c99_math.h"
/* Comment this out to deactivate the cycle counter.
* NOTE: it works only on CPUs which know the 'rdtsc' command (586 or higher)
* (hope, you don't try to debug Mesa on a 386 ;)
@ -286,9 +289,9 @@ static int significand_match( GLfloat a, GLfloat b )
return 0;
}
FREXPF( a, &a_ex );
FREXPF( b, &b_ex );
FREXPF( 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;

View File

@ -35,6 +35,7 @@
*/
#include "c99_math.h"
#include "main/glheader.h"
#include "main/colormac.h"
#include "main/macros.h"
@ -718,7 +719,7 @@ _mesa_execute_program(struct gl_context * ctx,
q[2] = 0.0F;
}
else {
q[0] = LDEXPF(1.0, (int) floor_t0);
q[0] = ldexpf(1.0, (int) floor_t0);
/* Note: GL_NV_vertex_program expects
* result.z = result.x * APPX(result.y)
* We do what the ARB extension says.
@ -884,7 +885,7 @@ _mesa_execute_program(struct gl_context * ctx,
}
else {
int exponent;
GLfloat mantissa = FREXPF(t[0], &exponent);
GLfloat mantissa = frexpf(t[0], &exponent);
q[0] = (GLfloat) (exponent - 1);
q[1] = (GLfloat) (2.0 * mantissa); /* map [.5, 1) -> [1, 2) */