[med-svn] [libpll] 01/03: uses GCC's __builtin_cpu_supports which is nicer than cpuid (Thanks a lot to James Cowgill for the patch)

Andreas Tille tille at debian.org
Tue May 16 14:52:51 UTC 2017


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository libpll.

commit 2e7f4a5afcb00e399ee4c0bc7f01547741c7a48d
Author: Andreas Tille <tille at debian.org>
Date:   Tue May 16 14:55:27 2017 +0200

    uses GCC's __builtin_cpu_supports which is nicer than cpuid (Thanks a lot to James Cowgill for the patch)
---
 debian/patches/hardware-detect.patch | 66 ++++++++++++++++++++++++++++++++++++
 debian/patches/series                |  1 +
 2 files changed, 67 insertions(+)

diff --git a/debian/patches/hardware-detect.patch b/debian/patches/hardware-detect.patch
new file mode 100644
index 0000000..ddf49a2
--- /dev/null
+++ b/debian/patches/hardware-detect.patch
@@ -0,0 +1,66 @@
+Author: James Cowgill <jcowgill at debian.org>
+Last-Update: Tue, 16 May 2017 12:28:15 +0100
+Bug-Debian: https://bugs.debian.org/861754
+Description: uses GCC's __builtin_cpu_supports which is nicer than cpuid
+
+--- a/src/hardware.c
++++ b/src/hardware.c
+@@ -21,45 +21,23 @@
+ 
+ #include "pll.h"
+ 
+-#ifndef __PPC__
+-#define cpuid(f1, f2, a, b, c, d)                                \
+-  __asm__ __volatile__ ("cpuid"                                  \
+-                        : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
+-                        : "a" (f1), "c" (f2));
+-#endif
+-
+ static void cpu_features_detect()
+ {
+-  unsigned int a,b,c,d;
+-
+   memset(pll_hardware,0,sizeof(pll_hardware_t));
+ 
+-#ifdef __PPC__
+-  pll_hardware->altivec_present = 1;
+-#else
+-
+-  cpuid(0,0,a,b,c,d);
+-  unsigned int maxlevel = a & 0xff;
+-
+-  if (maxlevel >= 1)
+-  {
+-    cpuid(1,0,a,b,c,d);
+-    pll_hardware->mmx_present    = (d >> 23) & 1;
+-    pll_hardware->sse_present    = (d >> 25) & 1;
+-    pll_hardware->sse2_present   = (d >> 26) & 1;
+-    pll_hardware->sse3_present   = (c >>  0) & 1;
+-    pll_hardware->ssse3_present  = (c >>  9) & 1;
+-    pll_hardware->sse41_present  = (c >> 19) & 1;
+-    pll_hardware->sse42_present  = (c >> 20) & 1;
+-    pll_hardware->popcnt_present = (c >> 23) & 1;
+-    pll_hardware->avx_present    = (c >> 28) & 1;
+-
+-    if (maxlevel >= 7)
+-    {
+-      cpuid(7,0,a,b,c,d);
+-      pll_hardware->avx2_present = (b >> 5) & 1;
+-    }
+-  }
++#if defined(__PPC__)
++  pll_hardware->altivec_present = __builtin_cpu_supports("altivec");
++#elif defined(__x86_64__) || defined(__i386__)
++  pll_hardware->mmx_present     = __builtin_cpu_supports("mmx");
++  pll_hardware->sse_present     = __builtin_cpu_supports("sse");
++  pll_hardware->sse2_present    = __builtin_cpu_supports("sse2");
++  pll_hardware->sse3_present    = __builtin_cpu_supports("sse3");
++  pll_hardware->ssse3_present   = __builtin_cpu_supports("ssse3");
++  pll_hardware->sse41_present   = __builtin_cpu_supports("sse4.1");
++  pll_hardware->sse42_present   = __builtin_cpu_supports("sse4.2");
++  pll_hardware->popcnt_present  = __builtin_cpu_supports("popcnt");
++  pll_hardware->avx_present     = __builtin_cpu_supports("avx");
++  pll_hardware->avx2_present    = __builtin_cpu_supports("avx2");
+ #endif
+ }
+ 
diff --git a/debian/patches/series b/debian/patches/series
index 47e6f28..ad606b6 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 have_x86intrin_h.patch
+hardware-detect.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/libpll.git



More information about the debian-med-commit mailing list