Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / unix / sysv / linux / hppa / ____longjmp_chk.c
blob8789538ded4f7564e10a142f5ee634330c8a5ebe
1 /* Copyright (C) 2009-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with GCC; see the file COPYING. If not, write to the Free
16 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA. */
19 #include <stdio.h>
20 #include <signal.h>
21 #include <sysdep.h>
22 #define __longjmp ____longjmp_chk
23 #define CHECK_SP(sp) \
24 do { \
25 register unsigned long this_sp asm ("r30"); \
26 /* The stack grows up, therefore frames that were created and then \
27 destroyed must all have stack values higher than ours. */ \
28 if ((unsigned long) (sp) > this_sp) \
29 { \
30 struct sigaltstack oss; \
31 INTERNAL_SYSCALL_DECL (err); \
32 int result = INTERNAL_SYSCALL (sigaltstack, err, 2, NULL, &oss);\
33 /* If we aren't using an alternate stack then we have already \
34 shown that we are jumping to a frame that doesn't exist so \
35 error out. If we are using an alternate stack we must prove \
36 that we are jumping *out* of the alternate stack. Note that \
37 the check for that is the same as that for _STACK_GROWS_UP \
38 as for _STACK_GROWS_DOWN. */ \
39 if (!INTERNAL_SYSCALL_ERROR_P (result, err) \
40 && ((oss.ss_flags & SS_ONSTACK) == 0 \
41 || ((unsigned long) oss.ss_sp + oss.ss_size \
42 - (unsigned long) (sp)) < oss.ss_size)) \
43 __fortify_fail ("longjmp causes uninitialized stack frame"); \
44 } \
45 } while (0)
47 #include <__longjmp.c>