[FFmpeg-devel] [PATCH]Use pushfl/popfl in cpuid.c

Reimar Döffinger Reimar.Doeffinger
Mon Nov 24 15:22:17 CET 2008


On Mon, Nov 24, 2008 at 02:14:48PM +0100, Reimar D?ffinger wrote:
> On Mon, Nov 24, 2008 at 12:20:35PM -0000, M?ns Rullg?rd wrote:
> > >> > How about
> > >> > #ifdef ARCH_X86_64
> > >> > #define PUSHF "pushfq\n\t"
> > >> > #define POPF  "popfq\n\t"
> > >> > #else
> > >> > #define PUSHF "pushfl\n\t"
> > >> > #define POPF  "popfl\n\t"
> > >> > #endif
> > >> > ?
> > >>
> > >> Just make sure you test it on both.
> > >
> > > Attached patch seems to work fine on x86_64 (make test passes).
> > 
> > Does it detect the cpuid/simd support correctly?  make test would pass
> > even if it didn't.
> 
> Oh well, let's just do this the easy way:

Same thing for 32 bit, gcc (Debian 4.3.2-1) 4.3.2:
after patch:
00000000 <mm_support>:
   0:   83 ec 14                sub    $0x14,%esp
   3:   89 5c 24 04             mov    %ebx,0x4(%esp)
   7:   89 74 24 08             mov    %esi,0x8(%esp)
   b:   89 7c 24 0c             mov    %edi,0xc(%esp)
   f:   89 6c 24 10             mov    %ebp,0x10(%esp)
  13:   9c                      pushf  
  14:   58                      pop    %eax
  15:   89 c1                   mov    %eax,%ecx
  17:   35 00 00 20 00          xor    $0x200000,%eax
  1c:   50                      push   %eax
  1d:   9d                      popf   
  1e:   9c                      pushf  
  1f:   58                      pop    %eax
  20:   39 c8                   cmp    %ecx,%eax
  22:   c7 04 24 00 00 00 00    movl   $0x0,(%esp)
  29:   0f 84 a1 00 00 00       je     d0 <mm_support+0xd0>
  2f:   31 c0                   xor    %eax,%eax
  31:   89 de                   mov    %ebx,%esi
  33:   0f a2                   cpuid  

before patch:
00000000 <mm_support>:
   0:   83 ec 14                sub    $0x14,%esp
   3:   89 5c 24 04             mov    %ebx,0x4(%esp)
   7:   89 74 24 08             mov    %esi,0x8(%esp)
   b:   89 7c 24 0c             mov    %edi,0xc(%esp)
   f:   89 6c 24 10             mov    %ebp,0x10(%esp)
  13:   9c                      pushf  
  14:   58                      pop    %eax
  15:   89 c1                   mov    %eax,%ecx
  17:   35 00 00 20 00          xor    $0x200000,%eax
  1c:   50                      push   %eax
  1d:   9d                      popf   
  1e:   9c                      pushf  
  1f:   58                      pop    %eax
  20:   39 c8                   cmp    %ecx,%eax
  22:   c7 04 24 00 00 00 00    movl   $0x0,(%esp)
  29:   0f 84 a1 00 00 00       je     d0 <mm_support+0xd0>
  2f:   31 c0                   xor    %eax,%eax
  31:   89 de                   mov    %ebx,%esi
  33:   0f a2                   cpuid  

in both cases
mm_support = 0x0000007F

Now someone must test ICC and maybe also gcc 2.95, I currently have
neither around.

Greetings,
Reimar D?ffinger




More information about the ffmpeg-devel mailing list