Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-64 / ____longjmp_chk.c
bloba3b1375a0d9476e1c7f796ffc1052ad62bea468b
1 /* Copyright (C) 2009-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jakub@redhat.com>.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <errno.h>
20 #include <sysdep.h>
21 #include <setjmp.h>
22 #include <bits/setjmp.h>
23 #include <stdlib.h>
24 #include <unistd.h>
25 #include <stdio.h>
26 #include <stdint.h>
27 #include <signal.h>
28 #include <sys/syscall.h>
30 #define __longjmp ____longjmp_chk
32 #define CHECK_SP(env, guard) \
33 do \
34 { \
35 uintptr_t cur_sp; \
36 uintptr_t new_sp = env->__gregs[9]; \
37 __asm ("lgr %0, %%r15" : "=r" (cur_sp)); \
38 new_sp ^= guard; \
39 if (new_sp < cur_sp) \
40 { \
41 stack_t oss; \
42 INTERNAL_SYSCALL_DECL (err); \
43 int res = INTERNAL_SYSCALL (sigaltstack, err, 2, NULL, &oss); \
44 if (!INTERNAL_SYSCALL_ERROR_P (res, err)) \
45 { \
46 if ((oss.ss_flags & SS_ONSTACK) == 0 \
47 || ((uintptr_t) (oss.ss_sp + oss.ss_size) - new_sp \
48 < oss.ss_size)) \
49 __fortify_fail ("longjmp causes uninitialized stack frame");\
50 } \
51 } \
52 } while (0)
54 #include "__longjmp.c"