i386-interix.h revision 117395
1244158Sdteske/* Target definitions for GNU compiler for Intel 80386 running Interix 2222417Sjulian Parts Copyright (C) 1991, 1999, 2000, 2002 Free Software Foundation, Inc. 3222417Sjulian 4222417Sjulian Parts: 5222417Sjulian by Douglas B. Rupp (drupp@cs.washington.edu). 6222417Sjulian by Ron Guilmette (rfg@netcom.com). 7222417Sjulian by Donn Terry (donn@softway.com). 8222417Sjulian by Mumit Khan (khan@xraylith.wisc.edu). 9222417Sjulian 10222417SjulianThis file is part of GNU CC. 11222417Sjulian 12222417SjulianGNU CC is free software; you can redistribute it and/or modify 13222417Sjulianit under the terms of the GNU General Public License as published by 14222417Sjulianthe Free Software Foundation; either version 2, or (at your option) 15222417Sjulianany later version. 16222417Sjulian 17222417SjulianGNU CC is distributed in the hope that it will be useful, 18222417Sjulianbut WITHOUT ANY WARRANTY; without even the implied warranty of 19222417SjulianMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20222417SjulianGNU General Public License for more details. 21222417Sjulian 22222417SjulianYou should have received a copy of the GNU General Public License 23222417Sjulianalong with GNU CC; see the file COPYING. If not, write to 24222417Sjulianthe Free Software Foundation, 59 Temple Place - Suite 330, 25222417SjulianBoston, MA 02111-1307, USA. */ 26222417Sjulian 27271135Semaste/* The rest must follow. */ 28222417Sjulian 29222417Sjulian#define DBX_DEBUGGING_INFO 1 30222417Sjulian#define SDB_DEBUGGING_INFO 1 31222417Sjulian#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG 32235873Swblock 33222417Sjulian#define HANDLE_SYSV_PRAGMA 1 34222417Sjulian#undef HANDLE_PRAGMA_WEAK /* until the link format can handle it */ 35222417Sjulian 36222417Sjulian/* By default, target has a 80387, uses IEEE compatible arithmetic, 37222417Sjulian and returns float values in the 387 and needs stack probes 38222417Sjulian We also align doubles to 64-bits for MSVC default compatibility */ 39222417Sjulian#undef TARGET_SUBTARGET_DEFAULT 40222417Sjulian#define TARGET_SUBTARGET_DEFAULT \ 41222417Sjulian (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE | \ 42222417Sjulian MASK_ALIGN_DOUBLE) 43222417Sjulian 44222417Sjulian#undef TARGET_CPU_DEFAULT 45222417Sjulian#define TARGET_CPU_DEFAULT 2 /* 486 */ 46222417Sjulian 47222417Sjulian#define WCHAR_TYPE_SIZE 16 48222417Sjulian#define WCHAR_TYPE "short unsigned int" 49222417Sjulian 50222417Sjulian/* WinNT (and thus Interix) use unsigned int */ 51222417Sjulian#define SIZE_TYPE "unsigned int" 52222417Sjulian 53222417Sjulian#define ASM_LOAD_ADDR(loc, reg) " leal " #loc "," #reg "\n" 54222417Sjulian 55222417Sjulian/* cpp handles __STDC__ */ 56222417Sjulian#define TARGET_OS_CPP_BUILTINS() \ 57222417Sjulian do \ 58222417Sjulian { \ 59222417Sjulian builtin_define ("__INTERIX"); \ 60222417Sjulian builtin_define ("__OPENNT"); \ 61222417Sjulian builtin_define ("_M_IX86=300"); \ 62222417Sjulian builtin_define ("_X86_=1"); \ 63222417Sjulian builtin_define ("__stdcall=__attribute__((__stdcall__))"); \ 64222417Sjulian builtin_define ("__cdecl=__attribute__((__cdecl__))"); \ 65222417Sjulian builtin_define ("__declspec(x)=__attribute__((x))"); \ 66222417Sjulian builtin_assert ("system=unix"); \ 67222417Sjulian builtin_assert ("system=interix"); \ 68222417Sjulian if (preprocessing_asm_p ()) \ 69222417Sjulian builtin_define_std ("LANGUAGE_ASSEMBLY"); \ 70222417Sjulian else \ 71222417Sjulian { \ 72222417Sjulian builtin_define_std ("LANGUAGE_C"); \ 73222417Sjulian if (c_language == clk_cplusplus) \ 74222417Sjulian builtin_define_std ("LANGUAGE_C_PLUS_PLUS"); \ 75222417Sjulian if (flag_objc) \ 76222417Sjulian builtin_define_std ("LANGUAGE_OBJECTIVE_C"); \ 77222417Sjulian } \ 78222417Sjulian } \ 79222417Sjulian while (0) 80222417Sjulian 81222417Sjulian#undef CPP_SPEC 82222417Sjulian/* Write out the correct language type definition for the header files. 83222417Sjulian Unless we have assembler language, write out the symbols for C. 84222417Sjulian mieee is an Alpha specific variant. Cross polination a bad idea. 85222417Sjulian */ 86222417Sjulian#define CPP_SPEC "-remap %{posix:-D_POSIX_SOURCE} \ 87222417Sjulian-isystem %$INTERIX_ROOT/usr/include" 88222417Sjulian 89222417Sjulian#define TARGET_VERSION fprintf (stderr, " (i386 Interix)"); 90222417Sjulian 91222417Sjulian/* The global __fltused is necessary to cause the printf/scanf routines 92222417Sjulian for outputting/inputting floating point numbers to be loaded. Since this 93222417Sjulian is kind of hard to detect, we just do it all the time. */ 94222417Sjulian 95222417Sjulian#ifdef ASM_FILE_START 96222417Sjulian#undef ASM_FILE_START 97244158Sdteske#endif 98244158Sdteske#define ASM_FILE_START(FILE) \ 99244158Sdteske do { fprintf (FILE, "\t.file\t"); \ 100222417Sjulian output_quoted_string (FILE, dump_base_name); \ 101222417Sjulian fprintf (FILE, "\n"); \ 102222417Sjulian fprintf (FILE, ".global\t__fltused\n"); \ 103222417Sjulian } while (0) 104222417Sjulian 105222417Sjulian/* A table of bytes codes used by the ASM_OUTPUT_ASCII and 106222417Sjulian ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table 107222417Sjulian corresponds to a particular byte value [0..255]. For any 108222417Sjulian given byte value, if the value in the corresponding table 109222417Sjulian position is zero, the given character can be output directly. 110222417Sjulian If the table value is 1, the byte must be output as a \ooo 111222417Sjulian octal escape. If the tables value is anything else, then the 112222417Sjulian byte value should be output as a \ followed by the value 113222417Sjulian in the table. Note that we can use standard UN*X escape 114222417Sjulian sequences for many control characters, but we don't use 115222417Sjulian \a to represent BEL because some svr4 assemblers (e.g. on 116222417Sjulian the i386) don't know about that. Also, we don't use \v 117222417Sjulian since some versions of gas, such as 2.2 did not accept it. */ 118222417Sjulian 119222417Sjulian#define ESCAPES \ 120222417Sjulian"\1\1\1\1\1\1\1\1btn\1fr\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\ 121222417Sjulian\0\0\"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ 122271135Semaste\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\0\0\0\ 123271135Semaste\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\ 124222417Sjulian\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\ 125222417Sjulian\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\ 126222417Sjulian\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\ 127222417Sjulian\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1" 128222417Sjulian 129222417Sjulian/* Some svr4 assemblers have a limit on the number of characters which 130222417Sjulian can appear in the operand of a .string directive. If your assembler 131222417Sjulian has such a limitation, you should define STRING_LIMIT to reflect that 132222417Sjulian limit. Note that at least some svr4 assemblers have a limit on the 133222417Sjulian actual number of bytes in the double-quoted string, and that they 134222417Sjulian count each character in an escape sequence as one byte. Thus, an 135222417Sjulian escape sequence like \377 would count as four bytes. 136222417Sjulian 137222417Sjulian If your target assembler doesn't support the .string directive, you 138222417Sjulian should define this to zero. 139222417Sjulian*/ 140222417Sjulian 141222417Sjulian#define STRING_LIMIT ((unsigned) 256) 142222417Sjulian 143222417Sjulian#define STRING_ASM_OP "\t.string\t" 144222417Sjulian 145222417Sjulian/* The routine used to output NUL terminated strings. We use a special 146222417Sjulian version of this for most svr4 targets because doing so makes the 147222417Sjulian generated assembly code more compact (and thus faster to assemble) 148222417Sjulian as well as more readable, especially for targets like the i386 149222417Sjulian (where the only alternative is to output character sequences as 150222417Sjulian comma separated lists of numbers). */ 151222417Sjulian 152222417Sjulian#define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \ 153222417Sjulian do \ 154222417Sjulian { \ 155222417Sjulian register const unsigned char *_limited_str = \ 156222417Sjulian (const unsigned char *) (STR); \ 157222417Sjulian register unsigned ch; \ 158222417Sjulian fprintf ((FILE), "%s\"", STRING_ASM_OP); \ 159222417Sjulian for (; (ch = *_limited_str); _limited_str++) \ 160222417Sjulian { \ 161222417Sjulian register int escape = ESCAPES[ch]; \ 162222417Sjulian switch (escape) \ 163222417Sjulian { \ 164222417Sjulian case 0: \ 165222417Sjulian putc (ch, (FILE)); \ 166222417Sjulian break; \ 167222417Sjulian case 1: \ 168222417Sjulian fprintf ((FILE), "\\%03o", ch); \ 169222417Sjulian break; \ 170222417Sjulian default: \ 171222417Sjulian putc ('\\', (FILE)); \ 172222417Sjulian putc (escape, (FILE)); \ 173222417Sjulian break; \ 174238431Sdteske } \ 175 } \ 176 fprintf ((FILE), "\"\n"); \ 177 } \ 178 while (0) 179 180/* The routine used to output sequences of byte values. We use a special 181 version of this for most svr4 targets because doing so makes the 182 generated assembly code more compact (and thus faster to assemble) 183 as well as more readable. Note that if we find subparts of the 184 character sequence which end with NUL (and which are shorter than 185 STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */ 186 187#undef ASM_OUTPUT_ASCII 188#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \ 189 do \ 190 { \ 191 register const unsigned char *_ascii_bytes = \ 192 (const unsigned char *) (STR); \ 193 register const unsigned char *limit = _ascii_bytes + (LENGTH); \ 194 register unsigned bytes_in_chunk = 0; \ 195 for (; _ascii_bytes < limit; _ascii_bytes++) \ 196 { \ 197 register const unsigned char *p; \ 198 if (bytes_in_chunk >= 64) \ 199 { \ 200 fputc ('\n', (FILE)); \ 201 bytes_in_chunk = 0; \ 202 } \ 203 for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \ 204 continue; \ 205 if (p < limit && (p - _ascii_bytes) <= (long) STRING_LIMIT) \ 206 { \ 207 if (bytes_in_chunk > 0) \ 208 { \ 209 fputc ('\n', (FILE)); \ 210 bytes_in_chunk = 0; \ 211 } \ 212 ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \ 213 _ascii_bytes = p; \ 214 } \ 215 else \ 216 { \ 217 if (bytes_in_chunk == 0) \ 218 fprintf ((FILE), "\t.byte\t"); \ 219 else \ 220 fputc (',', (FILE)); \ 221 fprintf ((FILE), "0x%02x", *_ascii_bytes); \ 222 bytes_in_chunk += 5; \ 223 } \ 224 } \ 225 if (bytes_in_chunk > 0) \ 226 fprintf ((FILE), "\n"); \ 227 } \ 228 while (0) 229 230/* Emit code to check the stack when allocating more that 4000 231 bytes in one go. */ 232 233#define CHECK_STACK_LIMIT 0x1000 234 235/* the following are OSF linker (not gld) specific... we don't want them */ 236#undef HAS_INIT_SECTION 237#undef LD_INIT_SWITCH 238#undef LD_FINI_SWITCH 239 240/* The following are needed for us to be able to use winnt.c, but are not 241 otherwise meaningful to Interix. (The functions that use these are 242 never called because we don't do DLLs.) */ 243#define TARGET_NOP_FUN_DLLIMPORT 1 244#define drectve_section() /* nothing */ 245 246#define EH_FRAME_IN_DATA_SECTION 247 248#define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rdata,\"r\"" 249 250/* The MS compilers take alignment as a number of bytes, so we do as well */ 251#undef ASM_OUTPUT_ALIGN 252#define ASM_OUTPUT_ALIGN(FILE,LOG) \ 253 if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1<<(LOG)) 254 255/* The linker will take care of this, and having them causes problems with 256 ld -r (specifically -rU). */ 257#define CTOR_LISTS_DEFINED_EXTERNALLY 1 258 259#define SET_ASM_OP "\t.set\t" 260/* Output a definition (implements alias) */ 261#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ 262do \ 263{ \ 264 fprintf ((FILE), "%s", SET_ASM_OP); \ 265 assemble_name (FILE, LABEL1); \ 266 fprintf (FILE, ","); \ 267 assemble_name (FILE, LABEL2); \ 268 fprintf (FILE, "\n"); \ 269 } \ 270while (0) 271 272#define HOST_PTR_PRINTF "%p" 273#define HOST_PTR_AS_INT unsigned long 274 275#define PCC_BITFIELD_TYPE_MATTERS 1 276#define PCC_BITFIELD_TYPE_TEST TYPE_NATIVE(rec) 277#define GROUP_BITFIELDS_BY_ALIGN TYPE_NATIVE(rec) 278 279/* The following two flags are usually "off" for i386, because some non-gnu 280 tools (for the i386) don't handle them. However, we don't have that 281 problem, so.... */ 282 283/* Forward references to tags are allowed. */ 284#define SDB_ALLOW_FORWARD_REFERENCES 285 286/* Unknown tags are also allowed. */ 287#define SDB_ALLOW_UNKNOWN_REFERENCES 288 289/* The integer half of this list needs to be constant. However, there's 290 a lot of disagreement about what the floating point adjustments should 291 be. We pick one that works with gdb. (The underlying problem is 292 what to do about the segment registers. Since we have access to them 293 from /proc, we'll allow them to be accessed in gdb, even tho the 294 gcc compiler can't generate them. (There's some evidence that 295 MSVC does, but possibly only for certain special "canned" sequences.) */ 296 297#undef DBX_REGISTER_NUMBER 298#define DBX_REGISTER_NUMBER(n) \ 299(TARGET_64BIT ? dbx64_register_map[n] \ 300 : (n) == 0 ? 0 \ 301 : (n) == 1 ? 2 \ 302 : (n) == 2 ? 1 \ 303 : (n) == 3 ? 3 \ 304 : (n) == 4 ? 6 \ 305 : (n) == 5 ? 7 \ 306 : (n) == 6 ? 5 \ 307 : (n) == 7 ? 4 \ 308 : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+8 \ 309 : (-1)) 310 311/* Define this macro if references to a symbol must be treated 312 differently depending on something about the variable or 313 function named by the symbol (such as what section it is in). */ 314 315#undef TARGET_ENCODE_SECTION_INFO 316#define TARGET_ENCODE_SECTION_INFO i386_pe_encode_section_info 317#undef TARGET_STRIP_NAME_ENCODING 318#define TARGET_STRIP_NAME_ENCODING i386_pe_strip_name_encoding_full 319 320#if 0 321/* Turn this back on when the linker is updated to handle grouped 322 .data$ sections correctly. See corresponding note in i386/interix.c. 323 MK. */ 324 325/* Define this macro if in some cases global symbols from one translation 326 unit may not be bound to undefined symbols in another translation unit 327 without user intervention. For instance, under Microsoft Windows 328 symbols must be explicitly imported from shared libraries (DLLs). */ 329#define MULTIPLE_SYMBOL_SPACES 330 331extern void i386_pe_unique_section PARAMS ((tree, int)); 332#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section 333 334#define SUPPORTS_ONE_ONLY 1 335#endif /* 0 */ 336 337/* Switch into a generic section. */ 338#define TARGET_ASM_NAMED_SECTION default_pe_asm_named_section 339 340/* DWARF2 Unwinding doesn't work with exception handling yet. */ 341#define DWARF2_UNWIND_INFO 0 342 343/* Don't assume anything about the header files. */ 344#define NO_IMPLICIT_EXTERN_C 345 346/* MSVC returns structs of up to 8 bytes via registers. */ 347 348#define DEFAULT_PCC_STRUCT_RETURN 0 349 350#undef RETURN_IN_MEMORY 351#define RETURN_IN_MEMORY(TYPE) \ 352 (TYPE_MODE (TYPE) == BLKmode || \ 353 (AGGREGATE_TYPE_P (TYPE) && int_size_in_bytes(TYPE) > 8 )) 354