Paul Eggert [Sun, 6 May 2018 02:39:37 +0000 (19:39 -0700)]
crypto/{md5,sha1,sha256,sha512}: simplify
* lib/md5.c (md5_stream):
* lib/sha1.c (sha1_stream):
* lib/sha256.c (shaxxx_stream):
Simplify, partly by assuming C99.
* lib/sha256.c (shaxxx_stream):
New function, which implements both sha256 and sha224.
Simplify, partly by assuming C99.
(sha256_stream, sha224_stream):
Use it to avoid code duplication, removing a FIXME.
* lib/sha512.c (shaxxx_stream, sha512_stream, sha384_stream):
Likewise.
Bruno Haible [Sat, 5 May 2018 18:27:33 +0000 (20:27 +0200)]
af_alg: New module.
* lib/af_alg.h: Test HAVE_* macro through '#if', not '#ifdef'.
* lib/af_alg.c: Include "af_alg.h" before the other header files.
* lib/md5.c: Include "af_alg.h" unconditionally.
(md5_stream): Invoke afalg_stream unconditionally.
* lib/sha1.c: Include "af_alg.h" unconditionally.
(sha1_stream): Invoke afalg_stream unconditionally.
* lib/sha256.c: Include "af_alg.h" unconditionally.
(sha256_stream, sha224_stream): Invoke afalg_stream unconditionally.
* lib/sha512.c: Include "af_alg.h" unconditionally.
(sha512_stream, sha384_stream): Invoke afalg_stream unconditionally.
* m4/af_alg.m4: Renamed from m4/linux-if-alg.m4.
(gl_AF_ALG): Renamed from gl_LINUX_IF_ALG_H.
* modules/crypto/af_alg: New file.
* modules/crypto/md5 (Files): Remove files that are now in the
'crypto/af_alg' module.
(Depends-on): Add crypto/af_alg.
(configure.ac): Remove gl_LINUX_IF_ALG_H invocation.
(Makefile.am): Don't mention af_alg.c here.
* modules/crypto/sha1 (Files): Remove files that are now in the
'crypto/af_alg' module.
(Depends-on): Add crypto/af_alg.
(configure.ac): Remove gl_LINUX_IF_ALG_H invocation.
(Makefile.am): Don't mention af_alg.c here.
* modules/crypto/sha256 (Files): Remove files that are now in the
'crypto/af_alg' module.
(Depends-on): Add crypto/af_alg.
(configure.ac): Remove gl_LINUX_IF_ALG_H invocation.
(Makefile.am): Don't mention af_alg.c here.
* modules/crypto/sha512 (Files): Remove files that are now in the
'crypto/af_alg' module.
(Depends-on): Add crypto/af_alg.
(configure.ac): Remove gl_LINUX_IF_ALG_H invocation.
(Makefile.am): Don't mention af_alg.c here.
Paul Eggert [Sat, 5 May 2018 18:08:08 +0000 (11:08 -0700)]
af_alg: minor style improvements
* lib/af_alg.c (afalg_stream): Prefer C99 style
decl-after-statement, since we’re already assuming C99. Clarify
by strengthening the bind test and omit unnecessary assignment.
Paul Eggert [Sat, 5 May 2018 17:27:38 +0000 (10:27 -0700)]
sys-limits.h: new file for crypto and safe I/O
* lib/af_alg.c: Include sys-limits.h.
(MAX_RW_COUNT): Remove. Use replaced by SYS_BUFSIZE_MAX.
(afalg_stream): Also reject negative sizes for sendfile; they
should not happen and the code is a bit cleaner and faster this way.
* lib/safe-read.c: Include sys-limits.h.
(BUGGY_READ_MAXIMUM): Remove. All uses replaced by SYS_BUFSIZE_MAX.
* lib/sys-limits.h: New file, with values and commentary derived
from the old safe-read.c and from GNU Emacs sysdep.c.
* modules/crypto/md5, modules/crypto/sha1, modules/crypto/sha256:
* modules/crypto/sha512, modules/safe-read, modules/safe-write:
Add lib/sys-limits.h to Files section.
Linux supports accessing kernel crypto API via AF_ALG since
version 2.6.38. Coreutils uses libcrypto when available and fallbacks to
generic C implementation of various hashing functions.
Add a generic afalg_stream() function which uses AF_ALG to calculate the
hash of a stream and use sendfile() when possible (regular file with size
less or equal than 0x7ffff000 (2,147,479,552) bytes, AKA MAX_RW_COUNT).
Use afalg_stream() only in sha1sum for now, but other hashes are possible.
The speed gain really depends on the CPU type, on systems which doesn't use
libcrypto ranges from ~10% to 320%.
This is a test on a Intel(R) Xeon(R) CPU E3-1265L V2 and Debian stretch:
Bruno Haible [Wed, 2 May 2018 21:36:18 +0000 (23:36 +0200)]
localename: Fix test failures on mingw.
* lib/localename.c (gl_locale_name_thread): Remove code specific to
native Windows.
(gl_locale_name_posix): Move code specific to native Windows here.
* tests/test-localename.c (test_locale_name, test_locale_name_posix):
Accept result without charset suffix, as it appears on mingw.
Paul Smith [Sat, 28 Apr 2018 23:37:50 +0000 (16:37 -0700)]
bootstrap: Avoid gnulib operations if not needed
* build-aux/bootstrap: Remove unused variable gnulib_mk.
Set $gnulib_extra_files early so it can be overridden in .conf.
Remove redundant --import flag from $gnulib_tool_options.
Set $use_gnulib to false if no gnulib modules or files are needed.
If $use_gnulib is false, don't do anything related to gnulib.
A lot of this is just whitespace (indentation) changes.
localcharset: short-circuit the search for an alias on a Mac
* lib/localcharset.c (get_charset_aliases): Add a tautological
UTF-8 entry to speed up the search for this case.
Most machines default to a UTF-8 locale nowadays, so begin the
list of aliases with a dummy UTF-8 entry so it will be found
immediately and a time-consuming search through the rest of
the list is avoided.
Paul Eggert [Wed, 11 Apr 2018 19:50:35 +0000 (12:50 -0700)]
fts: fix bug in find across filesystems
This fixes a bug I introduced last summer.
Problem reported by Kamil Dudka in:
https://lists.gnu.org/r/bug-gnulib/2018-04/msg00033.html
* lib/fts.c (filesystem_type, dirent_inode_sort_may_be_useful)
(leaf_optimization):
New arg for file descriptor. All callers changed.
(fts_build): Check for whether inodes should be sorted
before closing the directory.
Paul Eggert [Thu, 5 Apr 2018 15:48:01 +0000 (08:48 -0700)]
fts: treat CIFS like NFS
Problem reported by Kamil Dudka in:
https://lists.gnu.org/r/bug-gnulib/2018-04/msg00015.html
* lib/fts.c (S_MAGIC_CIFS): New macro.
(dirent_inode_sort_may_be_useful, leaf_optimization):
Treat CIFS like NFS.
Paul Eggert [Wed, 28 Mar 2018 19:45:45 +0000 (12:45 -0700)]
time_rz: fix workaround for Mac OS X 10.6 infloop
Problems reported by Charles A. Roelli (Bug#27736#117).
* m4/time_rz.m4 (gl_TIME_RZ): Use a slightly different timestamp.
Also, discard output, which clutters the 'configure' log.
Paul Eggert [Tue, 27 Mar 2018 02:23:33 +0000 (19:23 -0700)]
time_rz: work around Mac OS X 10.6 infloop
* doc/posix-functions/localtime.texi:
* doc/posix-functions/localtime_r.texi: Mention the bug.
* lib/time_rz.c (localtime_rz): Work around the bug. It’d be
better to fix localtime and localtime_r instead, but that would be
more work and is not needed to fix the Emacs problem.
* m4/time_rz.m4 (gl_TIME_RZ): Detect the bug.
Jim Meyering [Sat, 24 Mar 2018 16:48:47 +0000 (09:48 -0700)]
test-version-etc.sh: don't use diff directly: use init.sh's compare
We'd rather not sacrifice readable "diff -u" output even for
"diff -c" output (not supported by busybox) or for even less
readable ed-style "diff" output. So use init.sh's compare function
* tests/test-version-etc.sh: Source init.sh and add "." to path.
Remove "./" from invocation of test-version-etc, so we use path.
And s/diff/compare/.
* modules/version-etc-tests (Depends-on): Add test-framework-sh,
to get init.sh.
Prompted by Eric Blake's comments in
https://lists.gnu.org/r/sed-devel/2018-03/msg00015.html
Jim Meyering [Fri, 23 Mar 2018 23:46:13 +0000 (16:46 -0700)]
test-version-etc.sh: port to diff without -c
* tests/test-version-etc.sh: Don't use diff's -c option.
This caused spurious test failure on Alpine Linux, which
uses busybox's diff. Reported by Assaf Gordon in
https://lists.gnu.org/r/sed-devel/2018-03/msg00013.html
Bruno Haible [Fri, 16 Mar 2018 15:25:02 +0000 (16:25 +0100)]
glob: Don't compile replacements on recent glibc systems.
* lib/glob.in.h: Use the usual idiom for the double-inclusion guard. If
REPLACE_GLOB is 0, include the system's <glob.h> and use
_GL_CXXALIAS_SYS.
* m4/glob.m4 (gl_GLOB): Set REPLACE_GLOB instead of GLOB_H. Accept
_GNU_GLOB_INTERFACE_VERSION 2 as well. Delete the file conf$$-globtest
inside the AC_RUN_IFELSE block. Remove GL_GENERATE_GLOB_H conditional.
* modules/glob (Dependencies): Test REPLACE_GLOB instead of GLOB_H.
Remove snippet/warn-on-use.
(configure.ac): Test REPLACE_GLOB instead of GLOB_H.
(Makefile.am): Create glob.h always. Update list of substitutions in
glob.h. Don't depend on $(WARN_ON_USE_H).
Bruno Haible [Thu, 15 Mar 2018 21:26:09 +0000 (22:26 +0100)]
host-cpu-c-abi: Support for RISC-V CPU.
* m4/host-cpu-c-abi.m4 (gl_HOST_CPU_C_ABI): Recognize the various
riscv32 and riscv64 ABIs.
References:
https://github.com/riscv/riscv-toolchain-conventions
https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/RISC-V-Options.html
https://gnu-mcu-eclipse.github.io/toolchain/riscv/
Paul Eggert [Wed, 7 Mar 2018 08:29:38 +0000 (00:29 -0800)]
maint: write-file-hooks -> before-save-hook
write-file-hooks is obsolete since Emacs 22.1 (released June 2007) and
it's time to use the recommended replacement.
Problem reported by Glenn Morris in:
https://lists.gnu.org/r/bug-gnulib/2018-03/msg00008.html
* build-aux/announce-gen, build-aux/bootstrap:
* build-aux/do-release-commit-and-tag, build-aux/gendocs.sh:
* build-aux/git-version-gen, build-aux/gitlog-to-changelog:
* build-aux/gnu-web-doc-update, build-aux/gnupload:
* build-aux/move-if-change, build-aux/prefix-gnulib-mk:
* build-aux/update-copyright, build-aux/useless-if-before-free:
* build-aux/vc-list-files:
Update hook usage for files where Gnulib is the canonical source.
Paul Eggert [Mon, 5 Mar 2018 23:30:56 +0000 (15:30 -0800)]
binary-io: pacify gcc -Wunused-parameter
Problem reported by Reuben Thomas in:
https://lists.gnu.org/r/bug-gnulib/2018-03/msg00005.html
* lib/binary-io.h (__gl_setmode, __gl_setmode_check):
Use _GL_UNUSED where appropriate.
Paul Eggert [Tue, 27 Feb 2018 17:04:42 +0000 (09:04 -0800)]
environ: fix link error on 32-bit Cygwin
Problem reported for GNU Emacs by Ken Brown in:
https://lists.gnu.org/r/emacs-devel/2018-02/msg00765.html
* lib/unistd.in.h (environ) [__i386__]: Do not redeclare.
Bruno Haible [Sat, 24 Feb 2018 11:59:59 +0000 (12:59 +0100)]
localename: Add support for musl libc.
* m4/localename.m4 (gl_LOCALENAME): Check for <langinfo.h>.
* lib/localename.c (gl_locale_name_thread_unsafe): Use NL_LOCALE_NAME
on Linux platforms which define NL_LOCALE_NAME.
Paul Eggert [Fri, 23 Feb 2018 21:15:24 +0000 (13:15 -0800)]
nl_langinfo: pacify gcc -Wunused-function
* lib/nl_langinfo.c (ctype_codeset): Do not define if
REPLACE_NL_LANGINFO && !GNULIB_defined_CODESET, as it is unused in
this case. Without this change, I got a diagnostic when building
coreutils on Fedora 27 with gcc 7.3.1 20180130.
Paul Eggert [Fri, 23 Feb 2018 20:47:38 +0000 (12:47 -0800)]
malloca: pacify gcc -Wbad-function-cast
* lib/malloca.h (malloca): Pacify gcc -Wbad-function-cast
diagnostic that I got on Fedora 27 with gcc 7.3.1 20180130.
To pacify GCC, I had to cast alloca’s result to some type other
than void * before casting that to uintptr_t.
Paul Eggert [Tue, 20 Feb 2018 17:06:51 +0000 (09:06 -0800)]
utimecmp: new function utimecmpat
* lib/utimecmp.c: Include fcntl.h, sys/stat.h and dirname.h.
Do not include utimens.h.
(utimecmpat): New function, generalizing utimecmp.
(utimecmp): Now a thin layer around utimecmpat.
* modules/utimecmp (Depends-on): Depend on dirname-lgpl, fstatat,
utimensat instead of on lstat and utimens.
Paul Eggert [Tue, 20 Feb 2018 17:05:48 +0000 (09:05 -0800)]
same: new function same_nameat
* lib/same.c: Include fcntl.h.
* lib/same.c (same_nameat): New function, generalizing same_name.
(same_name): Now a thin layer around same_nameat.
* m4/same.m4 (gl_SAME): Check for fpathconf, not pathconf.
* modules/same (Depends-on): Depend on fstatat, openat.
Bruno Haible [Sat, 17 Feb 2018 08:55:43 +0000 (09:55 +0100)]
thread: Fix compilation error on IRIX.
* lib/glthread/thread.h: Include <unistd.h>. Include <signal.h> when
needed; include it outside the C++ extern "C" {} block.
* doc/posix-headers/pthread.texi: Mention the problem with
pthread_atfork on IRIX.