]> Savannah Git Hosting - gnulib.git/log
gnulib.git
4 years agofilenamecat-lgpl: Trim module dependencies.
Bruno Haible [Sun, 5 Jul 2020 19:10:11 +0000 (21:10 +0200)]
filenamecat-lgpl: Trim module dependencies.

* lib/filenamecat-lgpl.c: Include basename-lgpl.h, filename.h instead of
dirname.h.
* modules/filenamecat-lgpl (Depends-on): Remove dirname-lgpl. Add
basename-lgpl, filename.

4 years agobackupfile, backup-rename: Trim module dependencies.
Bruno Haible [Sun, 5 Jul 2020 19:07:46 +0000 (21:07 +0200)]
backupfile, backup-rename: Trim module dependencies.

* lib/backupfile.c: Include basename-lgpl.h instead of dirname.h.
* modules/backupfile (Depends-on): Remove dirname-lgpl. Add
basename-lgpl.
* modules/backup-rename (Depends-on): Likewise.

4 years agoargp: Trim module dependencies.
Bruno Haible [Sun, 5 Jul 2020 19:05:21 +0000 (21:05 +0200)]
argp: Trim module dependencies.

* lib/argp-namefrob.h: Include basename-lgpl.h instead of dirname.h.
* modules/argp (Depends-on): Remove dirname-lgpl. Add basename-lgpl.

4 years agobasename-lgpl: New module.
Bruno Haible [Sun, 5 Jul 2020 16:06:13 +0000 (18:06 +0200)]
basename-lgpl: New module.

* lib/basename-lgpl.h: New file, based on lib/dirname.h and
lib/basename-lgpl.c.
* lib/basename-lgpl.c: Include basename-lgpl.h, not dirname.h. Include
<stdbool.h>, filename.h.
(last_component): Rename a local variable.
* lib/dirname.h: Include basename-lgpl.h.
(DOUBLE_SLASH_IS_DISTINCT_ROOT): Remove macro.
(last_component, base_len): Remove declarations.
* modules/basename-lgpl: New file.
* modules/dirname-lgpl (Files): Remove lib/basename-lgpl.c.
(Depends-on): Add basename-lgpl. Remove double-slash-root.
(Makefile.am): Don't compile basename-lgpl.c.
* doc/posix-functions/basename.texi: Mention the module 'basename-lgpl',
not 'dirname'.

4 years agodirname, dirname-lgpl: Simplify.
Bruno Haible [Sun, 5 Jul 2020 16:05:31 +0000 (18:05 +0200)]
dirname, dirname-lgpl: Simplify.

* m4/dirname.m4: Remove file.
* modules/dirname (configure.ac): Don't invoke gl_DIRNAME.
* modules/dirname-lgpl (Files): Remove m4/dirname.m4.
(configure.ac): Don't invoke gl_DIRNAME_LGPL.

4 years agotests: avoid shadowing warning
Bernhard Voelker [Thu, 2 Jul 2020 21:11:52 +0000 (23:11 +0200)]
tests: avoid shadowing warning

* tests/test-memchr.c (main): Give page_boundary variable a tight scope.

4 years agosupersede: Add tests.
Bruno Haible [Sun, 5 Jul 2020 10:27:29 +0000 (12:27 +0200)]
supersede: Add tests.

* tests/test-supersede.c: New file.
* tests/test-supersede-open.h: New file.
* tests/test-supersede-fopen.h: New file.
* modules/supersede-tests: New file.

4 years agosupersede: New module.
Bruno Haible [Sun, 5 Jul 2020 10:27:24 +0000 (12:27 +0200)]
supersede: New module.

* lib/supersede.h: New file.
* lib/supersede.c: New file.
* m4/supersede.m4: New file.
* modules/supersede: New file.

4 years agoAdd some copyright headers.
Bruno Haible [Sun, 5 Jul 2020 09:07:03 +0000 (11:07 +0200)]
Add some copyright headers.

