From c4ca8219dd6b8f06e67a0b767475b1259653b8e0 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 23 Feb 2020 16:14:24 -0800 Subject: [PATCH] Update from Gnulib This incorporates: 2020-02-23 use 'restrict' * lib/careadlinkat.h, lib/md5.h, lib/sha1.h, lib/sha256.h: * lib/sha512.h, lib/strftime.h, lib/string.in.h, m4/nstrftime.m4: Copy from Gnulib. * m4/gnulib-comp.m4: Regenerate. --- lib/careadlinkat.h | 2 +- lib/md5.h | 8 +++++--- lib/sha1.h | 7 ++++--- lib/sha256.h | 20 ++++++++++++-------- lib/sha512.h | 20 ++++++++++++-------- lib/strftime.h | 2 +- lib/string.in.h | 3 ++- m4/gnulib-comp.m4 | 5 +++++ m4/nstrftime.m4 | 4 +++- 9 files changed, 45 insertions(+), 26 deletions(-) diff --git a/lib/careadlinkat.h b/lib/careadlinkat.h index 584cfe9ad8e..a4a37b274d0 100644 --- a/lib/careadlinkat.h +++ b/lib/careadlinkat.h @@ -47,7 +47,7 @@ struct allocator; set errno. */ char *careadlinkat (int fd, char const *filename, - char *buffer, size_t buffer_size, + char *restrict buffer, size_t buffer_size, struct allocator const *alloc, ssize_t (*preadlinkat) (int, char const *, char *, size_t)); diff --git a/lib/md5.h b/lib/md5.h index 239748ae0cb..3c6048242b0 100644 --- a/lib/md5.h +++ b/lib/md5.h @@ -105,13 +105,15 @@ extern void __md5_process_bytes (const void *buffer, size_t len, in first 16 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 *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW; +extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *restrict resbuf) + __THROW; /* Put result from CTX in first 16 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 *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW; +extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *restrict resbuf) + __THROW; /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The @@ -119,7 +121,7 @@ extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW; output yields to the wanted ASCII representation of the message digest. */ extern void *__md5_buffer (const char *buffer, size_t len, - void *resblock) __THROW; + void *restrict resblock) __THROW; # endif /* Compute MD5 message digest for bytes read from STREAM. diff --git a/lib/sha1.h b/lib/sha1.h index 2c9c2d4a5e2..b76788487c3 100644 --- a/lib/sha1.h +++ b/lib/sha1.h @@ -71,20 +71,21 @@ extern void sha1_process_bytes (const void *buffer, size_t len, in first 20 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 *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf); +extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *restrict resbuf); /* Put result from CTX in first 20 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 *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf); +extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *restrict resbuf); /* Compute SHA1 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 *sha1_buffer (const char *buffer, size_t len, void *resblock); +extern void *sha1_buffer (const char *buffer, size_t len, + void *restrict resblock); # endif /* Compute SHA1 message digest for bytes read from STREAM. diff --git a/lib/sha256.h b/lib/sha256.h index 1bc61d437c9..750d78a2696 100644 --- a/lib/sha256.h +++ b/lib/sha256.h @@ -70,23 +70,27 @@ extern void sha256_process_bytes (const void *buffer, size_t len, in first 32 (28) 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 *sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf); -extern void *sha224_finish_ctx (struct sha256_ctx *ctx, void *resbuf); +extern void *sha256_finish_ctx (struct sha256_ctx *ctx, void *restrict resbuf); +extern void *sha224_finish_ctx (struct sha256_ctx *ctx, void *restrict resbuf); /* Put result from CTX in first 32 (28) 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 *sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf); -extern void *sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf); +extern void *sha256_read_ctx (const struct sha256_ctx *ctx, + void *restrict resbuf); +extern void *sha224_read_ctx (const struct sha256_ctx *ctx, + void *restrict resbuf); -/* Compute SHA256 (SHA224) message digest for LEN bytes beginning at BUFFER. The - result is always in little endian byte order, so that a byte-wise +/* Compute SHA256 (SHA224) 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 *sha256_buffer (const char *buffer, size_t len, void *resblock); -extern void *sha224_buffer (const char *buffer, size_t len, void *resblock); +extern void *sha256_buffer (const char *buffer, size_t len, + void *restrict resblock); +extern void *sha224_buffer (const char *buffer, size_t len, + void *restrict resblock); # endif /* Compute SHA256 (SHA224) message digest for bytes read from STREAM. diff --git a/lib/sha512.h b/lib/sha512.h index aaf35a5f7d8..21c2f580147 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/lib/strftime.h b/lib/strftime.h index 97a062c631d..e8501631573 100644 --- a/lib/strftime.h +++ b/lib/strftime.h @@ -25,7 +25,7 @@ extern "C" { POSIX requires that strftime use the local timezone information. Use the timezone __TZ instead. Use __NS as the number of nanoseconds in the %N directive. */ -size_t nstrftime (char *, size_t, char const *, struct tm const *, +size_t nstrftime (char *restrict, size_t, char const *, struct tm const *, timezone_t __tz, int __ns); #ifdef __cplusplus diff --git a/lib/string.in.h b/lib/string.in.h index 5bc00845205..596c99bf2e2 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -969,7 +969,8 @@ _GL_EXTERN_C char * mbssep (char **stringp, const char *delim) Caveat: The identity of the delimiting character is lost. See also mbssep(). */ -_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr) +_GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim, + char **save_ptr) _GL_ARG_NONNULL ((2, 3)); #endif diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 48d8030f539..fea32b544f9 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -211,6 +211,7 @@ AC_DEFUN([gl_INIT], gl_MODULE_INDICATOR([canonicalize-lgpl]) gl_STDLIB_MODULE_INDICATOR([canonicalize_file_name]) gl_STDLIB_MODULE_INDICATOR([realpath]) + AC_REQUIRE([AC_C_RESTRICT]) AC_CHECK_FUNCS_ONCE([readlinkat]) gl_CLOCK_TIME gl_MODULE_INDICATOR([close-stream]) @@ -219,9 +220,13 @@ AC_DEFUN([gl_INIT], AC_LIBOBJ([copy-file-range]) fi gl_UNISTD_MODULE_INDICATOR([copy-file-range]) + AC_REQUIRE([AC_C_RESTRICT]) gl_MD5 + AC_REQUIRE([AC_C_RESTRICT]) gl_SHA1 + AC_REQUIRE([AC_C_RESTRICT]) gl_SHA256 + AC_REQUIRE([AC_C_RESTRICT]) gl_SHA512 gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE gl_DIRENT_H diff --git a/m4/nstrftime.m4 b/m4/nstrftime.m4 index c15fab3e98b..6f2762aa276 100644 --- a/m4/nstrftime.m4 +++ b/m4/nstrftime.m4 @@ -1,4 +1,4 @@ -# serial 34 +# serial 35 # Copyright (C) 1996-1997, 1999-2007, 2009-2020 Free Software Foundation, Inc. # @@ -10,6 +10,8 @@ AC_DEFUN([gl_FUNC_GNU_STRFTIME], [ + AC_REQUIRE([AC_C_RESTRICT]) + # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE. AC_REQUIRE([AC_STRUCT_TIMEZONE]) -- 2.39.2