Bruno Haible [Tue, 21 Jul 2020 08:03:42 +0000 (10:03 +0200)]
aligned-malloc: New module.
* lib/aligned-malloc.h: New file.
* m4/malloc-align.m4: New file.
* modules/aligned-malloc: New file.
* doc/posix-functions/posix_memalign.texi: Mention the new module.
* doc/glibc-functions/memalign.texi: Likewise.
Paul Eggert [Wed, 15 Jul 2020 17:57:05 +0000 (10:57 -0700)]
md5, sha1, sha256, sha512: pacify Autoconf 2.70
* m4/gl-openssl.m4 (gl_CRYPTO_CHECK): Use m4_if rather than a
shell if, so that the argument to AC_CHECK_HEADERS is
a simple string that does not require shell evaluation.
This fixes a warning generated by Autoconf 2.69b.
Bruno Haible [Thu, 9 Jul 2020 15:28:48 +0000 (17:28 +0200)]
unicodeio: Fix wrong result on Solaris 11.
Reported by Kiyoshi Kanazawa <yoi_no_myoujou@yahoo.co.jp>
via Akim Demaille <akim.demaille@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-07/msg00036.html>.
* lib/unicodeio.c (unicode_to_mb): Handle question mark fallback
characters on Solaris.
* tests/test-unicodeio.c (main): In the "C" locale, expect either the
UTF-8 output or the specified fallback.
Bruno Haible [Wed, 8 Jul 2020 18:01:36 +0000 (20:01 +0200)]
unicodeio: Add tests.
* tests/test-unicodeio.c: New file.
* tests/test-unicodeio1.sh: New file.
* tests/test-unicodeio2.sh: New file.
* tests/test-unicodeio3.sh: New file.
* modules/unicodeio-tests: New file.
Paul Eggert [Tue, 7 Jul 2020 01:54:11 +0000 (18:54 -0700)]
libgmp: new module
The idea is to let programs simply include <gmp.h>, and
so long as they live within the mini-gmp subset they need
not worry about whether the GMP libraries are installed.
* MODULES.html.sh: Mention it.
* config/srclist.txt: Mention files copied from GMP source.
* config/srclistvars.sh (GMP): New var.
* lib/mini-gmp-gnulib.c, m4/libgmp.m4, modules/libgmp:
* modules/libgmp-tests, tests/test-libgmp.c: New files.
* lib/mini-gmp.c, lib/mini-gmp.h: New files, copied from GMP.
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'.
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.
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.
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.
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.
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.
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.
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.
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.
* 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.
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.
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.
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>.
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.
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.
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.
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.
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.
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.