* lib/dev-ino.h: Add copyright header.
* lib/di-set.h: Likewise.
* lib/fchown-stub.c: Likewise.
* lib/file-set.h: Likewise.
* lib/hash-triple.h: Likewise.
* lib/idcache.h: Likewise.
* lib/ino-map.h: Likewise.
* lib/mkancesdirs.h: Likewise.
* lib/scratch_buffer.h: Likewise.
* lib/se-context.in.h: Likewise.
* lib/stdopen.h: Likewise.
* lib/userspec.h: Likewise.

4 years agogetrandom: Relicense under LGPLv2+.
Bruno Haible [Sat, 4 Jul 2020 16:24:45 +0000 (18:24 +0200)]
getrandom: Relicense under LGPLv2+.

Paul Eggert's approval is in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-07/msg00023.html>.

* modules/getrandom (License): Change to LGPLv2+.

4 years agogetumask: Add tests.
Bruno Haible [Sat, 4 Jul 2020 16:16:06 +0000 (18:16 +0200)]
getumask: Add tests.

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

4 years agogetumask: New module.
Bruno Haible [Sat, 4 Jul 2020 16:14:46 +0000 (18:14 +0200)]
getumask: New module.

* lib/sys_stat.in.h (getumask): New declaration.
* lib/getumask.c: New file.
* m4/getumask.m4: New file.
* m4/sys_stat_h.m4 (gl_HEADER_SYS_STAT_H): Test whether getumask is
declared.
(gl_SYS_STAT_H_DEFAULTS): Initialize GNULIB_GETUMASK, HAVE_GETUMASK.
* modules/sys_stat (Makefile.am): Substitute GNULIB_GETUMASK,
HAVE_GETUMASK.
* modules/getumask: New file.
* tests/test-sys_stat-c++.cc (getumask): Check signature.
* doc/glibc-functions/getumask.texi: New file.
* doc/gnulib.texi (Glibc sys/stat.h): Include it.

4 years agoclean-temp: Add support for temporary files with given mode.
Bruno Haible [Sat, 4 Jul 2020 16:06:52 +0000 (18:06 +0200)]
clean-temp: Add support for temporary files with given mode.

* lib/clean-temp.h (gen_register_open_temp): Add mode argument.
* lib/clean-temp.c (struct try_create_file_params): New type.
(try_create_file): New function.
(gen_register_open_temp): Add mode argument. Use try_tempname instead of
gen_tempname.

4 years agoclean-temp: Document limitations.
Bruno Haible [Sat, 4 Jul 2020 13:22:33 +0000 (15:22 +0200)]
clean-temp: Document limitations.

* lib/clean-temp.h: Document limitations.

4 years agoclean-temp: Add support for temporary files with unpredictable names.
Bruno Haible [Sat, 4 Jul 2020 13:18:20 +0000 (15:18 +0200)]
clean-temp: Add support for temporary files with unpredictable names.

* lib/clean-temp.h (gen_register_open_temp): New declaration.
* lib/clean-temp.c: Include tempname.h.
(gen_register_open_temp): New function.
* modules/tempname (configure.ac): Define a module indicator.

4 years agoclean-temp: Add support for temporary files anywhere in the file system.
Bruno Haible [Sat, 4 Jul 2020 13:17:32 +0000 (15:17 +0200)]
clean-temp: Add support for temporary files anywhere in the file system.

* lib/clean-temp.h (register_temporary_file, unregister_temporary_file,
cleanup_temporary_file): New declarations.
* lib/clean-temp.c (file_cleanup_list_lock, file_cleanup_list): New
variables.
(dir_cleanup_list_lock): Renamed from cleanup_list_lock.
(dir_cleanup_list): Renamed from cleanup_list.
(cleanup_action): Process the file_cleanup_list as well.
(do_init_clean_temp): New function.
(clean_temp_once): New variable.
(init_clean_temp): New function.
(create_temp_dir): Invoke it.
(register_temporary_file, unregister_temporary_file,
cleanup_temporary_file): New functions.
(do_unlink, do_rmdir): Remove 'dir' argument. Add 'cleanup_verbose'
argument.

