]> Savannah Git Hosting - gnulib.git/log
gnulib.git
4 years agoautoupdate
Karl Berry [Thu, 18 Jun 2020 14:50:23 +0000 (07:50 -0700)]
autoupdate

4 years agothread: Avoid possible compiler warnings in uses of gl_thread_exit.
Bruno Haible [Tue, 16 Jun 2020 23:46:41 +0000 (01:46 +0200)]
thread: Avoid possible compiler warnings in uses of gl_thread_exit.

* lib/glthread/thread.h (gl_thread_exit): Add a cast to void.

4 years agothread, thrd: Avoid a compiler warning.
Bruno Haible [Tue, 16 Jun 2020 23:44:49 +0000 (01:44 +0200)]
thread, thrd: Avoid a compiler warning.

* lib/windows-thread.h (glwthread_thread_exit): Mark as non-returning.

4 years agowindows-thread: Avoid a compiler warning.
Biswapriyo Nath [Tue, 16 Jun 2020 20:33:34 +0000 (02:03 +0530)]
windows-thread: Avoid a compiler warning.

* lib/windows-thread.h (glwthread_thread_exit): Change return type to
void.
* lib/windows-thread.c (glwthread_thread_exit): Likewise.

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
4 years agounictype/joininggroup-name: Fix warning on 64-bit mingw.
Bruno Haible [Mon, 15 Jun 2020 20:14:41 +0000 (22:14 +0200)]
unictype/joininggroup-name: Fix warning on 64-bit mingw.

Reported by Biswapriyo Nath <nathbappai@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-06/msg00036.html>.

* lib/unictype/joininggroup_name.c (ELEM): Cast struct offset to size_t
first.

4 years agoautoupdate
Karl Berry [Mon, 15 Jun 2020 14:19:33 +0000 (07:19 -0700)]
autoupdate

4 years agoautoupdate
Karl Berry [Sun, 14 Jun 2020 14:31:35 +0000 (07:31 -0700)]
autoupdate

4 years agocalloc-gnu tests: Avoid a test failure with clang.
Bruno Haible [Sat, 6 Jun 2020 08:14:24 +0000 (10:14 +0200)]
calloc-gnu tests: Avoid a test failure with clang.

* tests/test-calloc-gnu.c (main): Mark the pointer variable as
'volatile', to defeat compiler optimizations.

4 years agogit-version-gen: update scriptversion
Dmitry V. Levin [Wed, 3 Jun 2020 08:00:00 +0000 (08:00 +0000)]
git-version-gen: update scriptversion

scriptversion in git-version-gen should be kept up-to-date because
this script is used by projects that update it from gnulib
when its scriptversion changes.

* build-aux/git-version-gen (scriptversion): Update.

Fixes: 8f41f1918 ("git-version-gen: Allow 'snapshot' as .tarball-version contents.")
4 years agoautoupdate
Karl Berry [Tue, 2 Jun 2020 15:21:10 +0000 (08:21 -0700)]
autoupdate

4 years agogetloadavg: fix double-increment bug
Paul Eggert [Tue, 2 Jun 2020 00:57:27 +0000 (17:57 -0700)]
getloadavg: fix double-increment bug

* lib/getloadavg.c (getloadavg): Fix double-increment typo on
Linux without glibc, Android, Cygwin.  This fixes a bug I
introduced in 2011-02-08T20:23:29Z!eggert@cs.ucla.edu.
Problem and fix reported by Semen Verchenko in:
https://lists.gnu.org/r/bug-gnulib/2020-06/msg00007.html

4 years agogetentropy, getrandom: compare to crypto/gc-random
Paul Eggert [Tue, 2 Jun 2020 00:02:54 +0000 (17:02 -0700)]
getentropy, getrandom: compare to crypto/gc-random

4 years agotempname: use getrandom, not getentropy
Paul Eggert [Mon, 1 Jun 2020 22:58:29 +0000 (15:58 -0700)]
tempname: use getrandom, not getentropy

This removes a dependency, as getentropy depends on getrandom.
* lib/tempname.c: Include sys/random.h instead of unistd.h.
(RANDOM_BITS) [!_LIBC]: Use getrandom, not getentropy.
* modules/tempname (Depends-on): Depend on getrandom, not getentropy.

4 years agodoc: New chapter 'Multithreading'.
Bruno Haible [Mon, 1 Jun 2020 22:37:22 +0000 (00:37 +0200)]
doc: New chapter 'Multithreading'.

* doc/multithread.texi: New file.
* doc/gnulib.texi: Include it.

4 years agogetentropy, getrandom: update version numbers in doc
Paul Eggert [Mon, 1 Jun 2020 22:45:44 +0000 (15:45 -0700)]
getentropy, getrandom: update version numbers in doc

4 years agodoc: Move 'Running self-tests under valgrind' section.
Bruno Haible [Mon, 1 Jun 2020 18:45:20 +0000 (20:45 +0200)]
doc: Move 'Running self-tests under valgrind' section.

* doc/gnulib.texi (Build Infrastructure Modules): Include
valgrind-tests.texi here...
(Miscellaneous Notes): ... not here.

4 years agodoc: Move 'Visual Studio Compatibility' section.
Bruno Haible [Mon, 1 Jun 2020 18:41:20 +0000 (20:41 +0200)]
doc: Move 'Visual Studio Compatibility' section.

* doc/gnulib.texi (Native Windows Support): Include ld-output-def.texi
here...
(Build Infrastructure Modules): ... not here.

4 years agodoc: improve randomness discussion
Paul Eggert [Mon, 1 Jun 2020 18:18:06 +0000 (11:18 -0700)]
doc: improve randomness discussion

Inspired by comments from Jeffrey Walton in:
https://lists.gnu.org/r/bug-gnulib/2020-06/msg00002.html
* doc/glibc-functions/getentropy.texi (getentropy):
* doc/glibc-functions/getrandom.texi (getrandom):
Improve discussion of problems with "random" data,
and cite Ristenpart & Yilek.  Also, mention GRND_INSECURE.

4 years agodoc: Fix Texinfo syntax error.
Bruno Haible [Mon, 1 Jun 2020 18:05:14 +0000 (20:05 +0200)]
doc: Fix Texinfo syntax error.

* doc/glibc-functions/getrandom.texi: Add missing '@item'.

4 years agodoc: Change '.' to '@.' where appropriate.
Asher Gordon [Sun, 17 May 2020 19:34:20 +0000 (15:34 -0400)]
doc: Change '.' to '@.' where appropriate.

