From: Bruno Haible <bruno@clisp.org>
Date: Sun, 23 Feb 2020 12:20:18 +0000 (+0100)
Subject: crypto/sha512-buffer: Use 'restrict'.
X-Git-Tag: v1.0~4205
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=734c22abe7d5d046a360415bb030baf2952d5807;p=gnulib.git

crypto/sha512-buffer: Use 'restrict'.

* lib/sha512.h (sha512_finish_ctx, sha384_finish_ctx, sha512_read_ctx,
sha384_read_ctx, sha512_buffer, sha384_buffer): Use 'restrict'.
* modules/crypto/sha512-buffer (configure.ac): Require AC_C_RESTRICT.
---

diff --git a/ChangeLog b/ChangeLog
index 6e782e1be0..8701bead11 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2020-02-23  Bruno Haible  <bruno@clisp.org>
 
+	crypto/sha512-buffer: Use 'restrict'.
+	* lib/sha512.h (sha512_finish_ctx, sha384_finish_ctx, sha512_read_ctx,
+	sha384_read_ctx, sha512_buffer, sha384_buffer): Use 'restrict'.
+	* modules/crypto/sha512-buffer (configure.ac): Require AC_C_RESTRICT.
+
 	crypto/sha256-buffer: Use 'restrict'.
 	* lib/sha256.h (sha256_finish_ctx, sha224_finish_ctx, sha256_read_ctx,
 	sha224_read_ctx, sha256_buffer, sha224_buffer): Use 'restrict'.
diff --git a/lib/sha512.h b/lib/sha512.h
index aaf35a5f7d..21c2f58014 100644
--- a/lib/sha512.h
+++ b/lib/sha512.h
@@ -70,8 +70,8 @@ extern void sha512_process_bytes (const void *buffer, size_t len,
    in first 64 (48) bytes following RESBUF.  The result is always in little
    endian byte order, so that a byte-wise output yields to the wanted
    ASCII representation of the message digest.  */
-extern void *sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf);
-extern void *sha384_finish_ctx (struct sha512_ctx *ctx, void *resbuf);
+extern void *sha512_finish_ctx (struct sha512_ctx *ctx, void *restrict resbuf);
+extern void *sha384_finish_ctx (struct sha512_ctx *ctx, void *restrict resbuf);
 
 
 /* Put result from CTX in first 64 (48) bytes following RESBUF.  The result is
@@ -80,16 +80,20 @@ extern void *sha384_finish_ctx (struct sha512_ctx *ctx, void *resbuf);
 
    IMPORTANT: On some systems it is required that RESBUF is correctly
    aligned for a 32 bits value.  */
-extern void *sha512_read_ctx (const struct sha512_ctx *ctx, void *resbuf);
-extern void *sha384_read_ctx (const struct sha512_ctx *ctx, void *resbuf);
+extern void *sha512_read_ctx (const struct sha512_ctx *ctx,
+                              void *restrict resbuf);
+extern void *sha384_read_ctx (const struct sha512_ctx *ctx,
+                              void *restrict resbuf);
 
 
-/* Compute SHA512 (SHA384) message digest for LEN bytes beginning at BUFFER.  The
-   result is always in little endian byte order, so that a byte-wise
+/* Compute SHA512 (SHA384) message digest for LEN bytes beginning at BUFFER.
+   The result is always in little endian byte order, so that a byte-wise
    output yields to the wanted ASCII representation of the message
    digest.  */
-extern void *sha512_buffer (const char *buffer, size_t len, void *resblock);
-extern void *sha384_buffer (const char *buffer, size_t len, void *resblock);
+extern void *sha512_buffer (const char *buffer, size_t len,
+                            void *restrict resblock);
+extern void *sha384_buffer (const char *buffer, size_t len,
+                            void *restrict resblock);
 
 # endif
 /* Compute SHA512 (SHA384) message digest for bytes read from STREAM.
diff --git a/modules/crypto/sha512-buffer b/modules/crypto/sha512-buffer
index 32170a9a8a..7c5f64d64a 100644
--- a/modules/crypto/sha512-buffer
+++ b/modules/crypto/sha512-buffer
@@ -16,6 +16,7 @@ stdint
 u64
 
 configure.ac:
+AC_REQUIRE([AC_C_RESTRICT])
 gl_SHA512
 
 Makefile.am: