[MPlayer-dev-eng] [PATCH] Disable additional optimization if compiler doesn't support __attribute__((used))

Zuxy Meng zuxy.meng at gmail.com
Sun Jun 10 10:56:47 CEST 2007


Hi,

2007/6/10, Carl Eugen Hoyos <cehoyos at ag.or.at>:
> Hi!
>
> Attached patch disables optimizations in liba52 and mp3lib if compiler
> (icc) doesn't support __attribute__((used)).
>
> Please comment, Carl Eugen
>
> Index: configure
> ===================================================================
> --- configure   (Revision 23529)
> +++ configure   (Arbeitskopie)
> @@ -2221,7 +2221,20 @@
>  fi
>
>
> +echocheck "compiler support of __attribute__((used))"
> +_def_attribute_used="#undef HAVE_ATTRIBUTE_USED"
> +cat > $TMPC << EOF
> +static unsigned long long __attribute__((used)) x = 0xdeadbeefdeadbeefLL, y;
> +int main (void) {
> +  asm volatile ("movq x, %%mm0\n\t"
> +        "movq %%mm0, y\n\t" : :);
> +  printf ("%llx\n", y);
> +  return 0;
> +}
> +EOF
> +cc_check && _def_attribute_used="#define HAVE_ATTRIBUTE_USED 1" && echores "yes" || echores "no"
>
> +
>  echocheck "assembler support of -pipe option"
>  cat > $TMPC << EOF
>  int main(void) { return 0; }
> @@ -8353,6 +8373,7 @@
>  $_def_armv5te  // only define if you have Enhanced DSP Extensions (ARM)
>  $_def_armv6    // only define if you have ARMv6
>  $_def_iwmmxt   // only define if you have XScale IWMMX (ARM)
> +$_def_attribute_used   // only define if __attribute__((used)) works
>
>  $_def_altivec_h        // enables usage of altivec.h
>
> Index: mp3lib/sr1.c
> ===================================================================
> --- mp3lib/sr1.c        (Revision 23529)
> +++ mp3lib/sr1.c        (Arbeitskopie)
> @@ -460,12 +460,14 @@
>     }
>     else
>  #endif
> +#ifdef HAVE_ATTRIBUTE_USED
>     if (gCpuCaps.cpuType >= CPUTYPE_I586)
>     {
>        synth_func = synth_1to1_pent;
>        mp_msg(MSGT_DECAUDIO,MSGL_V,"mp3lib: using Pentium optimized decore!\n");
>     }
>     else
> +#endif
>  #endif /* ARCH_X86_32 */
>  #ifdef HAVE_ALTIVEC
>     if (gCpuCaps.hasAltiVec)
> Index: liba52/imdct.c
> ===================================================================
> --- liba52/imdct.c      (Revision 23529)
> +++ liba52/imdct.c      (Arbeitskopie)
> @@ -723,7 +723,7 @@
>
>  // Stuff below this line is borrowed from libac3
>  #include "srfftp.h"
> -#if defined(ARCH_X86) || defined(ARCH_X86_64)
> +#if (defined(ARCH_X86) || defined(ARCH_X86_64)) && defined(HAVE_ATTRIBUTE_USED)
>  #ifndef HAVE_3DNOW
>  #define HAVE_3DNOW 1
>  #endif
> @@ -1071,7 +1071,7 @@
>                : "%"REG_S, "%"REG_D
>        );
>  }
> -#endif // ARCH_X86 || ARCH_X86_64
> +#endif // (ARCH_X86 || ARCH_X86_64) && HAVE_ATTRIBUTE_USED
>
>  void a52_imdct_256(sample_t * data, sample_t * delay, sample_t bias)
>  {
> @@ -1269,7 +1269,7 @@
>        ifft128 = ifft128_c;
>        ifft64 = ifft64_c;
>
> -#if defined(ARCH_X86) || defined(ARCH_X86_64)
> +#if (defined(ARCH_X86) || defined(ARCH_X86_64)) && defined(HAVE_ATTRIBUTE_USED)
>        if(mm_accel & MM_ACCEL_X86_SSE)
>        {
>          fprintf (stderr, "Using SSE optimized IMDCT transform\n");
> @@ -1288,7 +1288,7 @@
>          a52_imdct_512 = imdct_do_512_3dnow;
>        }
>        else
> -#endif // ARCH_X86 || ARCH_X86_64
> +#endif // (ARCH_X86 || ARCH_X86_64) && HAVE_ATTRIBUTE_USED
>  #ifdef HAVE_ALTIVEC
>         if (mm_accel & MM_ACCEL_PPC_ALTIVEC)
>        {
> Index: liba52/resample.c
> ===================================================================
> --- liba52/resample.c   (Revision 23529)
> +++ liba52/resample.c   (Arbeitskopie)
> @@ -15,7 +15,7 @@
>
>  #include "resample_c.c"
>
> -#if defined(ARCH_X86) || defined(ARCH_X86_64)
> +#if (defined(ARCH_X86) || defined(ARCH_X86_64)) && HAVE_ATTRIBUTE_USED
>  #include "resample_mmx.c"
>  #endif
>
> @@ -26,7 +26,7 @@
>  void* a52_resample_init(uint32_t mm_accel,int flags,int chans){
>  void* tmp;
>
> -#if defined(ARCH_X86) || defined(ARCH_X86_64)
> +#if (defined(ARCH_X86) || defined(ARCH_X86_64)) && defined(HAVE_ATTRIBUTE_USED)
>     if(mm_accel&MM_ACCEL_X86_MMX){
>        tmp=a52_resample_MMX(flags,chans);
>        if(tmp){

Just curious, why use attribute_used and the MANGLE macro instead of
mentioning such variables to a constraint? For gcc 2.95 compatibility?
-- 
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6



More information about the MPlayer-dev-eng mailing list