Paul Eggert [Sun, 1 Jul 2018 14:08:32 +0000 (07:08 -0700)]
manywarnings: omit -Wswitch-default
This should make things more consistent, as we already ignore
-Wswitch-enum. Problem reported by Reuben Thomas; see:
https://lists.gnu.org/r/bug-gnulib/2018-05/msg00179.html
* build-aux/g++-warning.spec, build-aux/gcc-warning.spec:
Add -Wswitch-default.
* m4/manywarnings-c++.m4 (gl_MANYWARN_ALL_GCC_CXX_IMPL):
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC):
Remove -Wswitch-default.
Paul Eggert [Sun, 1 Jul 2018 13:37:38 +0000 (06:37 -0700)]
regex: revert most trimming
Problems reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2018-07/msg00001.html
* modules/regex (Depends-on): Add lock, memcmp, memmove,
and wctype back in. lock because regex users shouldn’t
need to know that regex needs locking, and the rest because
gnulib-tool should ordinarily ignore them anyway.
Paul Eggert [Sun, 1 Jul 2018 01:47:11 +0000 (18:47 -0700)]
regex: trim module dependencies
* modules/regex (Depends-on): Remove gettext-h and lock,
since the regex code should work OK without these modules,
and Emacs uses it that way. Also remove memcmp, memmove,
and wctype, as these modules are obsolete and should not be
needed any more.
Paul Eggert [Fri, 29 Jun 2018 22:34:57 +0000 (15:34 -0700)]
regex: glibc does not use intprops.h
Maybe we can talk glibc into using intprops.h someday, but
now doesn’t seem to be a good time.
* lib/regcomp.c (TYPE_SIGNED): Remove; regex_internal.h now defines.
* lib/regex_internal.h [_LIBC]: Do not include intprops.h.
(TYPE_SIGNED, INT_ADD_WRAPV): New macros.
Paul Eggert [Thu, 28 Jun 2018 19:23:31 +0000 (12:23 -0700)]
regex: port to recently proposed glibc regex merge
This patch is inspired by Adhemerval Zanella's recent proposal
https://www.sourceware.org/ml/libc-alpha/2018-06/msg00905.html
to merge glibc and Gnulib regex. It aims to simplify the merge on
the glibc side, without keeping Gnulib portable.
* lib/regex.h: Fix a problem with glibc installed-header checking,
as follows:
(_Restrict_): Prefer __restrict if defined or if GCC 2.95 or later.
(_Restrict_arr_): Prefer __restrict_arr if defined,
otherwise prefer _Restrict_ if C99 or GCC 3.1 or later (but not C++).
* lib/regex_internal.c (re_string_realloc_buffers, build_wcs_buffer)
(build_wcs_upper_buffer, build_upper_buffer)
(re_string_translate_buffer, re_string_context_at):
Move decls here from lib/regex_internal.h, for glibc internal tests.
(build_wcs_upper_buffer): Use __wcrtomb, not wcrtomb, fixing
glibc BZ #18496.
* lib/regex_internal.h (lock_fini) [_LIBC]: Cast to 0 to pacify
-Wunused-value.
(bitset_set, bitset_clear, bitset_contain, bitset_empty)
(bitset_set_all, bitset_copy, bitset_not, bitset_merge)
(bitset_mask): Now static inline, and without any __attribute__
((unused)) decoration, for glibc internal tests.
Bruno Haible [Tue, 26 Jun 2018 00:18:40 +0000 (02:18 +0200)]
threadlib: Fix LIBMULTITHREAD on platforms where --as-needed is enabled.
Reported by Erik Auerswald <auerswal@unix-ag.uni-kl.de>
in <https://lists.gnu.org/archive/html/coreutils/2018-06/msg00063.html>.
* m4/threadlib.m4 (gl_THREADLIB_BODY): Check whether the linker supports
--as-needed/--no-as-needed and --push-state/--pop-state. When defining
USE_POSIX_THREADS_WEAK or USE_SOLARIS_THREADS_WEAK or
USE_PTH_THREADS_WEAK, define LIBMULTITHREAD in such a way that -lpthread
/ -lthread / -lpth does not get optimized away by a preceding
--as-needed option.
Jim Meyering [Mon, 25 Jun 2018 15:28:12 +0000 (08:28 -0700)]
acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
* lib/acl-internal.h (free_permission_context): Remove that
attribute directive. Otherwise, it would provoke this from GCC 9:
lib/acl-internal.h:300:3: error: 'const' attribute on function \
returning 'void' [-Werror=attributes]
Jim Meyering [Mon, 25 Jun 2018 03:47:58 +0000 (20:47 -0700)]
parse-datetime: accommodate gcc-4.8.5
Bruno Haible reported the build failure in
https://lists.gnu.org/r/bug-gnulib/2018-06/msg00066.html
* lib/parse-datetime.y (parse_datetime2): Remove leading "static"
on declaration of new local.
Bruno Haible [Sun, 24 Jun 2018 22:41:03 +0000 (00:41 +0200)]
af_alg: Fix state of stream after sendfile() succeeds.
* lib/af_alg.c (afalg_stream): Invoke fflush and lseek, to ensure that
the stream is correctly positioned afterwards.
* modules/crypto/af_alg (Depends-on): Add fflush.
* tests/test-digest.h (test_digest_on_files): Verify that after the
operation the stream is positioned at end of file.
Jim Meyering [Sun, 24 Jun 2018 23:54:43 +0000 (16:54 -0700)]
canon-host: take GCC9's advice rather than ignoring warning
Pádraig Brady suggested not to ignore this GCC9 advice.
* lib/canon-host.c: Undo preceding change.
* lib/canon-host.h: Instead, declare with _GL_ATTRIBUTE_MALLOC.
Jim Meyering [Sun, 24 Jun 2018 22:58:09 +0000 (15:58 -0700)]
parse-datetime.y: avoid spurious GCC 9 warning
* lib/parse-datetime.y (parse_datetime2): Save RELATIVE_TIME_0 into
a function local prior to the first "goto fail". The prior use would
evoke this:
parse-datetime.y: In function 'parse_datetime2':
parse-datetime.y:1791:19: error: jump skips variable initialization \
[-Werror=jump-misses-init]
parse-datetime.y:2385:2: note: label 'fail' defined here
parse-datetime.y:188:43: note: '({anonymous})' declared here
parse-datetime.y:1841:12: note: in expansion of macro 'RELATIVE_TIME_0'
Jim Meyering [Sun, 24 Jun 2018 18:31:50 +0000 (11:31 -0700)]
manywarnings: accommodate GCC 9.0-pre: remove -Wchkp and -Wabi
* build-aux/gcc-warning.spec: Add them here, each with an explanation.
* m4/manywarnings.m4: Remove them.
Otherwise, building coreutils, I would see this:
cc1: error: deprecated command line option '-Wchkp' [-Werror]
cc1: error: -Wabi won't warn about anything [-Werror=abi]
cc1: note: -Wabi warns about differences from the most up-to-date ABI,\
which is also used by default
cc1: note: use e.g. -Wabi=11 to warn about changes from GCC 7
Pádraig Brady [Sun, 24 Jun 2018 22:15:16 +0000 (15:15 -0700)]
maint: clarify comments about sticky EOF
* lib/af_alg.c: Be more direct that we can't
assume stickiness of EOF for portability reasons.
* lib/md5.c: Clarify that this isn't just a glibc issue.
* lib/sha1.c: Likewise.
* lib/sha256.c: Likewise.
* lib/sha512.c: Likewise.
Pádraig Brady [Sun, 24 Jun 2018 09:09:12 +0000 (02:09 -0700)]
af_alg: disable kernel hash functions by default
All the kernel routines were seen to be significantly slower
with these relatively recent components on an i3-2310M system:
kernel-4.10.6-200.fc25.x86_64
openssl-1.0.2m-1.fc25.x86_64
sha1 was nearly twice as slow in the kernel for example,
compared to the libcrypto routines.
Further considerations why this should not be the default, at:
https://lists.gnu.org/r/coreutils/2018-06/msg00034.html
* m4/af_alg.m4: Require --with-linux-crypto to enable.
* m4/gl-openssl.m4: Tweak accordingly.
Pádraig Brady [Sun, 24 Jun 2018 08:46:10 +0000 (01:46 -0700)]
af_alg: avoid hangs when reading from streams
* lib/af_alg.c (afalg_stream): Don't assume EOF is sticky,
and thus avoid doing a fread() when feof() is set.
* lib/md5.c: Ensure feof() is called before fread().
* lib/sha1.c: Likewise.
* lib/sha256.c: Likewise.
* lib/sha512.c: Likewise.
Pádraig Brady [Sun, 24 Jun 2018 08:29:55 +0000 (01:29 -0700)]
af_alg: fix error handling when hash not returned
* lib/af_alg.c (afalg_stream): Handle the case where we've
successfully written data to the kernel in the read/write loop,
but the kernel doesn't respond with the hash.
Paul Eggert [Sun, 24 Jun 2018 15:50:36 +0000 (08:50 -0700)]
libc-config: merge from glibc
* lib/cdefs.h (__inline, __restrict):
Copy from current glibc. This fixes glibc bug 17721,
which Gnulib had already fixed in a different way.
(__nonnull): Lessen the distance from glibc by using the
glibc definition inside an ‘#ifndef __nonnull’.
(__attribute_nonstring__): New macro, copied from
current glibc.
* lib/libc-config.h (__attribute_nonstring__): New undef.
(__restrict): Remove; workaround no longer needed.
Keep the __inline workaround, though, as it uses HAVE___INLINE to
support more compilers than the glibc __inline can.
Paul Eggert [Thu, 21 Jun 2018 19:28:34 +0000 (12:28 -0700)]
random_r: do not crash if state is unaligned
Problem reported by Bruce Korb in:
https://lists.gnu.org/r/bug-gnulib/2018-06/msg00030.html
I reproduced the crash on 32-bit sparc with Oracle Studio 12.6
with 'cc -O2 -xmemalign=8s'.
* lib/random_r.c: Include string.h, for memcpy.
(get_int32, set_int32): New functions.
(__srandom_r, __initstate_r, __setstate_r, __random_r):
Use them to avoid assumption that state pointer is aligned.
(__random_r): Avoid integer overflow if INT_MAX == UINT32_MAX.
* tests/test-random_r.c (test_failed): New function.
(main): Use it, to test for alignment bugs.
Paul Eggert [Thu, 21 Jun 2018 18:25:02 +0000 (11:25 -0700)]
random, random_r: merge from glibc
* lib/random.c, lib/random_r.c:
Include libc-config.h if !_LIBC, not config.h unilaterally.
* lib/random.c:
Do not include stdint.h or time.h; not needed.
Include libc-lock.h if _LIBC, and define substitute macros otherwise.
(unsafe_state): Rename from generator. All uses changed.
Use C99-style initializers.
(__random, __srandom, __initstate, __setstate): Rename from
non-underscored version, but define it to non-underscored version
on Gnulib. Add a lock.
* lib/random_r.c (__srandom_r, __initstate_r, __setstate_r, __random_r):
Likewise.
Do not include <stdint.h>; not needed since stdlib.h defines int32_t.
(weak_alias, __set_errno) [!_LIBC]: Remove; now done by libc-config.
(__srandom_r): Use int32_t instead of long int where int32_t will do.
(__random_r): Use uint32 to fix glibc bug 17343.
* modules/random, modules/random_r (Depends-on): Add libc-config.
Depend on stdint only if $HAVE_RANDOM = 0.
Bruno Haible [Sun, 17 Jun 2018 21:12:54 +0000 (23:12 +0200)]
gettext po infrastructure: Update from current gettext git.
Reported by Akim Demaille <akim@lrde.epita.fr>.
* build-aux/po/Makefile.in.in: Update from current gettext git.
* build-aux/po/remove-potcdate.sin: Likewise.
* config/srclist.txt: Temporarily disable sync for these files.
Paul Eggert [Mon, 4 Jun 2018 01:02:10 +0000 (18:02 -0700)]
Port crypto/af_alg to GCC 4.8.4
Problem reported by Peter Simons in:
https://lists.gnu.org/r/bug-gnulib/2018-06/msg00002.html
* modules/crypto/af_alg (Depends-on): Add c99 if USE_AF_ALG.
Colin Watson [Sun, 27 May 2018 20:07:58 +0000 (22:07 +0200)]
bootstrap: allow non-submodule control of gnulib
Some projects prefer to avoid git submodules for various reasons (they
have rather strange UI), but at present they're the only way to pin a
particular gnulib commit. Add a couple of extra variables which can be
set in bootstrap.conf to control this separately.
* build-aux/bootstrap: Honour GNULIB_URL and GNULIB_REVISION in
bootstrap.conf when fetching gnulib using "git clone" or via
GNULIB_SRCDIR.
Paul Eggert [Mon, 21 May 2018 17:32:25 +0000 (10:32 -0700)]
crypto: omit stream ops Emacs doesn’t need
* lib/md5.c (md5_stream):
* lib/sha1.c (sha1_stream):
* lib/sha256.c (shaxxx_stream, sha256_stream, sha224_stream):
* lib/sha512.c (shaxxx_stream, sha512_stream, sha384_stream):
Compile stream functions only if GL_COMPILE_CRYPTO_STREAM is
defined. Emacs needs this, as it does not use the stream
operations and doesn’t need all the af_alg stuff we’ve recently
added. Perhaps a similar change is needed to the other crypto
modules, but this patch changes only those needed for Emacs.
* modules/crypto/md5-buffer, modules/crypto/sha1-buffer:
* modules/crypto/sha256-buffer, modules/crypto/sha512-buffer:
New modules, used by Emacs.
* modules/crypto/md5, modules/crypto/sha1, modules/crypto/sha256:
* modules/crypto/sha512: Rewrite to depend on the new modules.
Pádraig Brady [Mon, 14 May 2018 01:42:37 +0000 (18:42 -0700)]
fts: avoid a memory leak edge case
* lib/fts.c (fts_open): Set an appropriate fts_level
so that an immediate fts_close() will free the allocation.
* tests/test-fts.c (fts_dealloc): Add a test case which
will trigger under valgrind or address sanitizer.
Fixes https://bugs.gnu.org/31439
Bruno Haible [Sun, 20 May 2018 10:59:01 +0000 (12:59 +0200)]
localcharset: Optimize.
* lib/localcharset.c (alias_table): Comment out no-op mappings for
platforms where these don't matter. This reduces the table size,
which in turn reduces the lookup time.
Bruno Haible [Sun, 13 May 2018 23:48:22 +0000 (01:48 +0200)]
truncate: Fix compilation error on Android.
* m4/truncate.m4 (gl_FUNC_TRUNCATE): Test also whether 'truncate' is
declared. Set HAVE_DECL_TRUNCATE, not HAVE_TRUNCATE.
* lib/unistd.in.h (truncate): Test HAVE_DECL_TRUNCATE, not
HAVE_TRUNCATE.
* modules/truncate: Likewise.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize HAVE_DECL_TRUNCATE,
not HAVE_TRUNCATE.
* modules/unistd (Makefile.am): Substitute HAVE_DECL_TRUNCATE, not
HAVE_TRUNCATE.
* doc/posix-functions/truncate.texi: Mention the issue.
Bruno Haible [Sun, 13 May 2018 22:27:43 +0000 (00:27 +0200)]
posix_spawn: Fix compilation error on Android.
* lib/spawn.in.h (posix_spawnattr_t): Consider also the case
HAVE_POSIX_SPAWNATTR_T = 1 && HAVE_POSIX_SPAWN = 0.
(posix_spawn_file_actions_t): Consider also the case
HAVE_POSIX_SPAWN_FILE_ACTIONS_T = 1 && HAVE_POSIX_SPAWN = 0.
Bruno Haible [Sun, 13 May 2018 22:02:48 +0000 (00:02 +0200)]
tsearch: Fix compilation error on Android.
* lib/search.in.h (twalk): Declare when HAVE_TWALK, not HAVE_TSEARCH,
is 0.
(GNULIB_defined_tsearch, GNULIB_defined_twalk): New macros.
* lib/tsearch.c (tsearch, tfind, tdelete): Define only if
GNULIB_defined_tsearch is true.
(twalk): Define only if GNULIB_defined_twalk is true.
* modules/tsearch (configure.ac): Compile tsearch.c also if HAVE_TWALK
is 0.
* m4/tsearch.m4 (gl_FUNC_TSEARCH): Set HAVE_TWALK.
* m4/search_h.m4 (gl_SEARCH_H_DEFAULTS): Initialize HAVE_TWALK.
* modules/search (Makefile.am): Substitute HAVE_TWALK.
Bruno Haible [Sun, 13 May 2018 21:23:47 +0000 (23:23 +0200)]
imaxdiv: Fix compilation error on Android.
* m4/imaxdiv.m4 (gl_FUNC_IMAXDIV): Set HAVE_IMAXDIV_T to 0 if imaxdiv_t
is not defined.
* lib/inttypes.in.h (imaxdiv_t): Define if HAVE_IMAXDIV_T, not
HAVE_DECL_IMAXDIV, is 0.
* m4/inttypes.m4 (gl_INTTYPES_H_DEFAULTS): Initialize HAVE_IMAXDIV_T.
* modules/inttypes-incomplete (Makefile.am): Substitute HAVE_IMAXDIV_T.
Bruno Haible [Sun, 13 May 2018 20:20:13 +0000 (22:20 +0200)]
Support selective inclusion mechanism of recent mingw.org header files.
Reported by Eli Zaretskii <eliz@gnu.org>.
* lib/sys_types.in.h: On mingw, when __need_off_t, __need___off64_t,
__need_ssize_t, or __need_time_t is defined, just include the system's
<sys/types.h>.
* lib/locale.in.h: On mingw, when __need_locale_t is defined, just
include the system's <locale.h>.
Paul Eggert [Thu, 10 May 2018 01:07:29 +0000 (18:07 -0700)]
af_alg: recover better from crypto failures
* lib/af_alg.c (afalg_stream): Recover from crypto failures if the
input stream is seekable, by repositioning the stream back to
where it was, possibly by just calling sendfile with an offset
arg. This lets us return -EAFNOSUPPORT instead of -EIO in some
cases, which lets our callers try again with user-mode code.
* modules/crypto/af_alg (Depends-on): Depend on fseeko and ftello
instead of on fflush and lseek.
Paul Eggert [Wed, 9 May 2018 19:04:37 +0000 (12:04 -0700)]
af_alg: distiguish I/O errors better
* lib/af_alg.c (afalg_buffer, afalg_stream): Return -EAFNOSUPPORT,
not -EIO, if it’s OK for the caller to try again with user-mode code.
(afalg_stream) [!_WIN32 || __CYGWIN__]: Return -EIO (not possibly
some other error number) if fflush fails, as the caller should not
try again that case.
Paul Eggert [Wed, 9 May 2018 18:34:28 +0000 (11:34 -0700)]
af_alg: don’t leak file descriptors into children
* lib/af_alg.c (alg_socket): Use SOCK_CLOEXEC when creating sockets.
This code should be compiled only on recent GNU/Linux platforms
so we shouldn’t have to also depend on the accept4 module.