* doc/c-ctype.texi: Change '.' to '@.' where appropriate.
* doc/glibc-functions/fstatfs.texi: Likewise.
* doc/glibc-functions/fts_children.texi: Likewise.
* doc/glibc-functions/fts_read.texi: Likewise.
* doc/glibc-functions/getdirentries.texi: Likewise.
* doc/glibc-functions/mkostemp.texi: Likewise.
* doc/glibc-functions/mkostemps.texi: Likewise.
* doc/glibc-functions/mkstemps.texi: Likewise.
* doc/glibc-functions/preadv.texi: Likewise.
* doc/glibc-functions/pwritev.texi: Likewise.
* doc/glibc-functions/sendfile.texi: Likewise.
* doc/glibc-functions/statfs.texi: Likewise.
* doc/gnulib-intro.texi: Likewise.
* doc/gnulib-tool.texi: Likewise.
* doc/intprops.texi: Likewise.
* doc/lib-symbol-visibility.texi: Likewise.
* doc/licenses-texi.texi: Likewise.
* doc/pastposix-functions/bcmp.texi: Likewise.
* doc/pastposix-functions/bcopy.texi: Likewise.
* doc/pastposix-functions/bzero.texi: Likewise.
* doc/pastposix-functions/ecvt.texi: Likewise.
* doc/pastposix-functions/fcvt.texi: Likewise.
* doc/pastposix-functions/ftime.texi: Likewise.
* doc/pastposix-functions/gcvt.texi: Likewise.
* doc/pastposix-functions/getwd.texi: Likewise.
* doc/pastposix-functions/index.texi: Likewise.
* doc/pastposix-functions/mktemp.texi: Likewise.
* doc/pastposix-functions/rindex.texi: Likewise.
* doc/pastposix-functions/wcswcs.texi: Likewise.
* doc/posix-functions/aio_cancel.texi: Likewise.
* doc/posix-functions/aio_error.texi: Likewise.
* doc/posix-functions/aio_fsync.texi: Likewise.
* doc/posix-functions/aio_read.texi: Likewise.
* doc/posix-functions/aio_return.texi: Likewise.
* doc/posix-functions/aio_suspend.texi: Likewise.
* doc/posix-functions/aio_write.texi: Likewise.
* doc/posix-functions/creat.texi: Likewise.
* doc/posix-functions/ctime.texi: Likewise.
* doc/posix-functions/daylight.texi: Likewise.
* doc/posix-functions/fgetpos.texi: Likewise.
* doc/posix-functions/fopen.texi: Likewise.
* doc/posix-functions/freopen.texi: Likewise.
* doc/posix-functions/fseeko.texi: Likewise.
* doc/posix-functions/fsetpos.texi: Likewise.
* doc/posix-functions/fstatat.texi: Likewise.
* doc/posix-functions/fstatvfs.texi: Likewise.
* doc/posix-functions/ftello.texi: Likewise.
* doc/posix-functions/ftruncate.texi: Likewise.
* doc/posix-functions/getrlimit.texi: Likewise.
* doc/posix-functions/lio_listio.texi: Likewise.
* doc/posix-functions/localtime.texi: Likewise.
* doc/posix-functions/lseek.texi: Likewise.
* doc/posix-functions/mkstemp.texi: Likewise.
* doc/posix-functions/mktime.texi: Likewise.
* doc/posix-functions/open.texi: Likewise.
* doc/posix-functions/openat.texi: Likewise.
* doc/posix-functions/opendir.texi: Likewise.
* doc/posix-functions/pread.texi: Likewise.
* doc/posix-functions/pwrite.texi: Likewise.
* doc/posix-functions/readdir.texi: Likewise.
* doc/posix-functions/readdir_r.texi: Likewise.
* doc/posix-functions/scandir.texi: Likewise.
* doc/posix-functions/seekdir.texi: Likewise.
* doc/posix-functions/setrlimit.texi: Likewise.
* doc/posix-functions/statvfs.texi: Likewise.
* doc/posix-functions/strftime.texi: Likewise.
* doc/posix-functions/telldir.texi: Likewise.
* doc/posix-functions/timezone.texi: Likewise.
* doc/posix-functions/tmpfile.texi: Likewise.
* doc/posix-functions/truncate.texi: Likewise.
* doc/posix-functions/tzname.texi: Likewise.
* doc/posix-functions/wcsftime.texi: Likewise.
* doc/windows-sockets.texi: Likewise.

4 years agogetrandom-tests: do not assume GRND_RANDOM yields short read
Paul Eggert [Mon, 1 Jun 2020 06:29:21 +0000 (23:29 -0700)]
getrandom-tests: do not assume GRND_RANDOM yields short read

* tests/test-getrandom.c (main): Omit assertion that
getrandom (b, sizeof b, GRND_RANDOM | GRND_NONBLOCK) < sizeof b
when b’s size is 100000.  This assertion fails with Linux kernel
5.6.13, as that kernel ignores the GRND_RANDOM flag.
The separate blocking pool is going away in the Linux kernel, and
they’ve added a flag GRND_INSECURE instead; see:
https://lore.kernel.org/linux-api/705c5a091b63cc5da70c99304bb97e0109be0a26.1577088521.git.luto@kernel.org/
The assertion was iffy anyway; what’s to prevent a kernel from
lazily filling a large buffer with random bytes?

4 years agoread-file-test: pacify --enable-gcc-warnings
Paul Eggert [Mon, 1 Jun 2020 05:18:21 +0000 (22:18 -0700)]
read-file-test: pacify --enable-gcc-warnings

* tests/test-read-file.c (test_read_file): Now static.

4 years agotempname: merge from glibc and coreutils
Paul Eggert [Mon, 1 Jun 2020 03:15:25 +0000 (20:15 -0700)]
tempname: merge from glibc and coreutils

Also, merge in Gnulib’s more-recent methods of making it easier
to share between Gnulib and glibc, and fix a few randomness
glitches.
* lib/tempname.c: Include libc-config.h, not config.h, if !_LIBC.
(__set_errno): Remove; libc-config.h does that for us.
Do not include <sys/time.h>.
(__secure_getenv) [_LIBC]: New macro.
(__try_tempname, __getpid, __gettimeofday) [!_LIBC]: Remove macros.
(RANDOM_BITS): Rewrite.
(RANDOM_VALUE_MAX, BASE_62_DIGITS, BASE_62_POWER): New macros.
(random_value): New typedef.
(try_file, try_dir, try_nocreate): Move up.
(gen_tempname_len, try_tempname_len): New functions.
(gen_tempname_len): Use a constant array rather than a switch.
(try_tempname_len): Don’t assume string length fits in int.
Generalize use of RANDOM_BITS.  If _LIBC, don’t assume RANDOM_BITS
has enough entropy (it’s a bit short).
(__gen_tempname): Rewrite in terms of gen_tempname_len.
(__try_tempname): Rewrite in terms of try_tempname_len.
* lib/tempname.h (gen_tempname_len, try_tempname_len): New decls.
* modules/tempname (Depends-on): Remove gettimeofday, sys_time.
Add getentropy, libc-config.

4 years agogetrandom, getentropy: Mention the crypto/gc-random module.
Bruno Haible [Sun, 31 May 2020 19:01:19 +0000 (21:01 +0200)]
getrandom, getentropy: Mention the crypto/gc-random module.

Suggested by Simon Josefsson in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00400.html>.

* doc/glibc-functions/getrandom.texi: Mention the quality issues and the
crypto/gc-random module.
* doc/glibc-functions/getentropy.texi: Likewise.