4 years agoclean-temp: Improve comments.
Bruno Haible [Sat, 4 Jul 2020 12:52:27 +0000 (14:52 +0200)]
clean-temp: Improve comments.

* lib/clean-temp.h (open_temp, fopen_temp, close_temp, fclose_temp,
fwriteerror_temp, close_stream_temp): Clarify intended use.
* lib/clean-temp.c: Likewise.

4 years agoclean-temp: Fix last commit.
Bruno Haible [Sat, 4 Jul 2020 12:51:46 +0000 (14:51 +0200)]
clean-temp: Fix last commit.

4 years agoclean-temp: Make multithread-safe, part 2.
Bruno Haible [Sat, 4 Jul 2020 12:39:09 +0000 (14:39 +0200)]
clean-temp: Make multithread-safe, part 2.

* lib/fatal-signal.h: Include <signal.h>.
(get_fatal_signal_set): New declaration.
* lib/fatal-signal.c (get_fatal_signal_set): New function.
* lib/clean-temp.c: Include asyncsafe-spin.h, gl_linked_list.h.
(struct closeable_fd): New type.
(fatal_signal_set): New variable.
(init_fatal_signal_set): New function.
(asyncsafe_close, asyncsafe_fclose_variant): New functions.
(cleanup_action): Invoke asyncsafe_close instead of close.
(create_temp_dir): Invoke init_fatal_signal_set.
(register_fd): Use a plain linked list. Add a 'struct closeable_fd *'
element.
(unregister_fd): Remove function.
(close_temp): Cleanup descriptors list on the fly. Invoke
init_fatal_signal_set. Invoke asyncsafe_close instead of close.
(fclose_variant_temp): New function.
(fclose_temp, fwriteerror_temp, close_stream_temp): Use it.
* modules/clean-temp (Depends-on): Add asyncsafe-spin, linked-list.

4 years agoclean-temp: Make multithread-safe, part 1.
Bruno Haible [Sat, 4 Jul 2020 12:39:03 +0000 (14:39 +0200)]
clean-temp: Make multithread-safe, part 1.

* lib/clean-temp.c: Include glthread/lock.h.
(cleanup_list_lock): New variable.
(register_temp_file, unregister_temp_file, register_temp_subdir,
unregister_temp_subdir, cleanup_temp_dir_contents): Use it.
(create_temp_dir): Likewise. Don't free the old array.
(descriptors_lock): New variable.
(register_fd, unregister_fd): Use it.
* modules/clean-temp (Depends-on): Add lock.

4 years agofatal-signal: Make multithread-safe.
Bruno Haible [Sat, 4 Jul 2020 10:43:26 +0000 (12:43 +0200)]
fatal-signal: Make multithread-safe.

* lib/fatal-signal.c (init_fatal_signals): Add comment.
(do_init_fatal_signal_set): New function, extracted from
init_fatal_signal_set.
(fatal_signal_set_once): New variable.
(init_fatal_signal_set): Use gl_once.

4 years agogetrandom: Fix compilation error on native Windows (regression from 2020-06-28).
Bruno Haible [Sat, 4 Jul 2020 02:00:01 +0000 (04:00 +0200)]
getrandom: Fix compilation error on native Windows (regression from 2020-06-28).

* lib/getrandom.c: Don't include <ntdef.h>. Instead, define NTSTATUS.
* m4/getrandom.m4 (gl_FUNC_GETRANDOM): Include <windows.h> before
<bcrypt.h>.

4 years agodfa tests: Follow common file naming conventions.
Bruno Haible [Fri, 3 Jul 2020 16:49:18 +0000 (18:49 +0200)]
dfa tests: Follow common file naming conventions.

* tests/test-dfa-match-aux.c: Renamed from tests/dfa-match-aux.c.
* tests/test-dfa-match.sh: Renamed from tests/dfa-match.sh. Update.
* tests/test-dfa-invalid-char-class.sh: Renamed from
tests/dfa-invalid-char-class.sh. Update.
* modules/dfa-tests (Files, Makefile.am): Update.

