33
34 #ifdef _ASM
35 /* BEGIN CSTYLED */
36
37 /*
38 * Disable amd64 assembly code profiling for now.
39 */
40 #if defined(__amd64)
41 #undef PROF
42 #endif
43
44 #include <sys/asm_linkage.h>
45
46 #define NAME(x) x
47 #define TEXT .section ".text"
48 #define DATA .section ".data"
49 #define RO_DATA .section ".rodata"
50 #define IDENT(x) .ident x
51
52 #if defined(__sparc)
53
54 #define LIBM_ANSI_PRAGMA_WEAK(sym,stype) \
55 .weak __/**/sym; \
56 .type __/**/sym,#stype; \
57 __/**/sym = sym
58
59 #ifndef SET_FILE
60 #define SET_FILE(x) \
61 .file x
62 #endif /* !defined(SET_FILE) */
63
64 #ifdef PIC
65 /*
66 * One should *never* pass o7 to PIC_SETUP.
67 */
68 #define PIC_SETUP(via) \
69 9: call 8f; \
70 sethi %hi(NAME(_GLOBAL_OFFSET_TABLE_)-(9b-.)),%via; \
71 8: or %via,%lo(NAME(_GLOBAL_OFFSET_TABLE_)-(9b-.)),%via; \
72 add %via,%o7,%via
73 /*
85 #else /* defined(__sparcv9) */
86 #define PIC_SET(via,sym,dst) ld [%via+sym],%dst
87 #endif /* defined(__sparcv9) */
88 #else /* defined(PIC) */
89 #define PIC_SETUP(via)
90 #define PIC_LEAF_SETUP(via)
91 #ifdef __sparcv9
92 /*
93 * g1 is used as scratch register in V9 mode
94 */
95 #define PIC_SET(via,sym,dst) setx sym,%g1,%dst
96 #else /* defined(__sparcv9) */
97 #define PIC_SET(via,sym,dst) set sym,%dst
98 #endif /* defined(__sparcv9) */
99 #endif /* defined(PIC) */
100
101 /*
102 * Workaround for 4337025: MCOUNT in asm_linkage.h does not support __sparcv9
103 */
104 #if defined(PROF) && defined(__sparcv9)
105
106 #undef MCOUNT_SIZE
107 #undef MCOUNT
108
109 #if !defined(PIC)
110 #define MCOUNT_SIZE (9*4) /* 9 instructions */
111 #define MCOUNT(x) \
112 save %sp, -SA(MINFRAME), %sp; \
113 sethi %hh(.L_/**/x/**/1), %o0; \
114 sethi %lm(.L_/**/x/**/1), %o1; \
115 or %o0, %hm(.L_/**/x/**/1), %o0; \
116 or %o1, %lo(.L_/**/x/**/1), %o1; \
117 sllx %o0, 32, %o0; \
118 call _mcount; \
119 or %o0, %o1, %o0; \
120 restore; \
121 .common .L_/**/x/**/1, 8, 8
122 #elif defined(PIC32)
123 #define MCOUNT_SIZE (10*4) /* 10 instructions */
124 #define MCOUNT(x) \
125 save %sp,-SA(MINFRAME),%sp; \
130 add %o1,%lo(.L_/**/x/**/1),%o1; \
131 add %o0,%o7,%o0; \
132 call _mcount; \
133 ldx [%o0+%o1],%o0; \
134 restore; \
135 .common .L_/**/x/**/1,8,8
136 #else /* PIC13 */
137 #define MCOUNT_SIZE (8*4) /* 8 instructions */
138 #define MCOUNT(x) \
139 save %sp,-SA(MINFRAME),%sp; \
140 1: call .+8; \
141 sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)),%o0; \
142 add %o0,%lo(_GLOBAL_OFFSET_TABLE_-(1b-.)),%o0; \
143 add %o0,%o7,%o0; \
144 call _mcount; \
145 ldx [%o0+%lo(.L_/**/x/**/1)],%o0; \
146 restore; \
147 .common .L_/**/x/**/1,8,8
148 #endif /* !defined(PIC) */
149 #endif /* defined(PROF) && defined(__sparcv9) */
150
151 #elif defined(__x86)
152
153 #define LIBM_ANSI_PRAGMA_WEAK(sym,stype) \
154 .weak __/**/sym; \
155 .type __/**/sym,@stype; \
156 __/**/sym = sym
157
158 #ifdef PIC
159 #if defined(__amd64)
160 #define PIC_SETUP(x)
161 #define PIC_WRAPUP
162 #define PIC_F(x) x@PLT
163 #define PIC_G(x) x@GOTPCREL(%rip)
164 #define PIC_L(x) x(%rip)
165 #define PIC_G_LOAD(insn,sym,dst) \
166 movq PIC_G(sym),%dst; \
167 insn (%dst),%dst
168 #else
169 #define PIC_SETUP(label) \
170 pushl %ebx; \
171 call .label; \
172 .label: popl %ebx; \
173 addl $_GLOBAL_OFFSET_TABLE_+[.-.label],%ebx
174 #define PIC_WRAPUP popl %ebx
175 #define PIC_F(x) x@PLT
176 #define PIC_G(x) x@GOT(%ebx)
177 #define PIC_L(x) x@GOTOFF(%ebx)
178 #define PIC_G_LOAD(insn,sym,dst) \
179 mov PIC_G(sym),%dst; \
180 insn (%dst),%dst
181 #endif
182 #else /* defined(PIC) */
183 #define PIC_SETUP(x)
184 #define PIC_WRAPUP
185 #define PIC_F(x) x
186 #define PIC_G(x) x
187 #define PIC_L(x) x
188 #define PIC_G_LOAD(insn,sym,dst) insn sym,%dst
189 #endif /* defined(PIC) */
190
191 #else
192 #error Unknown architecture
193 #endif
194
195 /* END CSTYLED */
196 #else /* defined(_ASM) */
197
198 #include "libm_macros.h"
199 #include "libm_protos.h"
200 #include "libm_inlines.h"
201 #include <math.h>
202 #if defined(__SUNPRO_C)
203 #include <sunmath.h>
204 #endif
205
206 #endif /* defined(_ASM) */
207
208 #endif /* _LIBM_H */
|
33
34 #ifdef _ASM
35 /* BEGIN CSTYLED */
36
37 /*
38 * Disable amd64 assembly code profiling for now.
39 */
40 #if defined(__amd64)
41 #undef PROF
42 #endif
43
44 #include <sys/asm_linkage.h>
45
46 #define NAME(x) x
47 #define TEXT .section ".text"
48 #define DATA .section ".data"
49 #define RO_DATA .section ".rodata"
50 #define IDENT(x) .ident x
51
52 #if defined(__sparc)
53 #define LIBM_ANSI_PRAGMA_WEAK(sym,stype) \
54 .weak __/**/sym; \
55 .type __/**/sym,#stype; \
56 __/**/sym = sym
57
58 #ifndef SET_FILE
59 #define SET_FILE(x) \
60 .file x
61 #endif /* !defined(SET_FILE) */
62
63 #ifdef PIC
64 /*
65 * One should *never* pass o7 to PIC_SETUP.
66 */
67 #define PIC_SETUP(via) \
68 9: call 8f; \
69 sethi %hi(NAME(_GLOBAL_OFFSET_TABLE_)-(9b-.)),%via; \
70 8: or %via,%lo(NAME(_GLOBAL_OFFSET_TABLE_)-(9b-.)),%via; \
71 add %via,%o7,%via
72 /*
84 #else /* defined(__sparcv9) */
85 #define PIC_SET(via,sym,dst) ld [%via+sym],%dst
86 #endif /* defined(__sparcv9) */
87 #else /* defined(PIC) */
88 #define PIC_SETUP(via)
89 #define PIC_LEAF_SETUP(via)
90 #ifdef __sparcv9
91 /*
92 * g1 is used as scratch register in V9 mode
93 */
94 #define PIC_SET(via,sym,dst) setx sym,%g1,%dst
95 #else /* defined(__sparcv9) */
96 #define PIC_SET(via,sym,dst) set sym,%dst
97 #endif /* defined(__sparcv9) */
98 #endif /* defined(PIC) */
99
100 /*
101 * Workaround for 4337025: MCOUNT in asm_linkage.h does not support __sparcv9
102 */
103 #if defined(PROF) && defined(__sparcv9)
104 #undef MCOUNT_SIZE
105 #undef MCOUNT
106
107 #if !defined(PIC)
108 #define MCOUNT_SIZE (9*4) /* 9 instructions */
109 #define MCOUNT(x) \
110 save %sp, -SA(MINFRAME), %sp; \
111 sethi %hh(.L_/**/x/**/1), %o0; \
112 sethi %lm(.L_/**/x/**/1), %o1; \
113 or %o0, %hm(.L_/**/x/**/1), %o0; \
114 or %o1, %lo(.L_/**/x/**/1), %o1; \
115 sllx %o0, 32, %o0; \
116 call _mcount; \
117 or %o0, %o1, %o0; \
118 restore; \
119 .common .L_/**/x/**/1, 8, 8
120 #elif defined(PIC32)
121 #define MCOUNT_SIZE (10*4) /* 10 instructions */
122 #define MCOUNT(x) \
123 save %sp,-SA(MINFRAME),%sp; \
128 add %o1,%lo(.L_/**/x/**/1),%o1; \
129 add %o0,%o7,%o0; \
130 call _mcount; \
131 ldx [%o0+%o1],%o0; \
132 restore; \
133 .common .L_/**/x/**/1,8,8
134 #else /* PIC13 */
135 #define MCOUNT_SIZE (8*4) /* 8 instructions */
136 #define MCOUNT(x) \
137 save %sp,-SA(MINFRAME),%sp; \
138 1: call .+8; \
139 sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)),%o0; \
140 add %o0,%lo(_GLOBAL_OFFSET_TABLE_-(1b-.)),%o0; \
141 add %o0,%o7,%o0; \
142 call _mcount; \
143 ldx [%o0+%lo(.L_/**/x/**/1)],%o0; \
144 restore; \
145 .common .L_/**/x/**/1,8,8
146 #endif /* !defined(PIC) */
147 #endif /* defined(PROF) && defined(__sparcv9) */
148 #elif defined(__x86)
149 #define LIBM_ANSI_PRAGMA_WEAK(sym,stype) \
150 .weak __/**/sym; \
151 .type __/**/sym,@stype; \
152 __/**/sym = sym
153
154 #ifdef PIC
155 #if defined(__amd64)
156 #define PIC_SETUP(x)
157 #define PIC_WRAPUP
158 #define PIC_F(x) x@PLT
159 #define PIC_G(x) x@GOTPCREL(%rip)
160 #define PIC_L(x) x(%rip)
161 #define PIC_G_LOAD(insn,sym,dst) \
162 movq PIC_G(sym),%dst; \
163 insn (%dst),%dst
164 #else
165 #define PIC_SETUP(label) \
166 pushl %ebx; \
167 call .label; \
168 .label: popl %ebx; \
169 addl $_GLOBAL_OFFSET_TABLE_+[.-.label],%ebx
170 #define PIC_WRAPUP popl %ebx
171 #define PIC_F(x) x@PLT
172 #define PIC_G(x) x@GOT(%ebx)
173 #define PIC_L(x) x@GOTOFF(%ebx)
174 #define PIC_G_LOAD(insn,sym,dst) \
175 mov PIC_G(sym),%dst; \
176 insn (%dst),%dst
177 #endif
178 #else /* defined(PIC) */
179 #define PIC_SETUP(x)
180 #define PIC_WRAPUP
181 #define PIC_F(x) x
182 #define PIC_G(x) x
183 #define PIC_L(x) x
184 #define PIC_G_LOAD(insn,sym,dst) insn sym,%dst
185 #endif /* defined(PIC) */
186 #else
187 #error Unknown architecture
188 #endif
189
190 /* END CSTYLED */
191 #else /* defined(_ASM) */
192 #include "libm_macros.h"
193 #include "libm_protos.h"
194 #include "libm_inlines.h"
195 #include <math.h>
196 #if defined(__SUNPRO_C)
197 #include <sunmath.h>
198 #endif
199 #endif /* defined(_ASM) */
200 #endif /* _LIBM_H */
|