From c7bda0314dae8986496f3af770563fafd1f4bc2e Mon Sep 17 00:00:00 2001
From: =?utf8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Sun, 27 Nov 2016 00:23:14 +0000
Subject: [PATCH] md4,md5,sha*: allow _STRING_INLINE_unaligned enable unaligned
 operation

* lib/md4.c (md4_process_bytes): The existing define is made internal
in recent versions of glibc, so also use this new public define.
* lib/md5.c (md5_process_bytes): Likewise.
* lib/sha1.c (sha1_process_bytes): Likewise.
* lib/sha256.c (sha256_process_bytes): Likewise.
* lib/sha512.c (sha512_process_bytes): Likewise.
---
 ChangeLog    | 10 ++++++++++
 lib/md4.c    |  2 +-
 lib/md5.c    |  2 +-
 lib/sha1.c   |  2 +-
 lib/sha256.c |  2 +-
 lib/sha512.c |  2 +-
 6 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c27f6191e5..b2434b30c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2016-11-27  Pádraig Brady  <P@draigBrady.com>
+
+	md4,md5,sha*: allow _STRING_INLINE_unaligned enable unaligned operation
+	* lib/md4.c (md4_process_bytes): The existing define is made internal
+	in recent versions of glibc, so also use this new public define.
+	* lib/md5.c (md5_process_bytes): Likewise.
+	* lib/sha1.c (sha1_process_bytes): Likewise.
+	* lib/sha256.c (sha256_process_bytes): Likewise.
+	* lib/sha512.c (sha512_process_bytes): Likewise.
+
 2016-11-27  Pádraig Brady  <P@draigBrady.com>
 
 	maint: use a more standard return from mbrtowc test
diff --git a/lib/md4.c b/lib/md4.c
index 4f6193a643..ecfc45f574 100644
--- a/lib/md4.c
+++ b/lib/md4.c
@@ -237,7 +237,7 @@ md4_process_bytes (const void *buffer, size_t len, struct md4_ctx *ctx)
   /* Process available complete blocks.  */
   if (len >= 64)
     {
-#if !_STRING_ARCH_unaligned
+#if !(_STRING_ARCH_unaligned || _STRING_INLINE_unaligned)
 # define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
       if (UNALIGNED_P (buffer))
         while (len > 64)
diff --git a/lib/md5.c b/lib/md5.c
index 33c3a08b73..1b39da8135 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -259,7 +259,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
   /* Process available complete blocks.  */
   if (len >= 64)
     {
-#if !_STRING_ARCH_unaligned
+#if !(_STRING_ARCH_unaligned || _STRING_INLINE_unaligned)
 # define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
       if (UNALIGNED_P (buffer))
         while (len > 64)
diff --git a/lib/sha1.c b/lib/sha1.c
index d679d42fdc..6201e1f8ee 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -246,7 +246,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
   /* Process available complete blocks.  */
   if (len >= 64)
     {
-#if !_STRING_ARCH_unaligned
+#if !(_STRING_ARCH_unaligned || _STRING_INLINE_unaligned)
 # define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
       if (UNALIGNED_P (buffer))
         while (len > 64)
diff --git a/lib/sha256.c b/lib/sha256.c
index 0be8fd2a85..5251e8d950 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -379,7 +379,7 @@ sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx)
   /* Process available complete blocks.  */
   if (len >= 64)
     {
-#if !_STRING_ARCH_unaligned
+#if !(_STRING_ARCH_unaligned || _STRING_INLINE_unaligned)
 # define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
       if (UNALIGNED_P (buffer))
         while (len > 64)
diff --git a/lib/sha512.c b/lib/sha512.c
index 5494dcbdba..71a7eca14d 100644
--- a/lib/sha512.c
+++ b/lib/sha512.c
@@ -387,7 +387,7 @@ sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx)
   /* Process available complete blocks.  */
   if (len >= 128)
     {
-#if !_STRING_ARCH_unaligned
+#if !(_STRING_ARCH_unaligned || _STRING_INLINE_unaligned)
 # define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (u64) != 0)
       if (UNALIGNED_P (buffer))
         while (len > 128)
-- 
2.39.5