4 years agoasyncsafe-spin: Use GCC extended asm syntax for SunStudio 12 compiler.
Bruno Haible [Fri, 3 Jul 2020 10:35:45 +0000 (12:35 +0200)]
asyncsafe-spin: Use GCC extended asm syntax for SunStudio 12 compiler.

* lib/asyncsafe-spin.c (memory_barrier, atomic_compare_and_swap): Use
the GCC extended asm syntax also for the Sun Studio 12 compilers.

4 years agoasyncsafe-spin: Reduce code duplication.
Bruno Haible [Fri, 3 Jul 2020 10:27:37 +0000 (12:27 +0200)]
asyncsafe-spin: Reduce code duplication.

* lib/asyncsafe-spin.c: (do_lock, do_unlock): New functions.
(asyncsafe_spin_lock, asyncsafe_spin_unlock): Use them.
* modules/asyncsafe-spin (configure.ac): Require AC_C_INLINE.

4 years agolchmod: Simplify after 2020-02-22 change.
Bruno Haible [Fri, 3 Jul 2020 10:18:34 +0000 (12:18 +0200)]
lchmod: Simplify after 2020-02-22 change.

* m4/lchmod.m4 (gl_FUNC_LCHMOD): Don't require AC_C_INLINE.

4 years agogen-uni-tables: Make sure the compiler does not barf on 'inline'.
Bruno Haible [Fri, 3 Jul 2020 10:12:02 +0000 (12:12 +0200)]
gen-uni-tables: Make sure the compiler does not barf on 'inline'.

* modules/gen-uni-tables (configure.ac): Require AC_C_INLINE.

4 years agodfa: Make sure the compiler does not barf on 'inline'.
Bruno Haible [Fri, 3 Jul 2020 10:09:13 +0000 (12:09 +0200)]
dfa: Make sure the compiler does not barf on 'inline'.

* modules/dfa (configure.ac): Require AC_C_INLINE.

4 years agobitset: Make sure the compiler does not barf on 'inline'.
Bruno Haible [Fri, 3 Jul 2020 10:06:17 +0000 (12:06 +0200)]
bitset: Make sure the compiler does not barf on 'inline'.

* modules/bitset (configure.ac): New section.

4 years agomanywarnings: improve port to GCC 10.1
Paul Eggert [Thu, 2 Jul 2020 00:00:51 +0000 (17:00 -0700)]
manywarnings: improve port to GCC 10.1

* build-aux/gcc-warning.spec: Also list warnings that are default
or are enabled by already-given flags.  This lets us speed up
checking for attributes, and makes the generated compilation
commands shorter.  Add -Wanalyzer-too-complex (too much noise).
* m4/manywarnings.m4 (gl_MANYWARN_COMPLEMENT)
(gl_MANYWARN_ALL_GCC): Use gl_AS_VAR_APPEND to append
to shell variables that may have long values.
(gl_MANYWARN_ALL_GCC): Omit flags that are default or are
consequences of other flags, to speed up checking and
shorten commands.

4 years agotests: pacify gcc -fanalyzer on zerosize_ptr
Paul Eggert [Wed, 1 Jul 2020 23:45:41 +0000 (16:45 -0700)]
tests: pacify gcc -fanalyzer on zerosize_ptr

* tests/test-memcasecmp.c (main):
* tests/test-memchr.c (main):
* tests/test-memchr2.c (main):
* tests/test-memcmp.c (main):
* tests/test-memmem.c (main):
* tests/test-memrchr.c (main):
* tests/unistr/test-chr.h (main):
* tests/unistr/test-cmp.h (test_cmp):
Check whether zerosize_ptr returns NULL before using it.
This pacifies GCC 10.1’s new fanalyzer option, and matches
other uses of zerosize_ptr.

4 years agoasyncsafe-spin: Add tests.
Bruno Haible [Wed, 1 Jul 2020 21:00:44 +0000 (23:00 +0200)]
asyncsafe-spin: Add tests.

