Paul Eggert [Wed, 19 Jun 2019 00:41:46 +0000 (17:41 -0700)]
verify-tests: work around xlc bug
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2019-06/msg00049.html
* tests/test-verify.c (item): Move the arithmetic inside the
verify_expr, to avoid tickling a bug in IBM AIX xlc V12.1.
Bruno Haible [Sat, 15 Jun 2019 11:03:58 +0000 (13:03 +0200)]
Fix scripts to have valid executable format on Alpine Linux.
Reported by Tim Rühsen <tim.ruehsen@gmx.de>.
Idea by Paul Eggert.
* build-aux/useless-if-before-free: Use a prologue that starts with
'#!/bin/sh'.
* build-aux/announce-gen: Likewise.
* build-aux/gitlog-to-changelog: Likewise.
* build-aux/prefix-gnulib-mk: Likewise.
* build-aux/update-copyright: Likewise.
* tests/test-update-copyright.sh: Update test program accordingly.
Bruno Haible [Mon, 10 Jun 2019 14:51:51 +0000 (16:51 +0200)]
posix_spawn_file_actions_addchdir: Fix possible use-after-free bug.
* lib/spawn_int.h (struct __spawn_action): Remove 'const' from path.
* lib/spawn_faction_addchdir.c (posix_spawn_file_actions_addchdir): Make
a copy of the path argument.
* lib/spawn_faction_destroy.c (posix_spawn_file_actions_destroy): Free
it.
Bruno Haible [Mon, 10 Jun 2019 14:50:04 +0000 (16:50 +0200)]
posix_spawn_file_actions_addopen: Fix possible use-after-free bug.
Reported at <https://sourceware.org/bugzilla/show_bug.cgi?id=17048>.
* lib/spawn_int.h (struct __spawn_action): Remove 'const' from path.
* lib/spawn_faction_addopen.c (posix_spawn_file_actions_addopen): Make
a copy of the path argument.
* lib/spawn_faction_destroy.c (posix_spawn_file_actions_destroy): Free
it.
Bruno Haible [Mon, 10 Jun 2019 14:17:35 +0000 (16:17 +0200)]
posix_spawn_file_actions_addfchdir: Add tests.
* tests/test-posix_spawn_file_actions_addfchdir.c: New file.
* tests/test-posix_spawn5.c: New file.
* modules/posix_spawn_file_actions_addfchdir-tests: New file.
Bruno Haible [Mon, 10 Jun 2019 12:15:41 +0000 (14:15 +0200)]
doc: Update and improve documentation of glibc functions.
This is a series of commits that
- updates the documentation to the state of glibc 2.29,
- adds references to Linux man pages and glibc documentation,
- marks Linux specific functions as such.
These are the commits:
doc: Update after removal of crypt functions from glibc 2.28.
doc: Remove mention of function vm86 (does not exist on x86_64).
doc: Remove mention of functions that are gone from glibc.
doc: Mention that glibc no longer provides h_errno.
doc: Mention the availability of specific functions in glibc versions.
doc: Mention eaccess.
doc: Add references to Linux man pages.
doc: Add references to glibc documentation.
doc: Mention inotify_* functions.
doc: Mention ppoll.
doc: Mention sched_getcpu.
doc: Mention sync_file_range.
doc: Mention epoll_pwait.
doc: Mention eventfd, eventfd_read, eventfd_write.
doc: Mention signalfd.
doc: Mention timerfd_create, timerfd_gettime, timerfd_settime.
doc: Mention epoll_create1.
doc: Mention getauxval.
doc: Mention pthread_getattr_default_np, pthread_setattr_default_np.
doc: Mention nextdown, nextup.
doc: Mention more ISO TS 18661-1 <math.h> functions.
doc: Mention ISO TS 18661-1 <fenv.h> functions.
doc: Mention getrandom, getentropy.
doc: Mention strfromf, strfromd, strfroml.
doc: Mention preadv2, pwritev2.
doc: Mention copy_file_range.
doc: Mention memfd_create.
doc: Mention mlock2.
doc: Mention pkey_alloc, pkey_set, pkey_get, pkey_free, pkey_mprotect.
doc: Mention more ISO TS 18661-1 <math.h> functions.
doc: Mention renameat2.
doc: Mention statx.
doc: Mention the ISO C11 multithreading header and functions.
doc: Mention getcpu.
doc: Mention posix_spawn_file_actions_add[f]chdir_np.
doc: Some glibc functions also exist on IRIX 6.5 in 32-bit mode.
doc: Some glibc functions also exist on FreeBSD, AIX, HP-UX, Solaris 11.
doc: Some glibc functions also exist on FreeBSD, Solaris 11.
doc: Some glibc functions also exist on Solaris 11.
doc: Some glibc functions also exist on Solaris 11.4.
doc: Some glibc functions also exist on FreeBSD.
doc: Some glibc functions also exist on BeOS.
doc: Some glibc functions also exist on Haiku.
doc: Mark functions which exist only on Linux.
doc: Mark functions which exist only on Linux and illumos.
* doc/glibc-functions/posix_spawn_file_actions_addchdir_np.texi: New file.
* doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi: New file.
* doc/gnulib.texi (Glibc spawn.h): New section.
Bruno Haible [Mon, 10 Jun 2019 12:08:42 +0000 (14:08 +0200)]
doc: Mention the ISO C11 multithreading header and functions.
* doc/posix-headers/threads.texi: New file.
* doc/posix-functions/call_once.texi: New file.
* doc/posix-functions/cnd_broadcast.texi: New file.
* doc/posix-functions/cnd_destroy.texi: New file.
* doc/posix-functions/cnd_init.texi: New file.
* doc/posix-functions/cnd_signal.texi: New file.
* doc/posix-functions/cnd_timedwait.texi: New file.
* doc/posix-functions/cnd_wait.texi: New file.
* doc/posix-functions/mtx_destroy.texi: New file.
* doc/posix-functions/mtx_init.texi: New file.
* doc/posix-functions/mtx_lock.texi: New file.
* doc/posix-functions/mtx_timedlock.texi: New file.
* doc/posix-functions/mtx_trylock.texi: New file.
* doc/posix-functions/mtx_unlock.texi: New file.
* doc/posix-functions/thrd_create.texi: New file.
* doc/posix-functions/thrd_current.texi: New file.
* doc/posix-functions/thrd_detach.texi: New file.
* doc/posix-functions/thrd_equal.texi: New file.
* doc/posix-functions/thrd_exit.texi: New file.
* doc/posix-functions/thrd_join.texi: New file.
* doc/posix-functions/thrd_sleep.texi: New file.
* doc/posix-functions/thrd_yield.texi: New file.
* doc/posix-functions/tss_create.texi: New file.
* doc/posix-functions/tss_delete.texi: New file.
* doc/posix-functions/tss_get.texi: New file.
* doc/posix-functions/tss_set.texi: New file.
* doc/gnulib.texi (Header File Substitutes): Include posix-headers/threads.texi.
(Function Substitutes): Include the new posix-functions/*.texi files.
Bruno Haible [Mon, 10 Jun 2019 12:08:39 +0000 (14:08 +0200)]
doc: Mention more ISO TS 18661-1 <math.h> functions.
* doc/posix-functions/fadd.texi: New file.
* doc/posix-functions/faddl.texi: New file.
* doc/posix-functions/daddl.texi: New file.
* doc/posix-functions/fsub.texi: New file.
* doc/posix-functions/fsubl.texi: New file.
* doc/posix-functions/dsubl.texi: New file.
* doc/posix-functions/fmul.texi: New file.
* doc/posix-functions/fmull.texi: New file.
* doc/posix-functions/dmull.texi: New file.
* doc/posix-functions/fdiv.texi: New file.
* doc/posix-functions/fdivl.texi: New file.
* doc/posix-functions/ddivl.texi: New file.
* doc/gnulib.texi (Function Substitutes): Include them.
* doc/glibc-functions/pkey_alloc.texi: New file.
* doc/glibc-functions/pkey_set.texi: New file.
* doc/glibc-functions/pkey_get.texi: New file.
* doc/glibc-functions/pkey_free.texi: New file.
* doc/glibc-functions/pkey_mprotect.texi: New file.
* doc/gnulib.texi (Glibc sys/mman.h): Include them.
Bruno Haible [Mon, 10 Jun 2019 12:08:32 +0000 (14:08 +0200)]
doc: Mention strfromf, strfromd, strfroml.
* doc/posix-functions/strfromf.texi: New file.
* doc/posix-functions/strfromd.texi: New file.
* doc/posix-functions/strfroml.texi: New file.
* doc/gnulib.texi (Function Substitutes): Include them.
Bruno Haible [Mon, 10 Jun 2019 12:08:30 +0000 (14:08 +0200)]
doc: Mention ISO TS 18661-1 <fenv.h> functions.
* posix-functions/fesetexcept.texi: New file.
* posix-functions/fetestexceptflag.texi: New file.
* posix-functions/fegetmode.texi: New file.
* posix-functions/fesetmode.texi: New file.
* doc/gnulib.texi (Function Substitutes): Include them.
Bruno Haible [Mon, 10 Jun 2019 12:08:29 +0000 (14:08 +0200)]
doc: Mention more ISO TS 18661-1 <math.h> functions.
* doc/posix-functions/roundeven.texi: New file.
* doc/posix-functions/roundevenf.texi: New file.
* doc/posix-functions/roundevenl.texi: New file.
* doc/posix-functions/fromfp.texi: New file.
* doc/posix-functions/fromfpf.texi: New file.
* doc/posix-functions/fromfpl.texi: New file.
* doc/posix-functions/ufromfp.texi: New file.
* doc/posix-functions/ufromfpf.texi: New file.
* doc/posix-functions/ufromfpl.texi: New file.
* doc/posix-functions/fromfpx.texi: New file.
* doc/posix-functions/fromfpxf.texi: New file.
* doc/posix-functions/fromfpxl.texi: New file.
* doc/posix-functions/ufromfpx.texi: New file.
* doc/posix-functions/ufromfpxf.texi: New file.
* doc/posix-functions/ufromfpxl.texi: New file.
* doc/posix-functions/llogb.texi: New file.
* doc/posix-functions/llogbf.texi: New file.
* doc/posix-functions/llogbl.texi: New file.
* doc/posix-functions/fmaxmag.texi: New file.
* doc/posix-functions/fmaxmagf.texi: New file.
* doc/posix-functions/fmaxmagl.texi: New file.
* doc/posix-functions/fminmag.texi: New file.
* doc/posix-functions/fminmagf.texi: New file.
* doc/posix-functions/fminmagl.texi: New file.
* doc/posix-functions/totalorder.texi: New file.
* doc/posix-functions/totalorderf.texi: New file.
* doc/posix-functions/totalorderl.texi: New file.
* doc/posix-functions/totalordermag.texi: New file.
* doc/posix-functions/totalordermagf.texi: New file.
* doc/posix-functions/totalordermagl.texi: New file.
* doc/posix-functions/canonicalize.texi: New file.
* doc/posix-functions/canonicalizef.texi: New file.
* doc/posix-functions/canonicalizel.texi: New file.
* doc/posix-functions/getpayload.texi: New file.
* doc/posix-functions/getpayloadf.texi: New file.
* doc/posix-functions/getpayloadl.texi: New file.
* doc/posix-functions/setpayload.texi: New file.
* doc/posix-functions/setpayloadf.texi: New file.
* doc/posix-functions/setpayloadl.texi: New file.
* doc/posix-functions/setpayloadsig.texi: New file.
* doc/posix-functions/setpayloadsigf.texi: New file.
* doc/posix-functions/setpayloadsigl.texi: New file.
* doc/gnulib.texi (Function Substitutes): Include them.
Bruno Haible [Mon, 10 Jun 2019 12:08:28 +0000 (14:08 +0200)]
doc: Mention nextdown, nextup.
* doc/posix-functions/nextdown.texi: New file.
* doc/posix-functions/nextdownf.texi: New file.
* doc/posix-functions/nextdownl.texi: New file.
* doc/posix-functions/nextup.texi: New file.
* doc/posix-functions/nextupf.texi: New file.
* doc/posix-functions/nextupl.texi: New file.
* doc/gnulib.texi (Function Substitutes): Include them.
* doc/glibc-functions/pthread_getattr_default_np.texi: New file.
* doc/glibc-functions/pthread_setattr_default_np.texi: New file.
* doc/gnulib.texi (Glibc pthread.h): Include them.
* doc/glibc-functions/timerfd_create.texi: New file.
* doc/glibc-functions/timerfd_gettime.texi: New file.
* doc/glibc-functions/timerfd_settime.texi: New file.
* doc/gnulib.texi (Glibc sys/timerfd.h): New section.
* doc/glibc-functions/eventfd.texi: New file.
* doc/glibc-functions/eventfd_read.texi: New file.
* doc/glibc-functions/eventfd_write.texi: New file.
* doc/gnulib.texi (Glibc sys/eventfd.h): New section.
Bruno Haible [Mon, 10 Jun 2019 12:08:13 +0000 (14:08 +0200)]
doc: Mention inotify_* functions.
* doc/glibc-functions/inotify_add_watch.texi: New file.
* doc/glibc-functions/inotify_init.texi: New file.
* doc/glibc-functions/inotify_init1.texi: New file.
* doc/glibc-functions/inotify_rm_watch.texi: New file.
* doc/gnulib.texi (Glibc sys/inotify.h): New section.
Bruno Haible [Mon, 10 Jun 2019 12:08:10 +0000 (14:08 +0200)]
doc: Add references to glibc documentation.
* doc/glibc-functions/add-links.sh: Renamed from
doc/glibc-functions/add-manpage-link.sh. Emit also a link to the Glibc manual.
* doc/glibc-functions/*.texi: Add references to the glibc manual.
Bruno Haible [Mon, 10 Jun 2019 12:08:09 +0000 (14:08 +0200)]
doc: Add references to Linux man pages.
* doc/glibc-functions/add-manpage-link.sh: New file.
* doc/glibc-functions/*.texi: Add reference to man page on kernel.org when it
exists.
* doc/posix-functions/aligned_alloc.texi: Likewise.
Paul Eggert [Thu, 6 Jun 2019 22:44:33 +0000 (15:44 -0700)]
copy-file-range: simplify into a stub
Based on a comment by Florian Weimer in:
https://lists.gnu.org/r/bug-gnulib/2019-06/msg00007.html
It turns out that Emacs (which will use this module) won’t need an
emulation and I suspect other programs won’t either, because these
programs will need to fall back on read+write anyway. Perhaps I
am wrong and other programs will be able to use an emulation; if
so, this patch can be reverted.
* lib/copy-file-range.c (COPY_FILE_RANGE): Replace with a stub.
Just call it copy_file_range.
* m4/copy-file-range.m4 (gl_FUNC_COPY_FILE_RANGE):
Check via AC_LINK_IFELSE.
* modules/copy-file-range (Depends-on): Remove modules no longer used.
Paul Eggert [Wed, 5 Jun 2019 02:58:23 +0000 (19:58 -0700)]
copy-file: prefer copy_file_range
* lib/copy-file.c: Do not include xalloc.h.
(qcopy_file_preserving): Allocate a buffer only if
copy_file_range does not suffice. If the allocation fails
don't give up; just use a small stack-based buffer.
Prefer copy_file_range if it works.
* modules/copy-file (Depends-on): Add copy-file-range.
Remove xalloc.
Bruno Haible [Wed, 29 May 2019 00:44:52 +0000 (02:44 +0200)]
binary-io: Attempted use of O_BINARY on consoles no longer fails.
Reported by KO Myung-Hun <komh78@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-05/msg00124.html>.
* lib/binary-io.h (__gl_setmode_check): Remove function.
(set_binary_mode): Declare as notinline on DJGPP and EMX.
* lib/binary-io.c (__gl_setmode_check): Remove function.
(set_binary_mode): Define here on DJGPP and EMX. Inline
__gl_setmode_check. In case of a tty, don't return an error code.
Bruno Haible [Mon, 20 May 2019 19:25:01 +0000 (21:25 +0200)]
setlocale: Improve fallback on macOS.
* lib/setlocale.c (search): Optimize away a redundant strcmp()
invocation.
(locales_with_principal_territory): New array.
(langcmp, get_main_locale_with_same_language): New functions.
(locales_with_principal_language): New array.
(terrcmp, get_main_locale_with_same_territory): New functions.
(rpl_setlocale): When setlocale_single failed, try again with a locale
that is more likely to exist. Don't warn if the environment variable
SETLOCALE_VERBOSE is not set.
Bruno Haible [Mon, 20 May 2019 00:56:53 +0000 (02:56 +0200)]
localename: Fix default on macOS.
* m4/intlmacosx.m4 (gt_INTL_MACOSX): Don't test for CFLocaleCopyCurrent.
* lib/localename.c: Remove includes for HAVE_CFLOCALECOPYCURRENT.
(gl_locale_name_environ, gl_locale_name_default): Remove code for
HAVE_CFLOCALECOPYCURRENT.
* lib/localename.h (gl_locale_name_default): Update.
Bruno Haible [Sat, 18 May 2019 12:36:33 +0000 (14:36 +0200)]
pthread_sigmask: Fix compilation error with --enable-threads=windows.
Reported by Tim Rühsen in
<https://lists.gnu.org/archive/html/bug-gnulib/2018-01/msg00018.html>
and Michele Locati in
<https://lists.gnu.org/archive/html/bug-gettext/2019-04/msg00057.html>.
* m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK): Revert change from
2015-06-01. Test whether pthread_sigmask is a macro, regardless of
$LIBMULTITHREAD. Consider it regardless whether module 'threadlib' is
in use and regardless which threads API is chosen.
Paul Eggert [Tue, 14 May 2019 15:20:29 +0000 (08:20 -0700)]
close-stream, closein, closeout: simplify
I noticed this opportunity for simplification while drafting a
new, related module that I haven’t had time to finish yet.
* m4/close-stream.m4, m4/closein.m4, m4/closeout.m4: Remove.
* modules/close-stream (Files): Remove m4/close-stream.m4.
(configure.ac): Omit gl_CLOSE_STREAM.
* modules/closein (Files): Remove m4/closein.m4
(configure.ac): Omit gl_CLOSEIN.
* modules/closeout (Files): Remove m4/closeout.m4.
(configure.ac): Omit gl_CLOSEOUT.
Bruno Haible [Fri, 10 May 2019 14:08:38 +0000 (16:08 +0200)]
base64: Avoid false positive warning from Coverity.
Reported by Kamil Dudka <kdudka@redhat.com>.
Idea by Paul Eggert.
* lib/base64.c (base64_encode_fast, base64_encode): Add a no-op
'& 0x3f' to the array index expressions. This convinces Coverity that
there is no out-of-bounds array reference, regardless of the input.
Paul Eggert [Thu, 9 May 2019 15:57:56 +0000 (08:57 -0700)]
Support C2X and C++17 static_assert
C2X and C++17 finally added support for a simple, single-argument
‘static_assert’ that implements what the Gnulib ‘verify’ macro was
doing back in 2005. Implement static_assert on older platforms.
The only remaining advantage of ‘verify’ is a shorter name.
* doc/posix-headers/assert.texi (assert.h):
* doc/verify.texi (Compile-time Assertions):
Modernize for C2X and C++17.
* lib/verify.h (_GL_HAVE__STATIC_ASSERT1, _GL_HAVE_STATIC_ASSERT1):
New macros.
(_GL_HAVE__STATIC_ASSERT): Remove.
(_GL_HAVE__STATIC_ASSERT): Rely more heavily on __STDC_VERSION__.
(_GL_VERIFY_TRUE, _GL_VERIFY_TYPE): Remove 2nd arg, the diagnostic
string. All callers changed.
(_GL_VERIFY): Require 3 or more args, of which only the first 2
are used. All callers changed.
(_Static_assert): Allow either 1 or 2 args, and define if
!_GL_HAVE__STATIC_ASSERT1 instead of defining if
!_GL_HAVE__STATIC_ASSERT.
(static_assert): Define if !_GL_HAVE_STATIC_ASSERT1 instead
of defining if !_GL_HAVE_STATIC_ASSERT.
(verify_expr, verify): Don’t bother trying to copy the expression
into the diagnostic, since 1-argument static_assert doesn’t.
(verify): Prefer 1-argument _Static_assert if it works.
* m4/assert_h.m4 (gl_ASSERT_H): Check for 1-argument static_assert.
Bruno Haible [Sun, 5 May 2019 11:18:23 +0000 (13:18 +0200)]
wcwidth: Ensure width 1, not 2, for ambiguous characters.
Reported by Kiyoshi KANAZAWA <yoi_no_myoujou@yahoo.co.jp>
via Akim Demaille <akim.demaille@gmail.com>.
* m4/wcwidth.m4 (gl_FUNC_WCWIDTH): Check the width of U+2202. Use an
en_US.UTF-8 locale, since that is more likely to be present than an
fr_FR.UTF-8 locale.
* tests/test-wcwidth.c (main): Check the width of U+2202.
* doc/posix-functions/wcwidth.texi: Mention the issue.
Bruno Haible [Sun, 28 Apr 2019 09:21:41 +0000 (11:21 +0200)]
tls tests: Prevent that the test takes too long.
* tests/test-tls.c: Include <signal.h>, <unistd.h>.
(main): Let the test fail if it takes more than 10 minutes.
* modules/tls-tests (configure.ac): Test whether 'alarm' is declared.
Bruno Haible [Sat, 27 Apr 2019 22:19:33 +0000 (00:19 +0200)]
lock tests: Prevent that the test takes too long.
* tests/test-lock.c: Include <signal.h>, <unistd.h>.
(main): Let the test fail if it takes more than 10 minutes.
* modules/lock-tests (configure.ac): Test whether 'alarm' is declared.