Bruno Haible [Fri, 2 Feb 2018 18:32:02 +0000 (19:32 +0100)]
malloca, xmalloca: Make multithread-safe.
Reported by Florian Weimer <fweimer@redhat.com>.
Implements an idea by Ondřej Bílka <neleai@seznam.cz>.
* lib/malloca.h (malloca): In the stack allocation case, return a
pointer that is a multiple of 2 * sa_alignment_max.
(sa_increment): Remove enum item.
* lib/xmalloca.h (xmalloca): In the stack allocation case, return
a pointer that is a multiple of 2 * sa_alignment_max.
* lib/malloca.c (NO_SANITIZE_MEMORY): Remove macro.
(MAGIC_NUMBER, MAGIC_SIZE, preliminary_header, HEADER_SIZE, header,
HASH_TABLE_SIZE, mmalloca_results): Remove.
(small_t): New type.
(mmalloca, free): Rewritten.
* lib/malloca.valgrind: Remove file.
* modules/malloca (Files): Remove it.
(Depends-on): Remove verify.
Bruno Haible [Wed, 31 Jan 2018 08:04:52 +0000 (09:04 +0100)]
environ: Fix link error on 64-bit Cygwin.
* lib/unistd.in.h (environ): On Cygwin, redeclare with the
__declspec(dllimport) attribute.
* doc/posix-functions/environ.texi: Mention the Cygwin problem.
Bruno Haible [Sat, 27 Jan 2018 07:52:31 +0000 (08:52 +0100)]
getsockname tests: More tests.
* tests/test-getsockname.c (open_server_socket): New function, mostly
copied from test-poll.c.
(main): Check that getsockname fills in addr.
* modules/getsockname-tests (Depends-on): Add the necessary
dependencies.
(test_getsockname_LDADD): Link with $(INET_PTON_LIB).
Paul Eggert [Tue, 23 Jan 2018 08:42:04 +0000 (00:42 -0800)]
Merge strftime.c changes from glibc
This incorporates:
2017-11-14 [BZ #10871] Implement alternative month names
2017-11-14 [BZ #10871] Abbreviated alternative month names (%Ob)
2017-06-20 Use locale_t, not __locale_t, throughout glibc
* lib/nstrftime.c (ABALTMON_1) [!COMPILE_WIDE]: New macro.
(LOCALE_PARAM) [_LIBC && USE_IN_EXTENDED_LOCALE_MODEL]:
Use locale_t, not __locale_t.
(a_altmonth, f_altmonth, aam_len) [_NL_CURRENT]: New macros.
(__strftime_internal): Add support for alternate months.
Paul Eggert [Sun, 14 Jan 2018 21:27:20 +0000 (13:27 -0800)]
filenamecat: make base a suffix of result
* lib/filenamecat-lgpl.c (longest_relative_suffix): Remove.
(mfile_name_concat): Always make BASE a suffix of the result, as
cp expects this. To implement this, separate with '.' instead of
'/' in some rare cases. Clarify spec to say ./BASE not BASE.
* tests/test-filenamecat.c (main): Adjust tests to match
current behavior. Check that BASE_IN_RESULT points to
a copy of BASE and is a suffix of the resultk, and that DIR
is a prefix of the result that is no longer than the prefix
indicated by BASE_IN_RESULT.
To determine the file list that need the marker, I used the command:
for f in `find . -type f | grep -v '^\./\.git/' | grep -v '^\./tests/'`; do
if iconv -f ASCII -t ASCII < $f > /dev/null 2>&1 ; then : ; else
if iconv -f UTF-8 -t UTF-8 < $f > /dev/null 2>&1 ; then
if grep 'The GNU C Library is' $f > /dev/null; then :; else
if grep 'coding: utf-8' $f > /dev/null; then :; else
echo $f
fi
fi
fi
fi
done | LC_ALL=C sort
Paul Eggert [Wed, 3 Jan 2018 21:29:49 +0000 (13:29 -0800)]
test-framework-sh: ‘ps -ef’, not ‘ps ef’
* tests/init.sh (rand_bytes_): Put ‘-’ before new-style ps options.
Suggested by Bob Proulx (Bug#29968).
* build-aux/mktempd (rand_bytes): Make it like tests/init.sh.
Eric Blake [Tue, 2 Jan 2018 21:49:27 +0000 (15:49 -0600)]
stat-time: silence -Wunused-parameter regression
Commit 2c5d5587 causes warnings on non-Sun systems when compiled
under -Wunused-parameter; we've previously tweaked code in commit 81eb8486 to avoid such warnings. Prefer an attribute rather than
a cast to void (the attribute is always okay to apply; gcc
interprets it as 'may be unused', not 'must not be used', precisely
to cater to #if chains where determining whether or not the
parameter is used gets hairy).
* lib/stat-time.h (get_stat_birthtime_ns, get_stat_birthtime):
Prefer attribute over cast-to-void.
(stat_time_normalize): Mark st as potentially unused.
Paul Eggert [Wed, 3 Jan 2018 03:05:05 +0000 (19:05 -0800)]
test-framework-sh: avoid netstat
Problem reported by Kristýna Streitová (Bug#29947).
* tests/init.sh (rand_bytes_): Stop using netstat, as it's
deprecated on SuSE and it's not that important anyway.
Jim Meyering [Tue, 2 Jan 2018 00:12:39 +0000 (16:12 -0800)]
update-copyright: add code to handle more special cases
After running "make update-copyright" this year, five files
required additional manual changes. Automate those adjustments
for next year.
* Makefile (_year_and_prev): Define.
(update-copyright): Add perl commands to induce this year's post-
update-copyright adjustments.
Paul Eggert [Mon, 1 Jan 2018 00:57:25 +0000 (00:57 +0000)]
version-etc: new year
* build-aux/gendocs.sh (version):
* doc/gendocs_template:
* doc/gendocs_template_min:
* doc/gnulib.texi:
* lib/version-etc.c (COPYRIGHT_YEAR):
Update copyright dates by hand in templates and the like.
Paul Eggert [Tue, 19 Dec 2017 23:53:47 +0000 (15:53 -0800)]
regex: use re_malloc etc. consistently
Problem and original patch reported by Arnold Robbins in:
https://sourceware.org/ml/libc-alpha/2017-12/msg00241.html
* lib/regcomp.c (re_comp):
* lib/regexec.c (push_fail_stack, build_trtable, match_ctx_clean):
Use re_malloc/re_realloc/re_free instead of malloc/realloc/free.
Reuben Thomas [Mon, 11 Dec 2017 10:27:52 +0000 (10:27 +0000)]
doc: Improve explanation of supporting relocatable libraries.
* doc/relocatable-maint.texi (Supporting Relocation): Explain
properly how to build the relocatable module for
libraries. (Method and example code from Bruno Haible.)
Paul Eggert [Tue, 28 Nov 2017 22:30:25 +0000 (14:30 -0800)]
Port better to CentOS 5
Problems reported by Tom G. Christensen in:
https://lists.gnu.org/r/bug-gnulib/2017-11/msg00053.html
* doc/glibc-functions/strverscmp.texi (strverscmp):
Document strverscmp bug with glibc 2.9 and earlier.
* doc/posix-functions/tzset.texi (tzset):
Document that TZ with angle brackets is POSIX-2001 and later.
* tests/test-nstrftime.c: Include unistd.h.
(TZ_ANGLE_BRACKETS_SHOULD_WORK): New macro.
(TZ): Use it to skip tests with angle brackets in TZ,
for older systems.
Jim Meyering [Tue, 28 Nov 2017 15:52:47 +0000 (07:52 -0800)]
test-faccessat.c: correct BASE definition to avoid parallel test failure
* tests/test-faccessat.c (BASE): Define using this file's name, not
that of test-lstat.c. Using the latter caused this test to fail
sometimes when run concurrently with test-lstat.
Paul Eggert [Fri, 24 Nov 2017 08:29:04 +0000 (00:29 -0800)]
posixtm: remove PDS_LEADING_YEAR
This changes the API slightly, in a hopefully-innocuous way.
Without this change the code had undefined behavior when a
caller specified neither PDS_LEADING_YEAR nor PDS_TRAILING_YEAR.
Problem reported by Pádraig Brady in:
https://lists.gnu.org/r/bug-gnulib/2017-11/msg00048.html
* NEWS: Mention this.
* lib/posixtm.c (posix_time_parse): Treat the absence of
PDS_TRAILING_YEAR as if PDS_LEADING_YEAR were present.
* lib/posixtm.h (PDS_LEADING_YEAR): Remove (actually, leave it
present, but define it as zero, for compatibility with existing
source code). All other PDS_* values moved up.
* tests/test-posixtm.c (LY): New macro.
(T): Use it. Do not expect a particular numeric encoding
for PDS_CENTURY etc.
Paul Eggert [Sun, 12 Nov 2017 06:33:38 +0000 (22:33 -0800)]
faccessat: port to macOS (Bug#29231)
macOS faccessat has the same bug that lstat does: if the file
name ends in '/' it ignores the trailing slash.
Problem reported for Emacs by Vincent Zhang.
* doc/posix-functions/faccessat.texi (faccessat): Document this.
* lib/faccessat.c (_GL_INCLUDING_UNISTD_H): Define and undef
around the initial includes. Include errno.h, string.h, sys/stat.h.
(orig_faccessat) [HAVE_FACCESSAT]: New function.
Include "unistd.h" after defining it.
(rpl_faccessat) [HAVE_FACCESSAT]: New implementation.
* lib/unistd.in.h (faccessat) [REPLACE_FACCESSAT]:
Handle in the usual way.
* m4/faccessat.m4 (gl_FUNC_FACCESSAT): Replace faccessat if
lstat dereferences symlinks, since faccessat is likely to
have the same problem.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Default REPLACE_ACCESSAT.
* modules/faccessat (Depends-on): Add fstatat.
Depend if REPLACE_FACCESSAT is 1, too.
(configure.ac): Link if REPLACE_FACCESSAT is 1.
* modules/faccessat-tests (Depends-on): Add symlink.
* modules/unistd (unistd.h): Substitute REPLACE_FACCESSAT.
* tests/test-faccessat.c (main): Test for the bug.
Paul Eggert [Tue, 7 Nov 2017 07:20:23 +0000 (23:20 -0800)]
year2038: be more insistent about 64-bit time_t
Applications requiring access to arbitrary files should not be
built with 32-bit time_t on hosts that have 64-bit timestamps,
as this can lead to real trouble at runtime.
* m4/year2038.m4 (gl_YEAR2038): Do not require AC_CANONICAL_HOST.
Check on all systems, not just MinGW. Use a heuristic involving
TIME_T_32_BIT_OK, cross_compiling, and the touch command to
output a failure or just a warning, to make it more likely that
builders will select 64-bit time_t.
Paul Eggert [Mon, 6 Nov 2017 04:04:11 +0000 (20:04 -0800)]
Don’t use AC_EGREP_CPP if affected by CFLAGS
* m4/float_h.m4 (gl_FLOAT_H):
* m4/host-cpu-c-abi.m4 (gl_HOST_CPU_C_ABI):
* m4/lib-ld.m4 (AC_LIB_PROG_LD):
* m4/lib-prefix.m4 (AC_LIB_PREPARE_MULTILIB):
* m4/year2038.m4 (gl_YEAR2038):
Prefer AC_COMPILE_IFELSE to AC_EGREP_CPP when testing conditions
likely to be affected by the choice of CFLAGS, since CFLAGS are
not used by AC_EGREP_CPP. Without this patch, ‘./configure
CFLAGS="-m32"’ fails on gzip with GNU/Linux x86-64.
Paul Eggert [Sun, 29 Oct 2017 23:22:41 +0000 (16:22 -0700)]
timespec: prefer ‘assume’ to ‘assure’
This avoids some runtime tests. The rest of the module makes
similar assumptions and there is little point to testing here.
* lib/timespec.h: Include verify.h instead of assure.h.
(timespec_cmp): Use ‘assume’, not ‘assure’.
Also, remove an unnecessary cast to ‘int’, as lots of other
code in this module now causes -Wconversion to complain, and
this is a problem with -Wconversion not with the code.
* modules/timespec (Depends-on): Depend on ‘verify’, not ‘assure’.
Paul Eggert [Sun, 29 Oct 2017 22:46:10 +0000 (15:46 -0700)]
Port recent gnulib-tool change to Dash
* gnulib-tool (func_create_testdir): Don't assume that the shell
retokenizes after expanding "$@" inside the call to
func_execute_command. Dash 0.5.8-2.1ubuntu2 does not.
Jim Meyering [Sat, 28 Oct 2017 04:28:47 +0000 (21:28 -0700)]
timespec.h: use "assure" to avoid a spurious warning
* lib/timespec.h: Include "assure.h" and use it to help
gcc7's -Wstrict-overflow avoid a false positive warning
for a use in coreutils' ls.c. Suggested by Paul Eggert in
https://lists.gnu.org/r/bug-gnulib/2017-10/msg00007.html
* modules/timespec (Depends-on): Add assure.
Bruno Haible [Sun, 29 Oct 2017 16:33:22 +0000 (17:33 +0100)]
strerror_r-posix: Fix behaviour and test failure on Haiku.
* lib/strerror_r.c (strerror_r): Don't assume that valid error numbers
are positive. Work around return value 0 instead of ERANGE on Haiku.
For unknown error numbers, use a format string consistent with perror().
* doc/posix-functions/strerror_r.texi: Mention the Haiku problem.
* tests/test-strerror_r.c (main): Don't assume that valid error numbers
are positive.