* tests/test-asyncsafe-spin1.c: New file.
* tests/test-asyncsafe-spin2.c: New file, based on tests/test-lock.c and
tests/test-pthread-spin.c.
* modules/asyncsafe-spin-tests: New file.

4 years agoasyncsafe-spin: New module.
Bruno Haible [Wed, 1 Jul 2020 20:59:08 +0000 (22:59 +0200)]
asyncsafe-spin: New module.

* lib/asyncsafe-spin.h: New file.
* lib/asyncsafe-spin.c: New file, based on lib/pthread-spin.c.
* modules/asyncsafe-spin: New file.

4 years agowindows-spin: Fix race condition on multiprocessor systems.
Bruno Haible [Wed, 1 Jul 2020 20:55:50 +0000 (22:55 +0200)]
windows-spin: Fix race condition on multiprocessor systems.

* lib/windows-spin.c (glwthread_spin_init): Add a memory barrier.

4 years agopthread-spin: Add optimized fallback for GCC versions >= 4.1, < 4.7.
Bruno Haible [Wed, 1 Jul 2020 20:52:41 +0000 (22:52 +0200)]
pthread-spin: Add optimized fallback for GCC versions >= 4.1, < 4.7.

* lib/pthread-spin.c (pthread_spin_init, pthread_spin_lock,
pthread_spin_trylock, pthread_spin_unlock): For GCC >= 4.1, < 4.7, use
an implementation based on other GCC built-ins.

4 years agopthread-spin: Optimize fallback for GCC versions >= 4.7.
Bruno Haible [Wed, 1 Jul 2020 20:49:05 +0000 (22:49 +0200)]
pthread-spin: Optimize fallback for GCC versions >= 4.7.

* lib/pthread-spin.c (pthread_spin_init, pthread_spin_lock,
pthread_spin_trylock, pthread_spin_unlock): Use a lock word instead of a
lock byte.

4 years agopthread-spin: Add error checking.
Bruno Haible [Wed, 1 Jul 2020 20:13:27 +0000 (22:13 +0200)]
pthread-spin: Add error checking.

* lib/pthread-spin.c: Include <stdbool.h>.
(pthread_spin_init, pthread_spin_lock, pthread_spin_trylock,
pthread_spin_unlock) [GCC>=4.7]: Prefer an implementation that verifies
the unlocks.
* modules/pthread-spin (Depends-on): Add stdbool.

4 years agopthread-spin: Add tests.
Bruno Haible [Wed, 1 Jul 2020 20:06:45 +0000 (22:06 +0200)]
pthread-spin: Add tests.

* tests/test-pthread-spin.c: New file, based on tests/test-lock.c.
* modules/pthread-spin-tests: New file.

4 years agotests: Reduce code duplication.
Bruno Haible [Wed, 1 Jul 2020 20:06:27 +0000 (22:06 +0200)]
tests: Reduce code duplication.

* tests/atomic-int-posix.h: New file, extracted from
tests/test-pthread-mutex.c.
* tests/test-pthread-mutex.c: Include it. Remove the corresponding code.
* tests/test-pthread-rwlock.c: Likewise.
* modules/pthread-mutex-tests (Files): Add tests/atomic-int-posix.h.
* modules/pthread-rwlock-tests (Files): Likewise.

4 years agotests: Refactor.
Bruno Haible [Wed, 1 Jul 2020 20:06:13 +0000 (22:06 +0200)]
tests: Refactor.

* tests/atomic-int-isoc.h: New file, extracted from tests/test-mtx.c.
* tests/test-mtx.c: Include it. Remove the corresponding code.
* modules/mtx-tests (Files): Add tests/atomic-int-isoc.h.

4 years agotests: Refactor.
Bruno Haible [Wed, 1 Jul 2020 20:05:15 +0000 (22:05 +0200)]
tests: Refactor.

* tests/atomic-int-gnulib.h: New file, extracted from tests/test-lock.c.
* tests/test-lock.c: Include it. Remove the corresponding code.
* modules/lock-tests (Files): Add tests/atomic-int-gnulib.h.

