[Mesa-dev] [PATCH 01/12] mesa: replace FREXPF, LDEXPF with frexpf, ldexpf

Brian Paul brianp at vmware.com
Tue Feb 24 08:57:25 PST 2015


Start getting rid of some imports.h macros.  Use the c99 functions instead.
---
 include/c99_math.h              | 11 +++++++++++
 src/mesa/main/imports.h         |  6 ------
 src/mesa/math/m_debug_util.h    |  9 ++++++---
 src/mesa/program/prog_execute.c |  5 +++--
 4 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/include/c99_math.h b/include/c99_math.h
index 6680f54..e60e7d3 100644
--- a/include/c99_math.h
+++ b/include/c99_math.h
@@ -82,6 +82,17 @@ static inline float logf( float f )
    return (float) log( (double) f );
 }
 
+static inline float frexpf(float x, float y)
+{
+   return (float) frexp(x, y);
+}
+
+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
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 0fcba4f..cb87148 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -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
 
 
diff --git a/src/mesa/math/m_debug_util.h b/src/mesa/math/m_debug_util.h
index d05da89..25ee029 100644
--- a/src/mesa/math/m_debug_util.h
+++ b/src/mesa/math/m_debug_util.h
@@ -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;
diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c
index 8f83c31..05c5f29 100644
--- a/src/mesa/program/prog_execute.c
+++ b/src/mesa/program/prog_execute.c
@@ -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) */
 
-- 
1.9.1



More information about the mesa-dev mailing list