ppc: fix mq_send
[uclibc-ng.git] / libc / sysdeps / linux / powerpc / sysdep.h
blob9261174759712341389e1f30978b099b4031d103
1 /* Copyright (C) 1999, 2001, 2002, 2006 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, see
16 <http://www.gnu.org/licenses/>. */
18 #include <common/sysdep.h>
19 #include <sys/syscall.h>
21 /*
22 * Powerpc Feature masks for the Aux Vector Hardware Capabilities (AT_HWCAP).
23 * This entry is copied to _dl_hwcap or rtld_global._dl_hwcap during startup.
24 * The following must match the kernels linux/asm/cputable.h.
26 #define PPC_FEATURE_32 0x80000000 /* 32-bit mode. */
27 #define PPC_FEATURE_64 0x40000000 /* 64-bit mode. */
28 #define PPC_FEATURE_601_INSTR 0x20000000 /* 601 chip, Old POWER ISA. */
29 #define PPC_FEATURE_HAS_ALTIVEC 0x10000000 /* SIMD/Vector Unit. */
30 #define PPC_FEATURE_HAS_FPU 0x08000000 /* Floating Point Unit. */
31 #define PPC_FEATURE_HAS_MMU 0x04000000 /* Memory Management Unit. */
32 #define PPC_FEATURE_HAS_4xxMAC 0x02000000 /* 4xx Multiply Accumulator. */
33 #define PPC_FEATURE_UNIFIED_CACHE 0x01000000 /* Unified I/D cache. */
34 #define PPC_FEATURE_HAS_SPE 0x00800000 /* Signal Processing ext. */
35 #define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000 /* SPE Float. */
36 #define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000 /* SPE Double. */
37 #define PPC_FEATURE_NO_TB 0x00100000 /* 601/403gx have no timebase */
38 #define PPC_FEATURE_POWER4 0x00080000 /* POWER4 ISA 2.00 */
39 #define PPC_FEATURE_POWER5 0x00040000 /* POWER5 ISA 2.02 */
40 #define PPC_FEATURE_POWER5_PLUS 0x00020000 /* POWER5+ ISA 2.03 */
41 #define PPC_FEATURE_CELL_BE 0x00010000 /* CELL Broadband Engine */
42 #define PPC_FEATURE_BOOKE 0x00008000
43 #define PPC_FEATURE_SMT 0x00004000 /* Simultaneous Multi-Threading */
44 #define PPC_FEATURE_ICACHE_SNOOP 0x00002000
45 #define PPC_FEATURE_ARCH_2_05 0x00001000 /* ISA 2.05 */
46 #define PPC_FEATURE_PA6T 0x00000800 /* PA Semi 6T Core */
47 #define PPC_FEATURE_HAS_DFP 0x00000400 /* Decimal FP Unit */
48 #define PPC_FEATURE_POWER6_EXT 0x00000200 /* P6 + mffgpr/mftgpr */
49 #define PPC_FEATURE_ARCH_2_06 0x00000100 /* ISA 2.06 */
50 #define PPC_FEATURE_HAS_VSX 0x00000080 /* P7 Vector Extension. */
51 #define PPC_FEATURE_970 (PPC_FEATURE_POWER4 + PPC_FEATURE_HAS_ALTIVEC)
53 #ifdef __ASSEMBLER__
55 /* Symbolic names for the registers. The only portable way to write asm
56 code is to use number but this produces really unreadable code.
57 Therefore these symbolic names. */
59 /* Integer registers. */
60 #define r0 0
61 #define r1 1
62 #define r2 2
63 #define r3 3
64 #define r4 4
65 #define r5 5
66 #define r6 6
67 #define r7 7
68 #define r8 8
69 #define r9 9
70 #define r10 10
71 #define r11 11
72 #define r12 12
73 #define r13 13
74 #define r14 14
75 #define r15 15
76 #define r16 16
77 #define r17 17
78 #define r18 18
79 #define r19 19
80 #define r20 20
81 #define r21 21
82 #define r22 22
83 #define r23 23
84 #define r24 24
85 #define r25 25
86 #define r26 26
87 #define r27 27
88 #define r28 28
89 #define r29 29
90 #define r30 30
91 #define r31 31
93 /* Floating-point registers. */
94 #define fp0 0
95 #define fp1 1
96 #define fp2 2
97 #define fp3 3
98 #define fp4 4
99 #define fp5 5
100 #define fp6 6
101 #define fp7 7
102 #define fp8 8
103 #define fp9 9
104 #define fp10 10
105 #define fp11 11
106 #define fp12 12
107 #define fp13 13
108 #define fp14 14
109 #define fp15 15
110 #define fp16 16
111 #define fp17 17
112 #define fp18 18
113 #define fp19 19
114 #define fp20 20
115 #define fp21 21
116 #define fp22 22
117 #define fp23 23
118 #define fp24 24
119 #define fp25 25
120 #define fp26 26
121 #define fp27 27
122 #define fp28 28
123 #define fp29 29
124 #define fp30 30
125 #define fp31 31
127 /* Condition code registers. */
128 #define cr0 0
129 #define cr1 1
130 #define cr2 2
131 #define cr3 3
132 #define cr4 4
133 #define cr5 5
134 #define cr6 6
135 #define cr7 7
137 /* Vector registers. */
138 #define v0 0
139 #define v1 1
140 #define v2 2
141 #define v3 3
142 #define v4 4
143 #define v5 5
144 #define v6 6
145 #define v7 7
146 #define v8 8
147 #define v9 9
148 #define v10 10
149 #define v11 11
150 #define v12 12
151 #define v13 13
152 #define v14 14
153 #define v15 15
154 #define v16 16
155 #define v17 17
156 #define v18 18
157 #define v19 19
158 #define v20 20
159 #define v21 21
160 #define v22 22
161 #define v23 23
162 #define v24 24
163 #define v25 25
164 #define v26 26
165 #define v27 27
166 #define v28 28
167 #define v29 29
168 #define v30 30
169 #define v31 31
171 #define VRSAVE 256
173 /* This seems to always be the case on PPC. */
174 #define ALIGNARG(log2) log2
175 /* For ELF we need the `.type' directive to make shared libs work right. */
176 #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
177 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
179 /* In ELF C symbols are asm symbols. */
180 #undef NO_UNDERSCORES
181 #define NO_UNDERSCORES
183 #define ENTRY(name) \
184 .globl C_SYMBOL_NAME(name); \
185 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
186 .align ALIGNARG(2); \
187 C_LABEL(name) \
188 cfi_startproc; \
190 #define EALIGN_W_0 /* No words to insert. */
191 #define EALIGN_W_1 nop
192 #define EALIGN_W_2 nop;nop
193 #define EALIGN_W_3 nop;nop;nop
194 #define EALIGN_W_4 EALIGN_W_3;nop
195 #define EALIGN_W_5 EALIGN_W_4;nop
196 #define EALIGN_W_6 EALIGN_W_5;nop
197 #define EALIGN_W_7 EALIGN_W_6;nop
199 #define EALIGN(name, alignt, words) \
200 .globl C_SYMBOL_NAME(name); \
201 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
202 .align ALIGNARG(alignt); \
203 EALIGN_W_##words; \
204 C_LABEL(name) \
205 cfi_startproc;
207 #undef END
208 #define END(name) \
209 cfi_endproc; \
210 ASM_SIZE_DIRECTIVE(name)
212 #define DO_CALL(syscall) \
213 li 0,syscall; \
216 #undef JUMPTARGET
217 #ifdef PIC
218 # define JUMPTARGET(name) name##@plt
219 #else
220 # define JUMPTARGET(name) name
221 #endif
223 #if defined SHARED && defined DO_VERSIONING && defined PIC \
224 && !defined NO_HIDDEN
225 # undef HIDDEN_JUMPTARGET
226 # define HIDDEN_JUMPTARGET(name) __GI_##name##@local
227 #endif
229 #define PSEUDO(name, syscall_name, args) \
230 .section ".text"; \
231 ENTRY (name) \
232 DO_CALL (SYS_ify (syscall_name));
234 #define PSEUDO_RET \
235 bnslr+; \
236 b __syscall_error@local
237 #define ret PSEUDO_RET
239 #undef PSEUDO_END
240 #define PSEUDO_END(name) \
241 END (name)
243 #define PSEUDO_NOERRNO(name, syscall_name, args) \
244 .section ".text"; \
245 ENTRY (name) \
246 DO_CALL (SYS_ify (syscall_name));
248 #define PSEUDO_RET_NOERRNO \
250 #define ret_NOERRNO PSEUDO_RET_NOERRNO
252 #undef PSEUDO_END_NOERRNO
253 #define PSEUDO_END_NOERRNO(name) \
254 END (name)
256 #define PSEUDO_ERRVAL(name, syscall_name, args) \
257 .section ".text"; \
258 ENTRY (name) \
259 DO_CALL (SYS_ify (syscall_name));
261 #undef PSEUDO_END_ERRVAL
262 #define PSEUDO_END_ERRVAL(name) \
263 END (name)
265 /* Local labels stripped out by the linker. */
266 #undef L
267 #define L(x) .L##x
269 /* Label in text section. */
270 #define C_TEXT(name) name
272 #endif /* __ASSEMBLER__ */