]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/powerpc/powerpc32/sysdep.h
Update
[l4.git] / l4 / pkg / l4re-core / 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, see
17    <http://www.gnu.org/licenses/>.  */
18
19 #ifdef __ASSEMBLER__
20
21 #ifdef __ELF__
22
23 /* If compiled for profiling, call `_mcount' at the start of each
24    function.  */
25 #ifdef  PROF
26 /* The mcount code relies on a the return address being on the stack
27    to locate our caller and so it can restore it; so store one just
28    for its benefit.  */
29 # define CALL_MCOUNT                                                          \
30   mflr  r0;                                                                   \
31   stw   r0,4(r1);                                                             \
32   cfi_offset (lr, 4);                                                         \
33   bl    JUMPTARGET(_mcount);
34 #else  /* PROF */
35 # define CALL_MCOUNT            /* Do nothing.  */
36 #endif /* PROF */
37
38 #define ENTRY(name)                                                           \
39   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                   \
40   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                          \
41   .align ALIGNARG(2);                                                         \
42   C_LABEL(name)                                                               \
43   cfi_startproc;                                                              \
44   CALL_MCOUNT
45
46 #define EALIGN_W_0  /* No words to insert.  */
47 #define EALIGN_W_1  nop
48 #define EALIGN_W_2  nop;nop
49 #define EALIGN_W_3  nop;nop;nop
50 #define EALIGN_W_4  EALIGN_W_3;nop
51 #define EALIGN_W_5  EALIGN_W_4;nop
52 #define EALIGN_W_6  EALIGN_W_5;nop
53 #define EALIGN_W_7  EALIGN_W_6;nop
54
55 /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
56    past a 2^align boundary.  */
57 #ifdef PROF
58 # define EALIGN(name, alignt, words)                                          \
59   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                   \
60   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                          \
61   .align ALIGNARG(2);                                                         \
62   C_LABEL(name)                                                               \
63   cfi_startproc;                                                              \
64   CALL_MCOUNT                                                                 \
65   b 0f;                                                                       \
66   .align ALIGNARG(alignt);                                                    \
67   EALIGN_W_##words;                                                           \
68   0:
69 #else /* PROF */
70 # define EALIGN(name, alignt, words)                                          \
71   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                   \
72   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                          \
73   .align ALIGNARG(alignt);                                                    \
74   EALIGN_W_##words;                                                           \
75   C_LABEL(name)                                                               \
76   cfi_startproc;
77 #endif
78
79 #undef  END
80 #define END(name)                                                             \
81   cfi_endproc;                                                                \
82   ASM_SIZE_DIRECTIVE(name)
83
84 #define DO_CALL(syscall)                                                      \
85     li 0,syscall;                                                             \
86     sc
87
88 #undef JUMPTARGET
89 #ifdef PIC
90 # define JUMPTARGET(name) name##@plt
91 #else
92 # define JUMPTARGET(name) name
93 #endif
94
95 #if defined SHARED && defined DO_VERSIONING && defined PIC \
96     && !defined NO_HIDDEN
97 # undef HIDDEN_JUMPTARGET
98 # define HIDDEN_JUMPTARGET(name) __GI_##name##@local
99 #endif
100
101 #define PSEUDO(name, syscall_name, args)                                      \
102   .section ".text";                                                           \
103   ENTRY (name)                                                                \
104     DO_CALL (SYS_ify (syscall_name));
105
106 #define PSEUDO_RET                                                            \
107     bnslr+;                                                                   \
108     b __syscall_error@local
109 #define ret PSEUDO_RET
110
111 #undef  PSEUDO_END
112 #define PSEUDO_END(name)                                                      \
113   END (name)
114
115 #define PSEUDO_NOERRNO(name, syscall_name, args)                              \
116   .section ".text";                                                           \
117   ENTRY (name)                                                                \
118     DO_CALL (SYS_ify (syscall_name));
119
120 #define PSEUDO_RET_NOERRNO                                                    \
121     blr
122 #define ret_NOERRNO PSEUDO_RET_NOERRNO
123
124 #undef  PSEUDO_END_NOERRNO
125 #define PSEUDO_END_NOERRNO(name)                                              \
126   END (name)
127
128 #define PSEUDO_ERRVAL(name, syscall_name, args)                               \
129   .section ".text";                                                           \
130   ENTRY (name)                                                                \
131     DO_CALL (SYS_ify (syscall_name));
132
133 #define PSEUDO_RET_ERRVAL                                                     \
134     blr
135 #undef ret_ERRVAL
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__ */