OSDN Git Service

* config/i386/cygming.h: Fix comment formatting.
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / i386-interix.h
1 /* Target definitions for GCC for Intel 80386 running Interix
2    Parts Copyright (C) 1991, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
3
4    Parts:
5      by Douglas B. Rupp (drupp@cs.washington.edu).
6      by Ron Guilmette (rfg@netcom.com).
7      by Donn Terry (donn@softway.com).
8      by Mumit Khan (khan@xraylith.wisc.edu).
9
10 This file is part of GCC.
11
12 GCC is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2, or (at your option)
15 any later version.
16
17 GCC is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with GCC; see the file COPYING.  If not, write to
24 the Free Software Foundation, 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.  */
26
27 /* The rest must follow.  */
28
29 #define DBX_DEBUGGING_INFO 1
30 #define SDB_DEBUGGING_INFO 1
31 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
32
33 #define HANDLE_SYSV_PRAGMA 1
34 #undef HANDLE_PRAGMA_WEAK  /* until the link format can handle it */
35
36 /* By default, target has a 80387, uses IEEE compatible arithmetic,
37    and returns float values in the 387 and needs stack probes
38    We also align doubles to 64-bits for MSVC default compatibility
39    We do bitfields MSVC-compatibly by default, too.  */
40 #undef TARGET_SUBTARGET_DEFAULT
41 #define TARGET_SUBTARGET_DEFAULT \
42    (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE | \
43     MASK_ALIGN_DOUBLE | MASK_MS_BITFIELD_LAYOUT)
44
45 #undef TARGET_CPU_DEFAULT
46 #define TARGET_CPU_DEFAULT 2 /* 486 */
47
48 #define WCHAR_TYPE_SIZE 16
49 #define WCHAR_TYPE "short unsigned int"
50
51 /* WinNT (and thus Interix) use unsigned int */
52 #define SIZE_TYPE "unsigned int"
53
54 #define ASM_LOAD_ADDR(loc, reg)   "     leal " #loc "," #reg "\n"
55
56 /* cpp handles __STDC__ */
57 #define TARGET_OS_CPP_BUILTINS()                                        \
58   do                                                                    \
59     {                                                                   \
60         builtin_define ("__INTERIX");                                   \
61         builtin_define ("__OPENNT");                                    \
62         builtin_define ("_M_IX86=300");                                 \
63         builtin_define ("_X86_=1");                                     \
64         builtin_define ("__stdcall=__attribute__((__stdcall__))");      \
65         builtin_define ("__cdecl=__attribute__((__cdecl__))");          \
66         builtin_define ("__declspec(x)=__attribute__((x))");            \
67         builtin_assert ("system=unix");                                 \
68         builtin_assert ("system=interix");                              \
69         if (preprocessing_asm_p ())                                     \
70           builtin_define_std ("LANGUAGE_ASSEMBLY");                     \
71         else                                                            \
72           {                                                             \
73              builtin_define_std ("LANGUAGE_C");                         \
74              if (c_dialect_cxx ())                                      \
75                builtin_define_std ("LANGUAGE_C_PLUS_PLUS");             \
76              if (c_dialect_objc ())                                     \
77                builtin_define_std ("LANGUAGE_OBJECTIVE_C");             \
78           }                                                             \
79     }                                                                   \
80   while (0)
81
82 #undef CPP_SPEC
83 /* Write out the correct language type definition for the header files.  
84    Unless we have assembler language, write out the symbols for C.
85    mieee is an Alpha specific variant.  Cross polination a bad idea.
86    */
87 #define CPP_SPEC "-remap %{posix:-D_POSIX_SOURCE} \
88 -isystem %$INTERIX_ROOT/usr/include"
89
90 #define TARGET_VERSION fprintf (stderr, " (i386 Interix)");
91
92 /* The global __fltused is necessary to cause the printf/scanf routines
93    for outputting/inputting floating point numbers to be loaded.  Since this
94    is kind of hard to detect, we just do it all the time.  */
95 #undef X86_FILE_START_FLTUSED
96 #define X86_FILE_START_FLTUSED 1
97
98 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
99    ASM_OUTPUT_LIMITED_STRING macros.  Each byte in the table
100    corresponds to a particular byte value [0..255].  For any
101    given byte value, if the value in the corresponding table
102    position is zero, the given character can be output directly.
103    If the table value is 1, the byte must be output as a \ooo
104    octal escape.  If the tables value is anything else, then the
105    byte value should be output as a \ followed by the value
106    in the table.  Note that we can use standard UN*X escape
107    sequences for many control characters, but we don't use
108    \a to represent BEL because some svr4 assemblers (e.g. on
109    the i386) don't know about that.  Also, we don't use \v
110    since some versions of gas, such as 2.2 did not accept it.  */
111
112 #define ESCAPES \
113 "\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\
114 \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\
115 \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\
116 \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\
117 \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\
118 \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\
119 \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\
120 \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"
121
122 /* Some svr4 assemblers have a limit on the number of characters which
123    can appear in the operand of a .string directive.  If your assembler
124    has such a limitation, you should define STRING_LIMIT to reflect that
125    limit.  Note that at least some svr4 assemblers have a limit on the
126    actual number of bytes in the double-quoted string, and that they
127    count each character in an escape sequence as one byte.  Thus, an
128    escape sequence like \377 would count as four bytes.
129
130    If your target assembler doesn't support the .string directive, you
131    should define this to zero.
132 */
133
134 #define STRING_LIMIT    ((unsigned) 256)
135
136 #define STRING_ASM_OP   "\t.string\t"
137
138 /* The routine used to output NUL terminated strings.  We use a special
139    version of this for most svr4 targets because doing so makes the
140    generated assembly code more compact (and thus faster to assemble)
141    as well as more readable, especially for targets like the i386
142    (where the only alternative is to output character sequences as
143    comma separated lists of numbers).  */
144
145 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR)                            \
146   do                                                                    \
147     {                                                                   \
148       const unsigned char *_limited_str =                               \
149         (const unsigned char *) (STR);                                  \
150       unsigned ch;                                                      \
151       fprintf ((FILE), "%s\"", STRING_ASM_OP);                          \
152       for (; (ch = *_limited_str); _limited_str++)                      \
153         {                                                               \
154           int escape = ESCAPES[ch];                                     \
155           switch (escape)                                               \
156             {                                                           \
157             case 0:                                                     \
158               putc (ch, (FILE));                                        \
159               break;                                                    \
160             case 1:                                                     \
161               fprintf ((FILE), "\\%03o", ch);                           \
162               break;                                                    \
163             default:                                                    \
164               putc ('\\', (FILE));                                      \
165               putc (escape, (FILE));                                    \
166               break;                                                    \
167             }                                                           \
168         }                                                               \
169       fprintf ((FILE), "\"\n");                                         \
170     }                                                                   \
171   while (0)
172
173 /* The routine used to output sequences of byte values.  We use a special
174    version of this for most svr4 targets because doing so makes the
175    generated assembly code more compact (and thus faster to assemble)
176    as well as more readable.  Note that if we find subparts of the
177    character sequence which end with NUL (and which are shorter than
178    STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING.  */
179
180 #undef ASM_OUTPUT_ASCII
181 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH)                             \
182   do                                                                    \
183     {                                                                   \
184       const unsigned char *_ascii_bytes =                               \
185         (const unsigned char *) (STR);                                  \
186       const unsigned char *limit = _ascii_bytes + (LENGTH);             \
187       unsigned bytes_in_chunk = 0;                                      \
188       for (; _ascii_bytes < limit; _ascii_bytes++)                      \
189         {                                                               \
190           const unsigned char *p;                                       \
191           if (bytes_in_chunk >= 64)                                     \
192             {                                                           \
193               fputc ('\n', (FILE));                                     \
194               bytes_in_chunk = 0;                                       \
195             }                                                           \
196           for (p = _ascii_bytes; p < limit && *p != '\0'; p++)          \
197             continue;                                                   \
198           if (p < limit && (p - _ascii_bytes) <= (long) STRING_LIMIT)   \
199             {                                                           \
200               if (bytes_in_chunk > 0)                                   \
201                 {                                                       \
202                   fputc ('\n', (FILE));                                 \
203                   bytes_in_chunk = 0;                                   \
204                 }                                                       \
205               ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes);         \
206               _ascii_bytes = p;                                         \
207             }                                                           \
208           else                                                          \
209             {                                                           \
210               if (bytes_in_chunk == 0)                                  \
211                 fprintf ((FILE), "\t.byte\t");                          \
212               else                                                      \
213                 fputc (',', (FILE));                                    \
214               fprintf ((FILE), "0x%02x", *_ascii_bytes);                \
215               bytes_in_chunk += 5;                                      \
216             }                                                           \
217         }                                                               \
218       if (bytes_in_chunk > 0)                                           \
219         fprintf ((FILE), "\n");                                         \
220     }                                                                   \
221   while (0)
222
223 /* Emit code to check the stack when allocating more that 4000
224    bytes in one go.  */
225
226 #define CHECK_STACK_LIMIT 0x1000
227
228 /* the following are OSF linker (not gld) specific... we don't want them */
229 #undef HAS_INIT_SECTION
230 #undef LD_INIT_SWITCH
231 #undef LD_FINI_SWITCH
232
233 /* The following are needed for us to be able to use winnt.c, but are not
234    otherwise meaningful to Interix.  (The functions that use these are
235    never called because we don't do DLLs.) */
236 #define TARGET_NOP_FUN_DLLIMPORT 1
237 #define drectve_section()  /* nothing */
238
239 /* Objective-C has its own packing rules...
240    Objc tries to parallel the code in stor-layout.c at runtime  
241    (see libobjc/encoding.c).  This (compile-time) packing info isn't 
242    available at runtime, so it's hopeless to try.
243
244    And if the user tries to set the flag for objc, give an error
245    so he has some clue.  */
246
247 #undef  SUBTARGET_OVERRIDE_OPTIONS
248 #define SUBTARGET_OVERRIDE_OPTIONS                                      \
249 do {                                                                    \
250   if (strcmp (lang_hooks.name, "GNU Objective-C") == 0)                 \
251     {                                                                   \
252       if ((target_flags & MASK_MS_BITFIELD_LAYOUT) != 0                 \
253           && (target_flags_explicit & MASK_MS_BITFIELD_LAYOUT) != 0)    \
254         {                                                               \
255            error ("ms-bitfields not supported for objc");               \
256         }                                                               \
257       target_flags &= ~MASK_MS_BITFIELD_LAYOUT;                         \
258     }                                                                   \
259 } while (0)
260
261 #define EH_FRAME_IN_DATA_SECTION
262
263 #define READONLY_DATA_SECTION_ASM_OP    "\t.section\t.rdata,\"r\""
264
265 /* The MS compilers take alignment as a number of bytes, so we do as well */
266 #undef ASM_OUTPUT_ALIGN
267 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
268   if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1<<(LOG))
269
270 /* The linker will take care of this, and having them causes problems with
271    ld -r (specifically -rU).  */
272 #define CTOR_LISTS_DEFINED_EXTERNALLY 1
273
274 #define SET_ASM_OP      "\t.set\t"
275 /* Output a definition (implements alias) */
276 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
277 do                                                                      \
278 {                                                                       \
279     fprintf ((FILE), "%s", SET_ASM_OP);                                 \
280     assemble_name (FILE, LABEL1);                                       \
281     fprintf (FILE, ",");                                                \
282     assemble_name (FILE, LABEL2);                                       \
283     fprintf (FILE, "\n");                                               \
284     }                                                                   \
285 while (0)
286
287 #define HOST_PTR_PRINTF "%p"
288 #define HOST_PTR_AS_INT unsigned long
289
290 #define PCC_BITFIELD_TYPE_MATTERS 1
291
292 /* The following two flags are usually "off" for i386, because some non-gnu
293    tools (for the i386) don't handle them.  However, we don't have that
294    problem, so....  */
295
296 /* Forward references to tags are allowed.  */
297 #define SDB_ALLOW_FORWARD_REFERENCES
298
299 /* Unknown tags are also allowed.  */
300 #define SDB_ALLOW_UNKNOWN_REFERENCES
301
302 /* The integer half of this list needs to be constant.  However, there's
303    a lot of disagreement about what the floating point adjustments should
304    be.  We pick one that works with gdb.  (The underlying problem is
305    what to do about the segment registers.  Since we have access to them
306    from /proc, we'll allow them to be accessed in gdb, even tho the
307    gcc compiler can't generate them.  (There's some evidence that 
308    MSVC does, but possibly only for certain special "canned" sequences.) */
309
310 #undef DBX_REGISTER_NUMBER
311 #define DBX_REGISTER_NUMBER(n) \
312 (TARGET_64BIT ? dbx64_register_map[n] \
313  : (n) == 0 ? 0 \
314  : (n) == 1 ? 2 \
315  : (n) == 2 ? 1 \
316  : (n) == 3 ? 3 \
317  : (n) == 4 ? 6 \
318  : (n) == 5 ? 7 \
319  : (n) == 6 ? 5 \
320  : (n) == 7 ? 4 \
321  : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+8 \
322  : (-1))
323
324 /* Define this macro if references to a symbol must be treated
325    differently depending on something about the variable or
326    function named by the symbol (such as what section it is in).  */
327
328 #undef TARGET_ENCODE_SECTION_INFO
329 #define TARGET_ENCODE_SECTION_INFO i386_pe_encode_section_info
330 #undef  TARGET_STRIP_NAME_ENCODING
331 #define TARGET_STRIP_NAME_ENCODING  i386_pe_strip_name_encoding_full
332
333 #if 0   
334 /* Turn this back on when the linker is updated to handle grouped
335    .data$ sections correctly. See corresponding note in i386/interix.c. 
336    MK.  */
337
338 /* Define this macro if in some cases global symbols from one translation
339    unit may not be bound to undefined symbols in another translation unit
340    without user intervention.  For instance, under Microsoft Windows
341    symbols must be explicitly imported from shared libraries (DLLs).  */
342 #define MULTIPLE_SYMBOL_SPACES
343
344 extern void i386_pe_unique_section (tree, int);
345 #define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
346
347 #define SUPPORTS_ONE_ONLY 1
348 #endif /* 0 */
349
350 /* Switch into a generic section.  */
351 #define TARGET_ASM_NAMED_SECTION  default_pe_asm_named_section
352
353 /* DWARF2 Unwinding doesn't work with exception handling yet.  */
354 #define DWARF2_UNWIND_INFO 0
355
356 /* Don't assume anything about the header files.  */
357 #define NO_IMPLICIT_EXTERN_C
358
359 /* MSVC returns structs of up to 8 bytes via registers.  */
360
361 #define DEFAULT_PCC_STRUCT_RETURN 0
362
363 #undef RETURN_IN_MEMORY
364 #define RETURN_IN_MEMORY(TYPE) \
365   (TYPE_MODE (TYPE) == BLKmode || \
366      (AGGREGATE_TYPE_P (TYPE) && int_size_in_bytes(TYPE) > 8 ))