[Ffmpeg-devel] ARCH_X86 vs ARCH_X86_32 vs ARCH_X86_64

Diego Biurrun diego
Mon Oct 16 23:00:59 CEST 2006


On Sun, Oct 08, 2006 at 11:55:55PM +0200, Diego Biurrun wrote:
> I'd like to introduce a define that encompasses both x86 and x86_64 to
> simplify statements like
> 
>   #if defined(ARCH_X86) || defined(ARCH_X86_64)
> 
> of which we have tons in the code and be able to use it in the Makefiles
> where or expressions are troublesome.
> 
> My first idea was to rename ARCH_X86 --> ARCH_X86_32 and use ARCH_X86
> for the general case.  It seems like the cleanest and most
> straightforward solution to me, but I'm getting second thoughts.  I'm
> afraid that ARCH_X86 semantics are kind of set in stone through years of
> usage (in autoconf as well).

OK, here is a first patch that introduces ARCH_X86_32.  Testing welcome.

Diego
-------------- next part --------------
Index: configure
===================================================================
--- configure	(revision 6713)
+++ configure	(working copy)
@@ -353,10 +353,10 @@
 mmi="default"
 case "$cpu" in
   i386|i486|i586|i686|i86pc|BePC)
-    cpu="x86"
+    cpu="x86_32"
   ;;
   x86_64|amd64)
-    cpu="x86"
+    cpu="x86_32"
     canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
     if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
       if [ -z "`echo $CFLAGS | grep -- -m32`"  ]; then
@@ -998,7 +998,7 @@
 
 # compute MMX state
 if test $mmx = "default"; then
-    if test $cpu = "x86" -o $cpu = "x86_64"; then
+    if test $cpu = "x86_32" -o $cpu = "x86_64"; then
         mmx="yes"
     else
         mmx="no"
@@ -1548,7 +1548,7 @@
 echo "big-endian       $bigendian"
 echo "inttypes.h       $inttypes"
 echo "broken inttypes.h $emu_fast_int"
-if test $cpu = "x86" -o $cpu = "x86_64"; then
+if test $cpu = "x86_32" -o $cpu = "x86_64"; then
     echo "MMX enabled      $mmx"
 fi
 if test $cpu = "armv4l"; then
@@ -1663,9 +1663,13 @@
 echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
 echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
 echo "TARGET_OS=$targetos" >> config.mak
-if test "$cpu" = "x86" ; then
+if test "$cpu" = "x86_32" -o "$cpu" = "x86_64" ; then
   echo "TARGET_ARCH_X86=yes" >> config.mak
   echo "#define ARCH_X86 1" >> $TMPH
+fi
+if test "$cpu" = "x86_32" ; then
+  echo "TARGET_ARCH_X86_32=yes" >> config.mak
+  echo "#define ARCH_X86_32 1" >> $TMPH
 elif test "$cpu" = "x86_64" ; then
   echo "TARGET_ARCH_X86_64=yes" >> config.mak
   echo "#define ARCH_X86_64 1" >> $TMPH
Index: libavcodec/cabac.h
===================================================================
--- libavcodec/cabac.h	(revision 6713)
+++ libavcodec/cabac.h	(working copy)
@@ -362,7 +362,7 @@
 
 static int always_inline get_cabac_inline(CABACContext *c, uint8_t * const state){
     //FIXME gcc generates duplicate load/stores for c->low and c->range
-#if defined(ARCH_X86) && !(defined(PIC) && defined(__GNUC__))
+#if defined(ARCH_X86_32) && !(defined(PIC) && defined(__GNUC__))
     int bit;
 
 #define LOW          "0"
@@ -522,7 +522,7 @@
     );
     bit&=1;
 #endif /* BRANCHLESS_CABAC_DECODER */
-#else /* ARCH_X86 */
+#else /* defined(ARCH_X86_32) && !(defined(PIC) && defined(__GNUC__)) */
     int s = *state;
     int RangeLPS= ff_h264_lps_range[0][2*(c->range&0xC0) + s];
     int bit, lps_mask attribute_unused;
@@ -561,7 +561,7 @@
     if(!(c->low & CABAC_MASK))
         refill2(c);
 #endif /* BRANCHLESS_CABAC_DECODER */
-#endif /* ARCH_X86 */
+#endif /* defined(ARCH_X86_32) && !(defined(PIC) && defined(__GNUC__)) */
     return bit;
 }
 
Index: libavcodec/mathops.h
===================================================================
--- libavcodec/mathops.h	(revision 6713)
+++ libavcodec/mathops.h	(working copy)
@@ -22,7 +22,7 @@
 #ifndef MATHOPS_H
 #define MATHOPS_H
 
-#ifdef ARCH_X86
+#ifdef ARCH_X86_32
 
 #include "i386/mathops.h"
 
Index: libavutil/internal.h
===================================================================
--- libavutil/internal.h	(revision 6713)
+++ libavutil/internal.h	(working copy)
@@ -217,7 +217,7 @@
 static always_inline long int lrintf(float x)
 {
 #ifdef __MINGW32__
-#  ifdef ARCH_X86
+#  ifdef ARCH_X86_32
     int32_t i;
     asm volatile(
         "fistpl %0\n\t"
@@ -227,7 +227,7 @@
 #  else
     /* XXX: incorrect, but make it compile */
     return (int)(x + (x < 0 ? -0.5 : 0.5));
-#  endif /* ARCH_X86 */
+#  endif /* ARCH_X86_32 */
 #else
     return (int)(rint(x));
 #endif /* __MINGW32__ */
Index: libavutil/common.h
===================================================================
--- libavutil/common.h	(revision 6713)
+++ libavutil/common.h	(working copy)
@@ -344,7 +344,7 @@
         );
         return (d << 32) | (a & 0xffffffff);
 }
-#elif defined(ARCH_X86)
+#elif defined(ARCH_X86_32)
 static inline long long read_time(void)
 {
         long long l;



More information about the ffmpeg-devel mailing list