Updated to fedora-glibc-20050620T1530
[glibc.git] / sysdeps / powerpc / powerpc32 / sysdep.h
blob552f595a10f607c17346a02b60d238b62ec20e88
1 /* Assembly macros for 32-bit PowerPC.
2 Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <sysdeps/powerpc/sysdep.h>
22 #ifdef __ASSEMBLER__
24 #ifdef __ELF__
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 bl JUMPTARGET(_mcount);
36 #else /* PROF */
37 # define CALL_MCOUNT /* Do nothing. */
38 #endif /* PROF */
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 CALL_MCOUNT
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
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 CALL_MCOUNT \
65 b 0f; \
66 .align ALIGNARG(alignt); \
67 EALIGN_W_##words; \
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 #endif
78 #undef END
79 #define END(name) \
80 ASM_SIZE_DIRECTIVE(name)
82 #define DO_CALL(syscall) \
83 li 0,syscall; \
86 #undef JUMPTARGET
87 #ifdef PIC
88 # define JUMPTARGET(name) name##@plt
89 #else
90 # define JUMPTARGET(name) name
91 #endif
93 #if defined SHARED && defined DO_VERSIONING && defined PIC \
94 && !defined HAVE_BROKEN_ALIAS_ATTRIBUTE && !defined NO_HIDDEN
95 # undef HIDDEN_JUMPTARGET
96 # define HIDDEN_JUMPTARGET(name) __GI_##name##@local
97 #endif
99 #define PSEUDO(name, syscall_name, args) \
100 .section ".text"; \
101 ENTRY (name) \
102 DO_CALL (SYS_ify (syscall_name));
104 #define PSEUDO_RET \
105 bnslr+; \
106 b __syscall_error@local
107 #define ret PSEUDO_RET
109 #undef PSEUDO_END
110 #define PSEUDO_END(name) \
111 END (name)
113 #define PSEUDO_NOERRNO(name, syscall_name, args) \
114 .section ".text"; \
115 ENTRY (name) \
116 DO_CALL (SYS_ify (syscall_name));
118 #define PSEUDO_RET_NOERRNO \
120 #define ret_NOERRNO PSEUDO_RET_NOERRNO
122 #undef PSEUDO_END_NOERRNO
123 #define PSEUDO_END_NOERRNO(name) \
124 END (name)
126 #define PSEUDO_ERRVAL(name, syscall_name, args) \
127 .section ".text"; \
128 ENTRY (name) \
129 DO_CALL (SYS_ify (syscall_name));
131 #define PSEUDO_RET_ERRVAL \
133 #define ret_ERRVAL PSEUDO_RET_ERRVAL
135 #undef PSEUDO_END_ERRVAL
136 #define PSEUDO_END_ERRVAL(name) \
137 END (name)
139 /* Local labels stripped out by the linker. */
140 #undef L
141 #define L(x) .L##x
143 /* Label in text section. */
144 #define C_TEXT(name) name
146 #endif /* __ELF__ */
148 #endif /* __ASSEMBLER__ */