4 years agogetentropy: Enhance tests.
Bruno Haible [Sun, 31 May 2020 18:13:27 +0000 (20:13 +0200)]
getentropy: Enhance tests.

* tests/test-getentropy.c (main): Add one more test.
* tests/test-unistd-c++.cc: Check the signature of getentropy.

4 years agogetentropy: Work around a macOS and Solaris problem.
Bruno Haible [Sun, 31 May 2020 18:12:04 +0000 (20:12 +0200)]
getentropy: Work around a macOS and Solaris problem.

* lib/unistd.in.h: Include <sys/random.h>, when needed for the
'getentropy' module.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize
UNISTD_H_HAVE_SYS_RANDOM_H.
* m4/sys_random_h.m4 (gl_HEADER_SYS_RANDOM): Set
UNISTD_H_HAVE_SYS_RANDOM_H.
* modules/unistd (Makefile.am): Substitute UNISTD_H_HAVE_SYS_RANDOM_H.
* doc/glibc-functions/getentropy.texi: Document the macOS and Solaris
problem. List more platforms.

4 years agofnmatch: merge from glibc
Paul Eggert [Sun, 31 May 2020 17:14:41 +0000 (10:14 -0700)]
fnmatch: merge from glibc

Also, merge in Gnulib’s more-recent methods of making it easier
to share between Gnulib and glibc.
* lib/fnmatch.c: Reorder includes to match glibc better.
Include libc-config.h instead of config.h.
Include alloca.h only if _LIBC || HAVE_ALLOCA.
Do not include "../locale/elem-hash.h" if _LIBC.
Define macros for btowc, etc. if _LIBC.  All uses simplified.
Define FALLTHROUGH if _LIBC, instead of including attribute.h.
Include intprops.h, since glibc has it now.
(SIZE_MAX): Remove; use (size_t) -1 instead.
Omit the "Comment out all this code" ifdef, since Gnulib
has never really needed it.
(STREQ): Remove; no longer used.
(__libc_use_alloca, alloca, alloca_account): Define as
needed if !_LIBC.
(ISWCTYPE): Remove; all uses replaced by iswctype.
(HANDLE_MULTIBYTE): Remove.  All uses removed by assuming true.
(internal_function): Remove.  All uses removed.
(STRUCT): New macro.
(WIDE_CHAR_VERSION): Define to 0 instead of leaving undefined.
(WMEMCMP): New macro.
(FINDIDX): Define if _LIBC, and include <locale/weight.h>
and <locale/weightwc.h>.
(fnmatch): Prefer __glibc_likely and __glibc_unlikely to
__builtin_expect.  Check for integer overflow more
systematically.  Account for alloca storage better when
recursive.  Use strnlen instead of strlen for efficiency.
* lib/fnmatch_loop.c: Include stdint.h if _LIBC, for int32_t etc.
(struct STRUCT): New type.
(FCT, EXT): New ENDS and ALLOCA_USED args.
All callers changed.
(FCT): Prefer __glibc_unlikely to __builtin_expect.
Simplify by assuming WIDE_CHAR_SUPPORT.
Copy _LIBC code from glibc without worrying Gnulib compatibility.
Cast cold to UCHAR to avoid signedness warning.
(END): Check for invalid pattern.
(EXT): Improve alloca/malloc checking (taken from glibc),
and improve it some more by using intprops.h and checking
for integer overflow and using bool for booleans.
* lib/libc-config.h (compat_symbol): New macro.
(versioned_symbol): Make it ‘extern int dummy’ so that it’s
acceptable to non-GCC when a trailing semicolon is added.
* modules/fnmatch (Depends-on): Add alloca-opt, intprops,
libc-config, strnlen.  Remove alloca.

4 years agogetrandom: Doc and test tweaks.
Bruno Haible [Sun, 31 May 2020 16:47:12 +0000 (18:47 +0200)]
getrandom: Doc and test tweaks.

* lib/getrandom.c (getrandom): Mention that it never returns 0, and that
it sets errno when failing.
* tests/test-getrandom.c (main): Disable the high-quality check on those
platforms on which it fails.
* doc/glibc-functions/getrandom.texi: Add Minix, AIX, HP-UX, IRIX,
Cygwin to the list of platforms that don't have the function. Add a note
about the quality of the result.
* doc/glibc-headers/sys_random.texi: Don't mention the 'getrandom'
declaration; this is fixed by module 'getrandom'.

4 years agogetrandom: Add support for native Windows.
Bruno Haible [Sun, 31 May 2020 16:23:04 +0000 (18:23 +0200)]
getrandom: Add support for native Windows.

* lib/getrandom.c: Include <errno.h>, <windows.h>, <bcrypt.h>,
<wincrypt.h>.
(CRYPT_VERIFY_CONTEXT): New macro.
(LoadLibrary, CryptAcquireContext): Redirect to the variant with suffix
'A'.
(GetProcAddress): New macro.
(BCryptGenRandomFuncType): New type.
(BCryptGenRandomFunc, initialized): New variables.
(initialize): New function.
(getrandom): On native Windows, use <bcrypt.h> API when available, and
<wincrypt.h> API as fallback.
* m4/getrandom.m4 (gl_FUNC_GETRANDOM): Set LIB_GETRANDOM.
* modules/getrandom (Link): New section.
* modules/getentropy (Link): Likewise.
* modules/getrandom-tests (Makefile.am): Link test-getrandom against
$(LIB_GETRANDOM).
* modules/getentropy-tests (Makefile.am): Link test-getentropy against
$(LIB_GETRANDOM).
* modules/sys_random-c++-tests (Makefile.am): Link test-sys_random-c++
against $(LIB_GETRANDOM).
* doc/glibc-functions/getrandom.texi: Mention the native Windows
support.

4 years agogetrandom: Simplify the determination of the random number devices.
Bruno Haible [Sun, 31 May 2020 11:44:04 +0000 (13:44 +0200)]
getrandom: Simplify the determination of the random number devices.

Suggested by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00383.html>.

* lib/getrandom.c (NAME_OF_RANDOM_DEVICE, NAME_OF_NONCE_DEVICE): New
macros.
* modules/getrandom (Depends-on): Remove crypto/gc-random.

4 years agocrypto/gc-random: Fix list of crypto devices for Solaris.
Bruno Haible [Sun, 31 May 2020 10:55:52 +0000 (12:55 +0200)]
crypto/gc-random: Fix list of crypto devices for Solaris.

* m4/gc-random.m4 (gl_GC_RANDOM): Don't special-case Solaris.

4 years agolist: fix GCC warnings
Akim Demaille [Sun, 31 May 2020 06:59:25 +0000 (08:59 +0200)]
list: fix GCC warnings

* lib/gl_anytree_list2.h (gl_tree_iterator_free)
(gl_tree_next_node, gl_tree_node_nx_set_value)
(gl_tree_previous_node, gl_tree_next_node):
Mark unused arguments.
* lib/gl_anytree_oset.h (gl_tree_iterator_free): Likewise.
* lib/gl_anylinked_list2.h (gl_linked_node_value)
(gl_linked_node_nx_set_value, gl_linked_iterator_free): Likewise.

