summaryrefslogtreecommitdiff
path: root/src/mesa/main/imports.h
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2003-04-28 15:24:17 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2003-04-28 15:24:17 +0000
commit9e3a7cd6dd02b12f880d9e9e220bfdadc09417e1 (patch)
tree8cde4008b1d05583a20495556304f38505e3ba65 /src/mesa/main/imports.h
parentc8f2f456f94232671511745e1b236339af6b44ce (diff)
LOG2() clean-up (Klaus Niederkrueger)
Diffstat (limited to 'src/mesa/main/imports.h')
-rw-r--r--src/mesa/main/imports.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 5a42cfaf8b..e16e95cb0b 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -198,14 +198,14 @@ static INLINE GLfloat LOG2(GLfloat x)
*/
static INLINE GLfloat LOG2(GLfloat val)
{
- GLint *exp_ptr = (GLint *) &val;
- GLint x = *exp_ptr;
- const GLint log_2 = ((x >> 23) & 255) - 128;
- x &= ~(255 << 23);
- x += 127 << 23;
- *exp_ptr = x;
- val = ((-1.0f/3) * val + 2) * val - 2.0f/3;
- return val + log_2;
+ fi_type num;
+ GLint log_2;
+ num.f = val;
+ log_2 = ((num.i >> 23) & 255) - 128;
+ num.i &= ~(255 << 23);
+ num.i += 127 << 23;
+ num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3;
+ return num.f + log_2;
}
#elif defined(XFree86LOADER) && defined(IN_MODULE)
#define LOG2(x) ((GLfloat) (xf86log(x) * 1.442695))