[xiph-commits] r9959 - in trunk/vorbis: . lib

msmith at svn.xiph.org msmith at svn.xiph.org
Mon Sep 5 04:04:51 PDT 2005


Author: msmith
Date: 2005-09-05 04:04:48 -0700 (Mon, 05 Sep 2005)
New Revision: 9959

Modified:
   trunk/vorbis/configure.in
   trunk/vorbis/lib/scales.h
Log:
Fix bug 583 properly, this time.
Use magic-union tricks to prevent breaking C aliasing rules.
This means we can remove the turning-off-optimisations hack we temporarily put
in for gcc4.
Thanks to Richard Guenther for the tips.



Modified: trunk/vorbis/configure.in
===================================================================
--- trunk/vorbis/configure.in	2005-09-05 01:07:26 UTC (rev 9958)
+++ trunk/vorbis/configure.in	2005-09-05 11:04:48 UTC (rev 9959)
@@ -169,14 +169,6 @@
 		CFLAGS="-O20 -D__NO_MATH_INLINES -fsigned-char"
 		PROFILE="-O20 -g -pg -D__NO_MATH_INLINES -fsigned-char" ;;
         esac
-
-	case "$GCC_VERSION" in
-	4.*)
-		# work around a problem with the gcc4 optimizer
-		PROFILE="$DEBUG -fno-inline-functions"
-		CFLAGS="$CFLAGS -fno-inline-functions"
-		PROFILE="$PROFILE -fno-inline-functions" ;;
-	esac
 fi
 CFLAGS="$CFLAGS $cflags_save"
 LDFLAGS="$LDFLAGS $ldflags_save"

Modified: trunk/vorbis/lib/scales.h
===================================================================
--- trunk/vorbis/lib/scales.h	2005-09-05 01:07:26 UTC (rev 9958)
+++ trunk/vorbis/lib/scales.h	2005-09-05 11:04:48 UTC (rev 9959)
@@ -26,20 +26,24 @@
 #ifdef VORBIS_IEEE_FLOAT32
 
 static float unitnorm(float x){
-  ogg_uint32_t *ix=(ogg_uint32_t *)&x;
-  *ix=(*ix&0x80000000UL)|(0x3f800000UL);
-  return(x);
+  union {
+    ogg_uint32_t i;
+    float f;
+  } ix;
+  ix.f = x;
+  ix.i = (ix.i & 0x80000000U) | (0x3f800000U);
+  return ix.f;
 }
 
-static float FABS(float *x){
-  ogg_uint32_t *ix=(ogg_uint32_t *)x;
-  *ix&=0x7fffffffUL;
-  return(*x);
-}
-
 /* Segher was off (too high) by ~ .3 decibel.  Center the conversion correctly. */
 static float todB(const float *x){
-  return (float)((*(ogg_int32_t *)x)&0x7fffffff) * 7.17711438e-7f -764.6161886f;
+  union {
+    ogg_uint32_t i;
+    float f;
+  } ix;
+  ix.f = *x;
+  ix.i = ix.i&0x7fffffff;
+  return (float)(ix.i * 7.17711438e-7f -764.6161886f);
 }
 
 #define todB_nn(x) todB(x)
@@ -51,8 +55,6 @@
   return(1.f);
 }
 
-#define FABS(x) fabs(*(x))
-
 #define todB(x)   (*(x)==0?-400.f:log(*(x)**(x))*4.34294480f)
 #define todB_nn(x)   (*(x)==0.f?-400.f:log(*(x))*8.6858896f)
 



More information about the commits mailing list