* lib/gl_anytreehash_list2.h (gl_tree_search_from_to): Avoid using
the same variable name in nested scopes.

4 years agolist-c++, set-c++, oset-c++, map-c++, omap-c++: Don't fool the compiler.
Bruno Haible [Sun, 31 May 2020 10:01:27 +0000 (12:01 +0200)]
list-c++, set-c++, oset-c++, map-c++, omap-c++: Don't fool the compiler.

Reported by Akim Demaille in
<https://lists.gnu.org/archive/html/bug-bison/2020-05/msg00102.html>.

* lib/gl_list.hh (gl_List::iterator::next): Avoid a reinterpret_cast.
* lib/gl_set.hh (gl_Set::iterator::next): Likewise.
* lib/gl_oset.hh (gl_OSet::iterator::next): Likewise.
* lib/gl_map.hh (gl_Map::iterator::next): Likewise.
* lib/gl_omap.hh (gl_OMap::iterator::next): Likewise.

4 years agowmemchr: Relicense under LGPLv2+.
Bruno Haible [Sun, 31 May 2020 00:48:31 +0000 (02:48 +0200)]
wmemchr: Relicense under LGPLv2+.

* modules/wmemchr (License): Set to LGPLv2+.

4 years agowmempcpy: New module.
Bruno Haible [Sun, 31 May 2020 00:42:47 +0000 (02:42 +0200)]
wmempcpy: New module.

Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00387.html>.

* lib/wchar.in.h (wmempcpy): New declaration.
* lib/wmempcpy.c: New file.
* m4/wmempcpy.m4: New file.
* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wmempcpy is declared.
(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WMEMPCPY, HAVE_WMEMPCPY.
* modules/wchar (Makefile.am): Substitute GNULIB_WMEMPCPY,
HAVE_WMEMPCPY.
* modules/wmempcpy: New file.
* tests/test-wchar-c++.cc: Check the signature of wmempcpy.
* doc/glibc-functions/wmempcpy.texi: Mention the new module.
* modules/mempcpy (Description): Fix typo.

4 years agocrypto/gc-random: Fix list of crypto devices for NetBSD, OpenBSD.
Bruno Haible [Sat, 30 May 2020 23:10:37 +0000 (01:10 +0200)]
crypto/gc-random: Fix list of crypto devices for NetBSD, OpenBSD.

* m4/gc-random.m4 (gl_GC_RANDOM): Don't special-case NetBSD and OpenBSD.

4 years agosys_random: Work around macOS bug.
Bruno Haible [Sat, 30 May 2020 23:02:21 +0000 (01:02 +0200)]
sys_random: Work around macOS bug.

* m4/sys_random_h.m4 (gl_HEADER_SYS_RANDOM): Include <sys/types.h> and
<stdlib.h> before <sys/random.h>.
* m4/getrandom.m4 (gl_FUNC_GETRANDOM): Likewise.
* lib/sys_random.in.h: On macOS, include <sys/types.h> and <stdlib.h>
first.
* doc/glibc-headers/sys_random.texi: Mention the macOS problem.

4 years agogetrandom: Fix typo in last commit.
Bruno Haible [Sat, 30 May 2020 18:58:44 +0000 (20:58 +0200)]
getrandom: Fix typo in last commit.

* m4/sys_random_h.m4 (gl_SYS_RANDOM_H_DEFAULTS): Fix value of REPLACE_GETRANDOM.

4 years agogetrandom: Override incompatible system function on Solaris 11.
Bruno Haible [Sat, 30 May 2020 15:33:46 +0000 (17:33 +0200)]
getrandom: Override incompatible system function on Solaris 11.

* lib/sys_random.in.h (getrandom): Override if REPLACE_GETRANDOM is 1.
* lib/getrandom.c (getrandom): When the system has getrandom, just
invoke it.
* m4/getrandom.m4 (gl_FUNC_GETRANDOM): Set REPLACE_GETRANDOM if the
system's getrandom function's prototype is not the expected one.
* m4/sys_random_h.m4 (gl_SYS_RANDOM_H_DEFAULTS): Initialize
REPLACE_GETRANDOM.
* modules/sys_random (Makefile.am): Substitute REPLACE_GETRANDOM.
* modules/getrandom (modules/getrandom): Consider REPLACE_GETRANDOM.
* tests/test-getrandom.c (main): Allow error EINVAL as an alternative to
EAGAIN.
* doc/glibc-functions/getrandom.texi: Mention the new module and the
Solaris problem.

4 years agosys_random: Add C++ tests.
Bruno Haible [Sat, 30 May 2020 14:22:25 +0000 (16:22 +0200)]
sys_random: Add C++ tests.

* tests/test-sys_random-c++.cc: New file.
* modules/sys_random-c++-tests: New file.
* modules/sys_random-tests (Depends-on): Depend on it.

4 years agosys_random: Add tests.
Bruno Haible [Sat, 30 May 2020 14:20:32 +0000 (16:20 +0200)]
sys_random: Add tests.

* tests/test-sys_random.c: New file.
* modules/sys_random-tests: New file.

4 years agosys_random: New module.
Bruno Haible [Sat, 30 May 2020 14:18:36 +0000 (16:18 +0200)]
sys_random: New module.

* lib/sys_random.in.h: Use the common idioms for overridable header
files.
* m4/sys_random_h.m4: New file.
* m4/getrandom.m4 (gl_FUNC_GETRANDOM): Require gl_SYS_RANDOM_H_DEFAULTS.
* modules/sys_random: New file.
* modules/getrandom (Files): Remove lib/sys_random.in.h.
(Depends-on): Add sys_random.
(configure.ac): Use gl_SYS_RANDOM_MODULE_INDICATOR, not
gl_UNISTD_MODULE_INDICATOR.
(Makefile.am): Don't generate sys/random.h here.
* doc/glibc-headers/sys_random.texi: New file.
* doc/gnulib.texi: Include it.

4 years agounistd: Remove conflicting declaration of getrandom().
Bruno Haible [Sat, 30 May 2020 13:15:55 +0000 (15:15 +0200)]
unistd: Remove conflicting declaration of getrandom().

* lib/unistd.in.h (getrandom): Remove declaration.
* m4/unistd_h.m4 (gl_UNISTD_H): Don't test whether getrandom is
declared.
(gl_UNISTD_H_DEFAULTS): Don't initialize GNULIB_GETRANDOM,
HAVE_GETRANDOM.
* modules/unistd (Makefile.am): Don't substitute GNULIB_GETRANDOM,
HAVE_GETRANDOM.

4 years agogetrandom: Add tests.
Bruno Haible [Sat, 30 May 2020 12:58:28 +0000 (14:58 +0200)]
getrandom: Add tests.

* tests/test-getrandom.c: New file.
* modules/getrandom-tests: New file.

4 years agocrypto/gc-random: Fix typo in last commit.
Bruno Haible [Sat, 30 May 2020 12:16:09 +0000 (14:16 +0200)]
crypto/gc-random: Fix typo in last commit.

4 years agocrypto/gc-random: Fix link error on MSVC.
Bruno Haible [Sat, 30 May 2020 12:13:22 +0000 (14:13 +0200)]
crypto/gc-random: Fix link error on MSVC.

* m4/gc-random.m4 (gl_GC_RANDOM): Set LIB_GC_RAMDOM.
* modules/crypto/gc-random (Link): New section.
* modules/crypto/gc-tests (Makefile.am): Link test-gc against
$(LIB_GC_RAMDOM).

4 years agoDon't assume that UNICODE is not defined.
Bruno Haible [Sat, 30 May 2020 09:04:02 +0000 (11:04 +0200)]
Don't assume that UNICODE is not defined.

Many Windows API functions are defined differently (redirecting to a
function with suffix 'W') if the application defines the macro UNICODE
than by default (redirecting to a function with suffix 'A').

* lib/clean-temp.c (OSVERSIONINFO, GetVersionEx): Redirect to the
variant with suffix 'A'.
* lib/dirent-private.h (WIN32_FIND_DATA): Likewise.
* lib/gc-gnulib.c (CryptAcquireContext): Likewise.
* lib/getaddrinfo.c (GetModuleHandle): Likewise.
* lib/getlogin.c (GetUserName): Likewise.
* lib/getlogin_r.c (GetUserName): Likewise.
* lib/gettimeofday.c (LoadLibrary): Likewise.
* lib/isatty.c (LoadLibrary, QueryFullProcessImageName): Likewise.
* lib/link.c (GetModuleHandle, CreateHardLink): Likewise.
* lib/localename.c (GetLocaleInfo, EnumSystemLocales): Likewise.
* lib/mountlist.c (GetDriveType): Likewise.
* lib/nonblocking.c (GetNamedPipeHandleState): Likewise.
* lib/opendir.c (WIN32_FIND_DATA, GetFullPathName, FindFirstFile):
Likewise.
* lib/physmem.c (GetModuleHandle): Likewise.
* lib/poll.c (GetModuleHandle, PeekConsoleInput, CreateEvent,
PeekMessage, DispatchMessage): Likewise.
* lib/progreloc.c (GetModuleFileName): Likewise.
* lib/putenv.c (SetEnvironmentVariable): Likewise.
* lib/read.c (GetNamedPipeHandleState): Likewise.
* lib/readdir.c (FindNextFile): Likewise.
* lib/relocatable.c (GetModuleFileName): Likewise.
* lib/rename.c (MoveFileEx): Likewise.
* lib/rewinddir.c (FindFirstFile): Likewise.
* lib/select.c (GetModuleHandle, PeekConsoleInput, CreateEvent,
PeekMessage, DispatchMessage): Likewise.
* lib/sethostname.c (GetComputerNameEx, SetComputerNameEx): Likewise.
* lib/socket.c (WSASocket): Likewise.
* lib/stat-w32.c (LoadLibrary, GetFinalPathNameByHandle): Likewise.
* lib/stat.c (WIN32_FIND_DATA, CreateFile, FindFirstFile): Likewise.
* lib/stdio-read.c (GetNamedPipeHandleState): Likewise.
* lib/stdio-write.c (GetNamedPipeHandleState): Likewise.
* lib/tmpdir.c (GetTempPath): Likewise.
* lib/tmpfile.c (OSVERSIONINFO, GetVersionEx, GetTempPath): Likewise.
* lib/uname.c (OSVERSIONINFO, GetVersionEx): Likewise.
* lib/utime.c (CreateFile, GetFileAttributes): Likewise.
* lib/windows-cond.c (CreateEvent): Likewise.
* lib/windows-rwlock.c (CreateEvent): Likewise.
* lib/windows-timedmutex.c (CreateEvent): Likewise.
* lib/windows-timedrecmutex.c (CreateEvent): Likewise.
* lib/windows-timedrwlock.c (CreateEvent): Likewise.
* lib/write.c (GetNamedPipeHandleState): Likewise.

4 years agophysmem: Fix compilation errors on MSVC.
Bruno Haible [Sat, 30 May 2020 08:39:49 +0000 (10:39 +0200)]
physmem: Fix compilation errors on MSVC.

* lib/physmem.c (PFN_MS_EX): Use BOOL, not WINBOOL.
* modules/physmem (Depends-on): Add unistd.

4 years agognulib-tool: Fix link errors with a particular set of modules on mingw.
Bruno Haible [Sat, 30 May 2020 01:17:19 +0000 (03:17 +0200)]
gnulib-tool: Fix link errors with a particular set of modules on mingw.

* gnulib-tool (func_emit_tests_Makefile_am): Add ../lib/libgnu.a to
LDADD a second time, after the second occurrence of libtests.a.
* pygnulib/GLEmiter.py (tests_Makefile_am): Likewise.

4 years agofnmatch: Rely on more gnulib modules.
Bruno Haible [Fri, 29 May 2020 12:01:54 +0000 (14:01 +0200)]
fnmatch: Rely on more gnulib modules.

* modules/fnmatch (Depends-on): Add btowc, isblank, iswctype, wmemchr,
wmempcpy, mempcpy.
* lib/fnmatch.c: Assume that HAVE_WCTYPE_H, HAVE_BTOWC, HAVE_ISWCTYPE,
HAVE_WMEMCHR, HAVE_WMEMPCPY, HAVE_ISBLANK, HAVE_DECL_ISBLANK,
HAVE_MEMPCPY are all 1.
* m4/fnmatch.m4 (gl_PREREQ_FNMATCH): Don't test for btowc, isblank,
iswctype, mempcpy, wmemchr, wmemcpy, wmempcpy, <wctype.h>.

4 years agoAvoid dynamic lookup of Windows API functions when possible.
Bruno Haible [Fri, 29 May 2020 20:28:00 +0000 (22:28 +0200)]
Avoid dynamic lookup of Windows API functions when possible.

* lib/getaddrinfo.c (GetProcAddress, getaddrinfo_func,
freeaddrinfo_func, getnameinfo_func, getaddrinfo_ptr, freeaddrinfo_ptr,
getnameinfo_ptr): Don't define in a build for Windows XP or higher.
(use_win32_p): Define differently.
* lib/link.c (GetProcAddress, CreateHardLinkFuncType,
CreateHardLinkFunc, initialized, initialize): Don't define in a build
for Windows XP or higher.

4 years agoread-file: disable buffering if RF_SENSITIVE is set
Daiki Ueno [Fri, 29 May 2020 03:45:40 +0000 (05:45 +0200)]
read-file: disable buffering if RF_SENSITIVE is set

* lib/read-file.c (read_file): Call setvbuf if RF_SENSITIVE.
Suggested by Glenn Strauss.
(fread_file): Suggest calling setvbuf before calling this
function.  Suggested by Bruno Haible.

4 years agowmemchr, wmemcmp, wmemcpy, wmemmove, wmemset: Fix autoconf test.
Bruno Haible [Fri, 29 May 2020 11:20:46 +0000 (13:20 +0200)]
wmemchr, wmemcmp, wmemcpy, wmemmove, wmemset: Fix autoconf test.

* m4/wmemchr.m4 (gl_FUNC_WMEMCHR): Link, not only compile, the test
program.
* m4/wmemcmp.m4 (gl_FUNC_WMEMCMP): Likewise.
* m4/wmemcpy.m4 (gl_FUNC_WMEMCPY): Likewise.
* m4/wmemmove.m4 (gl_FUNC_WMEMMOVE): Likewise.
* m4/wmemset.m4 (gl_FUNC_WMEMSET): Likewise.

4 years agoFix compilation error on native Windows (regression from 2020-05-28).
Bruno Haible [Fri, 29 May 2020 10:33:46 +0000 (12:33 +0200)]
Fix compilation error on native Windows (regression from 2020-05-28).

Reported by Daiki Ueno.

* lib/gettimeofday.c (GetSystemTimePreciseAsFileTimeFunc): Define as
macro when not using dynamic loading.
* lib/isatty.c (GetNamedPipeClientProcessIdFunc,
QueryFullProcessImageNameFunc): Likewise.
* lib/stat-w32.c (GetFileInformationByHandleExFunc,
GetFinalPathNameByHandleFunc): Likewise.

4 years agofopen-gnu-tests: fix "\x" escape usage
Daiki Ueno [Fri, 29 May 2020 02:54:31 +0000 (04:54 +0200)]
fopen-gnu-tests: fix "\x" escape usage

* tests/test-fopen-gnu.c (DATA): Use safer escape sequence.

4 years agoAvoid dynamic loading of Windows API functions when possible.
Bruno Haible [Fri, 29 May 2020 00:03:12 +0000 (02:03 +0200)]
Avoid dynamic loading of Windows API functions when possible.

Reported by Steve Lhomme <robux4@ycbcr.xyz> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00182.html>.

* lib/gettimeofday.c (GetProcAddress,
GetSystemTimePreciseAsFileTimeFuncType,
GetSystemTimePreciseAsFileTimeFunc, initialized, initialize): Don't
define in a build for Windows 8 or higher.
* lib/isatty.c (GetProcAddress, GetNamedPipeClientProcessIdFuncType,
GetNamedPipeClientProcessIdFunc, QueryFullProcessImageNameFuncType,
QueryFullProcessImageNameFunc, initialized, initialize): Don't define
in a build for Windows Vista or higher.
* lib/stat-w32.c (GetProcAddress, GetFileInformationByHandleExFuncType,
GetFileInformationByHandleExFunc, GetFinalPathNameByHandleFuncType,
GetFinalPathNameByHandleFunc, initialized, initialize): Likewise.

4 years agoexplicit_bzero-tests: improve -Wmissing-declarations pacification
Paul Eggert [Thu, 28 May 2020 23:02:32 +0000 (16:02 -0700)]
explicit_bzero-tests: improve -Wmissing-declarations pacification

* tests/test-explicit_bzero.c: Now noinline.
Suggested by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00300.html

4 years agoFix build errors due to read-file changes (regression from 2020-05-27).
Bruno Haible [Thu, 28 May 2020 20:04:46 +0000 (22:04 +0200)]
Fix build errors due to read-file changes (regression from 2020-05-27).

* lib/git-merge-changelog.c (read_changelog_file): Update read_file
invocation.
* tests/test-sameacls.c (main): Likewise.
* tests/test-pipe-filter-gi1.c (main): Call read_file instead of
read_binary_file.
* tests/test-pipe-filter-ii1.c (main): Likewise.

4 years agofts: Make more robust in multithreaded applications.
Bruno Haible [Thu, 28 May 2020 19:48:13 +0000 (21:48 +0200)]
fts: Make more robust in multithreaded applications.

* lib/fts.c (fts_open): Pass an O_CLOEXEC flag to open().
* modules/fts (Depends-on): Add 'open'.

4 years agorelocatable-prog: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 18:35:39 +0000 (20:35 +0200)]
relocatable-prog: Make more robust in multithreaded applications.