4 years agosys_socket: Don't define socklen_t if it is already defined on mingw.
Bruno Haible [Tue, 30 Jun 2020 00:26:45 +0000 (02:26 +0200)]
sys_socket: Don't define socklen_t if it is already defined on mingw.

Reported by Keith Marshall <keith.d.marshall@ntlworld.com> in
<https://savannah.gnu.org/bugs/?57725>,
by Rahul Das <bokul_4u@yahoo.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-04/msg00081.html>,
and by Eli Zaretskii <eliz@gnu.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-06/msg00068.html>.

* lib/sys_socket.in.h (socklen_t): Remove definition.

4 years agoautoupdate
Paul Eggert [Tue, 30 Jun 2020 00:39:54 +0000 (17:39 -0700)]
autoupdate

4 years ago* top/maint.mk: Pacify Autoconf TAB-8-space rule.
Paul Eggert [Mon, 29 Jun 2020 23:37:14 +0000 (16:37 -0700)]
* top/maint.mk: Pacify Autoconf TAB-8-space rule.

4 years agoalloca-opt: Fix warning on mingw.
Bruno Haible [Mon, 29 Jun 2020 22:54:54 +0000 (00:54 +0200)]
alloca-opt: Fix warning on mingw.

Reported and solution by Eli Zaretskii <eliz@gnu.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-06/msg00069.html>.

* lib/alloca.in.h: On mingw, include <alloca.h> and then test again
whether alloca is defined.

4 years agogetrandom: do not depend on ‘open’ on mingw
Paul Eggert [Sun, 28 Jun 2020 20:18:11 +0000 (13:18 -0700)]
getrandom: do not depend on ‘open’ on mingw

Similarly for at-internal, getloadavg.  These modules do not call
the ‘open’ function when they are compiled on mingw.  On mingw,
this avoids having to compile open.c when building Emacs, which
does its own thing with ‘open’.
* modules/at-internal, modules/getloadavg, modules/getrandom:
(Depends-on): Don’t depend on ‘open’ on mingw.
(Depends-on): Require AC_CANONICAL_HOST, for host_os.
* modules/getloadavg (Depends-on):
Depend on intprops, open, stdbool, stdlib only if compiling
getloadavg.c.

4 years agodoc: Add a note about sigprocmask vs. pthread_sigmask.
Bruno Haible [Sun, 28 Jun 2020 20:10:32 +0000 (22:10 +0200)]
doc: Add a note about sigprocmask vs. pthread_sigmask.

* doc/posix-functions/sigprocmask.texi: Add note.

4 years agogetrandom: Fix compilation errors on older versions of mingw.
Bruno Haible [Sun, 28 Jun 2020 17:04:03 +0000 (19:04 +0200)]
getrandom: Fix compilation errors on older versions of mingw.

Reported by Eli Zaretskii <eliz@gnu.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-06/msg00059.html>.

* m4/getrandom.m4 (gl_FUNC_GETRANDOM): Test whether <bcrypt.h> exists.
* lib/getrandom.c: If <bcrypt.h> is not available, include <ntdef.h> and
define/declare BCRYPT_ALG_HANDLE, BCRYPT_USE_SYSTEM_PREFERRED_RNG,
BCryptGenRandom ourselves.

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

4 years agoclean-temp: Fix wrong errno in error message.
Bruno Haible [Sun, 28 Jun 2020 10:26:55 +0000 (12:26 +0200)]
clean-temp: Fix wrong errno in error message.

* lib/clean-temp.c (create_temp_dir): Save errno around
unblock_fatal_signals call.

4 years agofatal-signal: Make multithread-safe.
Bruno Haible [Sat, 27 Jun 2020 22:40:04 +0000 (00:40 +0200)]
fatal-signal: Make multithread-safe.

* lib/fatal-signal.c (at_fatal_signal): Don't free the old actions array.

4 years agoclean-temp: Don't force deletion of temporary files on native Windows.
Bruno Haible [Sat, 27 Jun 2020 22:03:44 +0000 (00:03 +0200)]
clean-temp: Don't force deletion of temporary files on native Windows.

