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.
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.
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).
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').
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.
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.
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.
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.
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'.
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.
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.
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.
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.
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.
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.
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.
Bruno Haible [Sun, 24 May 2020 11:57:59 +0000 (13:57 +0200)]
fopen: Fix the trailing slash workaround.
* lib/fopen.c (rpl_fopen): Parse the mode string. Recognize "r+" as a
write access. Pass the right flags to open().
* tests/test-fopen.h (test_fopen): Add a few more tests on directories.
Paul Eggert [Sun, 24 May 2020 02:06:16 +0000 (19:06 -0700)]
assure: new macro ‘affirm’
* lib/assure.h: Include verify.h.
(affirm): New macro, after a suggestion by Marc Nieper-Wißkirchen in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00263.html
and commentary by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00278.html
* modules/assure (Depends-on:): Add verify.
Bruno Haible [Sat, 23 May 2020 19:17:22 +0000 (21:17 +0200)]
isnanf, isnanl, isnan: Don't use nonexistent builtins with clang.
* m4/isnanf.m4 (gl_HAVE_ISNANF_NO_LIBM, gl_HAVE_ISNANF_IN_LIBM,
gl_ISNANF_WORKS): Don't use __builtin_isnanf on clang versions that
don't have it.
* m4/isnanl.m4 (gl_HAVE_ISNANL_NO_LIBM, gl_HAVE_ISNANL_IN_LIBM,
gl_FUNC_ISNANL_WORKS): Don't use __builtin_isnanl on clang versions that
don't have it.
* lib/isnanf-nolibm.h (__has_builtin): New macro.
(isnanf): Don't use __builtin_isnanf on clang versions that don't have
it.
* lib/isnanl-nolibm.h (__has_builtin): New macro.
(isnanl): Don't use __builtin_isnanl on clang versions that don't have
it.
* lib/math.in.h (__has_builtin): New macro.
(isnanf): Don't use __builtin_isnanf on clang versions that don't have
it.
(isnanl): Don't use __builtin_isnanl on clang versions that don't have
it.
(isnan): Don't use the builtins on clang versions that don't have
__builtin_isnanf and __builtin_isnanl.
Bruno Haible [Sat, 23 May 2020 10:19:34 +0000 (12:19 +0200)]
findprog-in: Ignore directories.
Reported by Frederick Eaton via Dmitry Goncharov in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-03/msg00003.html>.
* lib/findprog-in.c (find_in_given_path): When the file found is a
directory, set errno to EACCES and, during a PATH search, continue
searching.
* modules/findprog-in (Depends-on): Add sys_stat, stat.
Asher Gordon [Fri, 22 May 2020 17:39:01 +0000 (13:39 -0400)]
gendocs: Clarify licenses for templates.
* doc/gendocs_template: Add a GNU All-Permissive license notice and
bump Parent-Version.
* doc/gendocs_template_min: Add a GNU All-Permissive license notice
and copy the explanatory comment about the license notice at the
bottom from gendocs_template.
Bruno Haible [Thu, 21 May 2020 19:43:32 +0000 (21:43 +0200)]
group-member: Relicense under LGPLv2+.
Jim Meyering's approval is in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00218.html>.
Paul Eggert's approval is in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00225.html>.
Eric Blake's approval is in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00217.html>.
* modules/group-member (License): Change to LGPLv2+.
vcs-to-changelog: Rename vcs_to_changelog.py to use hyphens.
This was needed earlier because modules had to import the main script,
but that is no longer true. Rename the script so that it is
consistent with all other scripts in gnulib and uses hyphens.
* build-aux/vcs_to_changelog.py: Rename to...
* build-aux/vcs-to-changelog.py: ... this.
* doc/vcs-to-changelog.texi (VCS To ChangeLog): Update reference.
* modules/vcs-to-changelog: Likewise.
Bruno Haible [Sun, 17 May 2020 17:27:08 +0000 (19:27 +0200)]
Clarify intended usage of the license file modules.
Reported by Asher Gordon <AsDaGo@posteo.net> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00126.html>.
* doc/licenses-texi.texi (License Texinfo sources): Mention the
GNU AGPL. Explain the intended usage of the modules.
* modules/fdl (Notice): Discourage use as a module.
* modules/fdl-1.3 (Notice): Likewise.
Paul Eggert [Tue, 12 May 2020 16:24:05 +0000 (09:24 -0700)]
xalloc: pacify -Wanalyzer-possible-null-argument
Problem reported for GCC 10.1.0 by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00118.html
* lib/xmalloc.c (HAVE_GNU_MALLOC, HAVE_GNU_REALLOC): New constants.
(xmalloc): Suppress unnecessary check if HAVE_GNU_MALLOC.
(xrealloc): Suppress unnecssary check if HAVE_GNU_REALLOC.
Paul Eggert [Mon, 11 May 2020 17:46:07 +0000 (10:46 -0700)]
careadlinkat: fix GCC 10 workaround
* lib/careadlinkat.c (careadlinkat) [GCC_LINT]:
Massage the code so that it’s closer to what it was before
the GCC 10.1.0 workaround was introduced. This fixes
a loop when !buffer and the bug workaround is in effect.
Remove unnecessary casts. Defend in a different way
against (buffer && !buffer_size), by adding at least 1
to buf_size each time through the loop.
Bruno Haible [Sun, 10 May 2020 16:14:38 +0000 (18:14 +0200)]
string: Fix compilation error in C++ mode.
* lib/warn-on-use.h (_GL_WARN_ON_USE_CXX): In C mode, use plain
_GL_WARN_ON_USE.
* lib/string.in.h (strchr, strpbrk, strrchr): Use _GL_WARN_ON_USE_CXX
instead of _GL_WARN_ON_USE.
Paul Eggert [Sat, 9 May 2020 19:00:08 +0000 (12:00 -0700)]
attribute: remove ATTRIBUTE_DEPRECATED
* lib/attribute.h: Improve recently-added comments, mostly
by shortening them (use active voice, etc.).
(ATTRIBUTE_DEPRECATED): Remove, as it duplicates DEPRECATED.
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00089.html