about summary refs log tree commit diff
path: root/misc/sys
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2020-10-30 22:25:42 +0000
committerJoseph Myers <joseph@codesourcery.com>2020-10-30 22:25:42 +0000
commit548f467fa14ffe7d955beeb31b30e2aeae4467e0 (patch)
tree110b58e4d121c3650cb103a883f02091d06c5e84 /misc/sys
parent882774658cb8daee4c16677a3fd674f6052cc157 (diff)
downloadglibc-548f467fa14ffe7d955beeb31b30e2aeae4467e0.tar.gz
glibc-548f467fa14ffe7d955beeb31b30e2aeae4467e0.tar.xz
glibc-548f467fa14ffe7d955beeb31b30e2aeae4467e0.zip
Avoid -Wstringop-overflow warning in pthread_cleanup_push macros
GCC 11 introduces a -Wstringop-overflow warning for calls to functions
with an array argument passed as a pointer to memory not large enough
for that array.  This includes the __sigsetjmp calls from
pthread_cleanup_push macros, because those use a structure in
__pthread_unwind_buf_t, which has a common initial subsequence with
jmp_buf but does not include the saved signal mask; this is OK in this
case because the second argument to __sigsetjmp is 0 so the signal
mask is not accessed.

To avoid this warning, use a function alias __sigsetjmp_cancel with
first argument an array of exactly the type used in the calls to the
function, if using GCC 11 or later.  With older compilers, continue to
use __sigsetjmp with a cast, to avoid any issues with compilers
predating the returns_twice attribute not applying the same special
handling to __sigsetjmp_cancel as to __sigsetjmp.

Tested with build-many-glibcs.py for arm-linux-gnueabi that this fixes
the testsuite build failures.
Diffstat (limited to 'misc/sys')
-rw-r--r--misc/sys/cdefs.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 6b9763a92a..86906c2478 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -563,4 +563,12 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
 #  define __attr_access(x)
 #endif
 
+/* Specify that a function such as setjmp or vfork may return
+   twice.  */
+#if __GNUC_PREREQ (4, 1)
+# define __attribute_returns_twice__ __attribute__ ((__returns_twice__))
+#else
+# define __attribute_returns_twice__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */