From 64454448808cc261cebd4ed791110db291806a5e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Mon, 8 Jan 2018 22:14:54 +0100
Subject: [PATCH] Configure check for __builtin_bswap64.

---
 ChangeLog    |  3 +++
 configure.ac | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index d7076285..92658fe7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,9 @@
 
 2018-01-08  Niels Möller  <nisse@lysator.liu.se>
 
+	* configure.ac: Check for __builtin_bswap64, define
+	HAVE_BUILTIN_BSWAP64 if available.
+
 	* ctr.c (ctr_fill): New function. Use in ctr_crypt.
 
 	* ctr.c (ctr_crypt): For in-place operation, increase max buffer
diff --git a/configure.ac b/configure.ac
index 8668263c..8fb1cb2a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -203,6 +203,22 @@ LSH_FUNC_STRERROR
 AC_CHECK_FUNCS(secure_getenv getline)
 AC_C_BIGENDIAN
 
+AC_CACHE_CHECK([for __builtin_bswap64],
+		nettle_cv_c_builtin_bswap64,
+[AC_TRY_COMPILE([
+#include <stdint.h>
+],[
+uint64_t x = 17;
+uint64_t y = __builtin_bswap64(x);
+],
+nettle_cv_c_builtin_bswap64=yes,
+nettle_cv_c_builtin_bswap64=no)])
+
+AH_TEMPLATE([HAVE_BUILTIN_BSWAP64], [Define if __builtin_bswap64 is available])
+if test "x$nettle_cv_c_builtin_bswap64" = "xyes" ; then
+  AC_DEFINE(HAVE_BUILTIN_BSWAP64)
+fi
+
 LSH_GCC_ATTRIBUTES
 
 # According to Simon Josefsson, looking for uint32_t and friends in
-- 
GitLab