* lib/clean-temp.h (open_temp, fopen_temp): Add delete_on_close
argument.
* lib/clean-temp.c (open_temp, fopen_temp): Likewise.
* NEWS: Mention the change.
* lib/javacomp.c (write_temp_file): Update.

4 years agofatal-signal: Make multithread-safe.
Bruno Haible [Sat, 27 Jun 2020 21:17:38 +0000 (23:17 +0200)]
fatal-signal: Make multithread-safe.

* lib/fatal-signal.c: Include glthread/lock.h.
(at_fatal_signal_lock): New variable.
(at_fatal_signal): Use it.
(fatal_signals_block_lock, fatal_signals_block_counter): New variables.
(block_fatal_signals, unblock_fatal_signals): Use them.
* modules/fatal-signal (Depends-on): Add lock.

4 years agogetloadavg: don’t depend on fopen-gnu
Paul Eggert [Sat, 27 Jun 2020 16:44:11 +0000 (09:44 -0700)]
getloadavg: don’t depend on fopen-gnu

This is for Emacs, which does not need fopen-gnu for anything else,
and which would need it only on a NetBSD platform where getloadavg
does not work (does that even happen?).
* lib/getloadavg.c (getloadavg) [__NetBSD__]: Use open, not fopen.
* modules/getloadavg (Depends-on): Remove fopen-gnu.

4 years ago* tests/test-getloadavg.c (main): Fix typo.
Paul Eggert [Sat, 27 Jun 2020 16:40:29 +0000 (09:40 -0700)]
* tests/test-getloadavg.c (main): Fix typo.

4 years agoautoupdate
Karl Berry [Sat, 27 Jun 2020 16:04:19 +0000 (09:04 -0700)]
autoupdate

4 years agotempname et al.: Fix link errors on MSVC (regression from 2020-05-31).
Bruno Haible [Sat, 27 Jun 2020 09:47:59 +0000 (11:47 +0200)]
tempname et al.: Fix link errors on MSVC (regression from 2020-05-31).

* modules/tempname (Link): New section.
* modules/mkdtemp (Link): Likewise.
* modules/clean-temp (Link): Likewise.
* modules/mkstemp (Link): Likewise.
* modules/stdlib-safer (Link): Likewise.
* modules/mkstemps (Link): Likewise.
* modules/mkostemp (Link): Likewise.
* modules/mkostemps (Link): Likewise.
* modules/tmpfile (Link): Likewise.
* modules/tmpfile-safer (Link): Likewise.
* modules/javacomp (Link): Add $(LIB_GETRANDOM).
* modules/argv-iter-tests (Makefile.am): Link test-argv-iter with
$(LIB_GETRANDOM).
* NEWS: Mention the changes.

4 years agofopen-gnu: Simplify code.
Bruno Haible [Sat, 27 Jun 2020 09:08:51 +0000 (11:08 +0200)]
fopen-gnu: Simplify code.

* lib/fopen.c: Include <stdbool.h>.
(rpl_fopen): Use a single variable open_flags instead of
open_flags_standard and open_flags_gnu. Make open_flags_gnu a bool.
* modules/fopen (Depends-on): Add stdbool.

4 years agotmpfile: Fix a typo.
Bruno Haible [Sat, 27 Jun 2020 01:14:43 +0000 (03:14 +0200)]
tmpfile: Fix a typo.

* lib/tmpfile.c: Fix a typo.

4 years agocanonicalize: Improve documentation.
Bruno Haible [Sat, 27 Jun 2020 00:11:08 +0000 (02:11 +0200)]
canonicalize: Improve documentation.

* lib/canonicalize.h (canonicalize_filename_mode): Document the failure
return convention.

4 years agoxgetcwd: Improve documentation.
Bruno Haible [Sat, 27 Jun 2020 01:00:01 +0000 (03:00 +0200)]
xgetcwd: Improve documentation.

* lib/xgetcwd.c (xgetcwd): Document the failure return convention.

4 years agogetcwd: Improve documentation.
Bruno Haible [Sat, 27 Jun 2020 00:59:07 +0000 (02:59 +0200)]
getcwd: Improve documentation.

