1
0
mirror of https://https.git.savannah.gnu.org/git/gnulib.git synced 2026-09-01 02:34:55 +00:00
Commit Graph

10489 Commits

Author SHA1 Message Date
Paul Eggert 76eba39472 assert-h: port static_assert to strict C99
* lib/verify.h (_GL_VERIFY): Port MSVC hack back to C99.
Problem found when testing bleeding-edge gzip on IBM XL C for AIX,
V12.1 (5765-J02, 5725-C72), which complained ‘"malloca.c", line
42.56: 1506-041 (E) The invocation of macro _Static_assert
contains fewer arguments than are required by the macro
definition.’  This diagnostic is valid because C99 requires
that if you #define _Static_assert(R, ...) you must call
_Static_assert with at least two arguments.  I found a similar
problem with Sun C 5.9 SunOS_sparc Patch 124867-12 2009/11/22.
2023-01-01 10:27:38 +01:00
Bruno Haible 8a4e73687a Fix compilation errors in C++ mode on Solaris 11 OpenIndiana.
* m4/gnulib-common.m4 (gl_COMMON_BODY): In _GL_ATTRIBUTE_DEALLOC_FREE,
with GNU C++, cast the 'free' function.
* lib/string.in.h (_GL_ATTRIBUTE_DEALLOC_FREE): With GNU C++, cast the
'free' function.
* lib/wchar.in.h (_GL_ATTRIBUTE_DEALLOC_FREE): Likewise.
2023-01-01 10:23:10 +01:00
Paul Eggert f74ecfd735 explicit_bzero: work with gcc -std=c99
* lib/explicit_bzero.c (explicit_bzero) [__GNUC__ && !__clang__]:
Use __asm__ instead of asm.
2023-01-01 10:18:19 +01:00
Paul Eggert a41b6f260c fts: fix errno handling if dirfd fails
* lib/fts.c (fts_build): Use proper errno if dirfd failed.
Although I don’t know of any platform where dirfd can fail here,
we might as well get it right.
2023-01-01 10:10:04 +01:00
Bruno Haible 1239f24134 stdalign: Fix compilation error with MSVC in C++ mode.
* lib/stdalign.in.h: Treat MSVC in C++ mode like C++11 compliant
compilers.
2023-01-01 10:10:04 +01:00
Bruno Haible 64b2b36762 stdbool: Ensure that 'true' can be used in the preprocessor.
* lib/stdbool.in.h (true): Redefine if it does not evaluate to 1 in the
preprocessor.
2022-09-18 21:24:36 +02:00
Bruno Haible a945847ddc signal: Fix a C++ compilation error due to sched_yield on OpenBSD 6.0.
* lib/signal.in.h: On OpenBSD, include <sys/param.h>. Don't include
<pthread.h> on OpenBSD ≥ 5.1.
2022-09-18 21:23:14 +02:00
Bruno Haible 0aa9706f9e wchar: Fix compilation errors in C++ mode on Solaris 11.3.
* lib/wchar.in.h (wcsnlen, wcpcpy, wcpncpy, wcscasecmp, wcsncasecmp,
wcsdup): Force declaration in C++ mode on Solaris (which does not
declare these functions in the global namespace).
2022-09-18 21:22:41 +02:00
Bruno Haible 50bcc90faa swab: Fix compilation error with Sun C++ on Solaris 11.3.
* lib/unistd.in.h (swab): For the C++ declaration, under Solaris 11 but
not under Solaris 10, test also __XOPEN_OR_POSIX.
2022-09-18 21:22:29 +02:00
Bruno Haible 0152675d8e time: Fix compilation errors with clang/MSVC.
* m4/time_h.m4 (gl_TIME_H): Test whether asctime_r and ctime_r are
declared.
* lib/time.in.h (asctime_r, ctime_r): Skip _GL_WARN_ON_USE invocations
when these functions are not declared.
2022-09-18 21:21:43 +02:00
Bruno Haible df043f4541 verify: Avoid syntax error due to static_assert with clang in C++ mode.
* lib/verify.h (static_assert): Don't define in clang C++ 6 or newer.
2022-09-18 21:20:34 +02:00
Bruno Haible 1493d76c9f verify: Avoid syntax error due to static_assert with MSVC 14 in C++.
* lib/verify.h (static_assert): For MSVC in C++ mode, use a definition
that supports both the two-arguments and the one-argument syntax.
2022-09-18 21:17:11 +02:00
Bruno Haible 678ea42096 verify: Avoid syntax error due to static_assert with MSVC 14.
* lib/verify.h (_Static_assert): Pass only the first argument to
_GL_VERIFY.
2022-09-18 21:14:35 +02:00
Bruno Haible 8850ea37e4 verify: Avoid syntax error due to static_assert with GNU C++ 6.x.
* lib/verify.h (static_assert): Don't define in GNU C++ 6 or newer.
2022-09-18 21:12:52 +02:00
Bruno Haible 3f7d4c77e8 supersede: Avoid a failure when writing to /dev/null in Solaris zones.
* lib/supersede.c (open_supersede): Treat EACCES (seen on Solaris 11.3)
like EINVAL (seen on Illumos).
2022-09-12 10:53:06 +02:00
Bruno Haible dc631883e4 Revert two "Sync with GNU gettext" commits. 2022-09-11 15:22:21 +02:00
Bruno Haible 17394c80c6 pipe-filter-gi: Fix test failure on native Windows.
* lib/pipe-filter-aux.h (write): Redefine on native Windows.
2022-09-11 02:59:05 +02:00
Bruno Haible 1c36763093 uchar: Work around error in C++ mode on AIX 7.2 with xlclang.
* lib/uchar.in.h (char16_t, char32_t): On AIX with xlclang++, define
these as macros.
* doc/posix-headers/uchar.texi: Document the AIX + xlclang++ bug.
2022-09-11 02:58:27 +02:00
Bruno Haible 0c7fab6818 string: Fix compilation error in C++ mode on AIX 7.2 with xlclang.
* lib/string.in.h (mbslen): Enable the C++ alias warning only on glibc
systems.
2022-09-11 02:57:56 +02:00
Bruno Haible d7c2a92db8 math: Fix compilation error in C++ mode on AIX 7.2 with xlclang.
* lib/math.in.h (cbrtl, copysignl, exp2l, expm1l, fmal, ilogbl, log1pl,
log2l, logbl, remainderl, rintl, roundl, truncl): Enable the C++ alias
warning only on glibc systems.
2022-09-11 02:57:44 +02:00
Bruno Haible 40f62251c7 posix_spawn-internal: Don't lose flags while duplicating an fd.
* lib/spawni.c (do_dup2): Fix the flags of the new fd.
2022-09-10 03:03:35 +02:00
Bruno Haible 9ddf972ce1 spawn-pipe: Fix pipe-filter-* test hangs (regression 2020-12-24).
* lib/windows-spawn.h (struct inheritable_handles): Widen the per-fd
flags from 8 bits to 16 bits.
(KEEP_OPEN_IN_CHILD): New macro.
(init_inheritable_handles): Change description of what it does when
duplicate == true.
* lib/windows-spawn.c (init_inheritable_handles): If duplicate == true,
add all fds to the array, regardless whether they are scheduled to be
preserved in the child process.
(compose_handles_block): Update.
(spawnpvech): Update.
* lib/spawni.c (grow_inheritable_handles): Update.
(shrink_inheritable_handles): Also close the handles not marked with
KEEP_OPEN_IN_CHILD.
(do_open, do_dup2): Mark the new fd with KEEP_OPEN_IN_CHILD.
2022-09-10 03:03:20 +02:00
Bruno Haible 710b168cf4 spawn-pipe: Fix possible hangs in programs that spawn several children.
* lib/spawn-pipe.c (create_pipe) [Unix]: Create the ifd[] and ofd[] file
descriptors with the close-on-exec flag set.
2022-09-10 03:03:10 +02:00
Karl Berry 9bc59b5ebe autoupdate 2022-09-10 03:01:30 +02:00
Bruno Haible 1c06c41acd pthread-h: Fix compilation error on mingw with --enable-threads=windows.
* lib/pthread.in.h: In C++ mode, if mingw's <pthread.h> has not been
used, import many pthread_* symbols from the GNULIB_NAMESPACE into the
global namespace.
2022-09-10 03:01:22 +02:00
Bruno Haible 7040c17a73 count-leading-zeros: Fix a link error on 32-bit MSVC and a test failure.
* lib/count-leading-zeros.h: Correct syntax for #pragma intrinsic.
(COUNT_LEADING_ZEROS): Fix the return value.
(count_leading_zeros_ll): Use two _BitScanReverse invocations instead
of a _BitScanReverse64 invocation.
2022-09-05 04:00:31 +02:00
Bruno Haible f44f8a6ac6 count-trailing-zeros: Fix a link error on 32-bit MSVC.
* lib/count-trailing-zeros.h: Correct syntax for #pragma intrinsic.
(count_trailing_zeros_ll): Use two _BitScanForward invocations instead
of a _BitScanForward64 invocation.
2022-09-05 04:00:26 +02:00
Bruno Haible a36c175994 oset-c++: Fix compilation error with MSVC 14.
* lib/gl_oset.hh: With MSVC, avoid 'friend'.
2022-09-05 04:00:14 +02:00
Bruno Haible 5bbbee5fbb stdbool: Fix compilation error in C++ mode with MSVC 14.
* lib/stdbool.in.h (_Bool, bool, false, true): In C++ mode with MSVC 14,
don't define these as macros.
2022-09-05 03:59:46 +02:00
Bruno Haible d41252ce5c fts: Fix compilation error with MSVC 14.
* lib/fts.c (S_IFBLK): Add fallback definition.
2022-09-05 03:58:27 +02:00
Bruno Haible e841a924ab lstat: Fix compilation error in C++ mode on mingw.
* lib/sys_stat.h (lstat): Move declaration after the declaration of
'stat'.
2022-09-05 03:58:22 +02:00
Bruno Haible 6add7bbb6e pselect: Fix compilation error in C++ mode on mingw.
* lib/sys_select.in.h (pselect): Enable the C++ alias warning only on
glibc systems.
2022-09-05 03:58:15 +02:00
Bruno Haible 833bdf5f68 Fix a compilation error in C++ mode on Solaris 11.4.
* lib/uchar.in.h (c32rtomb): Enable the C++ alias warning only on
glibc ≥ 2.16 systems. Fix a GNULIB_POSIXCHECK mistake.
(mbrtoc32): Enable the C++ alias warning only on glibc ≥ 2.16 systems.
2022-09-05 03:54:38 +02:00
Bruno Haible 6000b1ff03 Fix a compilation error in C++ mode on FreeBSD 13.1.
* lib/signal.in.h: Don't include <pthread.h> on FreeBSD ≥ 8.0.
* lib/sys_select.in.h: Don't include <sys/time.h> on FreeBSD.
2022-09-04 02:09:15 +02:00
Bruno Haible 215fceb185 getrandom: Fix compilation error in C++ mode on FreeBSD 12.
* lib/sys_random.in.h (getrandom): Enable the C++ alias warning only on
glibc ≥ 2.25 systems.
2022-09-04 02:08:31 +02:00
Bruno Haible 39db1ef7ea math C++ tests: Fix compilation error with clang on FreeBSD 13.
* lib/math.in.h (isnan): For clang >= 11 on FreeBSD, declare 'isnan',
not 'rpl_isnan'.
2022-09-03 01:03:19 +02:00
Bruno Haible d2c8e80ae6 strerror_r-posix: Fix for Hurd.
* lib/strerror_r.c (strerror_r): Interpret return value of
__xpg_strerror_r correctly. Remove assumption about how strerror_r
behaves.
2022-09-03 01:03:15 +02:00
Bruno Haible 88f028169f strtol, strtoul: Fix compilation error in C++ mode on Solaris 11.
* lib/stdlib.in.h (strtol, strtoul): Enable the C++ alias warning only
on glibc systems.
2022-09-03 01:03:06 +02:00
Bruno Haible c4234d38bd aligned_alloc: Fix compilation error in C++ mode on Solaris 11.
* lib/stdlib.in.h (aligned_alloc): Enable the C++ alias warning only on
glibc systems.
2022-09-03 01:03:01 +02:00
Bruno Haible 4d526d2670 getdomainname: Fix compilation error in C++ mode on Solaris 11.
* lib/unistd.in.h (getdomainname): Enable the C++ alias warning only on
glibc systems.
2022-09-03 01:02:53 +02:00
Paul Eggert 11e3b02925 tempname: don't lose entropy in seed
* lib/tempname.c (random_bits): Don't lose entropy in S
in the rare case where where the template has more than 10 Xs.
From a suggestion by Bruno Haible in:
https://bugs.gnu.org/57129#149
2022-09-01 01:29:06 +02:00
Paul Eggert 52fd4af5a6 tempname: fix multithreading, ASLR leak etc.
Fix problems with tempname and multithreading, entropy loss,
and missing clock data (this last on non-GNU platforms).
See analysis by Bruno Haible in:
https://bugs.gnu.org/57129#149
While looking into this, I noticed that tempname can leak
info derived from ASLR into publicly-visible file names,
which is a no-no.  Fix that too.
* lib/tempname.c: Don't include stdalign.h.
(HAS_CLOCK_ENTROPY): Remove.
(mix_random_values): New function.
(random_bits): Use it.  Args are now new value address and
old value, and this function now returns a success indicator.
Omit old USE_GETRANDOM argument: always try getrandom now, as
there is no good reason not to now that GRND_NONBLOCK is used.
Caller changed.  Use CLOCK_REALTIME for for ersatz entropy,
as CLOCK_MONOTONIC doesn't work on some platforms.
Also, mix in ersatz entropy from tv_sec and from clock ().
(try_tempname_len): Do not mix in ASLR-based entropy, as
the result is published to the world and ASLR should be private.
Do not try to use a static var as that has issues if multithreaded.
Instead, simply generate new random bits.
Worry about bias only with high-quality random bits.
* modules/tempname (Depends-on): Do not depend on stdalign.
2022-09-01 01:28:58 +02:00
Paul Eggert e0a0558da7 tempname: merge 64-bit time_t fix from glibc
This merges glibc commit 52a5fe70a2c77935afe807fb6e904e512ddd894e
"Use 64 bit time_t stat internally".
* lib/tempname.c (struct_stat64) [_LIBC]: Use struct __stat64_t64.
(__lstat64_time64) [!_LIBC]: Rename from __lstat64.
All uses changed.
(direxists): Use __stat64_time64 instead of __stat64.
2022-09-01 01:28:47 +02:00
Paul Eggert 7d0a70d8ff tempname: generate better names for MinGW Emacs
On MinGW, GNU Emacs disables clock_gettime, which reliably breaks
some of gen_tempname’s optimistic callers.  Work around the
problem by making the generated names less predictable.  We don’t
need cryptographic randomness here, just enough unpredictability
to keep Emacs happy most of the time.
* lib/tempname.c (HAS_CLOCK_ENTROPY): New macro.
(random_bits): Use it.
(try_tempname_len): On systems lacking clock entropy, maintain
state so that gen_filename generates less-predictable names on
successive successful calls.
2022-09-01 01:28:16 +02:00
Bruno Haible 52ce8e3266 tempname: Fix a comment.
* lib/tempname.c (try_tempname_len): Use of entropy makes the function
more, not less, secure.
2022-09-01 01:26:50 +02:00
Paul Eggert bb52eb3dfb tempname: remove incorrect comment
* lib/tempname.c, lib/tempname.h: Remove incorrect comment,
as the names are not necessarily hard to predict (Bug#57129).
2022-09-01 01:26:35 +02:00
Marc Nieper-Wißkirchen ab089716f1 hamt: fix technically undefined behavior
Bug reported by Bruno Haible in
<https://lists.gnu.org/r/bug-gnulib/2022-04/msg00023.html>.
* lib/hamt.c (entry_insert): Remove technically undefined
behavior when shifting an integer of N bits by N or more bits.
2022-09-01 01:25:13 +02:00
Paul Eggert cd053975e1 verify: port ‘assume’ to C23 non-GCC
* lib/verify.h (assume): Use C23's unreachable if available
and if GCC and/or MSC primitives are not available.
2022-09-01 01:24:38 +02:00
Bruno Haible a959cb4e64 sigsegv: Optimize stackvma implementation for AIX 7.
Reported by Neha Jain <nehajain29@in.ibm.com> in
<https://lists.gnu.org/archive/html/bug-m4/2022-06/msg00005.html>
via Eric Blake.

* lib/stackvma.c: For AIX, add implementation that uses /proc/$pid/map,
based on lib/vma-iter.c.
(sigsegv_get_vma): Use it on AIX 7 or higher.
2022-09-01 01:18:44 +02:00
Bruno Haible 627a626ccd vma-iter: Add support for AIX 7.
* lib/vma-iter.h (VMA_ITERATE_SUPPORTED): Define also on AIX.
* lib/vma-iter.c (vma_iterate): Add code for AIX, known to work on
AIX 7.
* lib/get-rusage-as.c: Update comments.
* lib/get-rusage-data.c: Likewise.
* tests/test-get-rusage-as.c (main): Take into account the special
address space organization on AIX in 32-bit mode.
2022-09-01 01:18:29 +02:00