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

Måns Rullgård mans
Mon Nov 24 14:22:42 CET 2008


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:
> cpuid.o after patch:
> 0000000000000000 <mm_support>:
>    0:   9c                      pushfq
>    1:   58                      pop    %rax
>    2:   48 89 c1                mov    %rax,%rcx
>    5:   48 35 00 00 20 00       xor    $0x200000,%rax
>    b:   50                      push   %rax
>    c:   9d                      popfq
>    d:   9c                      pushfq
>    e:   58                      pop    %rax
>    f:   45 31 c0                xor    %r8d,%r8d
>   12:   48 39 c8                cmp    %rcx,%rax
>   15:   0f 84 b7 00 00 00       je     d2 <mm_support+0xd2>
>   1b:   31 c0                   xor    %eax,%eax
>   1d:   48 89 de                mov    %rbx,%rsi
>   20:   0f a2                   cpuid
>
>
> cpuid.o before patch:
> 0000000000000000 <mm_support>:
>    0:   9c                      pushfq
>    1:   58                      pop    %rax
>    2:   48 89 c1                mov    %rax,%rcx
>    5:   48 35 00 00 20 00       xor    $0x200000,%rax
>    b:   50                      push   %rax
>    c:   9d                      popfq
>    d:   9c                      pushfq
>    e:   58                      pop    %rax
>    f:   45 31 c0                xor    %r8d,%r8d
>   12:   48 39 c8                cmp    %rcx,%rax
>   15:   0f 84 b7 00 00 00       je     d2 <mm_support+0xd2>
>   1b:   31 c0                   xor    %eax,%eax
>   1d:   48 89 de                mov    %rbx,%rsi
>   20:   0f a2                   cpuid

Can't argue with that.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list