POSIX relaxed the relation of setjmp/longjmp and the signal mask
save/restore, meaning that setjmp does not require to be routed to
_setjmp to be standard compliant.
This is done to avoid breakage of SIGABRT handlers, since to fully
make abort AS-safe, it is required to remove the recurisve lock
used to unblock SIGABRT prior raised the signal.
Also, it allows caller to actually use setjmp, since from
7011c2622fe3e10a29dbe74f06aaebd07710127d the symbol is unconditionally
routed to _setjmp.
Checked on x86_64-linux-gnu.
@section Non-Local Exits and Signals
In BSD Unix systems, @code{setjmp} and @code{longjmp} also save and
-restore the set of blocked signals; see @ref{Blocking Signals}. However,
-the POSIX.1 standard requires @code{setjmp} and @code{longjmp} not to
-change the set of blocked signals, and provides an additional pair of
-functions (@code{sigsetjmp} and @code{siglongjmp}) to get the BSD
-behavior.
-
-The behavior of @code{setjmp} and @code{longjmp} in @theglibc{} is
-controlled by feature test macros; see @ref{Feature Test Macros}. The
-default in @theglibc{} is the POSIX.1 behavior rather than the BSD
-behavior.
+restore the set of blocked signals; see @ref{Blocking Signals}, while
+on @w{System V} they will not. POSIX does not specify the relation of
+@code{setjmp} and @code{longjmp} to signal mask. The default in
+@theglibc{} is the BSD behavior.
The facilities in this section are declared in the header file
@file{setjmp.h}.
the saved signal mask), so that is a false positive. */
DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overflow=");
#endif
- not_first_call = setjmp ((struct __jmp_buf_tag *) unwind_buf.cancel_jmp_buf);
+ not_first_call = __sigsetjmp (
+ (struct __jmp_buf_tag *) unwind_buf.cancel_jmp_buf, 0);
DIAG_POP_NEEDS_COMMENT;
/* No previous handlers. NB: This must be done after setjmp since the
Return 0. */
extern int _setjmp (struct __jmp_buf_tag __env[1]) __THROWNL;
-/* Do not save the signal mask. This is equivalent to the `_setjmp'
- BSD function. */
-#define setjmp(env) _setjmp (env)
-
-
/* Jump to the environment saved in ENV, making the
`setjmp' call there return VAL, or 1 if VAL is 0. */
extern void longjmp (struct __jmp_buf_tag __env[1], int __val)
the saved signal mask), so that is a false positive. */
DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overflow=");
#endif
- not_first_call = setjmp ((struct __jmp_buf_tag *) unwind_buf.cancel_jmp_buf);
+ not_first_call = __sigsetjmp (
+ (struct __jmp_buf_tag *) unwind_buf.cancel_jmp_buf, 0);
DIAG_POP_NEEDS_COMMENT;
if (__glibc_likely (! not_first_call))
{