vfs: check userland buffers before reading them.
[haiku.git] / src / system / libroot / posix / glibc / include / arch / ppc / sysdep.h
blobb6a35517143ab8d7103a4ec70cfc47c8a96c3253
1 /* Copyright (C) 1999, 2001 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 #include_next <sysdep.h>
21 #ifdef __ASSEMBLER__
23 /* Symbolic names for the registers. The only portable way to write asm
24 code is to use number but this produces really unreadable code.
25 Therefore these symbolic names. */
27 /* Integer registers. */
28 #define r0 0
29 #define r1 1
30 #define r2 2
31 #define r3 3
32 #define r4 4
33 #define r5 5
34 #define r6 6
35 #define r7 7
36 #define r8 8
37 #define r9 9
38 #define r10 10
39 #define r11 11
40 #define r12 12
41 #define r13 13
42 #define r14 14
43 #define r15 15
44 #define r16 16
45 #define r17 17
46 #define r18 18
47 #define r19 19
48 #define r20 20
49 #define r21 21
50 #define r22 22
51 #define r23 23
52 #define r24 24
53 #define r25 25
54 #define r26 26
55 #define r27 27
56 #define r28 28
57 #define r29 29
58 #define r30 30
59 #define r31 31
61 /* Floating-point registers. */
62 #define fp0 0
63 #define fp1 1
64 #define fp2 2
65 #define fp3 3
66 #define fp4 4
67 #define fp5 5
68 #define fp6 6
69 #define fp7 7
70 #define fp8 8
71 #define fp9 9
72 #define fp10 10
73 #define fp11 11
74 #define fp12 12
75 #define fp13 13
76 #define fp14 14
77 #define fp15 15
78 #define fp16 16
79 #define fp17 17
80 #define fp18 18
81 #define fp19 19
82 #define fp20 20
83 #define fp21 21
84 #define fp22 22
85 #define fp23 23
86 #define fp24 24
87 #define fp25 25
88 #define fp26 26
89 #define fp27 27
90 #define fp28 28
91 #define fp29 29
92 #define fp30 30
93 #define fp31 31
95 /* Condition code registers. */
96 #define cr0 0
97 #define cr1 1
98 #define cr2 2
99 #define cr3 3
100 #define cr4 4
101 #define cr5 5
102 #define cr6 6
103 #define cr7 7
106 #ifdef __ELF__
108 /* This seems to always be the case on PPC. */
109 #define ALIGNARG(log2) log2
110 /* For ELF we need the `.type' directive to make shared libs work right. */
111 #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
112 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
114 /* If compiled for profiling, call `_mcount' at the start of each function. */
115 #ifdef PROF
116 /* The mcount code relies on a the return address being on the stack
117 to locate our caller and so it can restore it; so store one just
118 for its benefit. */
119 #ifdef PIC
120 #define CALL_MCOUNT \
121 .pushsection; \
122 .section ".data"; \
123 .align ALIGNARG(2); \
124 0:.long 0; \
125 .previous; \
126 mflr r0; \
127 stw r0,4(r1); \
128 bl _GLOBAL_OFFSET_TABLE_@local-4; \
129 mflr r11; \
130 lwz r0,0b@got(r11); \
131 bl JUMPTARGET(_mcount);
132 #else /* PIC */
133 #define CALL_MCOUNT \
134 .section ".data"; \
135 .align ALIGNARG(2); \
136 0:.long 0; \
137 .previous; \
138 mflr r0; \
139 lis r11,0b@ha; \
140 stw r0,4(r1); \
141 addi r0,r11,0b@l; \
142 bl JUMPTARGET(_mcount);
143 #endif /* PIC */
144 #else /* PROF */
145 #define CALL_MCOUNT /* Do nothing. */
146 #endif /* PROF */
148 #define ENTRY(name) \
149 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
150 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
151 .align ALIGNARG(2); \
152 C_LABEL(name) \
153 CALL_MCOUNT
155 #define EALIGN_W_0 /* No words to insert. */
156 #define EALIGN_W_1 nop
157 #define EALIGN_W_2 nop;nop
158 #define EALIGN_W_3 nop;nop;nop
159 #define EALIGN_W_4 EALIGN_W_3;nop
160 #define EALIGN_W_5 EALIGN_W_4;nop
161 #define EALIGN_W_6 EALIGN_W_5;nop
162 #define EALIGN_W_7 EALIGN_W_6;nop
164 /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
165 past a 2^align boundary. */
166 #ifdef PROF
167 #define EALIGN(name, alignt, words) \
168 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
169 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
170 .align ALIGNARG(2); \
171 C_LABEL(name) \
172 CALL_MCOUNT \
173 b 0f; \
174 .align ALIGNARG(alignt); \
175 EALIGN_W_##words; \
177 #else /* PROF */
178 #define EALIGN(name, alignt, words) \
179 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
180 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
181 .align ALIGNARG(alignt); \
182 EALIGN_W_##words; \
183 C_LABEL(name)
184 #endif
186 #undef END
187 #define END(name) \
188 ASM_SIZE_DIRECTIVE(name)
190 #define DO_CALL(syscall) \
191 li 0,syscall; \
194 #ifdef PIC
195 #define JUMPTARGET(name) name##@plt
196 #else
197 #define JUMPTARGET(name) name
198 #endif
200 #define PSEUDO(name, syscall_name, args) \
201 .section ".text"; \
202 ENTRY (name) \
203 DO_CALL (SYS_ify (syscall_name));
205 #define PSEUDO_RET \
206 bnslr; \
207 b JUMPTARGET(__syscall_error)
208 #define ret PSEUDO_RET
210 #undef PSEUDO_END
211 #define PSEUDO_END(name) \
212 END (name)
214 /* Local labels stripped out by the linker. */
215 #undef L
216 #define L(x) .L##x
218 /* Label in text section. */
219 #define C_TEXT(name) name
221 #endif /* __ELF__ */
224 #endif /* __ASSEMBLER__ */