[git] GCRYPT - branch, cipher-amd64-optimizations, updated. libgcrypt-1.5.0-153-g3544fa8

by Jussi Kivilinna cvs at cvs.gnupg.org
Thu Jun 20 16:17:39 CEST 2013


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, cipher-amd64-optimizations has been updated
       via  3544fa8aa63bef9a35abf236e9376191b5ec206b (commit)
      from  ec2f8de409a93c80efa658134df22074a9bca5a4 (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 3544fa8aa63bef9a35abf236e9376191b5ec206b
Author: Jussi Kivilinna <jussi.kivilinna at iki.fi>
Date:   Thu Jun 20 14:20:36 2013 +0300

    Check if assembler is compatible with AMD64 assembly implementations
    
    * cipher/blowfish-amd64.S: Enable only if
    HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS is defined.
    * cipher/camellia-aesni-avx-amd64.S: Ditto.
    * cipher/camellia-aesni-avx2-amd64.S: Ditto.
    * cipher/cast5-amd64.S: Ditto.
    * cipher/rinjdael-amd64.S: Ditto.
    * cipher/serpent-avx2-amd64.S: Ditto.
    * cipher/serpent-sse2-amd64.S: Ditto.
    * cipher/twofish-amd64.S: Ditto.
    * cipher/blowfish.c: Use AMD64 assembly implementation only if
    HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS is defined
    * cipher/camellia-glue.c: Ditto.
    * cipher/cast5.c: Ditto.
    * cipher/rijndael.c: Ditto.
    * cipher/serpent.c: Ditto.
    * cipher/twofish.c: Ditto.
    * configure.ac: Check gcc/as compatibility with AMD64 assembly
    implementations.
    --
    
    Later these checks can be split and assembly implementations adapted to handle
    different platforms, but for now disable AMD64 assembly implementations if
    assembler does not look to be able to handle them.
    
    Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>

diff --git a/cipher/blowfish-amd64.S b/cipher/blowfish-amd64.S
index 1008387..6975e55 100644
--- a/cipher/blowfish-amd64.S
+++ b/cipher/blowfish-amd64.S
@@ -20,7 +20,7 @@
 
 #ifdef __x86_64
 #include <config.h>
-#if defined(USE_BLOWFISH)
+#if defined(USE_BLOWFISH) && defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS)
 
 .text
 
diff --git a/cipher/blowfish.c b/cipher/blowfish.c
index 39d4051..69baebe 100644
--- a/cipher/blowfish.c
+++ b/cipher/blowfish.c
@@ -45,7 +45,8 @@
 
 /* USE_AMD64_ASM indicates whether to use AMD64 assembly code. */
 #undef USE_AMD64_ASM
-#if defined(__x86_64__) && (BLOWFISH_ROUNDS == 16)
+#if defined(__x86_64__) && defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) && \
+    (BLOWFISH_ROUNDS == 16)
 # define USE_AMD64_ASM 1
 #endif
 
diff --git a/cipher/camellia-aesni-avx-amd64.S b/cipher/camellia-aesni-avx-amd64.S
index 95c96b8..b0ef5fd 100644
--- a/cipher/camellia-aesni-avx-amd64.S
+++ b/cipher/camellia-aesni-avx-amd64.S
@@ -20,7 +20,8 @@
 
 #ifdef __x86_64
 #include <config.h>
-#if defined(ENABLE_AESNI_SUPPORT) && defined(ENABLE_AVX_SUPPORT)
+#if defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) && \
+    defined(ENABLE_AESNI_SUPPORT) && defined(ENABLE_AVX_SUPPORT)
 
 #ifdef __PIC__
 #  define RIP (%rip)
diff --git a/cipher/camellia-aesni-avx2-amd64.S b/cipher/camellia-aesni-avx2-amd64.S
index f0a34fd..da427b4 100644
--- a/cipher/camellia-aesni-avx2-amd64.S
+++ b/cipher/camellia-aesni-avx2-amd64.S
@@ -20,7 +20,8 @@
 
 #ifdef __x86_64
 #include <config.h>
-#if defined(ENABLE_AESNI_SUPPORT) && defined(ENABLE_AVX2_SUPPORT)
+#if defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) && \
+    defined(ENABLE_AESNI_SUPPORT) && defined(ENABLE_AVX2_SUPPORT)
 
 #ifdef __PIC__
 #  define RIP (%rip)
diff --git a/cipher/camellia-glue.c b/cipher/camellia-glue.c
index a5468fa..b44bd7b 100644
--- a/cipher/camellia-glue.c
+++ b/cipher/camellia-glue.c
@@ -75,7 +75,7 @@
 /* USE_AESNI inidicates whether to compile with Intel AES-NI/AVX code. */
 #undef USE_AESNI_AVX
 #if defined(ENABLE_AESNI_SUPPORT) && defined(ENABLE_AVX_SUPPORT)
-# if defined(__x86_64__)
+# if defined(__x86_64__) && defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS)
 #  define USE_AESNI_AVX 1
 # endif
 #endif
@@ -83,7 +83,7 @@
 /* USE_AESNI_AVX2 inidicates whether to compile with Intel AES-NI/AVX2 code. */
 #undef USE_AESNI_AVX2
 #if defined(ENABLE_AESNI_SUPPORT) && defined(ENABLE_AVX2_SUPPORT)
-# if defined(__x86_64__)
+# if defined(__x86_64__) && defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS)
 #  define USE_AESNI_AVX2 1
 # endif
 #endif
diff --git a/cipher/cast5-amd64.S b/cipher/cast5-amd64.S
index c3007d3..1bca249 100644
--- a/cipher/cast5-amd64.S
+++ b/cipher/cast5-amd64.S
@@ -20,7 +20,7 @@
 
 #ifdef __x86_64
 #include <config.h>
-#if defined(USE_CAST5)
+#if defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) && defined(USE_CAST5)
 
 #ifdef __PIC__
 #  define RIP %rip
diff --git a/cipher/cast5.c b/cipher/cast5.c
index 8c5664d..41bc9ff 100644
--- a/cipher/cast5.c
+++ b/cipher/cast5.c
@@ -47,7 +47,7 @@
 
 /* USE_AMD64_ASM indicates whether to use AMD64 assembly code. */
 #undef USE_AMD64_ASM
-#if defined(__x86_64__)
+#if defined(__x86_64__) && defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS)
 # define USE_AMD64_ASM 1
 #endif
 
diff --git a/cipher/rijndael-amd64.S b/cipher/rijndael-amd64.S
index 6921f31..2519ada 100644
--- a/cipher/rijndael-amd64.S
+++ b/cipher/rijndael-amd64.S
@@ -20,7 +20,7 @@
 
 #ifdef __x86_64
 #include <config.h>
-#if defined(USE_AES)
+#if defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) && defined(USE_AES)
 
 #ifdef __PIC__
 #  define RIP %rip
diff --git a/cipher/rijndael.c b/cipher/rijndael.c
index 4a89e32..35e599a 100644
--- a/cipher/rijndael.c
+++ b/cipher/rijndael.c
@@ -63,7 +63,7 @@
 
 /* USE_AMD64_ASM indicates whether to use AMD64 assembly code. */
 #undef USE_AMD64_ASM
-#if defined(__x86_64__)
+#if defined(__x86_64__) && defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS)
 # define USE_AMD64_ASM 1
 #endif
 
diff --git a/cipher/serpent-avx2-amd64.S b/cipher/serpent-avx2-amd64.S
index 7f4f8b5..7586c0c 100644
--- a/cipher/serpent-avx2-amd64.S
+++ b/cipher/serpent-avx2-amd64.S
@@ -20,7 +20,8 @@
 
 #ifdef __x86_64
 #include <config.h>
-#if defined(USE_SERPENT) && defined(ENABLE_AVX2_SUPPORT)
+#if defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) && defined(USE_SERPENT) && \
+    defined(ENABLE_AVX2_SUPPORT)
 
 #ifdef __PIC__
 #  define RIP (%rip)
diff --git a/cipher/serpent-sse2-amd64.S b/cipher/serpent-sse2-amd64.S
index 5f9e9d2..fe9feee 100644
--- a/cipher/serpent-sse2-amd64.S
+++ b/cipher/serpent-sse2-amd64.S
@@ -20,7 +20,7 @@
 
 #ifdef __x86_64
 #include <config.h>
-#if defined(USE_SERPENT)
+#if defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) && defined(USE_SERPENT)
 
 #ifdef __PIC__
 #  define RIP (%rip)
diff --git a/cipher/serpent.c b/cipher/serpent.c
index 89e14ae..8aded34 100644
--- a/cipher/serpent.c
+++ b/cipher/serpent.c
@@ -34,13 +34,13 @@
 
 /* USE_SSE2 indicates whether to compile with AMD64 SSE2 code. */
 #undef USE_SSE2
-#if defined(__x86_64__)
+#if defined(__x86_64__) && defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS)
 # define USE_SSE2 1
 #endif
 
 /* USE_AVX2 indicates whether to compile with AMD64 AVX2 code. */
 #undef USE_AVX2
-#if defined(__x86_64__)
+#if defined(__x86_64__) && defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS)
 # if defined(ENABLE_AVX2_SUPPORT)
 #  define USE_AVX2 1
 # endif
diff --git a/cipher/twofish-amd64.S b/cipher/twofish-amd64.S
index a2a878a..d466834 100644
--- a/cipher/twofish-amd64.S
+++ b/cipher/twofish-amd64.S
@@ -20,7 +20,7 @@
 
 #ifdef __x86_64
 #include <config.h>
-#if defined(USE_TWOFISH)
+#if defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) && defined(USE_TWOFISH)
 
 #ifdef __PIC__
 #  define RIP %rip
diff --git a/cipher/twofish.c b/cipher/twofish.c
index ee721c6..07a4ebe 100644
--- a/cipher/twofish.c
+++ b/cipher/twofish.c
@@ -53,7 +53,7 @@
 
 /* USE_AMD64_ASM indicates whether to use AMD64 assembly code. */
 #undef USE_AMD64_ASM
-#if defined(__x86_64__)
+#if defined(__x86_64__) && defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS)
 # define USE_AMD64_ASM 1
 #endif
 
diff --git a/configure.ac b/configure.ac
index 5b9d837..d9b1639 100644
--- a/configure.ac
+++ b/configure.ac
@@ -941,6 +941,36 @@ if test "$gcry_cv_gcc_inline_asm_avx2" = "yes" ; then
 fi
 
 
+#
+# Check whether GCC assembler supports features needed for our amd64
+# implementations
+#
+AC_CACHE_CHECK([whether GCC assembler is compatible for amd64 assembly implementations],
+       [gcry_cv_gcc_amd64_platform_as_ok],
+       [gcry_cv_gcc_amd64_platform_as_ok=no
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+          [[__asm__(
+                /* Test if '.set' is supported by underlying assembler.  */
+                ".set a0, %rax\n\t"
+                ".set b0, %rdx\n\t"
+                "asmfunc:\n\t"
+                "movq a0, b0;\n\t" /* Fails here if .set ignored by as.  */
+
+                /* Test if '.type' and '.size' are supported.  */
+                /* These work only on ELF targets. */
+		/* TODO: add COFF (mingw64, cygwin64) support to assembly
+                 * implementations.  Mingw64/cygwin64 also require additional
+                 * work because they use different calling convention. */
+                ".size asmfunc,.-asmfunc;\n\t"
+                ".type asmfunc, at function;\n\t"
+            );]])],
+          [gcry_cv_gcc_amd64_platform_as_ok=yes])])
+if test "$gcry_cv_gcc_amd64_platform_as_ok" = "yes" ; then
+   AC_DEFINE(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS,1,
+     [Defined if underlying assembler is compatible with amd64 assembly implementations])
+fi
+
+
 #######################################
 #### Checks for library functions. ####
 #######################################

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

Summary of changes:
 cipher/blowfish-amd64.S            |    2 +-
 cipher/blowfish.c                  |    3 ++-
 cipher/camellia-aesni-avx-amd64.S  |    3 ++-
 cipher/camellia-aesni-avx2-amd64.S |    3 ++-
 cipher/camellia-glue.c             |    4 ++--
 cipher/cast5-amd64.S               |    2 +-
 cipher/cast5.c                     |    2 +-
 cipher/rijndael-amd64.S            |    2 +-
 cipher/rijndael.c                  |    2 +-
 cipher/serpent-avx2-amd64.S        |    3 ++-
 cipher/serpent-sse2-amd64.S        |    2 +-
 cipher/serpent.c                   |    4 ++--
 cipher/twofish-amd64.S             |    2 +-
 cipher/twofish.c                   |    2 +-
 configure.ac                       |   30 ++++++++++++++++++++++++++++++
 15 files changed, 50 insertions(+), 16 deletions(-)


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




More information about the Gnupg-commits mailing list