* lib/progreloc.c (O_CLOEXEC): Define fallback to 0 when use from module
relocatable-prog-wrapper.
(find_executable): Pass an O_CLOEXEC flag to open().
* modules/relocatable-prog (Depends-on): Add 'open'.

4 years agogetloadavg: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 18:16:33 +0000 (20:16 +0200)]
getloadavg: Make more robust in multithreaded applications.

* lib/getloadavg.c (getloadavg): Pass an O_CLOEXEC flag to open().
Simplify use of O_CLOEXEC.
* modules/getloadavg (Depends-on): Add 'open'.

4 years agovma-iter: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 18:11:27 +0000 (20:11 +0200)]
vma-iter: Make more robust in multithreaded applications.

* lib/vma-iter.c (rof_open, vma_iterate): Pass an O_CLOEXEC flag to
open().
* modules/vma-iter (Depends-on): Add 'open'.

4 years agotruncate: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 18:09:49 +0000 (20:09 +0200)]
truncate: Make more robust in multithreaded applications.

* lib/truncate.c (truncate): Pass an O_CLOEXEC flag to open().

4 years agopagealign_alloc: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 18:08:33 +0000 (20:08 +0200)]
pagealign_alloc: Make more robust in multithreaded applications.

* lib/pagealign_alloc.c (pagealign_alloc): Pass an O_CLOEXEC flag to
open().
* modules/pagealign_alloc (Depends-on): Add 'open'.

4 years agoopenat: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 18:06:37 +0000 (20:06 +0200)]
openat: Make more robust in multithreaded applications.

* lib/openat.c (openat_needs_fchdir): Pass an O_CLOEXEC flag to open().

4 years agoat-internal: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 18:04:38 +0000 (20:04 +0200)]
at-internal: Make more robust in multithreaded applications.

* lib/openat-proc.c (openat_proc_name): Pass an O_CLOEXEC flag to
open().

4 years agomountlist: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 18:02:57 +0000 (20:02 +0200)]
mountlist: Make more robust in multithreaded applications.

* lib/mountlist.c (read_file_system_list): Pass an O_CLOEXEC flag to
open().
* modules/mountlist (Depends-on): Add 'open'.

4 years agologin_tty: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 18:01:30 +0000 (20:01 +0200)]
login_tty: Make more robust in multithreaded applications.

* lib/login_tty.c (login_tty): Pass an O_CLOEXEC flag to open().
* modules/login_tty (Depends-on): Add 'open'.

4 years agojavacomp: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 17:46:45 +0000 (19:46 +0200)]
javacomp: Make more robust in multithreaded applications.

* lib/javacomp.c (get_classfile_version): Pass an O_CLOEXEC flag to
open().
* modules/javacomp (Depends-on): Add 'open'.