* lib/getcwd.c (__getcwd): Document the failure return convention.

4 years agofchdir: Improve documentation.
Bruno Haible [Sat, 27 Jun 2020 00:44:38 +0000 (02:44 +0200)]
fchdir: Improve documentation.

* lib/fchdir.c (get_name, _gl_register_fd): Document the failure return
convention.

4 years agofilenamecat-lgpl: Set errno upon failure.
Bruno Haible [Sat, 27 Jun 2020 00:39:08 +0000 (02:39 +0200)]
filenamecat-lgpl: Set errno upon failure.

* lib/filenamecat-lgpl.c (mfile_name_concat): Document the failure
return convention.
* modules/filenamecat-lgpl (Depends-on): Add malloc-posix.

4 years agoareadlink-with-size: Set errno upon failure.
Bruno Haible [Sat, 27 Jun 2020 00:06:54 +0000 (02:06 +0200)]
areadlink-with-size: Set errno upon failure.

* lib/areadlink-with-size.c (areadlink_with_size): Set errno when malloc
fails.
* lib/areadlinkat-with-size.c (areadlinkat_with_size): Add comment.

4 years agocopy-file: Shrink dependencies.
Bruno Haible [Fri, 26 Jun 2020 14:04:15 +0000 (16:04 +0200)]
copy-file: Shrink dependencies.

* modules/copy-file (Depends-on): Remove acl. Add acl-permissions,
qcopy-acl.

4 years agodoc: Mention declaration fixes implemented by some modules.
Bruno Haible [Fri, 26 Jun 2020 11:38:22 +0000 (13:38 +0200)]
doc: Mention declaration fixes implemented by some modules.

* doc/posix-functions/chdir.texi: Mention the module 'chdir'.
* doc/posix-functions/close.texi: Mention that Gnulib makes the function
declaration appear in <unistd.h>.
* doc/posix-functions/dup.texi: Likewise.
* doc/posix-functions/dup2.texi: Likewise.
* doc/posix-functions/gethostname.texi: Likewise.
* doc/posix-functions/isatty.texi: Likewise.
* doc/posix-functions/lseek.texi: Likewise.
* doc/posix-functions/unlink.texi: Likewise.
* doc/posix-functions/read.texi: Mention the module 'read'.
* doc/posix-functions/write.texi: Mention the effects of the module
'write'.

4 years agoc-dtoastr, c-ldtoastr: new modules
Marc Nieper-Wißkirchen [Wed, 20 May 2020 11:59:31 +0000 (13:59 +0200)]
c-dtoastr, c-ldtoastr: new modules

These modules provide the same functionality as the modules
dtoastr and ldtoastr except for the formatting taking place in the
C locale.

* MODULES.html.sh: Add c-dtoastr and c-ldtoastr.
* lib/c-dtoastr.c, lib/c-ldtoastr.c: New files.
* lib/ftoastr.c: Prefix exported functions when the macro C_LOCALE is
defined.  Use c_snprintf and c_strtod/c_strtold instead of
snprintf and strtod/strtold whhen the macro C_LOCALE is defined.
* lib/ftoastr.h: Add prototypes for c_dtoastr and c_ldtoastr.
* modules/c-dtoastr, modules/c-dtoastr-tests, modules/c-ldtoastr,
modules/c-ldtoastr-tests: New files.
* tests/test-c-dtoastr.c, tests/test-c-dtoastr.sh,
tests-c-ldtoastr.c tests-c-ldtoastr.sh: New files.

4 years agotzset: Fix compilation warnings on mingw (regression from 2017-05-01).
Bruno Haible [Sun, 21 Jun 2020 20:54:46 +0000 (22:54 +0200)]
tzset: Fix compilation warnings on mingw (regression from 2017-05-01).

* lib/tzset.c: Include <stdlib.h>, <string.h>.

4 years agoautoupdate
Karl Berry [Sun, 21 Jun 2020 15:10:10 +0000 (08:10 -0700)]
autoupdate

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.