2002-05-07 David S. Miller <davem@redhat.com>
[official-gcc.git] / gcc / config / sparc / sol2.h
blobf27b3ad73d23ba72d5c07f8fce1481a266579fbe
1 /* Definitions of target machine for GNU compiler, for SPARC running Solaris 2
2 Copyright 1992, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
4 Contributed by Ron Guilmette (rfg@netcom.com).
5 Additional changes by David V. Henkel-Wallace (gumby@cygnus.com).
7 This file is part of GNU CC.
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING. If not, write to
21 the Free Software Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
24 /* Supposedly the same as vanilla sparc svr4, except for the stuff below: */
26 /* Solaris 2 (at least as of 2.5.1) uses a 32-bit wchar_t. */
27 #undef WCHAR_TYPE
28 #define WCHAR_TYPE "long int"
30 #undef WCHAR_TYPE_SIZE
31 #define WCHAR_TYPE_SIZE 32
33 /* Solaris 2 uses a wint_t different from the default. This is required
34 by the SCD 2.4.1, p. 6-83, Figure 6-66. */
35 #undef WINT_TYPE
36 #define WINT_TYPE "long int"
38 #undef WINT_TYPE_SIZE
39 #define WINT_TYPE_SIZE 32
41 #define HANDLE_PRAGMA_REDEFINE_EXTNAME 1
43 #undef CPP_PREDEFINES
44 #define CPP_PREDEFINES \
45 "-Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__PRAGMA_REDEFINE_EXTNAME \
46 -Asystem=unix -Asystem=svr4"
48 #undef CPP_SUBTARGET_SPEC
49 #define CPP_SUBTARGET_SPEC "\
50 %{pthreads:-D_REENTRANT -D_PTHREADS} \
51 %{!pthreads:%{threads:-D_REENTRANT -D_SOLARIS_THREADS}} \
52 %{compat-bsd:-iwithprefixbefore ucbinclude -I/usr/ucbinclude} \
55 /* For C++ we need to add some additional macro definitions required
56 by the C++ standard library. */
57 #define CPLUSPLUS_CPP_SPEC "\
58 -D_XOPEN_SOURCE=500 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 \
59 -D__EXTENSIONS__ \
60 %(cpp) \
63 /* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
64 It's safe to pass -s always, even if -g is not used. */
65 #undef ASM_SPEC
66 #define ASM_SPEC "\
67 %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
68 %{fpic:-K PIC} %{fPIC:-K PIC} \
69 %(asm_cpu) \
72 /* This is here rather than in sparc.h because it's not known what
73 other assemblers will accept. */
74 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9
75 #undef ASM_CPU_DEFAULT_SPEC
76 #define ASM_CPU_DEFAULT_SPEC "-xarch=v8plus"
77 #endif
78 #if TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
79 #undef ASM_CPU_DEFAULT_SPEC
80 #define ASM_CPU_DEFAULT_SPEC "-xarch=v8plusa"
81 #endif
82 #undef ASM_CPU_SPEC
83 #define ASM_CPU_SPEC "\
84 %{mcpu=v8plus:-xarch=v8plus} \
85 %{mcpu=ultrasparc:-xarch=v8plusa} \
86 %{!mcpu*:%(asm_cpu_default)} \
89 /* However it appears that Solaris 2.0 uses the same reg numbering as
90 the old BSD-style system did. */
92 /* Same as sparc.h */
93 #undef DBX_REGISTER_NUMBER
94 #define DBX_REGISTER_NUMBER(REGNO) \
95 (TARGET_FLAT && (REGNO) == HARD_FRAME_POINTER_REGNUM ? 31 : REGNO)
97 /* We use stabs-in-elf by default, because that is what the native
98 toolchain uses. */
99 #undef PREFERRED_DEBUGGING_TYPE
100 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
102 /* The Solaris 2 assembler uses .skip, not .zero, so put this back. */
103 #undef ASM_OUTPUT_SKIP
104 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
105 fprintf (FILE, "\t.skip %u\n", (SIZE))
107 #undef LOCAL_LABEL_PREFIX
108 #define LOCAL_LABEL_PREFIX "."
110 /* This is how to output a definition of an internal numbered label where
111 PREFIX is the class of label and NUM is the number within the class. */
113 #undef ASM_OUTPUT_INTERNAL_LABEL
114 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
115 fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
117 /* This is how to output a reference to an internal numbered label where
118 PREFIX is the class of label and NUM is the number within the class. */
120 #undef ASM_OUTPUT_INTERNAL_LABELREF
121 #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
122 fprintf (FILE, ".L%s%d", PREFIX, NUM)
124 /* This is how to store into the string LABEL
125 the symbol_ref name of an internal numbered label where
126 PREFIX is the class of label and NUM is the number within the class.
127 This is suitable for output with `assemble_name'. */
129 #undef ASM_GENERATE_INTERNAL_LABEL
130 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
131 sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
134 /* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us.
135 We don't use the standard LIB_SPEC only because we don't yet support c++ */
137 #undef STARTFILE_SPEC
138 #define STARTFILE_SPEC "%{!shared: \
139 %{!symbolic: \
140 %{p:mcrt1.o%s} \
141 %{!p: \
142 %{pg:gcrt1.o%s gmon.o%s} \
143 %{!pg:crt1.o%s}}}} \
144 crti.o%s \
145 %{ansi:values-Xc.o%s} \
146 %{!ansi:values-Xa.o%s} \
147 crtbegin.o%s"
149 /* ??? Note: in order for -compat-bsd to work fully,
150 we must somehow arrange to fixincludes /usr/ucbinclude
151 and put the result in $(libsubdir)/ucbinclude. */
153 #undef LIB_SPEC
154 #define LIB_SPEC \
155 "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \
156 %{!shared:\
157 %{!symbolic:\
158 %{pthreads:-lpthread} \
159 %{!pthreads:%{threads:-lthread}} \
160 %{p|pg:-ldl} -lc}}"
162 #undef ENDFILE_SPEC
163 #define ENDFILE_SPEC \
164 "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
165 crtend.o%s crtn.o%s"
167 /* This should be the same as in svr4.h, except with -R added. */
168 #undef LINK_SPEC
169 #define LINK_SPEC \
170 "%{h*} %{v:-V} \
171 %{b} %{Wl,*:%*} \
172 %{static:-dn -Bstatic} \
173 %{shared:-G -dy %{!mimpure-text:-z text}} \
174 %{symbolic:-Bsymbolic -G -dy -z text} \
175 %{G:-G} \
176 %{YP,*} \
177 %{R*} \
178 %{compat-bsd: \
179 %{!YP,*:%{pg:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
180 %{!pg:%{p:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
181 %{!p:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}}} \
182 -R /usr/ucblib} \
183 %{!compat-bsd: \
184 %{!YP,*:%{pg:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
185 %{!pg:%{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
186 %{!p:-Y P,/usr/ccs/lib:/usr/lib}}}} \
187 %{Qy:} %{!Qn:-Qy}"
189 /* This defines which switch letters take arguments.
190 It is as in svr4.h but with -R added. */
192 #undef SWITCH_TAKES_ARG
193 #define SWITCH_TAKES_ARG(CHAR) \
194 (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
195 || (CHAR) == 'R' \
196 || (CHAR) == 'h' \
197 || (CHAR) == 'x' \
198 || (CHAR) == 'z')
200 /* Select a format to encode pointers in exception handling data. CODE
201 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
202 true if the symbol may be affected by dynamic relocations.
204 Some Solaris dynamic linkers don't handle unaligned section relative
205 relocs properly, so force them to be aligned. */
206 #ifndef HAVE_AS_SPARC_UA_PCREL
207 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
208 ((flag_pic || GLOBAL) ? DW_EH_PE_aligned : DW_EH_PE_absptr)
209 #endif
211 /* ??? This does not work in SunOS 4.x, so it is not enabled in sparc.h.
212 Instead, it is enabled here, because it does work under Solaris. */
213 /* Define for support of TFmode long double.
214 Sparc ABI says that long double is 4 words. */
215 #define LONG_DOUBLE_TYPE_SIZE 128
217 /* But indicate that it isn't supported by the hardware. */
218 #define WIDEST_HARDWARE_FP_SIZE 64
220 #define STDC_0_IN_SYSTEM_HEADERS 1
222 #define MULDI3_LIBCALL "__mul64"
223 #define DIVDI3_LIBCALL "__div64"
224 #define UDIVDI3_LIBCALL "__udiv64"
225 #define MODDI3_LIBCALL "__rem64"
226 #define UMODDI3_LIBCALL "__urem64"
228 /* Solaris's _Qp_* library routine implementation clobbers the output
229 memory before the inputs are fully consumed. */
231 #undef TARGET_BUGGY_QP_LIB
232 #define TARGET_BUGGY_QP_LIB 1
234 #undef INIT_SUBTARGET_OPTABS
235 #define INIT_SUBTARGET_OPTABS \
236 fixsfdi_libfunc \
237 = init_one_libfunc (TARGET_ARCH64 ? "__ftol" : "__ftoll"); \
238 fixunssfdi_libfunc \
239 = init_one_libfunc (TARGET_ARCH64 ? "__ftoul" : "__ftoull"); \
240 fixdfdi_libfunc \
241 = init_one_libfunc (TARGET_ARCH64 ? "__dtol" : "__dtoll"); \
242 fixunsdfdi_libfunc \
243 = init_one_libfunc (TARGET_ARCH64 ? "__dtoul" : "__dtoull")
245 /* Solaris allows 64 bit out and global registers in 32 bit mode.
246 sparc_override_options will disable V8+ if not generating V9 code. */
247 #undef TARGET_DEFAULT
248 #define TARGET_DEFAULT (MASK_FPU + MASK_V8PLUS + MASK_LONG_DOUBLE_128)
251 * Attempt to turn on access permissions for the stack.
253 * This code must be defined when compiling gcc but not when compiling
254 * libgcc2.a, unless we're generating code for 64 bits SPARC
256 * _SC_STACK_PROT is only defined for post 2.6, but we want this code
257 * to run always. 2.6 can change the stack protection but has no way to
258 * query it.
262 /* This declares mprotect (used in TRANSFER_FROM_TRAMPOLINE) for
263 libgcc2.c. */
264 /* We don't want to include this because sys/mman.h is not present on
265 some non-Solaris configurations that use sol2.h. */
266 #if 0 /* def L_trampoline */
267 #include <sys/mman.h>
268 #endif
270 #define TRANSFER_FROM_TRAMPOLINE \
271 static int need_enable_exec_stack; \
273 static void check_enabling(void) __attribute__ ((constructor)); \
274 static void check_enabling(void) \
276 extern long sysconf(int); \
278 int prot = (int) sysconf(515 /*_SC_STACK_PROT */); \
279 if (prot != 7) \
280 need_enable_exec_stack = 1; \
283 extern void __enable_execute_stack (void *); \
284 void \
285 __enable_execute_stack (addr) \
286 void *addr; \
288 if (!need_enable_exec_stack) \
289 return; \
290 else { \
291 long size = getpagesize (); \
292 long mask = ~(size-1); \
293 char *page = (char *) (((long) addr) & mask); \
294 char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
296 /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */ \
297 if (mprotect (page, end - page, 7) < 0) \
298 perror ("mprotect of trampoline code"); \