4 years agogetprogname: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 17:45:19 +0000 (19:45 +0200)]
getprogname: Make more robust in multithreaded applications.

* lib/getprogname.c (getprogname): Pass an O_CLOEXEC flag to open().
* modules/getprogname (Depends-on): Add 'open'.

4 years agoget_progname_of: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 17:43:23 +0000 (19:43 +0200)]
get_progname_of: Make more robust in multithreaded applications.

* lib/get_progname_of.c (get_progname_of): Pass an O_CLOEXEC flag to
open().
* modules/get_progname_of (Depends-on): Add 'open'.

4 years agoget_ppid_of: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 17:41:38 +0000 (19:41 +0200)]
get_ppid_of: Make more robust in multithreaded applications.

* lib/get_ppid_of.c (get_ppid_of): Pass an O_CLOEXEC flag to open().
* modules/get_ppid_of (Depends-on): Add 'open'.

4 years agoget-rusage-as: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 17:40:08 +0000 (19:40 +0200)]
get-rusage-as: Make more robust in multithreaded applications.

* lib/get-rusage-as.c (get_rusage_as_via_setrlimit): Pass an O_CLOEXEC
flag to open().
* modules/get-rusage-as (Depends-on): Add 'open'.

4 years agocrypto/gc: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 17:38:36 +0000 (19:38 +0200)]
crypto/gc: Make more robust in multithreaded applications.

* lib/gc-gnulib.c (randomize): Pass an O_CLOEXEC flag to open().
* modules/crypto/gc (Depends-on): Add 'open'.

4 years agocopy-file: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 17:36:54 +0000 (19:36 +0200)]
copy-file: Make more robust in multithreaded applications.

* lib/copy-file.c (qcopy_file_preserving): Pass an O_CLOEXEC flag to
open().

4 years agochown: Make more robust in multithreaded applications.
Bruno Haible [Wed, 27 May 2020 17:35:28 +0000 (19:35 +0200)]
chown: Make more robust in multithreaded applications.

* lib/chown.c (rpl_chown): Pass an O_CLOEXEC flag to open().

4 years agodoc: Fix statement about O_CLOEXEC (wrong since 2017-08-14).
Bruno Haible [Wed, 27 May 2020 18:33:28 +0000 (20:33 +0200)]
doc: Fix statement about O_CLOEXEC (wrong since 2017-08-14).

* doc/posix-headers/fcntl.texi: Gnulib no longer defines O_CLOEXEC to 0.

4 years agofopen-gnu: make 'b' flag can be used with 'e' on Windows
Daiki Ueno [Thu, 28 May 2020 09:40:49 +0000 (11:40 +0200)]
fopen-gnu: make 'b' flag can be used with 'e' on Windows

* lib/fopen.c (rpl_fopen): Pass O_BINARY to open, if a 'b' flag is
specified on Windows.
* tests/test-fopen-gnu.c (DATA): New define.
(main): Add test for reading binary files with an 'e' flag.

4 years agoDon't assume that UNICODE is not defined.
Bruno Haible [Thu, 28 May 2020 00:31:53 +0000 (02:31 +0200)]
Don't assume that UNICODE is not defined.

Some Windows types, such as TCHAR, LPTSTR, LPCTSTR, are defined
differently if the application defines the macro UNICODE.

Reported by Steve Lhomme <robux4@ycbcr.xyz> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00184.html>.

* lib/link.c (CreateHardLinkFuncType): Use LPCSTR, not LPCTSTR.
* lib/localename.c (enum_locales_fn): Use LPSTR, not LPTSTR.
* lib/stat-w32.c (GetFinalPathNameByHandleFuncType): Likewise.

4 years agoImprove pattern for defining _WIN32_WINNT.
Bruno Haible [Thu, 28 May 2020 00:06:51 +0000 (02:06 +0200)]
Improve pattern for defining _WIN32_WINNT.

Newer versions of the Windows API may not only add, but also remove API
functions. Therefore, when the user is e.g. building for Windows 10, we
should not set _WIN32_WINNT to e.g. Windows 8, as this may enable the
use of APIs that were present in Windows 8 but removed in Windows 10.

Suggested by Steve Lhomme <robux4@ycbcr.xyz> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00318.html>.

* lib/ftruncate.c (_WIN32_WINNT): Don't set to a smaller value.
* lib/sethostname.c (_WIN32_WINNT): Likewise.
* lib/stat-w32.c (_WIN32_WINNT): Likewise.

4 years agojavacomp: Make more robust in multithreaded applications.
Bruno Haible [Tue, 26 May 2020 16:05:34 +0000 (18:05 +0200)]
javacomp: Make more robust in multithreaded applications.

* lib/javacomp.c (write_temp_file): Pass an 'e' flag to fopen_temp.
* modules/javacomp (Depends-on): Add fopen-gnu.

4 years agomountlist: Make more robust in multithreaded applications.
Bruno Haible [Tue, 26 May 2020 16:04:26 +0000 (18:04 +0200)]
mountlist: Make more robust in multithreaded applications.

* lib/mountlist.c (setmntent, read_file_system_list): Pass an 'e' flag
to fopen.
* modules/mountlist (Depends-on): Add fopen-gnu.

4 years agosethostname: Make more robust in multithreaded applications.
Bruno Haible [Tue, 26 May 2020 16:00:04 +0000 (18:00 +0200)]
sethostname: Make more robust in multithreaded applications.

* lib/sethostname.c (sethostname): Pass an 'e' flag to fopen.
* modules/sethostname (Depends-on): Add fopen-gnu.

4 years agoreadutmp: Make more robust in multithreaded applications.
Bruno Haible [Tue, 26 May 2020 15:57:58 +0000 (17:57 +0200)]
readutmp: Make more robust in multithreaded applications.

* lib/readutmp.c (read_utmp): Pass an 'e' flag to fopen.
* modules/readutmp (Depends-on): Add fopen-gnu.

4 years agogetpass: Make more robust in multithreaded applications.
Bruno Haible [Tue, 26 May 2020 15:56:31 +0000 (17:56 +0200)]
getpass: Make more robust in multithreaded applications.

* lib/getpass.c (getpass): Pass an 'e' flag to fopen.
* modules/getpass (Depends-on): Add fopen-gnu.

4 years agogetloadavg: Make more robust in multithreaded applications.
Bruno Haible [Tue, 26 May 2020 15:53:47 +0000 (17:53 +0200)]
getloadavg: Make more robust in multithreaded applications.

* lib/getloadavg.c (getloadavg): Pass an 'e' flag to fopen.
* modules/getloadavg (Depends-on): Add fopen-gnu.

4 years agoexclude: Make more robust in multithreaded applications.
Bruno Haible [Tue, 26 May 2020 15:52:23 +0000 (17:52 +0200)]
exclude: Make more robust in multithreaded applications.

* lib/exclude.c (add_exclude_file): Pass an 'e' flag to fopen.
* modules/exclude (Depends-on): Add fopen-gnu.

