]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/powerpc/powerpc32/sysdep.h
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / 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 #ifdef __ASSEMBLER__
21
22 #ifdef __ELF__
23
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 */
38
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
46
47 #define EALIGN_W_0  /* No words to insert.  */
48 #define EALIGN_W_1  nop
49 #define EALIGN_W_2  nop;nop
50 #define EALIGN_W_3  nop;nop;nop
51 #define EALIGN_W_4  EALIGN_W_3;nop
52 #define EALIGN_W_5  EALIGN_W_4;nop
53 #define EALIGN_W_6  EALIGN_W_5;nop
54 #define EALIGN_W_7  EALIGN_W_6;nop
55
56 /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
57    past a 2^align boundary.  */
58 #ifdef PROF
59 # define EALIGN(name, alignt, words)                                          \
60   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                   \
61   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                          \
62   .align ALIGNARG(2);                                                         \
63   C_LABEL(name)                                                               \
64   cfi_startproc;                                                              \
65   CALL_MCOUNT                                                                 \
66   b 0f;                                                                       \
67   .align ALIGNARG(alignt);                                                    \
68   EALIGN_W_##words;                                                           \
69   0:
70 #else /* PROF */
71 # define EALIGN(name, alignt, words)                                          \
72   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                   \
73   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                          \
74   .align ALIGNARG(alignt);                                                    \
75   EALIGN_W_##words;                                                           \
76   C_LABEL(name)                                                               \
77   cfi_startproc;
78 #endif
79
80 #undef  END
81 #define END(name)                                                             \
82   cfi_endproc;                                                                \
83   ASM_SIZE_DIRECTIVE(name)
84
85 #define DO_CALL(syscall)                                                      \
86     li 0,syscall;                                                             \
87     sc
88
89 #undef JUMPTARGET
90 #ifdef PIC
91 # define JUMPTARGET(name) name##@plt
92 #else
93 # define JUMPTARGET(name) name
94 #endif
95
96 #if defined SHARED && defined DO_VERSIONING && defined PIC \
97     && !defined NO_HIDDEN
98 # undef HIDDEN_JUMPTARGET
99 # define HIDDEN_JUMPTARGET(name) __GI_##name##@local
100 #endif
101
102 #define PSEUDO(name, syscall_name, args)                                      \
103   .section ".text";                                                           \
104   ENTRY (name)                                                                \
105     DO_CALL (SYS_ify (syscall_name));
106
107 #define PSEUDO_RET                                                            \
108     bnslr+;                                                                   \
109     b __syscall_error@local
110 #define ret PSEUDO_RET
111
112 #undef  PSEUDO_END
113 #define PSEUDO_END(name)                                                      \
114   END (name)
115
116 #define PSEUDO_NOERRNO(name, syscall_name, args)                              \
117   .section ".text";                                                           \
118   ENTRY (name)                                                                \
119     DO_CALL (SYS_ify (syscall_name));
120
121 #define PSEUDO_RET_NOERRNO                                                    \
122     blr
123 #define ret_NOERRNO PSEUDO_RET_NOERRNO
124
125 #undef  PSEUDO_END_NOERRNO
126 #define PSEUDO_END_NOERRNO(name)                                              \
127   END (name)
128
129 #define PSEUDO_ERRVAL(name, syscall_name, args)                               \
130   .section ".text";                                                           \
131   ENTRY (name)                                                                \
132     DO_CALL (SYS_ify (syscall_name));
133
134 #define PSEUDO_RET_ERRVAL                                                     \
135     blr
136 #define ret_ERRVAL PSEUDO_RET_ERRVAL
137
138 #undef  PSEUDO_END_ERRVAL
139 #define PSEUDO_END_ERRVAL(name)                                               \
140   END (name)
141
142 /* Local labels stripped out by the linker.  */
143 #undef L
144 #define L(x) .L##x
145
146 /* Label in text section.  */
147 #define C_TEXT(name) name
148
149 #endif /* __ELF__ */
150
151 #endif  /* __ASSEMBLER__ */