Bruno Haible [Thu, 6 Sep 2018 12:28:38 +0000 (14:28 +0200)]
limits-h: Provide numerical limits macros.
* lib/limits.in.h (LLONG_MIN, LLONG_MAX, ULLONG_MAX): Define also for
IRIX and for GCC.
(WORD_BIT, LONG_BIT): Define.
* m4/limits-h.m4 (gl_LIMITS_H): Set LIMITS_H to non-empty also when
<limits.h> does not define LLONG_MAX or WORD_BIT.
* tests/test-limits-h.c (TYPE_SIGNED, TYPE_WIDTH, TYPE_MINIMUM,
TYPE_MAXIMUM): New macros, from intprops.h.
Add tests for CHAR_BIT, WORD_BIT, LONG_BIT, <type>_MIN, and <type>_MAX.
* doc/posix-headers/limits.texi: Document what the 'limits-h' module
provides.
Reported by Frank Busse <f.busse@imperial.ac.uk> in
<https://lists.gnu.org/archive/html/bug-gnulib/2018-09/msg00018.html>.
* lib/fcntl.c (rpl_fcntl): For actions that don't take an argument,
don't consume an argument. For actions that take an 'int' argument,
consume an 'int' argument.
Bruno Haible [Mon, 3 Sep 2018 19:19:16 +0000 (21:19 +0200)]
gnulib-tool: Fix build order when $testsbase is a subdir of $sourcebase.
Reported by Antoine Luong <antoine.luong@c-s.fr> in
<https://lists.gnu.org/archive/html/bug-gnulib/2018-09/msg00008.html>.
* gnulib-tool (func_import): For the tests, set a dotfirst flag.
(func_emit_lib_Makefile_am): Consider the dotfirst flag.
(func_emit_tests_Makefile_am): Don't consider the dotfirst flag.
Paul Eggert [Sun, 2 Sep 2018 09:53:31 +0000 (02:53 -0700)]
mktime: fix unlikely race+overflow bug
Problem reported by Alexandre Oliva in:
https://sourceware.org/bugzilla/show_bug.cgi?id=16346
* lib/mktime.c (__mktime_internal): Access *OFFSET only once,
to avoid an unlikely race if the compiler delays a load and
if this cascades into a signed integer overflow.
Paul Eggert [Sat, 1 Sep 2018 01:02:48 +0000 (18:02 -0700)]
mktime, timegm: simplify glibc time64_t
* lib/mktime.c, lib/timegm.c (mktime_offset_t) [_LIBC]:
Now long int, not time_t, since long int is the longstanding type
for this in glibc and there is no need to change it even if time_t
becomes 64 bits - even int would do, though this would be a change
to the glibc generated code. When this change is merged into
glibc, it should simplify the time_t vs time64_t situation.
Paul Eggert [Sat, 1 Sep 2018 01:02:48 +0000 (18:02 -0700)]
mktime, timegm: simplify merge to glibc
Move code around to make a merge to glibc easier to audit.
This should not change behavior.
* lib/mktime.c: Include more standard files unconditionally.
(NEED_MKTIME_INTERNAL, NEED_MKTIME_WINDOWS)
(NEED_MKTIME_WORKING): Give default values to pacify -Wundef,
which glibc uses. Default NEED_MKTIME_WORKING to DEBUG_MKTIME, to
simplify later conditionals; default the others to zero. In uses
of these conditionals, explicitly spell out how _LIBC affects
things, so it’s easier to review from a glibc viewpoint.
(my_tzset, __tzset) [!_LIBC]: New function and macro, to better
compartmentalize tzset issues. Move system-dependent tzsettish
code here from mktime.
(mktime): Move tzsettish code to my_tzset, and move
localtime_offset to within mktime so that it doesn’t
need a separate ifdef.
* lib/mktime-internal.h (__gmtime_r, __localtime_r, __mktime_internal):
Move these macros here from lib/mktime.c and lib/gmtime.c.
Paul Eggert [Tue, 28 Aug 2018 01:31:44 +0000 (18:31 -0700)]
intprops: avoid evaluation of some expressions
This makes EXPR_SIGNED (e) easier to use, as it no longer
evaluates the expression E. Formerly, E was required to be free
of side effects.
* lib/intprops.h (_GL_INT_CONVERT, _GL_INT_NEGATE_CONVERT)
(EXPR_SIGNED, TYPE_WIDTH, _GL_INT_MINIMUM, _GL_INT_MAXIMUM)
(_GL_SIGNED_INT_MAXIMUM): Do not evaluate the expression arg.
Bruno Haible [Sun, 19 Aug 2018 12:14:17 +0000 (14:14 +0200)]
getpass: Move declaration to <unistd.h>.
* lib/unistd.in.h (getpass): New declaration.
* lib/getpass.h: Replace with a stub that just includes <unistd.h>.
* m4/getpass.m4 (gl_FUNC_GETPASS): Declare through AC_DEFUN_ONCE.
Require gl_UNISTD_H_DEFAULTS. Don't test whether getpass is declared.
(gl_FUNC_GETPASS_GNU): Require gl_UNISTD_H_DEFAULTS and gl_FUNC_GETPASS.
On glibc systems, don't set REPLACE_GETPASS to 1.
* modules/getpass (Depends-on): Add 'unistd'.
(configure.ac): Test also REPLACE_GETPASS. Define a module indicator.
(Include): Specify <unistd.h> instead of "getpass.h".
* modules/getpass-gnu (Depends-on): Merely depend on 'getpass'.
(configure.ac): Sync with the configure.ac section of modules/getpass.
(Include): Specify <unistd.h> instead of "getpass.h".
* m4/unistd_h.m4 (gl_UNISTD_H): Test whether getpass is declared.
(gl_UNISTD_H_DEFAULTS): Initialize GNULIB_GETPASS, HAVE_GETPASS,
REPLACE_GETPASS.
* modules/unistd (Makefile.am): Substitute GNULIB_GETPASS, HAVE_GETPASS,
REPLACE_GETPASS.
* tests/test-unistd-c++.cc: Test also the declaration of 'getpass'.
* doc/glibc-functions/getpass.texi: A length limit exists also on uClibc
and musl.
* NEWS: Mention the change.
Bruno Haible [Sat, 18 Aug 2018 21:26:06 +0000 (23:26 +0200)]
Avoid -Wcast-function-type warnings from casts after GetProcAddress.
Reported by Andy Moreton <andrewjmoreton@gmail.com> in
<https://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00468.html>.
Solution proposed by Eli Zaretskii.
Paul Eggert [Sat, 18 Aug 2018 07:54:35 +0000 (00:54 -0700)]
glob-h: always build glob.h
This works around a problem reported by Reuben Thomas in:
http://lists.gnu.org/r/bug-gnulib/2018-08/msg00079.html
This workaround always builds glob.h, even on platforms that
do not need it; perhaps this could be improved someday.
* m4/glob_h.m4 (gl_GLOB_H): Do not set or use GLOB_H, since glob.h
is always created now.
* modules/glob-h (BUILT_SOURCES, glob.h): Always build glob.h.
Bruno Haible [Tue, 14 Aug 2018 00:00:05 +0000 (02:00 +0200)]
fnmatch, fnmatch-gnu: Fix compilation error on Mac OS X.
Reported by Jeroen Meijer <jjgmeijer@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2018-08/msg00046.html>
and by Paul J. Lucas <paul@lucasmail.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2018-08/msg00069.html>.
* m4/fnmatch_h.m4 (gl_FNMATCH_H): Define through AC_DEFUN_ONCE.
(gl_FNMATCH_H_GNU): New macro.
* m4/fnmatch.m4 (gl_FUNC_FNMATCH_GNU): Require gl_FNMATCH_H_GNU.
Bruno Haible [Tue, 7 Aug 2018 08:54:41 +0000 (10:54 +0200)]
glob-h: Add tests.
* tests/test-glob-h.c: New file, partially based on tests/test-glob.c.
* tests/test-glob.c: Reorder #includes. Remove tests that are moved to
tests/test-glob-h.c.
* modules/glob-h-tests: New file.
* tests/test-glob-h-c++.cc: Renamed from tests/test-glob-c++.cc. Add
conditions.
* modules/glob-h-c++-tests: Renamed from modules/glob-c++-tests.
* modules/glob-tests (Depends-on): Remove glob-c++-tests.
Bruno Haible [Tue, 7 Aug 2018 08:43:06 +0000 (10:43 +0200)]
glob-h: New module.
* lib/glob.in.h: Use nearly the usual gnulib idioms for header file
replacements.
* lib/glob.c: Include <config.h>.
* m4/glob_h.m4: New file.
* m4/glob.m4 (gl_GLOB): Require gl_GLOB_H. Remove code that is moved to
glob_h.m4. Set HAVE_GLOB, REPLACE_GLOB, HAVE_GLOB_PATTERN_P,
REPLACE_GLOB_PATTERN_P as appropriate.
(gl_PREREQ_GLOB): Don't require AC_C_RESTRICT and
AC_USE_SYSTEM_EXTENSIONS, now done through module 'glob-h'.
* modules/glob-h: New file.
* modules/glob (Files): Remove lib/glob.in.h, lib/glob-libc.h.
(Dependencies): Add glob-h. Remove extensions, snippet/*, libc-config,
lstat, sys_stat. Change conditions.
(configure.ac): Test HAVE_GLOB, REPLACE_GLOB, HAVE_GLOB_PATTERN_P,
REPLACE_GLOB_PATTERN_P. Set module indicator.
(Makefile.am): Remove code that is moved to glob-h.
* doc/posix-headers/glob.texi: Mention the 'glob-h' module.
* modules/posixcheck (Depends-on): Add glob-h.
Bruno Haible [Tue, 7 Aug 2018 00:00:37 +0000 (02:00 +0200)]
Force generation of substitute .h file when C++ support is enabled.
* m4/ansi-c++.m4 (gl_ANSI_CXX): New macro.
* modules/ansi-c++-opt (configure.ac): Just require gl_ANSI_CXX.
* m4/fnmatch_h.m4 (gl_FNMATCH_H): If C++ support is enabled, set
FNMATCH_H to non-empty.
* m4/iconv_h.m4 (gl_ICONV_H_DEFAULTS): If C++ support is enabled, set
ICONV_H to non-empty.
* m4/monetary_h.m4 (gl_MONETARY_H_BODY): If C++ support is enabled, set
MONETARY_H to non-empty.
* m4/utime_h.m4 (gl_UTIME_H): If C++ support is enabled, set UTIME_H to
non-empty.
Bruno Haible [Mon, 6 Aug 2018 13:07:30 +0000 (15:07 +0200)]
fnmatch-h: Add tests.
* tests/test-fnmatch-h.c: New file.
* modules/fnmatch-h-tests: New file.
* tests/test-fnmatch-h-c++.cc: New file.
* modules/fnmatch-h-c++-tests: New file.
Bruno Haible [Mon, 6 Aug 2018 13:00:38 +0000 (15:00 +0200)]
fnmatch-h: New module.
* lib/fnmatch.in.h: Use the usual gnulib idioms for header file
replacements.
(FNM_*): Don't redefine if fnmatch exists and we are not overriding it.
(fnmatch): Use the usual gnulib idiom for function declarations. Enable
'posixcheck' warning.
* m4/fnmatch_h.m4: New file.
* m4/fnmatch.m4 (gl_FUNC_FNMATCH_POSIX): Require gl_FNMATCH_H. Remove
code that is moved to fnmatch_h.m4. When fnmatch does not exist, don't
bother testing whether it is working. Set HAVE_FNMATCH, REPLACE_FNMATCH
as appropriate.
* modules/fnmatch-h: New file.
* modules/fnmatch (Files): Remove lib/fnmatch.in.h.
(Dependencies): Add fnmatch-h. Remove extensions, snippet/*. Change
conditions.
(configure.ac): Test HAVE_FNMATCH and REPLACE_FNMATCH. Set module
indicator.
(Makefile.am): Remove code that is moved to fnmatch-h.
* modules/fnmatch-gnu (configure.ac): Test HAVE_FNMATCH and
REPLACE_FNMATCH.
* doc/posix-headers/fnmatch.texi: Mention the 'fnmatch-h' module.
* modules/posixcheck (Depends-on): Add fnmatch-h.
Bruno Haible [Sun, 5 Aug 2018 12:06:08 +0000 (14:06 +0200)]
Fix link error regarding 'rpl_environ' (regression from 2012-11-21).
* m4/extern-inline.m4: Add more comments.
* lib/warn-on-use.h (_GL_WARN_ON_USE_ATTRIBUTE): New macro.
* lib/unistd.in.h (rpl_environ): Use it instead of _GL_WARN_ON_USE.
* lib/math.in.h (_GL_WARN_REAL_FLOATING_DECL): Likewise.
Bruno Haible [Sat, 4 Aug 2018 15:25:57 +0000 (17:25 +0200)]
New module 'posixcheck'.
* modules/posixcheck: New file.
* m4/posixcheck.m4: New file.
* doc/gnulib-tool.texi (Finding POSIX substitutes): New section.
(Which modules?): Reference it.
Paul Eggert [Wed, 1 Aug 2018 23:08:26 +0000 (16:08 -0700)]
ieee754-h: new module
It looks like Emacs can use this for some NaN processing.
Emacs uses it only on double NaNs so it should be safe.
* MODULES.html.sh (func_all_modules): Add ieee754-h.
* config/srclist.txt: Mention ieee754.h in a comment.
* doc/glibc-headers/ieee754.texi (ieee754.h):
Gnulib now has a substitute that should work
except for long double and for non-IEEE platforms.
* lib/ieee754.in.h, m4/ieee754-h.m4, modules/ieee754-h:
* modules/ieee754-h-tests, tests/test-ieee754-h.c: New files.
Werner LEMBERG [Tue, 24 Jul 2018 00:46:14 +0000 (02:46 +0200)]
doc: Avoid some overfull lines in the TeX output.
* doc/glibc-functions/futimesat.texi: Replace a long @code with a
@example.
* doc/pastposix-functions/pthread_attr_getstackaddr.texi: Insert a
newline before the long URL.
* doc/pastposix-functions/pthread_attr_setstackaddr.texi: Likewise.
* doc/relocatable-maint.texi: Use @smallexample instead of @example.
Add line breaks in code snippets.
Paul Eggert [Thu, 5 Jul 2018 16:22:09 +0000 (09:22 -0700)]
renameatu: rename from renameat2
It's looking like Glibc will add a renameat2 function
that is incompatible with Gnulib renameat2; see:
https://sourceware.org/ml/libc-alpha/2018-07/msg00064.html
To help avoid future confusion, rename renameat2 to something else.
Use the name 'renameatu', as the Gnulib function is close to the
Glibc function. Perhaps someday there will also be a renameat2
Gnulib module, which mimicks the future glibc renameat2, but that
can wait as nobody seems to need such a module now.
* NEWS: Mention this.
* lib/renameatu.c: Rename from lib/renameat2.c.
* lib/renameatu.h: Rename from lib/renameat2.h.
* modules/renameat2: Rename from modules/renameatu.
* modules/renameat2-tests: Rename from modules/renameat2-tests.
All uses of "renameat2" in identifiers or file name
changed to "renameatu", except for two instances in
lib/renameatu.c that deal with the Linux kernel's
renameat2 syscall.
Paul Eggert [Thu, 5 Jul 2018 03:42:07 +0000 (20:42 -0700)]
gnulib-tool: minor tweaks for --gnu-make
* gnulib-tool: Do not allow --gnu-make in test modes,
since they all require automake.
(func_emit_lib_Makefile_am): Don’t emit automake comment
if --gnu-make.
Paul Eggert [Thu, 5 Jul 2018 03:18:48 +0000 (20:18 -0700)]
regex: work around conditional-dependencies glitch
* modules/regex (Depends-on): Add langinfo.
Without this change, I had problems building an experimental
version of GNU Emacs. The symptom of the bug was a message
‘./configure: line 12726: test: =: unary operator expected’.
This was due to a line in gl_FUNC_NL_LANGINFO that invokes
‘test $HAVE_LANGINFO_CODESET = 1’ even though HAVE_LANGINFO_CODESET
was unset. Although gl_FUNC_NL_LANGINFO has
‘AC_REQUIRE([gl_LANGINFO_H])’ and gl_LANGINFO_H always sets
HAVE_LANGINFO_CODESET to 0 or 1, gnulib-tool with
--conditional-dependencies sometimes arranges for the
gl_FUNC_NL_LANGINFO code to be executed before the gl_LANGINFO_H
code. Since the regex code includes <langinfo.h> it should be
depending on the langinfo module anyway, and this happens to work
around the bug, so install that as a workaround for now. To
reproduce the original problem, run the following shell script on
the version of Gnulib just before this patch was installed.
rm -fr foo
mkdir foo
cat >foo/configure.ac <<'EOF'
AC_INIT(GNU Emacs, 27.0.50, bug-gnu-emacs@gnu.org, , https://www.gnu.org/software/emacs/)
gl_EARLY
gl_INIT
AC_OUTPUT
EOF
./gnulib-tool --import --conditional-dependencies --gnu-make --dir foo regex
./gnulib-tool --copy build-aux/install-sh foo/install-sh
./gnulib-tool --copy build-aux/config.sub foo/config.sub
./gnulib-tool --copy build-aux/config.guess foo/config.guess
cd foo
aclocal -I m4
autoconf
./configure --with-included-regex
Paul Eggert [Mon, 2 Jul 2018 01:57:01 +0000 (18:57 -0700)]
wchar: fix bug when checking for ‘inline’
I discovered this when looking into using the regex module
with Emacs.
* m4/wchar_h.m4 (gl_WCHAR_H_INLINE_OK): Fix bug introduced in
2016-08-17T23:09:38Z!skunk@iSKUNK.ORG; the code compiled
conftest1.c and conftest2.c but these files were not created.
As far as I can see, this check never worked and nobody reported
it until now, which is a bit worrisome.
Jim Meyering [Sun, 1 Jul 2018 02:57:07 +0000 (19:57 -0700)]
bootstrap: s/--option val/--option=val/
* build-aux/bootstrap (gnulib_tool_options): Change the
spelling of "--option val" pairs to "--option=val", for
aesthetics, and also so that this file no longer triggers
a common help2man syntax-check warning when copied into
projects like grep, gzip, etc.
Paul Eggert [Sun, 1 Jul 2018 14:08:32 +0000 (07:08 -0700)]
manywarnings: omit -Wswitch-default
This should make things more consistent, as we already ignore
-Wswitch-enum. Problem reported by Reuben Thomas; see:
https://lists.gnu.org/r/bug-gnulib/2018-05/msg00179.html
* build-aux/g++-warning.spec, build-aux/gcc-warning.spec:
Add -Wswitch-default.
* m4/manywarnings-c++.m4 (gl_MANYWARN_ALL_GCC_CXX_IMPL):
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC):
Remove -Wswitch-default.
Paul Eggert [Sun, 1 Jul 2018 13:37:38 +0000 (06:37 -0700)]
regex: revert most trimming
Problems reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2018-07/msg00001.html
* modules/regex (Depends-on): Add lock, memcmp, memmove,
and wctype back in. lock because regex users shouldn’t
need to know that regex needs locking, and the rest because
gnulib-tool should ordinarily ignore them anyway.
Paul Eggert [Sun, 1 Jul 2018 01:47:11 +0000 (18:47 -0700)]
regex: trim module dependencies
* modules/regex (Depends-on): Remove gettext-h and lock,
since the regex code should work OK without these modules,
and Emacs uses it that way. Also remove memcmp, memmove,
and wctype, as these modules are obsolete and should not be
needed any more.
Paul Eggert [Fri, 29 Jun 2018 22:34:57 +0000 (15:34 -0700)]
regex: glibc does not use intprops.h
Maybe we can talk glibc into using intprops.h someday, but
now doesn’t seem to be a good time.
* lib/regcomp.c (TYPE_SIGNED): Remove; regex_internal.h now defines.
* lib/regex_internal.h [_LIBC]: Do not include intprops.h.
(TYPE_SIGNED, INT_ADD_WRAPV): New macros.
Paul Eggert [Thu, 28 Jun 2018 19:23:31 +0000 (12:23 -0700)]
regex: port to recently proposed glibc regex merge
This patch is inspired by Adhemerval Zanella's recent proposal
https://www.sourceware.org/ml/libc-alpha/2018-06/msg00905.html
to merge glibc and Gnulib regex. It aims to simplify the merge on
the glibc side, without keeping Gnulib portable.
* lib/regex.h: Fix a problem with glibc installed-header checking,
as follows:
(_Restrict_): Prefer __restrict if defined or if GCC 2.95 or later.
(_Restrict_arr_): Prefer __restrict_arr if defined,
otherwise prefer _Restrict_ if C99 or GCC 3.1 or later (but not C++).
* lib/regex_internal.c (re_string_realloc_buffers, build_wcs_buffer)
(build_wcs_upper_buffer, build_upper_buffer)
(re_string_translate_buffer, re_string_context_at):
Move decls here from lib/regex_internal.h, for glibc internal tests.
(build_wcs_upper_buffer): Use __wcrtomb, not wcrtomb, fixing
glibc BZ #18496.
* lib/regex_internal.h (lock_fini) [_LIBC]: Cast to 0 to pacify
-Wunused-value.
(bitset_set, bitset_clear, bitset_contain, bitset_empty)
(bitset_set_all, bitset_copy, bitset_not, bitset_merge)
(bitset_mask): Now static inline, and without any __attribute__
((unused)) decoration, for glibc internal tests.
Bruno Haible [Tue, 26 Jun 2018 00:18:40 +0000 (02:18 +0200)]
threadlib: Fix LIBMULTITHREAD on platforms where --as-needed is enabled.
Reported by Erik Auerswald <auerswal@unix-ag.uni-kl.de>
in <https://lists.gnu.org/archive/html/coreutils/2018-06/msg00063.html>.
* m4/threadlib.m4 (gl_THREADLIB_BODY): Check whether the linker supports
--as-needed/--no-as-needed and --push-state/--pop-state. When defining
USE_POSIX_THREADS_WEAK or USE_SOLARIS_THREADS_WEAK or
USE_PTH_THREADS_WEAK, define LIBMULTITHREAD in such a way that -lpthread
/ -lthread / -lpth does not get optimized away by a preceding
--as-needed option.