chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / sysdeps / powerpc / powerpc32 / sysdep.h
1 /* Assembly macros for 32-bit PowerPC.
2    Copyright (C) 1999, 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
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.
9
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.
14
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., 51 Franklin Street, Fifth Floor, Boston MA
18    02110-1301 USA.  */
19
20 #include <sysdeps/powerpc/sysdep.h>
21
22 #ifdef __ASSEMBLER__
23
24 #ifdef __ELF__
25
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 # define CALL_MCOUNT                                                          \
33   mflr  r0;                                                                   \
34   stw   r0,4(r1);                                                             \
35   cfi_offset (lr, 4);                                                         \
36   bl    JUMPTARGET(_mcount);
37 #else  /* PROF */
38 # define CALL_MCOUNT            /* Do nothing.  */
39 #endif /* PROF */
40
41 #define ENTRY(name)                                                           \
42   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                   \
43   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                          \
44   .align ALIGNARG(2);                                                         \
45   C_LABEL(name)                                                               \
46   cfi_startproc;                                                              \
47   CALL_MCOUNT
48
49 #define EALIGN_W_0  /* No words to insert.  */
50 #define EALIGN_W_1  nop
51 #define EALIGN_W_2  nop;nop
52 #define EALIGN_W_3  nop;nop;nop
53 #define EALIGN_W_4  EALIGN_W_3;nop
54 #define EALIGN_W_5  EALIGN_W_4;nop
55 #define EALIGN_W_6  EALIGN_W_5;nop
56 #define EALIGN_W_7  EALIGN_W_6;nop
57
58 /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
59    past a 2^align boundary.  */
60 #ifdef PROF
61 # define EALIGN(name, alignt, words)                                          \
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   cfi_startproc;                                                              \
67   CALL_MCOUNT                                                                 \
68   b 0f;                                                                       \
69   .align ALIGNARG(alignt);                                                    \
70   EALIGN_W_##words;                                                           \
71   0:
72 #else /* PROF */
73 # define EALIGN(name, alignt, words)                                          \
74   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                   \
75   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                          \
76   .align ALIGNARG(alignt);                                                    \
77   EALIGN_W_##words;                                                           \
78   C_LABEL(name)                                                               \
79   cfi_startproc;
80 #endif
81
82 #undef  END
83 #define END(name)                                                             \
84   cfi_endproc;                                                                \
85   ASM_SIZE_DIRECTIVE(name)
86
87 #define DO_CALL(syscall)                                                      \
88     li 0,syscall;                                                             \
89     sc
90
91 #undef JUMPTARGET
92 #ifdef PIC
93 # define JUMPTARGET(name) name##@plt
94 #else
95 # define JUMPTARGET(name) name
96 #endif
97
98 #if defined SHARED && defined DO_VERSIONING && defined PIC \
99     && !defined NO_HIDDEN
100 # undef HIDDEN_JUMPTARGET
101 # define HIDDEN_JUMPTARGET(name) __GI_##name##@local
102 #endif
103
104 #define PSEUDO(name, syscall_name, args)                                      \
105   .section ".text";                                                           \
106   ENTRY (name)                                                                \
107     DO_CALL (SYS_ify (syscall_name));
108
109 #define PSEUDO_RET                                                            \
110     bnslr+;                                                                   \
111     b __syscall_error@local
112 #define ret PSEUDO_RET
113
114 #undef  PSEUDO_END
115 #define PSEUDO_END(name)                                                      \
116   END (name)
117
118 #define PSEUDO_NOERRNO(name, syscall_name, args)                              \
119   .section ".text";                                                           \
120   ENTRY (name)                                                                \
121     DO_CALL (SYS_ify (syscall_name));
122
123 #define PSEUDO_RET_NOERRNO                                                    \
124     blr
125 #define ret_NOERRNO PSEUDO_RET_NOERRNO
126
127 #undef  PSEUDO_END_NOERRNO
128 #define PSEUDO_END_NOERRNO(name)                                              \
129   END (name)
130
131 #define PSEUDO_ERRVAL(name, syscall_name, args)                               \
132   .section ".text";                                                           \
133   ENTRY (name)                                                                \
134     DO_CALL (SYS_ify (syscall_name));
135
136 #define PSEUDO_RET_ERRVAL                                                     \
137     blr
138 #define ret_ERRVAL PSEUDO_RET_ERRVAL
139
140 #undef  PSEUDO_END_ERRVAL
141 #define PSEUDO_END_ERRVAL(name)                                               \
142   END (name)
143
144 /* Local labels stripped out by the linker.  */
145 #undef L
146 #define L(x) .L##x
147
148 /* Label in text section.  */
149 #define C_TEXT(name) name
150
151 #endif /* __ELF__ */
152
153 #endif  /* __ASSEMBLER__ */