4 years agobitset: Make more robust in multithreaded applications.
Bruno Haible [Tue, 26 May 2020 15:51:03 +0000 (17:51 +0200)]
bitset: Make more robust in multithreaded applications.

* lib/bitset/stats.c (bitset_stats_read, bitset_stats_write): Pass an
'e' flag to fopen.
* modules/bitset (Depends-on): Add fopen-gnu.

4 years agoread-file: add RF_SENSITIVE flag
Daiki Ueno [Tue, 26 May 2020 08:22:37 +0000 (10:22 +0200)]
read-file: add RF_SENSITIVE flag

* lib/read-file.h (RF_SENSITIVE): New define.
* lib/read-file.c (fread_file, read_file): Take into account of
RF_SENSITIVE flag.
* modules/read-file (Depends-on): Add explicit_bzero.
This adds an alternative behavior of those functions to explicitly
clear the internal memory block when it becomes unused.  This is
useful for reading sensitive information from a file.

4 years agoread-file: add flags to modify reading behavior
Daiki Ueno [Wed, 27 May 2020 06:14:44 +0000 (08:14 +0200)]
read-file: add flags to modify reading behavior

* lib/read-file.h (RF_BINARY): New define.
(fread_file, read_file): Take FLAGS argument.
(read_binary_file): Remove.
* lib/read-file.c (internal_read_file): Merge into ...
(read_file): ... here.
* modules/read-file-tests (Files): Add "tests/macros.h".
* tests/test-read-file.c (main): Refactor using ASSERT macro.
* NEWS: Mention this change.

4 years agodoc/gnulib-intro.texi: add missing "to" in sentence
Bernhard Voelker [Tue, 26 May 2020 21:16:44 +0000 (23:16 +0200)]
doc/gnulib-intro.texi: add missing "to" in sentence

Reported by Bjarni Ingi Gislason <bjarniig@rhi.hi.is> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00316.html>.

* doc/gnulib-intro.texi (Collaborative Development): Add "to".

4 years agocount-one-bits: Fix MSVC specific code.
Bruno Haible [Tue, 26 May 2020 20:27:51 +0000 (22:27 +0200)]
count-one-bits: Fix MSVC specific code.

Reported by Gisle Vanem <gisle.vanem@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00309.html>.

* lib/count-one-bits.h (COUNT_ONE_BITS_GENERIC): Don't define if we're
using GCC.
[_MSC_VER]: Use correct syntax for #pragma intrinsic.
(__popcnt64): In 32-bit mode, define as an inline function.
(COUNT_ONE_BITS): Rename first argument to GCC_BUILTIN.

4 years agoargz: Avoid name clashes through argz.h.
Bruno Haible [Tue, 26 May 2020 19:26:13 +0000 (21:26 +0200)]
argz: Avoid name clashes through argz.h.

Reported by Gisle Vanem <gisle.vanem@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00308.html>.

* lib/argz.h: Don't use __ prefixed identifiers.
(const): Remove definition.
(argz_next): Remove inline definitions.

4 years agoread-file: make use of fopen-gnu
Daiki Ueno [Tue, 26 May 2020 05:56:13 +0000 (07:56 +0200)]
read-file: make use of fopen-gnu

* lib/read-file.c (read_file): Pass an 'e' flag to fopen.
(read_binary_file): Likewise.
* modules/read-file (Depends-on): Add fopen-gnu.

4 years agogetentropy, getrandom: new modules
Paul Eggert [Mon, 25 May 2020 16:19:56 +0000 (09:19 -0700)]
getentropy, getrandom: new modules

* MODULES.html.sh (func_all_modules):
* lib/unistd.in.h (getentropy, getrandom):
* m4/unistd_h.m4 (gl_UNISTD_H, gl_UNISTD_H_DEFAULTS):
* modules/unistd (unistd.h):
Add support for getentropy, getrandom.
* doc/glibc-functions/getentropy.texi (getentropy):
* doc/glibc-functions/getrandom.texi (getrandom):
These are now fixed on some platforms.
* lib/getentropy.c, lib/getrandom.c, lib/sys_random.in.h:
* m4/getentropy.m4, m4/getrandom.m4:
* modules/getentropy, modules/getentropy-tests:
* modules/getrandom, modules/getrandom-tests:
* tests/test-getentropy.c, tests/test-getrandom.c:
New files.

4 years agoAdd missing C99 dependencies.
Bruno Haible [Mon, 25 May 2020 06:57:52 +0000 (08:57 +0200)]
Add missing C99 dependencies.

Reported by Paul Smith <psmith@gnu.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00290.html>.

* modules/assert (Depends-on): Add c99.
* modules/filenamecat-lgpl (Depends-on): Likewise.
* modules/libc-config (Depends-on): Likewise.
* modules/mktime (Depends-on): Likewise.
* modules/random_r (Depends-on): Likewise.
* modules/regex (Depends-on): Likewise.
* modules/scratch_buffer (Depends-on): Likewise.
* modules/timespec-add (Depends-on): Likewise.
* modules/timespec-sub (Depends-on): Likewise.
* modules/verify (Depends-on): Likewise.

4 years agoexplicit_bzero-tests: pacify -Wmissing-declarations
Paul Eggert [Sun, 24 May 2020 20:51:27 +0000 (13:51 -0700)]
explicit_bzero-tests: pacify -Wmissing-declarations

* tests/test-explicit_bzero.c (do_secret_stuff, test_stack):
Now static.

4 years agofopen-gnu: Add tests.
Bruno Haible [Sun, 24 May 2020 18:40:01 +0000 (20:40 +0200)]
fopen-gnu: Add tests.

* tests/test-fopen-gnu.c: New file.
* modules/fopen-gnu-tests: New file.

4 years agofopen-gnu: New module.
Bruno Haible [Sun, 24 May 2020 18:38:53 +0000 (20:38 +0200)]
fopen-gnu: New module.

Suggested by Tim Rühsen <tim.ruehsen@gmx.de> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00119.html>.

* lib/fopen.c (rpl_fopen): When the fopen-gnu module is enabled and the
mode contains an 'x' or 'e' flag, use open() followed by fdopen().
* m4/fopen.m4 (gl_FUNC_FOPEN_GNU): New macro.
* modules/fopen-gnu: New file.
* doc/posix-functions/fopen.texi: Document the 'fopen-gnu' module.

4 years agoopen, openat: Really support O_CLOEXEC.
Bruno Haible [Sun, 24 May 2020 18:27:39 +0000 (20:27 +0200)]
open, openat: Really support O_CLOEXEC.

* lib/open.c (open): When have_cloexec is still undecided, do pass a
O_CLOEXEC flag to orig_open.
* lib/openat.c (rpl_openat): When have_cloexec is still undecided, do
pass a O_CLOEXEC flag to orig_openat.
* tests/test-open.h (test_open): Verify that O_CLOEXEC is honoured.
* modules/open-tests (Depends-on): Add fcntl.
* modules/openat-tests (Depends-on): Likewise.
* modules/fcntl-safer-tests (Depends-on): Likewise.