Remove __ELF__ conditionals
[platform/upstream/glibc.git] / sysdeps / powerpc / powerpc32 / sysdep.h
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.
5
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.
10
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.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA
19    02110-1301 USA.  */
20
21 #include <sysdeps/powerpc/sysdep.h>
22
23 #ifdef __ASSEMBLER__
24
25 /* If compiled for profiling, call `_mcount' at the start of each
26    function.  */
27 #ifdef  PROF
28 /* The mcount code relies on a the return address being on the stack
29    to locate our caller and so it can restore it; so store one just
30    for its benefit.  */
31 # define CALL_MCOUNT                                                          \
32   mflr  r0;                                                                   \
33   stw   r0,4(r1);                                                             \
34   cfi_offset (lr, 4);                                                         \
35   bl    JUMPTARGET(_mcount);
36 #else  /* PROF */
37 # define CALL_MCOUNT            /* Do nothing.  */
38 #endif /* PROF */
39
40 #define ENTRY(name)                                                           \
41   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                   \
42   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                          \
43   .align ALIGNARG(2);                                                         \
44   C_LABEL(name)                                                               \
45   cfi_startproc;                                                              \
46   CALL_MCOUNT
47
48 /* helper macro for accessing the 32-bit powerpc GOT. */
49
50 #define SETUP_GOT_ACCESS(regname,GOT_LABEL)                                   \
51         bcl     20,31,GOT_LABEL ;                                             \
52 GOT_LABEL:                      ;                                             \
53         mflr    (regname)
54
55 #define EALIGN_W_0  /* No words to insert.  */
56 #define EALIGN_W_1  nop
57 #define EALIGN_W_2  nop;nop
58 #define EALIGN_W_3  nop;nop;nop
59 #define EALIGN_W_4  EALIGN_W_3;nop
60 #define EALIGN_W_5  EALIGN_W_4;nop
61 #define EALIGN_W_6  EALIGN_W_5;nop
62 #define EALIGN_W_7  EALIGN_W_6;nop
63
64 /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
65    past a 2^align boundary.  */
66 #ifdef PROF
67 # define EALIGN(name, alignt, words)                                          \
68   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                   \
69   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                          \
70   .align ALIGNARG(2);                                                         \
71   C_LABEL(name)                                                               \
72   cfi_startproc;                                                              \
73   CALL_MCOUNT                                                                 \
74   b 0f;                                                                       \
75   .align ALIGNARG(alignt);                                                    \
76   EALIGN_W_##words;                                                           \
77   0:
78 #else /* PROF */
79 # define EALIGN(name, alignt, words)                                          \
80   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                   \
81   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                          \
82   .align ALIGNARG(alignt);                                                    \
83   EALIGN_W_##words;                                                           \
84   C_LABEL(name)                                                               \
85   cfi_startproc;
86 #endif
87
88 #undef  END
89 #define END(name)                                                             \
90   cfi_endproc;                                                                \
91   ASM_SIZE_DIRECTIVE(name)
92
93 #define DO_CALL(syscall)                                                      \
94     li 0,syscall;                                                             \
95     sc
96
97 #undef JUMPTARGET
98 #ifdef PIC
99 # define JUMPTARGET(name) name##@plt
100 #else
101 # define JUMPTARGET(name) name
102 #endif
103
104 #if defined SHARED && defined DO_VERSIONING && defined PIC \
105     && !defined NO_HIDDEN
106 # undef HIDDEN_JUMPTARGET
107 # define HIDDEN_JUMPTARGET(name) __GI_##name##@local
108 #endif
109
110 #define PSEUDO(name, syscall_name, args)                                      \
111   .section ".text";                                                           \
112   ENTRY (name)                                                                \
113     DO_CALL (SYS_ify (syscall_name));
114
115 #define PSEUDO_RET                                                            \
116     bnslr+;                                                                   \
117     b __syscall_error@local
118 #define ret PSEUDO_RET
119
120 #undef  PSEUDO_END
121 #define PSEUDO_END(name)                                                      \
122   END (name)
123
124 #define PSEUDO_NOERRNO(name, syscall_name, args)                              \
125   .section ".text";                                                           \
126   ENTRY (name)                                                                \
127     DO_CALL (SYS_ify (syscall_name));
128
129 #define PSEUDO_RET_NOERRNO                                                    \
130     blr
131 #define ret_NOERRNO PSEUDO_RET_NOERRNO
132
133 #undef  PSEUDO_END_NOERRNO
134 #define PSEUDO_END_NOERRNO(name)                                              \
135   END (name)
136
137 #define PSEUDO_ERRVAL(name, syscall_name, args)                               \
138   .section ".text";                                                           \
139   ENTRY (name)                                                                \
140     DO_CALL (SYS_ify (syscall_name));
141
142 #define PSEUDO_RET_ERRVAL                                                     \
143     blr
144 #define ret_ERRVAL PSEUDO_RET_ERRVAL
145
146 #undef  PSEUDO_END_ERRVAL
147 #define PSEUDO_END_ERRVAL(name)                                               \
148   END (name)
149
150 /* Local labels stripped out by the linker.  */
151 #undef L
152 #define L(x) .L##x
153
154 #define XGLUE(a,b) a##b
155 #define GLUE(a,b) XGLUE (a,b)
156 #define GENERATE_GOT_LABEL(name) GLUE (.got_label, name)
157
158 /* Label in text section.  */
159 #define C_TEXT(name) name
160
161 #endif  /* __ASSEMBLER__ */