Bruno Haible [Thu, 12 Dec 2019 01:43:07 +0000 (02:43 +0100)]
getaddrinfo: Fix calling convention in 32-bit mode on native Windows.
* m4/getaddrinfo.m4 (gl_GETADDRINFO): Test whether getaddrinfo has a
non-POSIX signature. If so, set REPLACE_GETADDRINFO. Define
HAVE_GETADDRINFO as a C macro.
* lib/netdb.in.h (getaddrinfo, freeaddrinfo): If REPLACE_GETADDRINFO,
declare as replacement functions.
* lib/getaddrinfo.c (getaddrinfo, freeaddrinfo): If HAVE_GETADDRINFO,
define as no-op overrides.
* m4/netdb_h.m4 (gl_NETDB_H_DEFAULTS): Initialize REPLACE_GETADDRINFO.
* modules/netdb (Makefile.am): Substitute REPLACE_GETADDRINFO.
* modules/getaddrinfo (Depends-on, configure.ac): Test
REPLACE_GETADDRINFO.
* doc/posix-functions/getaddrinfo.texi: Mention calling convention
problem.
* doc/posix-functions/freeaddrinfo.texi: Mention header file and calling
convention problems.
Paul Eggert [Wed, 11 Dec 2019 23:08:35 +0000 (15:08 -0800)]
dfa: prefer signed integers for internals
Signed integers can be checked more easily for integer overflow.
* lib/dfa.c (position, struct lexer_state, struct parser_state)
(struct dfa, mbs_to_wchar, fetch_wc, parse_bracket_exp)
(struct lexptr, lex, addtok_mb, add_utf8_anychar, atom)
(nsubtoks, copytoks, closure, alloc_position_set, delete)
(replace, state_index, epsclosure, charclass_context)
(state_separate_contexts, merge_nfa_state, dfaoptimize)
(dfaanalyze, build_state, dfaexec_main, dfa_supported)
(maybe_disable_superset_dfa, dfassbuild, dfafree, enlist)
(comsubs, inboth, allocmust):
Prefer a signed to an unsigned integer when calculating indexes,
unless the integer is part of the external API (a bigger deal,
and to be done later).
Norihiro Tanaka [Wed, 11 Dec 2019 20:53:09 +0000 (12:53 -0800)]
dfa: separate parse and compile phase
‘dfamust’ must be called after parsing and before tokens are
reordered, but both are executed in the compilation phase.
Token reordering was introduced in Gnulib commit
2018-10-22T15:01:08Z!noritnk@kcn.ne.jp
(5c7a0371823876cca7a1347fa09ca26bbbff0c98).
* lib/dfa.c (dfaparse): Change it to global function.
(dfacomp): If first argument is NULL, skip parse.
* lib/dfa.h: (dfaparse): Add a prototype.
Bruno Haible [Sat, 7 Dec 2019 14:13:57 +0000 (15:13 +0100)]
Fix compilation errors in C++ mode on Solaris 10.
* m4/stdbool.m4 (AM_STDBOOL_H): Require AC_CANONICAL_HOST. Set STDBOOL_H
to non-empty on Solaris with a non-GCC compiler.
* doc/posix-headers/stdbool.texi: Mention the Solaris issue.
Pino Toscano [Thu, 5 Dec 2019 15:18:35 +0000 (16:18 +0100)]
Move xstrtol_fatal to a new xstrtol-error module
The xstrtol module provides a xstrtol_fatal function which uses other
modules suitable mostly for command line handling (e.g. gettext,
getopt), and that are completely unused when using only xstrto*
functions. Furthermore, xstrtol_fatal is used only in the xstrtol-tests
(within gnulib itself).
As solution, move the xstrtol_fatal to a new xstrtol-error module,
making xstrtol-tests depend on it. Since the prototype of xstrtol_fatal
is automatically provided by xstrtol.h, it is very difficult to know
whether anyone is actually using it, so add a note about this in NEWS.
* lib/xstrtol.h: Stop including <getopt.h>.
(xstrtol_fatal): Move ...
* lib/xstrtol-error.h: ... here. New file.
* lib/xstrtol-error.c: Include xstrtol-error.h instead of xstrtol.h.
* tests/test-xstrtol.c: Likewise.
* modules/xstrtol (Files): Remove lib/xstrtol-error.c.
(Depends-on): Remove exitfail, error, getopt-gnu, and gettext-h.
(Makefile.am): Remove xstrtol-error.c from lib_SOURCES.
* modules/xstrtol-error: New file.
* modules/xstrtol-tests (Depends-on): Add xstrtol-error.
* MODULES.html.sh: Add xstrtol-error.
* NEWS: Document the change.
Paul Eggert [Fri, 6 Dec 2019 22:48:04 +0000 (14:48 -0800)]
nstrftime: better width support for %N, %z
* lib/nstrftime.c (width_add, width_add1, width_cpy):
New macros, which generalize ‘add’, ‘add1’, ‘cpy’ by adding
a new WIDTH parameter.
(add, add1, cpy): Use these macros.
(width_add): Do not treat digits == 0 as a special case,
do not pad if padding is ‘-’, and do not use a negative width.
(__strftime_internal): Redo formatting of nanoseconds and numeric
timezones to avoid buffer misuse in unusual cases, and so that
widths make more sense. Add support for widths greater than 9 to
the %N format; they are zero filled on the right.
* tests/test-nstrftime.c (posixtm_test): Add a %12N test.
Bruno Haible [Thu, 5 Dec 2019 21:25:04 +0000 (22:25 +0100)]
Fix compilation errors in C++ mode on Solaris 10 and Solaris 11.
* m4/isfinite.m4 (gl_ISFINITE): Require AC_CANONICAL_HOST. On Solaris,
set REPLACE_ISFINITE to 1.
* m4/isinf.m4 (gl_ISINF): Require AC_CANONICAL_HOST. On Solaris, set
REPLACE_ISINF to 1.
* m4/signbit.m4 (gl_SIGNBIT): On Solaris, set REPLACE_SIGNBIT to 1.
* lib/pthread.in.h (pthread_create, pthread_once, pthread_key_create):
Use _GL_CXXALIAS_SYS_CAST instead of _GL_CXXALIAS_SYS.
* lib/threads.in.h (call_once): Likewise.
* lib/iconv.in.h (iconv): Likewise.
Bruno Haible [Thu, 5 Dec 2019 08:11:45 +0000 (09:11 +0100)]
Add more C++ tests.
assert-h: Add C++ tests.
* tests/test-assert-h-c++.cc: New file.
* tests/test-assert-h-c++2.cc: New file.
* modules/assert-h-c++-tests: New file.
* modules/assert-h-tests: New file.
ctype: Add C++ tests.
* tests/test-ctype-c++.cc: New file.
* tests/test-ctype-c++2.cc: New file.
* modules/ctype-c++-tests: New file.
* modules/ctype-tests (Depends-on): Add ctype-c++-tests.
errno: Add C++ tests.
* tests/test-errno-c++.cc: New file.
* tests/test-errno-c++2.cc: New file.
* modules/errno-c++-tests: New file.
* modules/errno-tests (Depends-on): Add errno-c++-tests.
float: Add C++ tests.
* tests/test-float-c++.cc: New file.
* tests/test-float-c++2.cc: New file.
* modules/float-c++-tests: New file.
* modules/float-tests (Depends-on): Add float-c++-tests.
inttypes: Add more C++ tests.
* tests/test-inttypes-c++2.cc: New file.
* modules/inttypes-c++-tests (Files): Add it.
(Makefile.am): Compile it.
limits-h: Add C++ tests.
* tests/test-limits-h-c++.cc: New file.
* tests/test-limits-h-c++2.cc: New file.
* modules/limits-h-c++-tests: New file.
* modules/limits-h-tests (Depends-on): Add limits-h-c++-tests.
stdarg: Add C++ tests.
* tests/test-stdarg-c++.cc: New file.
* tests/test-stdarg-c++2.cc: New file.
* modules/stdarg-c++-tests: New file.
* modules/stdarg-tests: New file.
stdbool: Add C++ tests.
* tests/test-stdbool-c++.cc: New file.
* tests/test-stdbool-c++2.cc: New file.
* modules/stdbool-c++-tests: New file.
* modules/stdbool-tests (Depends-on): Add stdbool-c++-tests.
stddef: Add C++ tests.
* tests/test-stddef-c++.cc: New file.
* tests/test-stddef-c++2.cc: New file.
* modules/stddef-c++-tests: New file.
* modules/stddef-tests (Depends-on): Add stddef-c++-tests.
stdint: Add C++ tests.
* tests/test-stdint-c++.cc: New file.
* tests/test-stdint-c++2.cc: New file.
* modules/stdint-c++-tests: New file.
* modules/stdint-tests (Depends-on): Add stdint-c++-tests.
wchar: Add more C++ tests.
* tests/test-wchar-c++2.cc: New file.
* modules/wchar-c++-tests (Files): Add it.
(Makefile.am): Compile it.
wctype-h: Add more C++ tests.
* tests/test-wctype-h-c++2.cc: New file.
* modules/wctype-h-c++-tests (Files): Add it.
(Makefile.am): Compile it.
Bruno Haible [Thu, 5 Dec 2019 02:18:42 +0000 (03:18 +0100)]
Fix compilation errors in C++ mode with xlclang++ on AIX.
* lib/math.in.h (expm1l, fmal, remainderl, roundl): Don't redeclare in
C++ mode on AIX.
(isfinite, signbit): In C++ mode on AIX with clang, use the approach
without C preprocessor macro.
* lib/pthread.in.h (pthread_exit): Use _GL_CXXALIAS_SYS_CAST instead of
_GL_CXXALIAS_SYS.
* lib/threads.in.h (thrd_exit): Likewise.
Bruno Haible [Tue, 3 Dec 2019 01:04:23 +0000 (02:04 +0100)]
Fix link errors with --enable-threads=posix on AIX.
* modules/string-c++-tests (Makefile.am): Link the test-string-c++
program with $(LIBTHREAD).
* modules/wchar-c++-tests (Makefile.am): Link the test-wchar-c++
program with $(LIBTHREAD).
Tim Rühsen [Sat, 30 Nov 2019 12:04:28 +0000 (13:04 +0100)]
gnulib-tool.py: Fix libgnu_la_LDFLAGS section in generated Makefile.am.
Reported by Dagobert Michelsen <dam@opencsw.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00086.html>.
* pygnulib/GLModuleSystem.py (getLink): Don't join the parts. Return a
list of strings instead of one string.
* pygnulib/GLEmiter.py (lib_Makefile_am): Adapt accordingly.
* pygnulib/GLImport.py (execute): Likewise.
Bruno Haible [Wed, 27 Nov 2019 23:34:34 +0000 (00:34 +0100)]
openpty, forkpty: Fix build error on Solaris 11.4.
* m4/pty_h.m4 (gl_PTY_H): Test for termios.h. Look for the declarations
also in <termios.h>.
* m4/pty.m4 (gl_FUNC_FORKPTY, gl_FUNC_OPENPTY): Look for the declaration
of the function also in <termios.h>.
* doc/glibc-functions/openpty.texi: Mention the Solaris 11.4 problems.
* doc/glibc-functions/forkpty.texi: Likewise.
Bruno Haible [Wed, 27 Nov 2019 05:03:21 +0000 (06:03 +0100)]
New options --enable-threads=isoc and --enable-threads=isoc+posix.
* m4/threadlib.m4 (gl_THREADLIB_EARLY_BODY): Accept the options
--enable-threads=isoc and --enable-threads=isoc+posix.
(gl_THREADLIB_BODY): Test whether the ISO C threads API is available.
When both the ISO C and the POSIX threads API are available, choose
USE_ISOC_AND_POSIX_THREADS instead of USE_POSIX_THREADS if
--enable-threads=isoc+posix was specified. When only the ISO C threads
API is available and --enable-threads=iso was specified, choose
USE_ISOC_THREADS.
* lib/glthread/lock.h: Add new code for USE_ISOC_THREADS ||
USE_ISOC_AND_POSIX_THREADS.
* lib/glthread/lock.c: Likewise.
* lib/glthread/cond.h: Likewise.
* lib/glthread/cond.c: Likewise.
* lib/glthread/tls.h: Likewise.
* lib/glthread/tls.c: Likewise.
* lib/glthread/yield.h: Likewise.
* lib/glthread/thread.h: Add new code for USE_ISOC_THREADS. Treat
USE_ISOC_AND_POSIX_THREADS like USE_POSIX_THREADS.
* lib/glthread/thread.c: Likewise.
* lib/glthread/threadlib.c: Likewise.
* tests/test-lock.c: Save and restore the values of USE_ISOC_THREADS and
USE_ISOC_AND_POSIX_THREADS.
* tests/test-cond.c: Consider USE_ISOC_THREADS and
USE_ISOC_AND_POSIX_THREADS.
* tests/test-tls.c: Likewise.
* tests/test-thread_create.c (main): Likewise.
* tests/test-pthread-cond.c: Likewise.
* tests/test-pthread-mutex.c: Likewise.
* tests/test-pthread-once2.c: Likewise.
* tests/test-pthread-rwlock.c: Likewise.
* tests/test-pthread-tss.c: Likewise.
* tests/test-pthread_sigmask2.c: Treat USE_ISOC_AND_POSIX_THREADS like
USE_POSIX_THREADS.
Bruno Haible [Sun, 24 Nov 2019 19:31:50 +0000 (20:31 +0100)]
mbrtowc: Modernize autoconf test.
* m4/mbrtowc.m4 (gl_MBRTOWC_INCOMPLETE_STATE): Require
gt_LOCALE_FR_UTF8. If a traditional Japanese locale is not available,
try a UTF-8 locale.
* doc/posix-functions/mbrtowc.texi: Update info about AIX.
Bruno Haible [Sun, 24 Nov 2019 19:11:28 +0000 (20:11 +0100)]
sys_time: Fix errors in C++ mode on mingw.
* lib/sys_time.in.h (timeval): Restore the redirection
'#define timeval rpl_timeval', for when the symbol timeval is being used
outside the 'gnulib' namespace.
* lib/sys_select.in.h (select): In C++, write 'timeval', not
'struct timeval'.
Bruno Haible [Sun, 24 Nov 2019 19:10:56 +0000 (20:10 +0100)]
iswctype: Fix errors in C++ mode on mingw.
* lib/wctype.in.h (rpl_iswctype): Override if GNULIB_OVERRIDES_WINT_T
is 1.
* lib/iswctype.c (iswctype): Add another implementation, for the
GNULIB_defined_wint_t case.
* modules/iswctype (configure.ac): Compile iswctype.c also if
GNULIB_OVERRIDES_WINT_T is 1.
Bruno Haible [Thu, 21 Nov 2019 10:44:05 +0000 (11:44 +0100)]
pthread-spin: Fix errors in C++ mode.
* m4/pthread-spin.m4 (gl_PTHREAD_SPIN): Mark the pthread_spin_*
functions as nonexistent when <pthread.h> exists but does not define
the pthread_spinlock_t type.
Bruno Haible [Thu, 21 Nov 2019 10:44:01 +0000 (11:44 +0100)]
pthread-mutex: Fix errors in C++ mode.
* m4/pthread-mutex.m4 (gl_PTHREAD_MUTEX): Test whether
pthread_mutexattr_getrobust exists. If not, define
PTHREAD_MUTEXATTR_ROBUST_UNIMPLEMENTED.
* lib/pthread-mutex.c (pthread_mutexattr_getrobust,
pthread_mutexattr_setrobust): Define also if <pthread.h> exists but
PTHREAD_MUTEXATTR_ROBUST_UNIMPLEMENTED.
* modules/pthread-mutex (configure.ac): Compile pthread-mutex.c also
when <pthread.h> exists but pthread_mutexattr_getrobust needs a gnulib
definition.
Paul Eggert [Tue, 19 Nov 2019 01:57:53 +0000 (17:57 -0800)]
glob: get closer to glibc glob.c
Omit differences from glibc when the differences don’t matter.
* lib/glob.c [_LIBC]: Include shlib-compat.h.
(__glob) [!_LIBC]: New macro. All uses of glob changed to __glob.
(glob_lstat): New function.
(glob_in_dir): Use it.
(GLOB_ATTRIBUTE): Define to empty if not already defined.
Use changed.
Bruno Haible [Mon, 18 Nov 2019 21:41:09 +0000 (22:41 +0100)]
stdint: Define [u]intptr_t correctly on 64-bit native Windows.
* lib/stdint.in.h (gl_intptr_t, gl_uintptr_t, INTPTR_MIN, INTPTR_MAX,
UINTPTR_MAX): Consider _WIN64.
* tests/test-stdint.c: Verify that [u]intptr_t is large enough to hold
a pointer.
* build-aux/vcs_to_changelog.py: New file.
* build-aux/vcstocl/frontend_c.py: New file.
* build-aux/vcstocl/misc_util.py: New file.
* build-aux/vcstocl/vcs_git.py: New file.
Bruno Haible [Mon, 18 Nov 2019 12:57:46 +0000 (13:57 +0100)]
stdint: Avoid triggering a "conflicting types" error on mingw 5.22.
Reported by Keith Marshall <keith@users.osdn.me> in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-10/msg00044.html>
and <https://osdn.net/projects/mingw/ticket/39677>.
* lib/stdint.in.h (intptr_t, uintptr_t): Don't define if the types have
already been defined by mingw's <crtdefs.h>.
Bruno Haible [Mon, 18 Nov 2019 00:17:49 +0000 (01:17 +0100)]
locale, localename: Improve z/OS support.
Reported by Daniel Richard G. in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00001.html>.
* m4/locale_h.m4 (gl_LOCALE_T): New macro, partially extracted from
gl_LOCALE_H.
(gl_LOCALE_H): Require it.
* m4/localename.m4 (gl_LOCALENAME): Likewise. If locale_t is not
defined, don't even check for newlocale, duplocale, freelocale.
* m4/intl-thread-locale.m4 (gt_FUNC_USELOCALE): Make the test fail when
locale_t is not defined.
Bruno Haible [Sun, 17 Nov 2019 22:57:00 +0000 (23:57 +0100)]
havelib: Make libdirstems processing more flexible.
* m4/lib-prefix.m4 (AC_LIB_PREPARE_MULTILIB): Set 3 libdirstem
variables: Consider 'lib' always, also on Solaris. Look for lib32 in
addition to lib64. Don't invoke /usr/bin/gcc (reverting the second
patch from 2017-02-19).
* m4/lib-link.m4 (AC_LIB_LINKFLAGS_BODY): Consider up to 3 additional
libdirs, even when the first one exists as a directory.
Bruno Haible [Sun, 17 Nov 2019 22:56:55 +0000 (23:56 +0100)]
havelib: Match the bitness when searching for libraries.
* m4/lib-prefix.m4 (AC_LIB_PREPARE_MULTILIB): Define a function
acl_is_expected_elfclass.
* m4/lib-link.m4 (AC_LIB_LINKFLAGS_BODY): When testing whether a library
file exists, in ELF, also test whether it has the ELF class that
corresponds to the host's bitness.
Bruno Haible [Sun, 17 Nov 2019 22:56:43 +0000 (23:56 +0100)]
havelib: Fix a bug in dependency processing.
* m4/lib-link.m4 (AC_LIB_LINKFLAGS_BODY): During dependency processing
of .la files, don't overwrite the value of additional_libdir for the
next rounds.
Bruno Haible [Sun, 17 Nov 2019 03:02:22 +0000 (04:02 +0100)]
wctype-h: When overriding wint_t, override also the related functions.
Reported by Christian Biesinger <cbiesinger@google.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00027.html>.
* m4/wctype_h.m4 (gl_WCTYPE_H): When GNULIB_OVERRIDES_WINT_T is 1, set
REPLACE_ISWCNTRL to 1.
* lib/wctype.in.h (rpl_iswalnum, rpl_iswalpha, rpl_iswblank,
rpl_iswcntrl, rpl_iswdigit, rpl_iswgraph, rpl_iswlower, rpl_iswprint,
rpl_iswpunct, rpl_iswspace, rpl_iswupper, rpl_iswxdigit, rpl_towlower,
rpl_towupper): New definitions when GNULIB_OVERRIDES_WINT_T is 1.
* doc/posix-headers/wchar.texi: Mention that wint_t is also overridden
on mingw.
* doc/posix-headers/wctype.texi: Likewise.
Bruno Haible [Sat, 16 Nov 2019 12:13:58 +0000 (13:13 +0100)]
time_r: Fix for mingw.
Reported by Christian Biesinger <cbiesinger@google.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00014.html>.
* lib/time.in.h: On mingw, include <unistd.h>.
* m4/time_r.m4 (gl_TIME_R): On mingw, include <unistd.h> before
<time.h>. Test for localtime_r in a way that works when it is defined
as an inline function.
Paul Eggert [Sat, 9 Nov 2019 20:02:24 +0000 (12:02 -0800)]
config: add msys support
Requested by Arnold Robbins in:
https://lists.gnu.org/r/bug-gnulib/2019-11/msg00008.html
He also requested a change to config.guess, which I’ll forward
upstream.
* build-aux/ar-lib (func_file_conv):
* build-aux/compile (func_file_conv):
* build-aux/config.rpath (wl, with_gnu_ld)
(hardcode_libdir_flag_spec, libext, shrext, library_names_spec):
Treat msys like cygwin.
Bruno Haible [Sun, 27 Oct 2019 14:34:25 +0000 (15:34 +0100)]
host-cpu-c-abi: Recognize i386 and a couple of other CPUs as 32-bit.
* m4/host-cpu-c-abi.m4 (gl_HOST_CPU_C_ABI): Include i386 in the case
statement.
(gl_HOST_CPU_C_ABI_32BIT): Likewise. Also recognize a couple of other
32-bit CPUs.
Paul Eggert [Fri, 25 Oct 2019 00:30:44 +0000 (17:30 -0700)]
timespec-add, timespec-sub: simplify
* lib/timespec-add.c (timespec_add):
* lib/timespec-sub.c (timespec_sub):
Simplify, now that INT_ADD_WRAPV and INT_SUBTRACT_WRAPV
work on unsigned integers.
Paul Eggert [Wed, 23 Oct 2019 20:33:37 +0000 (13:33 -0700)]
nstrftime: speed up integer overflow checking
* lib/nstrftime.c: Include intprops.h.
(INT_STRLEN_BOUND): Remove, as we can use intprops.h’s defn.
(__strftime_internal): Use INT_MULTIPLY_WRAPV and INT_ADD_WRAPV
instead of doing it by hand.
* modules/nstrftime (Depends-on): Add intprops.
Paul Eggert [Wed, 23 Oct 2019 20:31:15 +0000 (13:31 -0700)]
Port better to GCC under macOS
Work around macOS header that has ‘#define __has_builtin(x) 0’
when compiled by GCC. Apple really, really doesn’t want you to
use GCC, apparently. Rroblem reported by Akim Demaille in:
https://lists.gnu.org/r/bug-bison/2019-10/msg00071.html
The fix is to not trust __has_builtin when being compiled by
recent-enough GCC.
* lib/intprops.h (__has_builtin)
(_GL_HAS___builtin_add_overflow, _GL_TEMPDEF___has_builtin):
* lib/verify.h (__has_builtin, _GL_HAS___builtin_unreachable)
(_GL_HAS___builtin_trap, _GL_TEMPDEF___has_builtin):
Remove. All uses removed.
* lib/intprops.h (_GL_HAS_BUILTIN_ADD_OVERFLOW): Use __has_builtin
directly, if defined and if not newer GCC.
* lib/verify.h (_GL_HAS_BUILTIN_TRAP, _GL_HAS_BUILTIN_UNREACHABLE):
New macro, that use __has_builtin directly, if defined and if
not newer GCC.
(assume): Use them.