(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / sysdeps / powerpc / bits / setjmp.h
blob3134916a51798ef4eceb62728224a196e0a0f4d8
1 /* Copyright (C) 1997, 1998, 2000, 2003, 2004 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 Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 /* Define the machine-dependent type `jmp_buf'. PowerPC version. */
20 #ifndef _BITS_SETJMP_H
21 #define _BITS_SETJMP_H 1
23 #if !defined _SETJMP_H && !defined _PTHREAD_H
24 # error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
25 #endif
27 /* The previous bits/setjmp.h had __jmp_buf defined as a structure.
28 We use an array of 'long int' instead, to make writing the
29 assembler easier. Naturally, user code should not depend on
30 either representation. */
32 #include <bits/wordsize.h>
34 #if defined __USE_MISC || defined _ASM
35 # define JB_GPR1 0 /* Also known as the stack pointer */
36 # define JB_GPR2 1
37 # define JB_LR 2 /* The address we will return to */
38 # if __WORDSIZE == 64
39 # define JB_GPRS 3 /* GPRs 14 through 31 are saved, 18*2 words total. */
40 # define JB_CR 21 /* Condition code registers with the VRSAVE at */
41 /* offset 172 (low half of the double word. */
42 # define JB_FPRS 22 /* FPRs 14 through 31 are saved, 18*2 words total. */
43 # define JB_SIZE (64 * 8) /* As per PPC64-VMX ABI. */
44 # define JB_VRSAVE 21 /* VRSAVE shares a double word with the CR at offset */
45 /* 168 (high half of the double word). */
46 # define JB_VRS 40 /* VRs 20 through 31 are saved, 12*4 words total. */
47 # else
48 # define JB_GPRS 3 /* GPRs 14 through 31 are saved, 18 in total. */
49 # define JB_CR 21 /* Condition code registers. */
50 # define JB_FPRS 22 /* FPRs 14 through 31 are saved, 18*2 words total. */
51 # define JB_SIZE ((64 + (12 * 4)) * 4)
52 # define JB_VRSAVE 62
53 # define JB_VRS 64
54 # endif
55 #endif
58 /* The current powerpc 32-bit Altivec ABI specifies for SVR4 ABI and EABI
59 the vrsave must be at byte 248 & v20 at byte 256. So we must pad this
60 correctly on 32 bit. It also insists that vecregs are only gauranteed
61 4 byte alignment so we need to use vperm in the setjmp/longjmp routines.
62 We have to version the code because members like int __mask_was_saved
63 in the jmp_buf will move as jmp_buf is now larger than 248 bytes. We
64 cannot keep the altivec jmp_buf backward compatible with the jmp_buf. */
65 #ifndef _ASM
66 # if __WORDSIZE == 64
67 typedef long int __jmp_buf[64] __attribute__ ((__aligned__ (16)));
68 # else
69 /* The alignment is not essential, i.e.the buffer can be copied to a 4 byte
70 aligned buffer as per the ABI it is just added for performance reasons. */
71 typedef long int __jmp_buf[64 + (12 * 4)] __attribute__ ((__aligned__ (16)));
72 # endif
73 #endif
75 /* Test if longjmp to JMPBUF would unwind the frame
76 containing a local variable at ADDRESS. */
77 #define _JMPBUF_UNWINDS(jmpbuf, address) \
78 ((void *) (address) < (void *) (jmpbuf)[JB_GPR1])
80 #endif /* bits/setjmp.h */