Replace FSF snail mail address with URLs.
[glibc.git] / sysdeps / powerpc / powerpc32 / sysdep.h
blob621022effdc10718174d58928a885c3c3a196f1a
1 /* Assembly macros for 32-bit PowerPC.
2 Copyright (C) 1999, 2001-2003, 2006, 2011-2012
3 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #include <sysdeps/powerpc/sysdep.h>
22 #ifdef __ASSEMBLER__
24 /* If compiled for profiling, call `_mcount' at the start of each
25 function. */
26 #ifdef PROF
27 /* The mcount code relies on a the return address being on the stack
28 to locate our caller and so it can restore it; so store one just
29 for its benefit. */
30 # define CALL_MCOUNT \
31 mflr r0; \
32 stw r0,4(r1); \
33 cfi_offset (lr, 4); \
34 bl JUMPTARGET(_mcount);
35 #else /* PROF */
36 # define CALL_MCOUNT /* Do nothing. */
37 #endif /* PROF */
39 #define ENTRY(name) \
40 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
41 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
42 .align ALIGNARG(2); \
43 C_LABEL(name) \
44 cfi_startproc; \
45 CALL_MCOUNT
47 /* helper macro for accessing the 32-bit powerpc GOT. */
49 #define SETUP_GOT_ACCESS(regname,GOT_LABEL) \
50 bcl 20,31,GOT_LABEL ; \
51 GOT_LABEL: ; \
52 mflr (regname)
54 #define EALIGN_W_0 /* No words to insert. */
55 #define EALIGN_W_1 nop
56 #define EALIGN_W_2 nop;nop
57 #define EALIGN_W_3 nop;nop;nop
58 #define EALIGN_W_4 EALIGN_W_3;nop
59 #define EALIGN_W_5 EALIGN_W_4;nop
60 #define EALIGN_W_6 EALIGN_W_5;nop
61 #define EALIGN_W_7 EALIGN_W_6;nop
63 /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
64 past a 2^align boundary. */
65 #ifdef PROF
66 # define EALIGN(name, alignt, words) \
67 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
68 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
69 .align ALIGNARG(2); \
70 C_LABEL(name) \
71 cfi_startproc; \
72 CALL_MCOUNT \
73 b 0f; \
74 .align ALIGNARG(alignt); \
75 EALIGN_W_##words; \
77 #else /* PROF */
78 # define EALIGN(name, alignt, words) \
79 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
80 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
81 .align ALIGNARG(alignt); \
82 EALIGN_W_##words; \
83 C_LABEL(name) \
84 cfi_startproc;
85 #endif
87 #undef END
88 #define END(name) \
89 cfi_endproc; \
90 ASM_SIZE_DIRECTIVE(name)
92 #define DO_CALL(syscall) \
93 li 0,syscall; \
96 #undef JUMPTARGET
97 #ifdef PIC
98 # define JUMPTARGET(name) name##@plt
99 #else
100 # define JUMPTARGET(name) name
101 #endif
103 #if defined SHARED && defined DO_VERSIONING && defined PIC \
104 && !defined NO_HIDDEN
105 # undef HIDDEN_JUMPTARGET
106 # define HIDDEN_JUMPTARGET(name) __GI_##name##@local
107 #endif
109 #define PSEUDO(name, syscall_name, args) \
110 .section ".text"; \
111 ENTRY (name) \
112 DO_CALL (SYS_ify (syscall_name));
114 #define PSEUDO_RET \
115 bnslr+; \
116 b __syscall_error@local
117 #define ret PSEUDO_RET
119 #undef PSEUDO_END
120 #define PSEUDO_END(name) \
121 END (name)
123 #define PSEUDO_NOERRNO(name, syscall_name, args) \
124 .section ".text"; \
125 ENTRY (name) \
126 DO_CALL (SYS_ify (syscall_name));
128 #define PSEUDO_RET_NOERRNO \
130 #define ret_NOERRNO PSEUDO_RET_NOERRNO
132 #undef PSEUDO_END_NOERRNO
133 #define PSEUDO_END_NOERRNO(name) \
134 END (name)
136 #define PSEUDO_ERRVAL(name, syscall_name, args) \
137 .section ".text"; \
138 ENTRY (name) \
139 DO_CALL (SYS_ify (syscall_name));
141 #define PSEUDO_RET_ERRVAL \
143 #define ret_ERRVAL PSEUDO_RET_ERRVAL
145 #undef PSEUDO_END_ERRVAL
146 #define PSEUDO_END_ERRVAL(name) \
147 END (name)
149 /* Local labels stripped out by the linker. */
150 #undef L
151 #define L(x) .L##x
153 #define XGLUE(a,b) a##b
154 #define GLUE(a,b) XGLUE (a,b)
155 #define GENERATE_GOT_LABEL(name) GLUE (.got_label, name)
157 /* Label in text section. */
158 #define C_TEXT(name) name
160 #endif /* __ASSEMBLER__ */