[git] GCRYPT - branch, LIBGCRYPT-1-6-BRANCH, updated. libgcrypt-1.6.1-3-ga76148a

by Jussi Kivilinna cvs at cvs.gnupg.org
Fri Jan 31 08:54:59 CET 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU crypto library".

The branch, LIBGCRYPT-1-6-BRANCH has been updated
       via  a76148ac8fed0f0b82d85e94df5018659592893a (commit)
      from  3216da3ddbc3eeb49171ab179acd9d75ca4d0218 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a76148ac8fed0f0b82d85e94df5018659592893a
Author: Jussi Kivilinna <jussi.kivilinna at iki.fi>
Date:   Mon Dec 30 15:10:13 2013 +0200

    Parse /proc/cpuinfo for ARM HW features
    
    * src/hwf-arm.c [__linux__] (HAS_PROC_CPUINFO)
    (detect_arm_proc_cpuinfo): New.
    (_gcry_hwf_detect_arm) [HAS_PROC_CPUINFO]: Check '/proc/cpuinfo' for
    HW features.
    --
    
    Some Linux platforms (read: Android) block read access to '/proc/self/auxv',
    which prevents NEON HW detection. Patch adds alternative check which parses
    '/proc/cpuinfo' which should be accessable by Android applications.
    
    Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
    (cherry picked from commit a05be441d8cd89b90d8d58e3a343a436dae377d0)

diff --git a/src/hwf-arm.c b/src/hwf-arm.c
index 5c99a1d..aa4bfd7 100644
--- a/src/hwf-arm.c
+++ b/src/hwf-arm.c
@@ -32,6 +32,7 @@
 #endif
 
 #undef HAS_SYS_AT_HWCAP
+#undef HAS_PROC_CPUINFO
 #ifdef __linux__
 
 #define HAS_SYS_AT_HWCAP 1
@@ -94,6 +95,54 @@ detect_arm_at_hwcap(void)
   return features;
 }
 
+#define HAS_PROC_CPUINFO 1
+
+static unsigned int
+detect_arm_proc_cpuinfo(void)
+{
+  char buf[1024]; /* large enough */
+  char *str_features, *str_neon;
+  FILE *f;
+  int readlen, i;
+  static int cpuinfo_initialized = 0;
+  static unsigned int stored_cpuinfo_features;
+
+  if (cpuinfo_initialized)
+    return stored_cpuinfo_features;
+
+  f = fopen("/proc/cpuinfo", "r");
+  if (!f)
+    return 0;
+
+  memset (buf, 0, sizeof(buf));
+  readlen = fread (buf, 1, sizeof(buf), f);
+  fclose (f);
+  if (readlen <= 0 || readlen > sizeof(buf))
+    return 0;
+
+  buf[sizeof(buf) - 1] = '\0';
+
+  cpuinfo_initialized = 1;
+  stored_cpuinfo_features = 0;
+
+  /* Find features line. */
+  str_features = strstr(buf, "Features");
+  if (!str_features)
+    return stored_cpuinfo_features;
+
+  /* Lines to strings. */
+  for (i = 0; i < sizeof(buf); i++)
+    if (buf[i] == '\n')
+      buf[i] = '\0';
+
+  /* Check for NEON. */
+  str_neon = strstr(str_features, " neon");
+  if (str_neon && (str_neon[5] == ' ' || str_neon[5] == '\0'))
+    stored_cpuinfo_features |= HWF_ARM_NEON;
+
+  return stored_cpuinfo_features;
+}
+
 #endif /* __linux__ */
 
 unsigned int
@@ -103,8 +152,10 @@ _gcry_hwf_detect_arm (void)
 
 #if defined (HAS_SYS_AT_HWCAP)
   ret |= detect_arm_at_hwcap ();
-#else
-  ret |= 0;
+#endif
+
+#if defined (HAS_PROC_CPUINFO)
+  ret |= detect_arm_proc_cpuinfo ();
 #endif
 
 #if defined(__ARM_NEON__) && defined(ENABLE_NEON_SUPPORT)

-----------------------------------------------------------------------

Summary of changes:
 src/hwf-arm.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 53 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
The GNU crypto library
http://git.gnupg.org




More information about the Gnupg-commits mailing list