| 1 | /* Operating system specific defines to be used when targeting GCC for |
| 2 | sparc-rtems system. |
| 3 | Copyright 2003 Free Software Foundation, Inc. |
| 4 | |
| 5 | This file is part of GNU CC. |
| 6 | |
| 7 | GNU CC is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 2, or (at your option) |
| 10 | any later version. |
| 11 | |
| 12 | GNU CC is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with GNU CC; see the file COPYING. If not, write to |
| 19 | the Free Software Foundation, 59 Temple Place - Suite 330, |
| 20 | Boston, MA 02111-1307, USA. */ |
| 21 | |
| 22 | /* We use stabs-in-elf for debugging, because that is what the native |
| 23 | toolchain uses. */ |
| 24 | #undef PREFERRED_DEBUGGING_TYPE |
| 25 | #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG |
| 26 | |
| 27 | /* Solaris 2 (at least as of 2.5.1) uses a 32-bit wchar_t. */ |
| 28 | #undef WCHAR_TYPE |
| 29 | #define WCHAR_TYPE "long int" |
| 30 | |
| 31 | #undef WCHAR_TYPE_SIZE |
| 32 | #define WCHAR_TYPE_SIZE BITS_PER_WORD |
| 33 | |
| 34 | /* Solaris 2 uses a wint_t different from the default. This is required |
| 35 | by the SCD 2.4.1, p. 6-83, Figure 6-66. */ |
| 36 | #undef WINT_TYPE |
| 37 | #define WINT_TYPE "long int" |
| 38 | |
| 39 | #undef WINT_TYPE_SIZE |
| 40 | #define WINT_TYPE_SIZE BITS_PER_WORD |
| 41 | |
| 42 | #define HANDLE_PRAGMA_REDEFINE_EXTNAME 1 |
| 43 | |
| 44 | /* ??? Note: in order for -compat-bsd to work fully, |
| 45 | we must somehow arrange to fixincludes /usr/ucbinclude |
| 46 | and put the result in $(libsubdir)/ucbinclude. */ |
| 47 | |
| 48 | #if NOTUSED |
| 49 | #undef CPP_SUBTARGET_SPEC |
| 50 | #define CPP_SUBTARGET_SPEC "\ |
| 51 | %{pthreads:-D_REENTRANT -D_PTHREADS} \ |
| 52 | %{!pthreads:%{threads:-D_REENTRANT -D_SOLARIS_THREADS}} \ |
| 53 | %{compat-bsd:-iwithprefixbefore ucbinclude -I/usr/ucbinclude} \ |
| 54 | " |
| 55 | #endif |
| 56 | |
| 57 | #if NOTUSED |
| 58 | /* Names to predefine in the preprocessor for this target machine. */ |
| 59 | #define TARGET_OS_CPP_BUILTINS() \ |
| 60 | do { \ |
| 61 | builtin_define_std ("unix"); \ |
| 62 | builtin_define_std ("sun"); \ |
| 63 | builtin_define ("__svr4__"); \ |
| 64 | builtin_define ("__SVR4"); \ |
| 65 | builtin_define ("__PRAGMA_REDEFINE_EXTNAME"); \ |
| 66 | builtin_assert ("system=unix"); \ |
| 67 | builtin_assert ("system=svr4"); \ |
| 68 | /* For C++ we need to add some additional macro \ |
| 69 | definitions required by the C++ standard \ |
| 70 | library. */ \ |
| 71 | if (c_language == clk_cplusplus) \ |
| 72 | { \ |
| 73 | builtin_define ("_XOPEN_SOURCE=500"); \ |
| 74 | builtin_define ("_LARGEFILE_SOURCE=1"); \ |
| 75 | builtin_define ("_LARGEFILE64_SOURCE=1"); \ |
| 76 | builtin_define ("__EXTENSIONS__"); \ |
| 77 | } \ |
| 78 | } while (0) |
| 79 | #endif |
| 80 | |
| 81 | #if NOTUSED |
| 82 | /* The sun bundled assembler doesn't accept -Yd, (and neither does gas). |
| 83 | It's safe to pass -s always, even if -g is not used. */ |
| 84 | #undef ASM_SPEC |
| 85 | #define ASM_SPEC "\ |
| 86 | %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \ |
| 87 | %{fpic:-K PIC} %{fPIC:-K PIC} \ |
| 88 | %(asm_cpu) \ |
| 89 | " |
| 90 | #endif |
| 91 | |
| 92 | #if NOTUSED |
| 93 | /* We don't use the standard LIB_SPEC only because we don't yet support c++. */ |
| 94 | #undef LIB_SPEC |
| 95 | #define LIB_SPEC \ |
| 96 | "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \ |
| 97 | %{!shared:\ |
| 98 | %{!symbolic:\ |
| 99 | %{pthreads:-lpthread} \ |
| 100 | %{!pthreads:%{threads:-lthread}} \ |
| 101 | -ldl -lc}}" |
| 102 | #endif |
| 103 | |
| 104 | #if NOTUSED |
| 105 | #undef ENDFILE_SPEC |
| 106 | #define ENDFILE_SPEC "crtend.o%s crtn.o%s" |
| 107 | |
| 108 | /* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us. */ |
| 109 | #undef STARTFILE_SPEC |
| 110 | #define STARTFILE_SPEC "%{!shared: \ |
| 111 | %{!symbolic: \ |
| 112 | %{p:mcrt1.o%s} \ |
| 113 | %{!p: \ |
| 114 | %{pg:gcrt1.o%s gmon.o%s} \ |
| 115 | %{!pg:crt1.o%s}}}} \ |
| 116 | crti.o%s %(startfile_arch) \ |
| 117 | crtbegin.o%s" |
| 118 | |
| 119 | #undef STARTFILE_ARCH32_SPEC |
| 120 | #define STARTFILE_ARCH32_SPEC "%{ansi:values-Xc.o%s} \ |
| 121 | %{!ansi:values-Xa.o%s}" |
| 122 | |
| 123 | #undef STARTFILE_ARCH_SPEC |
| 124 | #define STARTFILE_ARCH_SPEC STARTFILE_ARCH32_SPEC |
| 125 | #endif |
| 126 | |
| 127 | #if NOTUSED |
| 128 | #undef LINK_ARCH32_SPEC |
| 129 | #define LINK_ARCH32_SPEC \ |
| 130 | "%{G:-G} \ |
| 131 | %{YP,*} \ |
| 132 | %{R*} \ |
| 133 | %{compat-bsd: \ |
| 134 | %{!YP,*:%{p|pg:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \ |
| 135 | %{!p:%{!pg:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}}} \ |
| 136 | -R /usr/ucblib} \ |
| 137 | %{!compat-bsd: \ |
| 138 | %{!YP,*:%{p|pg:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \ |
| 139 | %{!p:%{!pg:-Y P,/usr/ccs/lib:/usr/lib}}}}" |
| 140 | |
| 141 | #undef LINK_ARCH_SPEC |
| 142 | #define LINK_ARCH_SPEC LINK_ARCH32_SPEC |
| 143 | #endif /* NOTUSED */ |
| 144 | |
| 145 | #if NOTUSED |
| 146 | /* This should be the same as in svr4.h, except with -R added. */ |
| 147 | #undef LINK_SPEC |
| 148 | #define LINK_SPEC \ |
| 149 | "%{h*} %{v:-V} \ |
| 150 | %{b} %{Wl,*:%*} \ |
| 151 | %{static:-dn -Bstatic} \ |
| 152 | %{shared:-G -dy %{!mimpure-text:-z text}} \ |
| 153 | %{symbolic:-Bsymbolic -G -dy -z text} \ |
| 154 | %(link_arch) \ |
| 155 | %{Qy:} %{!Qn:-Qy}" |
| 156 | #endif |
| 157 | |
| 158 | /* This defines which switch letters take arguments. |
| 159 | It is as in svr4.h but with -R added. */ |
| 160 | #undef SWITCH_TAKES_ARG |
| 161 | #define SWITCH_TAKES_ARG(CHAR) \ |
| 162 | (DEFAULT_SWITCH_TAKES_ARG(CHAR) \ |
| 163 | || (CHAR) == 'R' \ |
| 164 | || (CHAR) == 'h' \ |
| 165 | || (CHAR) == 'z') |
| 166 | #if NOTUSED |
| 167 | #define STDC_0_IN_SYSTEM_HEADERS 1 |
| 168 | #endif /* NOTUSED */ |
| 169 | |
| 171 | /* |
| 172 | * Attempt to turn on access permissions for the stack. |
| 173 | * |
| 174 | * This code must be defined when compiling gcc but not when compiling |
| 175 | * libgcc2.a, unless we're generating code for 64-bit SPARC |
| 176 | * |
| 177 | * _SC_STACK_PROT is only defined for post 2.6, but we want this code |
| 178 | * to run always. 2.6 can change the stack protection but has no way to |
| 179 | * query it. |
| 180 | * |
| 181 | */ |
| 182 | |
| 183 | /* This declares mprotect (used in TRANSFER_FROM_TRAMPOLINE) for |
| 184 | libgcc2.c. */ |
| 185 | /* We don't want to include this because sys/mman.h is not present on |
| 186 | some non-Solaris configurations that use sol2.h. */ |
| 187 | #if 0 /* def L_trampoline */ |
| 188 | #include <sys/mman.h> |
| 189 | #endif |
| 190 | |
| 191 | #define TRANSFER_FROM_TRAMPOLINE \ |
| 192 | \ |
| 193 | /* #define STACK_PROT_RWX (PROT_READ | PROT_WRITE | PROT_EXEC) */ \ |
| 194 | \ |
| 195 | static int need_enable_exec_stack; \ |
| 196 | \ |
| 197 | static void check_enabling(void) __attribute__ ((constructor)); \ |
| 198 | static void check_enabling(void) \ |
| 199 | { \ |
| 200 | extern long sysconf(int); \ |
| 201 | \ |
| 202 | int prot = (int) sysconf(515 /* _SC_STACK_PROT */); \ |
| 203 | if (prot != 7 /* STACK_PROT_RWX */) \ |
| 204 | need_enable_exec_stack = 1; \ |
| 205 | } \ |
| 206 | \ |
| 207 | extern void __enable_execute_stack (void *); \ |
| 208 | void \ |
| 209 | __enable_execute_stack (addr) \ |
| 210 | void *addr; \ |
| 211 | { \ |
| 212 | if (!need_enable_exec_stack) \ |
| 213 | return; \ |
| 214 | else { \ |
| 215 | long size = getpagesize (); \ |
| 216 | long mask = ~(size-1); \ |
| 217 | char *page = (char *) (((long) addr) & mask); \ |
| 218 | char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \ |
| 219 | \ |
| 220 | if (mprotect (page, end - page, 7 /* STACK_PROT_RWX */) < 0) \ |
| 221 | perror ("mprotect of trampoline code"); \ |
| 222 | } \ |
| 223 | } |
| 224 | /* Definitions of target machine for GNU compiler, for SPARC running Solaris 2 |
| 225 | Copyright 1992, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 |
| 226 | Free Software Foundation, Inc. |
| 227 | Contributed by Ron Guilmette (rfg@netcom.com). |
| 228 | Additional changes by David V. Henkel-Wallace (gumby@cygnus.com). |
| 229 | |
| 230 | This file is part of GNU CC. |
| 231 | |
| 232 | GNU CC is free software; you can redistribute it and/or modify |
| 233 | it under the terms of the GNU General Public License as published by |
| 234 | the Free Software Foundation; either version 2, or (at your option) |
| 235 | any later version. |
| 236 | |
| 237 | GNU CC is distributed in the hope that it will be useful, |
| 238 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 239 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 240 | GNU General Public License for more details. |
| 241 | |
| 242 | You should have received a copy of the GNU General Public License |
| 243 | along with GNU CC; see the file COPYING. If not, write to |
| 244 | the Free Software Foundation, 59 Temple Place - Suite 330, |
| 245 | Boston, MA 02111-1307, USA. */ |
| 246 | |
| 247 | #if NOTUSED |
| 248 | /* Supposedly the same as vanilla sparc svr4, except for the stuff below: */ |
| 249 | |
| 250 | #undef CPP_PREDEFINES |
| 251 | #define CPP_PREDEFINES "-Dsparc" |
| 252 | #endif |
| 253 | |
| 254 | /* This is here rather than in sparc.h because it's not known what |
| 255 | other assemblers will accept. */ |
| 256 | |
| 257 | #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 |
| 258 | #undef ASM_CPU_DEFAULT_SPEC |
| 259 | #define ASM_CPU_DEFAULT_SPEC "-xarch=v8plus" |
| 260 | #endif |
| 261 | |
| 262 | #if TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc |
| 263 | #undef ASM_CPU_DEFAULT_SPEC |
| 264 | #define ASM_CPU_DEFAULT_SPEC "-xarch=v8plusa" |
| 265 | #endif |
| 266 | |
| 267 | #undef ASM_CPU_SPEC |
| 268 | #define ASM_CPU_SPEC "\ |
| 269 | %{mcpu=v8plus:-xarch=v8plus} \ |
| 270 | %{mcpu=v9:-xarch=v8plus} \ |
| 271 | %{mcpu=ultrasparc:-xarch=v8plusa} \ |
| 272 | %{!mcpu*:%(asm_cpu_default)} \ |
| 273 | " |
| 274 | |
| 275 | #if NOTUSED |
| 276 | #undef SUBTARGET_EXTRA_SPECS |
| 277 | #define SUBTARGET_EXTRA_SPECS \ |
| 278 | { "startfile_arch", STARTFILE_ARCH_SPEC }, \ |
| 279 | { "link_arch", LINK_ARCH_SPEC } |
| 280 | #endif |
| 281 | |
| 282 | /* However it appears that Solaris 2.0 uses the same reg numbering as |
| 283 | the old BSD-style system did. */ |
| 284 | |
| 285 | /* Same as sparc.h */ |
| 286 | #undef DBX_REGISTER_NUMBER |
| 287 | #define DBX_REGISTER_NUMBER(REGNO) \ |
| 288 | (TARGET_FLAT && (REGNO) == HARD_FRAME_POINTER_REGNUM ? 31 : REGNO) |
| 289 | |
| 290 | /* The Solaris 2 assembler uses .skip, not .zero, so put this back. */ |
| 291 | #undef ASM_OUTPUT_SKIP |
| 292 | #define ASM_OUTPUT_SKIP(FILE,SIZE) \ |
| 293 | fprintf (FILE, "\t.skip %u\n", (SIZE)) |
| 294 | |
| 295 | #undef LOCAL_LABEL_PREFIX |
| 296 | #define LOCAL_LABEL_PREFIX "." |
| 297 | |
| 298 | /* This is how to output a definition of an internal numbered label where |
| 299 | PREFIX is the class of label and NUM is the number within the class. */ |
| 300 | |
| 301 | #undef ASM_OUTPUT_INTERNAL_LABEL |
| 302 | #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ |
| 303 | fprintf (FILE, ".L%s%d:\n", PREFIX, NUM) |
| 304 | |
| 305 | /* This is how to output a reference to an internal numbered label where |
| 306 | PREFIX is the class of label and NUM is the number within the class. */ |
| 307 | |
| 308 | #undef ASM_OUTPUT_INTERNAL_LABELREF |
| 309 | #define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \ |
| 310 | fprintf (FILE, ".L%s%d", PREFIX, NUM) |
| 311 | |
| 312 | /* This is how to store into the string LABEL |
| 313 | the symbol_ref name of an internal numbered label where |
| 314 | PREFIX is the class of label and NUM is the number within the class. |
| 315 | This is suitable for output with `assemble_name'. */ |
| 316 | |
| 317 | #undef ASM_GENERATE_INTERNAL_LABEL |
| 318 | #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ |
| 319 | sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM)) |
| 320 | |
| 321 | |
| 342 | /* ??? This does not work in SunOS 4.x, so it is not enabled in sparc.h. |
| 343 | Instead, it is enabled here, because it does work under Solaris. */ |
| 344 | /* Define for support of TFmode long double. |
| 345 | SPARC ABI says that long double is 4 words. */ |
| 346 | /* FIXME: This conflicts with LONG_DOUBLE_TYPE_SIZE in elf.h */ |
| 347 | #if NOTUSED |
| 348 | #undef LONG_DOUBLE_TYPE_SIZE |
| 349 | #define LONG_DOUBLE_TYPE_SIZE 128 |
| 350 | #endif |
| 351 | |
| 352 | /* But indicate that it isn't supported by the hardware. */ |
| 353 | #define WIDEST_HARDWARE_FP_SIZE 64 |
| 354 | |
| 355 | #if NOTUSED |
| 356 | #define MULDI3_LIBCALL "__mul64" |
| 357 | #define DIVDI3_LIBCALL "__div64" |
| 358 | #define UDIVDI3_LIBCALL "__udiv64" |
| 359 | #define MODDI3_LIBCALL "__rem64" |
| 360 | #define UMODDI3_LIBCALL "__urem64" |
| 361 | #endif |
| 362 | |
| 363 | #if NOTUSED |
| 364 | /* Solaris's _Qp_* library routine implementation clobbers the output |
| 365 | memory before the inputs are fully consumed. */ |
| 366 | |
| 367 | #undef TARGET_BUGGY_QP_LIB |
| 368 | #define TARGET_BUGGY_QP_LIB 1 |
| 369 | #endif |
| 370 | |
| 371 | #undef INIT_SUBTARGET_OPTABS |
| 372 | #define INIT_SUBTARGET_OPTABS \ |
| 373 | fixsfdi_libfunc \ |
| 374 | = init_one_libfunc (TARGET_ARCH64 ? "__ftol" : "__ftoll"); \ |
| 375 | fixunssfdi_libfunc \ |
| 376 | = init_one_libfunc (TARGET_ARCH64 ? "__ftoul" : "__ftoull"); \ |
| 377 | fixdfdi_libfunc \ |
| 378 | = init_one_libfunc (TARGET_ARCH64 ? "__dtol" : "__dtoll"); \ |
| 379 | fixunsdfdi_libfunc \ |
| 380 | = init_one_libfunc (TARGET_ARCH64 ? "__dtoul" : "__dtoull") |
| 381 | |
| 382 | /* Solaris allows 64 bit out and global registers in 32 bit mode. |