[git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-162-g9d2a22c

by Werner Koch cvs at cvs.gnupg.org
Thu Jan 15 10:38:11 CET 2015


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, master has been updated
       via  9d2a22c94ae99f9301321082c4fb8d73f4085fda (commit)
       via  27a91a93d101ef080f71e5d7e50c3cbf3dbb2e39 (commit)
      from  9d328962660da72f094dc5424d5ef67abbaffdf6 (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 9d2a22c94ae99f9301321082c4fb8d73f4085fda
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jan 15 10:04:43 2015 +0100

    Add functions to count trailing zero bits in a word.
    
    * cipher/bithelp.h (_gcry_ctz, _gcry_ctz64): New.
    * configure.ac (HAVE_BUILTIN_CTZ): Add new test.
    --
    
    Note that these functions return the number of bits in the word when
    passing 0.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/cipher/bithelp.h b/cipher/bithelp.h
index 6e59c53..2220bc8 100644
--- a/cipher/bithelp.h
+++ b/cipher/bithelp.h
@@ -77,4 +77,49 @@ _gcry_bswap64(u64 x)
 # endif
 #endif
 
+
+/* Count trailing zero bits in an unsigend int.  We return an int
+   because that is what gcc's builtin does.  Returns the number of
+   bits in X if X is 0. */
+static inline int
+_gcry_ctz (unsigned int x)
+{
+#if defined (HAVE_BUILTIN_CTZ)
+  return x? __builtin_ctz (x) : 8 * sizeof (x);
+#else
+  /* See
+   * http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightModLookup
+   */
+  static const unsigned char mod37[] =
+    {
+      sizeof (unsigned int)*8,
+          0,  1, 26,  2, 23, 27,  0,  3, 16, 24, 30, 28, 11,  0, 13,
+      4,  7, 17,  0, 25, 22, 31, 15, 29, 10, 12,  6,  0, 21, 14,  9,
+      5, 20,  8, 19, 18
+    };
+  return (int)mod37[(-x & x) % 37];
+#endif
+}
+
+
+/* Count trailing zero bits in an u64.  We return an int because that
+   is what gcc's builtin does.  Returns the number of bits in X if X
+   is 0.  */
+#ifdef HAVE_U64_TYPEDEF
+static inline int
+_gcry_ctz64(u64 x)
+{
+#if defined (HAVE_BUILTIN_CTZ) && SIZEOF_UNSIGNED_INT >= 8
+#warning hello
+  return x? __builtin_ctz (x) : 8 * sizeof (x);
+#else
+  if ((x & 0xffffffff))
+    return _gcry_ctz (x);
+  else
+    return 32 + _gcry_ctz (x >> 32);
+#endif
+}
+#endif /*HAVE_U64_TYPEDEF*/
+
+
 #endif /*G10_BITHELP_H*/
diff --git a/configure.ac b/configure.ac
index 4cfebe7..4bbd686 100644
--- a/configure.ac
+++ b/configure.ac
@@ -827,6 +827,21 @@ fi
 
 
 #
+# Check for __builtin_ctz intrinsic.
+#
+AC_CACHE_CHECK(for __builtin_ctz,
+       [gcry_cv_have_builtin_ctz],
+       [gcry_cv_have_builtin_ctz=no
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([],
+          [unsigned int x = 0; int y = __builtin_ctz(x); return y;])],
+          [gcry_cv_have_builtin_ctz=yes])])
+if test "$gcry_cv_have_builtin_ctz" = "yes" ; then
+   AC_DEFINE(HAVE_BUILTIN_CTZ, 1,
+             [Defined if compiler has '__builtin_ctz' intrinsic])
+fi
+
+
+#
 # Check for VLA support (variable length arrays).
 #
 AC_CACHE_CHECK(whether the variable length arrays are supported,

commit 27a91a93d101ef080f71e5d7e50c3cbf3dbb2e39
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jan 15 10:02:28 2015 +0100

    Re-indent types.h for easier reading.
    
    --

diff --git a/src/types.h b/src/types.h
index ee0a62b..561b74d 100644
--- a/src/types.h
+++ b/src/types.h
@@ -25,16 +25,16 @@
 /* The AC_CHECK_SIZEOF() in configure fails for some machines.
  * we provide some fallback values here */
 #if !SIZEOF_UNSIGNED_SHORT
-#undef SIZEOF_UNSIGNED_SHORT
-#define SIZEOF_UNSIGNED_SHORT 2
+# undef SIZEOF_UNSIGNED_SHORT
+# define SIZEOF_UNSIGNED_SHORT 2
 #endif
 #if !SIZEOF_UNSIGNED_INT
-#undef SIZEOF_UNSIGNED_INT
-#define SIZEOF_UNSIGNED_INT 4
+# undef SIZEOF_UNSIGNED_INT
+# define SIZEOF_UNSIGNED_INT 4
 #endif
 #if !SIZEOF_UNSIGNED_LONG
-#undef SIZEOF_UNSIGNED_LONG
-#define SIZEOF_UNSIGNED_LONG 4
+# undef SIZEOF_UNSIGNED_LONG
+# define SIZEOF_UNSIGNED_LONG 4
 #endif
 
 
@@ -42,87 +42,88 @@
 
 
 #ifndef HAVE_BYTE_TYPEDEF
-#undef byte	    /* maybe there is a macro with this name */
-/* Windows typedefs byte in the rpc headers.  Avoid warning about
-   double definition.  */
-#if !(defined(_WIN32) && defined(cbNDRContext))
-  typedef unsigned char byte;
-#endif
-#define HAVE_BYTE_TYPEDEF
+# undef byte	/* In case there is a macro with that name.  */
+# if !(defined(_WIN32) && defined(cbNDRContext))
+   /* Windows typedefs byte in the rpc headers.  Avoid warning about
+      double definition.  */
+   typedef unsigned char byte;
+# endif
+# define HAVE_BYTE_TYPEDEF
 #endif
 
 #ifndef HAVE_USHORT_TYPEDEF
-#undef ushort     /* maybe there is a macro with this name */
+# undef ushort  /* In case there is a macro with that name.  */
   typedef unsigned short ushort;
-#define HAVE_USHORT_TYPEDEF
+# define HAVE_USHORT_TYPEDEF
 #endif
 
 #ifndef HAVE_ULONG_TYPEDEF
-#undef ulong	    /* maybe there is a macro with this name */
+# undef ulong   /* In case there is a macro with that name.  */
   typedef unsigned long ulong;
-#define HAVE_ULONG_TYPEDEF
+# define HAVE_ULONG_TYPEDEF
 #endif
 
 #ifndef HAVE_U16_TYPEDEF
-#undef u16	    /* maybe there is a macro with this name */
-#if SIZEOF_UNSIGNED_INT == 2
-    typedef unsigned int   u16;
-#elif SIZEOF_UNSIGNED_SHORT == 2
-    typedef unsigned short u16;
-#else
-#error no typedef for u16
-#endif
-#define HAVE_U16_TYPEDEF
+# undef u16	/* In case there is a macro with that name.  */
+# if SIZEOF_UNSIGNED_INT == 2
+   typedef unsigned int   u16;
+# elif SIZEOF_UNSIGNED_SHORT == 2
+   typedef unsigned short u16;
+# else
+#  error no typedef for u16
+# endif
+# define HAVE_U16_TYPEDEF
 #endif
 
 #ifndef HAVE_U32_TYPEDEF
-#undef u32	    /* maybe there is a macro with this name */
-#if SIZEOF_UNSIGNED_INT == 4
-    typedef unsigned int u32;
-#elif SIZEOF_UNSIGNED_LONG == 4
-    typedef unsigned long u32;
-#else
-#error no typedef for u32
-#endif
-#define HAVE_U32_TYPEDEF
+# undef u32	/* In case there is a macro with that name.  */
+# if SIZEOF_UNSIGNED_INT == 4
+   typedef unsigned int  u32;
+# elif SIZEOF_UNSIGNED_LONG == 4
+   typedef unsigned long u32;
+# else
+#  error no typedef for u32
+# endif
+# define HAVE_U32_TYPEDEF
 #endif
 
-/****************
+/*
  * Warning: Some systems segfault when this u64 typedef and
  * the dummy code in cipher/md.c is not available.  Examples are
  * Solaris and IRIX.
  */
 #ifndef HAVE_U64_TYPEDEF
-#undef u64	    /* maybe there is a macro with this name */
-#if SIZEOF_UNSIGNED_INT == 8
-    typedef unsigned int u64;
-#define U64_C(c) (c ## U)
-#define HAVE_U64_TYPEDEF
-#elif SIZEOF_UNSIGNED_LONG == 8
-    typedef unsigned long u64;
-#define U64_C(c) (c ## UL)
-#define HAVE_U64_TYPEDEF
-#elif SIZEOF_UNSIGNED_LONG_LONG == 8
-    typedef unsigned long long u64;
-#define U64_C(c) (c ## ULL)
-#define HAVE_U64_TYPEDEF
-#elif SIZEOF_UINT64_T == 8
-    typedef uint64_t u64;
-#define U64_C(c) (UINT64_C(c))
-#define HAVE_U64_TYPEDEF
-#endif
+# undef u64	/* In case there is a macro with that name.  */
+# if SIZEOF_UNSIGNED_INT == 8
+   typedef unsigned int u64;
+#  define U64_C(c) (c ## U)
+#  define HAVE_U64_TYPEDEF
+# elif SIZEOF_UNSIGNED_LONG == 8
+   typedef unsigned long u64;
+#  define U64_C(c) (c ## UL)
+#  define HAVE_U64_TYPEDEF
+# elif SIZEOF_UNSIGNED_LONG_LONG == 8
+   typedef unsigned long long u64;
+#  define U64_C(c) (c ## ULL)
+#  define HAVE_U64_TYPEDEF
+# elif SIZEOF_UINT64_T == 8
+   typedef uint64_t u64;
+#  define U64_C(c) (UINT64_C(c))
+#  define HAVE_U64_TYPEDEF
+# endif
 #endif
 
-typedef union {
-    int a;
-    short b;
-    char c[1];
-    long d;
+typedef union
+{
+  int a;
+  short b;
+  char c[1];
+  long d;
 #ifdef HAVE_U64_TYPEDEF
-    u64 e;
+  u64 e;
 #endif
-    float f;
-    double g;
+  float f;
+  double g;
 } PROPERLY_ALIGNED_TYPE;
 
 #endif /*GCRYPT_TYPES_H*/

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

Summary of changes:
 cipher/bithelp.h |  45 ++++++++++++++++++++
 configure.ac     |  15 +++++++
 src/types.h      | 125 ++++++++++++++++++++++++++++---------------------------
 3 files changed, 123 insertions(+), 62 deletions(-)


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


_______________________________________________
Gnupg-commits mailing list
Gnupg-commits at gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-commits




More information about the Gcrypt-devel mailing list