Re: [libav-devel] [PATCH 2/5] x86: cpu: Break out test for cpuid capabilities into separate function

2012-10-04 Thread Måns Rullgård
Diego Biurrun di...@biurrun.de writes:

 ---

 The #define indirection will be reused by the yasm version of cpuid_test,
 so I'm adding it here already to avoid code churn.

  libavutil/x86/cpu.c |   27 ++-
  1 files changed, 18 insertions(+), 9 deletions(-)

 diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
 index 9cf68e4..e3a9fb6 100644
 --- a/libavutil/x86/cpu.c
 +++ b/libavutil/x86/cpu.c
 @@ -86,6 +86,23 @@

  #endif /* HAVE_INLINE_ASM */

 +#if HAVE_INLINE_ASM || HAVE_RWEFLAGS
 +#define have_cpuid cpuid_test
 +
 +static int cpuid_test(void)
 +{
 +x86_reg a, c;
 +
 +/* Check if CPUID is supported by attempting to toggle the ID bit in
 + * the EFLAGS register. */
 +get_eflags(a);
 +set_eflags(a ^ 0x20);
 +get_eflags(c);
 +
 +return a != c;
 +}
 +#endif
 +
  /* Function to test if multimedia instructions are supported...  */
  int ff_get_cpu_flags_x86(void)
  {
 @@ -96,15 +113,7 @@ int ff_get_cpu_flags_x86(void)
  union { int i[3]; char c[12]; } vendor;

  #if ARCH_X86_32
 -x86_reg a, c;
 -
 -/* Check if CPUID is supported by attempting to toggle the ID bit in
 - * the EFLAGS register. */
 -get_eflags(a);
 -set_eflags(a ^ 0x20);
 -get_eflags(c);
 -
 -if (a == c)
 +if (!have_cpuid())
  return 0; /* CPUID not supported */
  #endif

You could #define have_cpuid() 1 for x86_64 and get rid of this #if.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/5] x86: cpu: Break out test for cpuid capabilities into separate function

2012-10-04 Thread Diego Biurrun
On Thu, Oct 04, 2012 at 02:04:27PM +0100, Måns Rullgård wrote:
 Diego Biurrun di...@biurrun.de writes:
  --- a/libavutil/x86/cpu.c
  +++ b/libavutil/x86/cpu.c
  @@ -96,15 +113,7 @@ int ff_get_cpu_flags_x86(void)
 
   #if ARCH_X86_32
  -x86_reg a, c;
  -
  -/* Check if CPUID is supported by attempting to toggle the ID bit in
  - * the EFLAGS register. */
  -get_eflags(a);
  -set_eflags(a ^ 0x20);
  -get_eflags(c);
  -
  -if (a == c)
  +if (!have_cpuid())
   return 0; /* CPUID not supported */
   #endif
 
 You could #define have_cpuid() 1 for x86_64 and get rid of this #if.

But I rely on have_cpuid to mean that I have either yasm or inline asm
available in 5/5.  So if I set it unconditionally for x86_64, I have to
go back to HAVE_YASM || HAVE_INLINE_ASM in 5/5 or define have_cpuid
conditionally on x86_64 somehow.  Not worth the trouble - let's keep it
the way it is right now.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/5] x86: cpu: Break out test for cpuid capabilities into separate function

2012-10-04 Thread Måns Rullgård
Diego Biurrun di...@biurrun.de writes:

 On Thu, Oct 04, 2012 at 02:04:27PM +0100, Måns Rullgård wrote:
 Diego Biurrun di...@biurrun.de writes:
  --- a/libavutil/x86/cpu.c
  +++ b/libavutil/x86/cpu.c
  @@ -96,15 +113,7 @@ int ff_get_cpu_flags_x86(void)
 
   #if ARCH_X86_32
  -x86_reg a, c;
  -
  -/* Check if CPUID is supported by attempting to toggle the ID bit in
  - * the EFLAGS register. */
  -get_eflags(a);
  -set_eflags(a ^ 0x20);
  -get_eflags(c);
  -
  -if (a == c)
  +if (!have_cpuid())
   return 0; /* CPUID not supported */
   #endif
 
 You could #define have_cpuid() 1 for x86_64 and get rid of this #if.

 But I rely on have_cpuid to mean that I have either yasm or inline asm
 available in 5/5.

I thought you tested for cpuid there.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/5] x86: cpu: Break out test for cpuid capabilities into separate function

2012-10-04 Thread Diego Biurrun
On Thu, Oct 04, 2012 at 03:30:17PM +0100, Måns Rullgård wrote:
 Diego Biurrun di...@biurrun.de writes:
  On Thu, Oct 04, 2012 at 02:04:27PM +0100, Måns Rullgård wrote:
  Diego Biurrun di...@biurrun.de writes:
   --- a/libavutil/x86/cpu.c
   +++ b/libavutil/x86/cpu.c
   @@ -96,15 +113,7 @@ int ff_get_cpu_flags_x86(void)
  
