(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / sysdeps / powerpc / powerpc32 / sysdep.h
blob59761f75b9812ea89dbe88df38b62a6135e0690d
1 /* Assembly macros for 32-bit PowerPC.
2 Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <sysdeps/powerpc/sysdep.h>
22 #ifdef __ASSEMBLER__
24 #ifdef __ELF__
26 /* If compiled for profiling, call `_mcount' at the start of each
27 function. */
28 #ifdef PROF
29 /* The mcount code relies on a the return address being on the stack
30 to locate our caller and so it can restore it; so store one just
31 for its benefit. */
32 # ifdef PIC
33 # define CALL_MCOUNT \
34 .pushsection; \
35 .section ".data"; \
36 .align ALIGNARG(2); \
37 0:.long 0; \
38 .previous; \
39 mflr r0; \
40 stw r0,4(r1); \
41 bl _GLOBAL_OFFSET_TABLE_@local-4; \
42 mflr r11; \
43 lwz r0,0b@got(r11); \
44 bl JUMPTARGET(_mcount);
45 # else /* PIC */
46 # define CALL_MCOUNT \
47 .section ".data"; \
48 .align ALIGNARG(2); \
49 0:.long 0; \
50 .previous; \
51 mflr r0; \
52 lis r11,0b@ha; \
53 stw r0,4(r1); \
54 addi r0,r11,0b@l; \
55 bl JUMPTARGET(_mcount);
56 # endif /* PIC */
57 #else /* PROF */
58 # define CALL_MCOUNT /* Do nothing. */
59 #endif /* PROF */
61 #define ENTRY(name) \
62 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
63 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
64 .align ALIGNARG(2); \
65 C_LABEL(name) \
66 CALL_MCOUNT
68 #define EALIGN_W_0 /* No words to insert. */
69 #define EALIGN_W_1 nop
70 #define EALIGN_W_2 nop;nop
71 #define EALIGN_W_3 nop;nop;nop
72 #define EALIGN_W_4 EALIGN_W_3;nop
73 #define EALIGN_W_5 EALIGN_W_4;nop
74 #define EALIGN_W_6 EALIGN_W_5;nop
75 #define EALIGN_W_7 EALIGN_W_6;nop
77 /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
78 past a 2^align boundary. */
79 #ifdef PROF
80 # define EALIGN(name, alignt, words) \
81 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
82 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
83 .align ALIGNARG(2); \
84 C_LABEL(name) \
85 CALL_MCOUNT \
86 b 0f; \
87 .align ALIGNARG(alignt); \
88 EALIGN_W_##words; \
90 #else /* PROF */
91 # define EALIGN(name, alignt, words) \
92 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
93 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
94 .align ALIGNARG(alignt); \
95 EALIGN_W_##words; \
96 C_LABEL(name)
97 #endif
99 #undef END
100 #define END(name) \
101 ASM_SIZE_DIRECTIVE(name)
103 #define DO_CALL(syscall) \
104 li 0,syscall; \
107 #undef JUMPTARGET
108 #ifdef PIC
109 # define JUMPTARGET(name) name##@plt
110 #else
111 # define JUMPTARGET(name) name
112 #endif
114 #if defined SHARED && defined DO_VERSIONING && defined PIC \
115 && !defined HAVE_BROKEN_ALIAS_ATTRIBUTE && !defined NO_HIDDEN
116 # undef HIDDEN_JUMPTARGET
117 # define HIDDEN_JUMPTARGET(name) __GI_##name##@local
118 #endif
120 #define PSEUDO(name, syscall_name, args) \
121 .section ".text"; \
122 ENTRY (name) \
123 DO_CALL (SYS_ify (syscall_name));
125 #define PSEUDO_RET \
126 bnslr+; \
127 b JUMPTARGET(__syscall_error)
128 #define ret PSEUDO_RET
130 #undef PSEUDO_END
131 #define PSEUDO_END(name) \
132 END (name)
134 #define PSEUDO_NOERRNO(name, syscall_name, args) \
135 .section ".text"; \
136 ENTRY (name) \
137 DO_CALL (SYS_ify (syscall_name));
139 #define PSEUDO_RET_NOERRNO \
141 #define ret_NOERRNO PSEUDO_RET_NOERRNO
143 #undef PSEUDO_END_NOERRNO
144 #define PSEUDO_END_NOERRNO(name) \
145 END (name)
147 #define PSEUDO_ERRVAL(name, syscall_name, args) \
148 .section ".text"; \
149 ENTRY (name) \
150 DO_CALL (SYS_ify (syscall_name));
152 #define PSEUDO_RET_ERRVAL \
154 #define ret_ERRVAL PSEUDO_RET_ERRVAL
156 #undef PSEUDO_END_ERRVAL
157 #define PSEUDO_END_ERRVAL(name) \
158 END (name)
160 /* Local labels stripped out by the linker. */
161 #undef L
162 #define L(x) .L##x
164 /* Label in text section. */
165 #define C_TEXT(name) name
167 #endif /* __ELF__ */
169 #endif /* __ASSEMBLER__ */