536b91c6ca01c0f25f8bed558fae310d22627f5e
[gcc.git] / gcc / config / i386 / cygwin32.h
1 /* Operating system specific defines to be used when targeting GCC for
2 hosting on Windows NT 3.x, using a Unix style C library and tools,
3 as distinct from winnt.h, which is used to build GCC for use with a
4 windows style library and tool set and uses the Microsoft tools.
5 Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
6
7 This file is part of GNU CC.
8
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.
13
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.
18
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. */
23
24
25 #define YES_UNDERSCORES
26
27 #define DBX_DEBUGGING_INFO
28 #define SDB_DEBUGGING_INFO
29 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
30
31 #include "i386/gas.h"
32 #include "dbxcoff.h"
33
34 #ifdef CPP_PREDEFINES
35 #undef CPP_PREDEFINES
36 #endif
37
38 #define CPP_PREDEFINES "-Di386 -D_WIN32 \
39 -D__CYGWIN32__ -DWINNT -D_X86_=1 -D__STDC__=1\
40 -D__stdcall=__attribute__((__stdcall__)) \
41 -D__cdecl=__attribute__((__cdecl__)) \
42 -Asystem(winnt) -Acpu(i386) -Amachine(i386)"
43
44 #undef CPP_SPEC
45 #define CPP_SPEC "-remap %(cpp_cpu) %[cpp_cpu] %{posix:-D_POSIX_SOURCE}"
46
47 /* We have to dynamic link to get to the system DLLs. All of libc, libm and
48 the Unix stuff is in cygwin.dll. The import library is called
49 'libcygwin.a'. For Windows applications, include more libraries, but
50 always include kernel32. We'd like to specific subsystem windows to
51 ld, but that doesn't work just yet. */
52
53 #undef LIB_SPEC
54 #define LIB_SPEC "-lcygwin %{mwindows:-luser32 -lgdi32 -lcomdlg32} -lkernel32 \
55 -ladvapi32 -lshell32"
56
57 #define LINK_SPEC "%{mwindows:--subsystem windows}"
58
59 /* Normally, -lgcc is not needed since everything in it is in the DLL, but we
60 want to allow things to be added to it when installing new versions of
61 GCC without making a new CYGWIN.DLL, so we leave it. */
62
63 #undef STARTFILE_SPEC
64 #define STARTFILE_SPEC "crt0%O%s"
65
66 #define SIZE_TYPE "unsigned int"
67 #define PTRDIFF_TYPE "int"
68 #define WCHAR_UNSIGNED 1
69 #define WCHAR_TYPE_SIZE 16
70 #define WCHAR_TYPE "short unsigned int"
71 #define HAVE_ATEXIT 1
72
73 #undef EXTRA_SECTIONS
74 #define EXTRA_SECTIONS in_ctor, in_dtor
75
76 #undef EXTRA_SECTION_FUNCTIONS
77 #define EXTRA_SECTION_FUNCTIONS \
78 CTOR_SECTION_FUNCTION \
79 DTOR_SECTION_FUNCTION
80
81 #define CTOR_SECTION_FUNCTION \
82 void \
83 ctor_section () \
84 { \
85 if (in_section != in_ctor) \
86 { \
87 fprintf (asm_out_file, "\t.section .ctor\n"); \
88 in_section = in_ctor; \
89 } \
90 }
91
92 #define DTOR_SECTION_FUNCTION \
93 void \
94 dtor_section () \
95 { \
96 if (in_section != in_dtor) \
97 { \
98 fprintf (asm_out_file, "\t.section .dtor\n"); \
99 in_section = in_dtor; \
100 } \
101 }
102
103 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
104 do { \
105 ctor_section (); \
106 fprintf (FILE, "%s\t", ASM_LONG); \
107 assemble_name (FILE, NAME); \
108 fprintf (FILE, "\n"); \
109 } while (0)
110
111 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
112 do { \
113 dtor_section (); \
114 fprintf (FILE, "%s\t", ASM_LONG); \
115 assemble_name (FILE, NAME); \
116 fprintf (FILE, "\n"); \
117 } while (0)
118
119 /* Define this macro if references to a symbol must be treated
120 differently depending on something about the variable or
121 function named by the symbol (such as what section it is in).
122
123 On i386, if using PIC, mark a SYMBOL_REF for a non-global symbol
124 so that we may access it directly in the GOT.
125
126 On i386 running Windows NT, modify the assembler name with a suffix
127 consisting of an atsign (@) followed by string of digits that represents
128 the number of bytes of arguments passed to the function, if it has the
129 attribute STDCALL. */
130
131 #ifdef ENCODE_SECTION_INFO
132 #undef ENCODE_SECTION_INFO
133 #define ENCODE_SECTION_INFO(DECL) \
134 do \
135 { \
136 if (flag_pic) \
137 { \
138 rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
139 ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \
140 SYMBOL_REF_FLAG (XEXP (rtl, 0)) \
141 = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
142 || ! TREE_PUBLIC (DECL)); \
143 } \
144 if (TREE_CODE (DECL) == FUNCTION_DECL) \
145 if (lookup_attribute ("stdcall", \
146 TYPE_ATTRIBUTES (TREE_TYPE (DECL)))) \
147 XEXP (DECL_RTL (DECL), 0) = \
148 gen_rtx (SYMBOL_REF, Pmode, gen_stdcall_suffix (DECL)); \
149 } \
150 while (0)
151 #endif
152
153 /* This macro gets just the user-specified name
154 out of the string in a SYMBOL_REF. Discard
155 trailing @[NUM] encoded by ENCODE_SECTION_INFO.
156 Do we need the stripping of leading '*'? */
157 #undef STRIP_NAME_ENCODING
158 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
159 do { \
160 char *_p; \
161 char *_name = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*')); \
162 for (_p = _name; *_p && *_p != '@'; ++_p) \
163 ; \
164 if (*_p == '@') \
165 { \
166 int _len = _p - _name; \
167 (VAR) = (char *) alloca (_len + 1); \
168 strncpy ((VAR), _name, _len); \
169 (VAR)[_len] = '\0'; \
170 } \
171 else \
172 (VAR) = _name; \
173 } while (0)
174
175
176 /* Emit code to check the stack when allocating more that 4000
177 bytes in one go. */
178
179 #define CHECK_STACK_LIMIT 4000
180
181 /* By default, target has a 80387, uses IEEE compatible arithmetic,
182 and returns float values in the 387 and needs stack probes */
183 #undef TARGET_DEFAULT
184
185 #define TARGET_DEFAULT \
186 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE)
187
188 /* This is how to output an assembler line
189 that says to advance the location counter
190 to a multiple of 2**LOG bytes. */
191
192 #undef ASM_OUTPUT_ALIGN
193 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
194 if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
195
196 /* Define this macro if in some cases global symbols from one translation
197 unit may not be bound to undefined symbols in another translation unit
198 without user intervention. For instance, under Microsoft Windows
199 symbols must be explicitly imported from shared libraries (DLLs). */
200 #define MULTIPLE_SYMBOL_SPACES
201
202 #define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
203 extern void i386_pe_unique_section ();
204 #define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
205
206 #define SUPPORTS_ONE_ONLY 1
207
208 /* A C statement to output something to the assembler file to switch to section
209 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
210 NULL_TREE. Some target formats do not support arbitrary sections. Do not
211 define this macro in such cases. */
212 #undef ASM_OUTPUT_SECTION_NAME
213 #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
214 do { \
215 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
216 fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \
217 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
218 fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \
219 else \
220 fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \
221 /* Functions may have been compiled at various levels of \
222 optimization so we can't use `same_size' here. Instead, \
223 have the linker pick one. */ \
224 if ((DECL) && DECL_ONE_ONLY (DECL)) \
225 fprintf (STREAM, "\t.linkonce %s\n", \
226 TREE_CODE (DECL) == FUNCTION_DECL \
227 ? "discard" : "same_size"); \
228 } while (0)
229
230 #undef ASM_COMMENT_START
231 #define ASM_COMMENT_START " #"
232
233 /* DWARF2 Unwinding doesn't work with exception handling yet. */
234 #define DWARF2_UNWIND_INFO 0
235
236 /* Don't assume anything about the header files. */
237 #define NO_IMPLICIT_EXTERN_C