Mesa (master): mesa: replace LOGF, EXPF with logf, expf

Brian Paul brianp at kemper.freedesktop.org
Tue Feb 24 21:49:46 UTC 2015


Module: Mesa
Branch: master
Commit: 79b480ccc069b92d4614ed7f61d810bdc816cb7c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=79b480ccc069b92d4614ed7f61d810bdc816cb7c

Author: Brian Paul <brianp at vmware.com>
Date:   Tue Feb 24 09:01:51 2015 -0700

mesa: replace LOGF, EXPF with logf, expf

Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 include/c99_math.h         |   10 ++++++++++
 src/mesa/main/imports.h    |    6 ------
 src/mesa/swrast/s_aaline.c |    2 +-
 src/mesa/swrast/s_fog.c    |    9 +++++----
 src/mesa/tnl/t_vb_fog.c    |    3 ++-
 5 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/include/c99_math.h b/include/c99_math.h
index bb4bbd1..147bcee 100644
--- a/include/c99_math.h
+++ b/include/c99_math.h
@@ -92,6 +92,16 @@ static inline float ldexpf(float x, int exp)
    return (float) ldexp(x, exp);
 }
 
+static inline float logf(float x)
+{
+   return (float) log(x);
+}
+
+static inline float expf(float x)
+{
+   return (float) exp(x);
+}
+
 
 #else
 /* Work-around an extra semi-colon in VS 2005 logf definition */
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index cb87148..b7bb6e2 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -207,22 +207,16 @@ static inline GLfloat LOG2(GLfloat x)
  *** CEILF: ceiling of float
  *** FLOORF: floor of float
  *** FABSF: absolute value of float
- *** LOGF: the natural logarithm (base e) of the value
- *** EXPF: raise e to the value
  ***/
 #if defined(__gnu_linux__)
 /* C99 functions */
 #define CEILF(x)   ceilf(x)
 #define FLOORF(x)  floorf(x)
 #define FABSF(x)   fabsf(x)
-#define LOGF(x)    logf(x)
-#define EXPF(x)    expf(x)
 #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))
 #endif
 
 
diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c
index d73c498..0add124 100644
--- a/src/mesa/swrast/s_aaline.c
+++ b/src/mesa/swrast/s_aaline.c
@@ -203,7 +203,7 @@ compute_lambda(const GLfloat sPlane[4], const GLfloat tPlane[4],
    if (rho2 == 0.0F)
       return 0.0;
    else
-      return (GLfloat) (LOGF(rho2) * 1.442695 * 0.5);/* 1.442695 = 1/log(2) */
+      return logf(rho2) * 1.442695f * 0.5f;/* 1.442695 = 1/log(2) */
 }
 
 
diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c
index 6b9e698..380dcc1 100644
--- a/src/mesa/swrast/s_fog.c
+++ b/src/mesa/swrast/s_fog.c
@@ -23,6 +23,7 @@
  */
 
 
+#include "c99_math.h"
 #include "main/glheader.h"
 #include "main/colormac.h"
 #include "main/macros.h"
@@ -49,12 +50,12 @@ _swrast_z_to_fogfactor(struct gl_context *ctx, GLfloat z)
       return CLAMP(f, 0.0F, 1.0F);
    case GL_EXP:
       d = ctx->Fog.Density;
-      f = EXPF(-d * z);
+      f = expf(-d * z);
       f = CLAMP(f, 0.0F, 1.0F);
       return f;
    case GL_EXP2:
       d = ctx->Fog.Density;
-      f = EXPF(-(d * d * z * z));
+      f = expf(-(d * d * z * z));
       f = CLAMP(f, 0.0F, 1.0F);
       return f;
    default:
@@ -66,14 +67,14 @@ _swrast_z_to_fogfactor(struct gl_context *ctx, GLfloat z)
 
 #define LINEAR_FOG(f, coord)  f = (fogEnd - coord) * fogScale
 
-#define EXP_FOG(f, coord)  f = EXPF(density * coord)
+#define EXP_FOG(f, coord)  f = expf(density * coord)
 
 #define EXP2_FOG(f, coord)				\
 do {							\
    GLfloat tmp = negDensitySquared * coord * coord;	\
    if (tmp < FLT_MIN_10_EXP)				\
       tmp = FLT_MIN_10_EXP;				\
-   f = EXPF(tmp);					\
+   f = expf(tmp);					\
  } while(0)
 
 
diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c
index ab7901e..3c8950f 100644
--- a/src/mesa/tnl/t_vb_fog.c
+++ b/src/mesa/tnl/t_vb_fog.c
@@ -26,6 +26,7 @@
  */
 
 
+#include "c99_math.h"
 #include "main/glheader.h"
 #include "main/colormac.h"
 #include "main/macros.h"
@@ -78,7 +79,7 @@ init_static_data( void )
    GLfloat f = 0.0F;
    GLint i = 0;
    for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) {
-      exp_table[i] = EXPF(-f);
+      exp_table[i] = expf(-f);
    }
    inited = 1;
 }




More information about the mesa-commit mailing list