#if ARCH_X86_32
   -x86_reg a, c;
   -
   -/* Check if CPUID is supported by attempting to toggle the ID bit in
   - * the EFLAGS register. */
   -get_eflags(a);
   -set_eflags(a ^ 0x20);
   -get_eflags(c);
   -
   -if (a == c)
   +if (!have_cpuid())
return 0; /* CPUID not supported */
#endif
  
  You could #define have_cpuid() 1 for x86_64 and get rid of this #if.
 
  But I rely on have_cpuid to mean that I have either yasm or inline asm
  available in 5/5.
 
 I thought you tested for cpuid there.

No.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/5] x86: cpu: Break out test for cpuid capabilities into separate function

2012-10-04 Thread Måns Rullgård
Diego Biurrun di...@biurrun.de writes:

 On Thu, Oct 04, 2012 at 03:30:17PM +0100, Måns Rullgård wrote:
 Diego Biurrun di...@biurrun.de writes:
  On Thu, Oct 04, 2012 at 02:04:27PM +0100, Måns Rullgård wrote:
  Diego Biurrun di...@biurrun.de writes:
   --- a/libavutil/x86/cpu.c
   +++ b/libavutil/x86/cpu.c
   @@ -96,15 +113,7 @@ int ff_get_cpu_flags_x86(void)
  
#if ARCH_X86_32
   -x86_reg a, c;
   -
   -/* Check if CPUID is supported by attempting to toggle the ID bit 
   in
   - * the EFLAGS register. */
   -get_eflags(a);
   -set_eflags(a ^ 0x20);
   -get_eflags(c);
   -
   -if (a == c)
   +if (!have_cpuid())
return 0; /* CPUID not supported */
#endif
  
  You could #define have_cpuid() 1 for x86_64 and get rid of this #if.
 
  But I rely on have_cpuid to mean that I have either yasm or inline asm
  available in 5/5.
 
 I thought you tested for cpuid there.

 No.

Why not?

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/5] x86: cpu: Break out test for cpuid capabilities into separate function

2012-10-04 Thread Diego Biurrun
On Thu, Oct 04, 2012 at 03:36:40PM +0100, Måns Rullgård wrote:
 Diego Biurrun di...@biurrun.de writes:
  On Thu, Oct 04, 2012 at 03:30:17PM +0100, Måns Rullgård wrote:
  Diego Biurrun di...@biurrun.de writes:
   On Thu, Oct 04, 2012 at 02:04:27PM +0100, Måns Rullgård wrote:
   Diego Biurrun di...@biurrun.de writes:
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -96,15 +113,7 @@ int ff_get_cpu_flags_x86(void)
   
 #if ARCH_X86_32
-x86_reg a, c;
-
-/* Check if CPUID is supported by attempting to toggle the ID 
bit in
- * the EFLAGS register. */
-get_eflags(a);
-set_eflags(a ^ 0x20);
-get_eflags(c);
-
-if (a == c)
+if (!have_cpuid())
 return 0; /* CPUID not supported */
 #endif
   
   You could #define have_cpuid() 1 for x86_64 and get rid of this #if.
  
   But I rely on have_cpuid to mean that I have either yasm or inline asm
   available in 5/5.
  
  I thought you tested for cpuid there.
 
  No.
 
 Why not?

Because there is no cpuid symbol that I could check for.  The HAVE_CPUID
that I remove in 3/5 denotes the compiler intrinsic.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/5] x86: cpu: Break out test for cpuid capabilities into separate function

2012-10-04 Thread Måns Rullgård
Diego Biurrun di...@biurrun.de writes:

 On Thu, Oct 04, 2012 at 03:36:40PM +0100, Måns Rullgård wrote:
 Diego Biurrun di...@biurrun.de writes:
  On Thu, Oct 04, 2012 at 03:30:17PM +0100, Måns Rullgård wrote:
  Diego Biurrun di...@biurrun.de writes:
   On Thu, Oct 04, 2012 at 02:04:27PM +0100, Måns Rullgård wrote:
   Diego Biurrun di...@biurrun.de writes:
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -96,15 +113,7 @@ int ff_get_cpu_flags_x86(void)
   
 #if ARCH_X86_32
-x86_reg a, c;
-
-/* Check if CPUID is supported by attempting to toggle the ID 
bit in
- * the EFLAGS register. */
-get_eflags(a);
-set_eflags(a ^ 0x20);
-get_eflags(c);
-
-if (a == c)
+if (!have_cpuid())
 return 0; /* CPUID not supported */
 #endif
   
   You could #define have_cpuid() 1 for x86_64 and get rid of this #if.
  
   But I rely on have_cpuid to mean that I have either yasm or inline asm
   available in 5/5.
  
  I thought you tested for cpuid there.
 
  No.
 
 Why not?

 Because there is no cpuid symbol that I could check for.  The HAVE_CPUID
 that I remove in 3/5 denotes the compiler intrinsic.

#define cpuid(index, eax, ebx, ecx, edx)

^^ what's that then?

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel