1 /* Operating system specific defines to be used when targeting GCC for
2 hosting on Windows32, using a Unix style C library and tools.
3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 Free Software Foundation, Inc.
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 #define DBX_DEBUGGING_INFO 1
24 #define SDB_DEBUGGING_INFO 1
25 #undef PREFERRED_DEBUGGING_TYPE
26 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
28 #define TARGET_EXECUTABLE_SUFFIX ".exe"
32 /* Masks for subtarget switches used by other files. */
33 #define MASK_NOP_FUN_DLLIMPORT 0x08000000 /* Ignore dllimport for functions */
35 /* Used in winnt.c. */
36 #define TARGET_NOP_FUN_DLLIMPORT (target_flags & MASK_NOP_FUN_DLLIMPORT)
38 #undef SUBTARGET_SWITCHES
39 #define SUBTARGET_SWITCHES \
40 { "cygwin", 0, N_("Use the Cygwin interface") }, \
41 { "no-cygwin", 0, N_("Use the Mingw32 interface") }, \
42 { "windows", 0, N_("Create GUI application") }, \
43 { "no-win32", 0, N_("Don't set Windows defines") }, \
44 { "win32", 0, N_("Set Windows defines") }, \
45 { "console", 0, N_("Create console application") },\
46 { "dll", 0, N_("Generate code for a DLL") }, \
47 { "nop-fun-dllimport", MASK_NOP_FUN_DLLIMPORT, \
48 N_("Ignore dllimport for functions") }, \
49 { "no-nop-fun-dllimport", -MASK_NOP_FUN_DLLIMPORT, "" }, \
50 { "threads", 0, N_("Use Mingw-specific thread support") },
52 #define MAYBE_UWIN_CPP_BUILTINS() /* Nothing. */
54 /* Support the __declspec keyword by turning them into attributes.
55 We currently only support: dllimport and dllexport.
56 Note that the current way we do this may result in a collision with
57 predefined attributes later on. This can be solved by using one attribute,
58 say __declspec__, and passing args to it. The problem with that approach
59 is that args are not accumulated: each new appearance would clobber any
62 #define TARGET_OS_CPP_BUILTINS() \
65 builtin_define ("_X86_=1"); \
66 builtin_assert ("system=winnt"); \
67 builtin_define ("__stdcall=__attribute__((__stdcall__))"); \
68 builtin_define ("__fastcall=__attribute__((__fastcall__))"); \
69 builtin_define ("__cdecl=__attribute__((__cdecl__))"); \
70 builtin_define ("__declspec(x)=__attribute__((x))"); \
73 builtin_define ("_stdcall=__attribute__((__stdcall__))"); \
74 builtin_define ("_fastcall=__attribute__((__fastcall__))"); \
75 builtin_define ("_cdecl=__attribute__((__cdecl__))"); \
77 MAYBE_UWIN_CPP_BUILTINS (); \
78 EXTRA_OS_CPP_BUILTINS (); \
82 /* Get tree.c to declare a target-specific specialization of
83 merge_decl_attributes. */
84 #define TARGET_DLLIMPORT_DECL_ATTRIBUTES
86 /* This macro defines names of additional specifications to put in the specs
87 that can be used in various specifications like CC1_SPEC. Its definition
88 is an initializer with a subgrouping for each command option.
90 Each subgrouping contains a string constant, that defines the
91 specification name, and a string constant that used by the GNU CC driver
94 Do not define this macro if it does not need to do anything. */
96 #undef SUBTARGET_EXTRA_SPECS
97 #define SUBTARGET_EXTRA_SPECS \
98 { "mingw_include_path", DEFAULT_TARGET_MACHINE }
101 #define MATH_LIBRARY ""
103 #define SIZE_TYPE "unsigned int"
104 #define PTRDIFF_TYPE "int"
105 #define WCHAR_TYPE_SIZE 16
106 #define WCHAR_TYPE "short unsigned int"
109 /* Enable parsing of #pragma pack(push,<n>) and #pragma pack(pop). */
110 #define HANDLE_PRAGMA_PACK_PUSH_POP 1
113 #define TREE union tree_node *
115 #undef EXTRA_SECTIONS
116 #define EXTRA_SECTIONS in_drectve
118 #undef EXTRA_SECTION_FUNCTIONS
119 #define EXTRA_SECTION_FUNCTIONS \
120 DRECTVE_SECTION_FUNCTION \
121 SWITCH_TO_SECTION_FUNCTION
123 #define DRECTVE_SECTION_FUNCTION \
127 if (in_section != in_drectve) \
129 fprintf (asm_out_file, "%s\n", "\t.section .drectve\n"); \
130 in_section = in_drectve; \
133 void drectve_section PARAMS ((void));
135 /* Switch to SECTION (an `enum in_section').
137 ??? This facility should be provided by GCC proper.
138 The problem is that we want to temporarily switch sections in
139 ASM_DECLARE_OBJECT_NAME and then switch back to the original section
141 #define SWITCH_TO_SECTION_FUNCTION \
142 void switch_to_section PARAMS ((enum in_section, tree)); \
144 switch_to_section (section, decl) \
145 enum in_section section; \
150 case in_text: text_section (); break; \
151 case in_data: data_section (); break; \
152 case in_named: named_section (decl, NULL, 0); break; \
153 case in_drectve: drectve_section (); break; \
154 default: abort (); break; \
158 /* Don't allow flag_pic to propagate since gas may produce invalid code
161 #undef SUBTARGET_OVERRIDE_OPTIONS
162 #define SUBTARGET_OVERRIDE_OPTIONS \
166 warning ("-f%s ignored for target (all code is position independent)",\
167 (flag_pic > 1) ? "PIC" : "pic"); \
172 /* Define this macro if references to a symbol must be treated
173 differently depending on something about the variable or
174 function named by the symbol (such as what section it is in).
176 On i386 running Windows NT, modify the assembler name with a suffix
177 consisting of an atsign (@) followed by string of digits that represents
178 the number of bytes of arguments passed to the function, if it has the
181 In addition, we must mark dll symbols specially. Definitions of
182 dllexport'd objects install some info in the .drectve section.
183 References to dllimport'd objects are fetched indirectly via
184 _imp__. If both are declared, dllexport overrides. This is also
185 needed to implement one-only vtables: they go into their own
186 section and we need to set DECL_SECTION_NAME so we do that here.
187 Note that we can be called twice on the same decl. */
189 #undef TARGET_ENCODE_SECTION_INFO
190 #define TARGET_ENCODE_SECTION_INFO i386_pe_encode_section_info
191 #undef TARGET_STRIP_NAME_ENCODING
192 #define TARGET_STRIP_NAME_ENCODING i386_pe_strip_name_encoding_full
194 /* Output a reference to a label. */
195 #undef ASM_OUTPUT_LABELREF
196 #define ASM_OUTPUT_LABELREF i386_pe_output_labelref
198 /* Output a common block. */
199 #undef ASM_OUTPUT_COMMON
200 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \
202 if (i386_pe_dllexport_name_p (NAME)) \
203 i386_pe_record_exported_symbol (NAME, 1); \
204 if (! i386_pe_dllimport_name_p (NAME)) \
206 fprintf ((STREAM), "\t.comm\t"); \
207 assemble_name ((STREAM), (NAME)); \
208 fprintf ((STREAM), ", %d\t%s %d\n", \
209 (int)(ROUNDED), ASM_COMMENT_START, (int)(SIZE)); \
213 /* Output the label for an initialized variable. */
214 #undef ASM_DECLARE_OBJECT_NAME
215 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \
217 if (i386_pe_dllexport_name_p (NAME)) \
218 i386_pe_record_exported_symbol (NAME, 1); \
219 ASM_OUTPUT_LABEL ((STREAM), (NAME)); \
223 /* Emit code to check the stack when allocating more that 4000
226 #define CHECK_STACK_LIMIT 4000
228 /* By default, target has a 80387, uses IEEE compatible arithmetic,
229 returns float values in the 387 and needs stack probes.
230 We also align doubles to 64-bits for MSVC default compatibility. */
232 #undef TARGET_SUBTARGET_DEFAULT
233 #define TARGET_SUBTARGET_DEFAULT \
234 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE \
237 /* This is how to output an assembler line
238 that says to advance the location counter
239 to a multiple of 2**LOG bytes. */
241 #undef ASM_OUTPUT_ALIGN
242 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
243 if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
245 /* Define this macro if in some cases global symbols from one translation
246 unit may not be bound to undefined symbols in another translation unit
247 without user intervention. For instance, under Microsoft Windows
248 symbols must be explicitly imported from shared libraries (DLLs). */
249 #define MULTIPLE_SYMBOL_SPACES
251 extern void i386_pe_unique_section PARAMS ((TREE, int));
252 #define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
254 #define SUPPORTS_ONE_ONLY 1
256 /* Switch into a generic section. */
257 #define TARGET_ASM_NAMED_SECTION i386_pe_asm_named_section
259 /* Select attributes for named sections. */
260 #define TARGET_SECTION_TYPE_FLAGS i386_pe_section_type_flags
262 /* Write the extra assembler code needed to declare a function
263 properly. If we are generating SDB debugging information, this
264 will happen automatically, so we only need to handle other cases. */
265 #undef ASM_DECLARE_FUNCTION_NAME
266 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
269 if (i386_pe_dllexport_name_p (NAME)) \
270 i386_pe_record_exported_symbol (NAME, 0); \
271 if (write_symbols != SDB_DEBUG) \
272 i386_pe_declare_function_type (FILE, NAME, TREE_PUBLIC (DECL)); \
273 ASM_OUTPUT_LABEL (FILE, NAME); \
277 /* Add an external function to the list of functions to be declared at
278 the end of the file. */
279 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
282 if (TREE_CODE (DECL) == FUNCTION_DECL) \
283 i386_pe_record_external_function (NAME); \
287 /* Declare the type properly for any external libcall. */
288 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
289 i386_pe_declare_function_type (FILE, XSTR (FUN, 0), 1)
291 /* This says out to put a global symbol in the BSS section. */
292 #undef ASM_OUTPUT_ALIGNED_BSS
293 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
294 asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
296 /* Output function declarations at the end of the file. */
298 #define ASM_FILE_END(FILE) \
299 i386_pe_asm_file_end (FILE)
301 #undef ASM_COMMENT_START
302 #define ASM_COMMENT_START " #"
304 /* DWARF2 Unwinding doesn't work with exception handling yet. To make
305 it work, we need to build a libgcc_s.dll, and dcrt0.o should be
306 changed to call __register_frame_info/__deregister_frame_info. */
307 #define DWARF2_UNWIND_INFO 0
309 /* Don't assume anything about the header files. */
310 #define NO_IMPLICIT_EXTERN_C
313 #define PROFILE_HOOK(LABEL) \
314 if (MAIN_NAME_P (DECL_NAME (current_function_decl))) \
316 emit_call_insn (gen_rtx (CALL, VOIDmode, \
317 gen_rtx_MEM (FUNCTION_MODE, \
318 gen_rtx_SYMBOL_REF (Pmode, "_monstartup")), \
322 /* Java Native Interface (JNI) methods on Win32 are invoked using the
323 stdcall calling convention. */
324 #undef MODIFY_JNI_METHOD_CALL
325 #define MODIFY_JNI_METHOD_CALL(MDECL) \
326 build_type_attribute_variant ((MDECL), \
327 build_tree_list (get_identifier ("stdcall"), \
330 /* External function declarations. */
332 extern void i386_pe_record_external_function PARAMS ((const char *));
333 extern void i386_pe_declare_function_type PARAMS ((FILE *, const char *, int));
334 extern void i386_pe_record_exported_symbol PARAMS ((const char *, int));
335 extern void i386_pe_asm_file_end PARAMS ((FILE *));
336 extern int i386_pe_dllexport_name_p PARAMS ((const char *));
337 extern int i386_pe_dllimport_name_p PARAMS ((const char *));
339 /* For Win32 ABI compatibility */
340 #undef DEFAULT_PCC_STRUCT_RETURN
341 #define DEFAULT_PCC_STRUCT_RETURN 0
343 /* MSVC returns aggregate types of up to 8 bytes via registers.
344 See i386.c:ix86_return_in_memory. */
345 #undef MS_AGGREGATE_RETURN
346 #define MS_AGGREGATE_RETURN 1
348 /* No data type wants to be aligned rounder than this. */
349 #undef BIGGEST_ALIGNMENT
350 #define BIGGEST_ALIGNMENT 128
352 /* Native complier aligns internal doubles in structures on dword boundaries. */
353 #undef BIGGEST_FIELD_ALIGNMENT
354 #define BIGGEST_FIELD_ALIGNMENT 64
356 /* A bit-field declared as `int' forces `int' alignment for the struct. */
357 #undef PCC_BITFIELD_TYPE_MATTERS
358 #define PCC_BITFIELD_TYPE_MATTERS 1
359 #define GROUP_BITFIELDS_BY_ALIGN TYPE_NATIVE(rec)
361 /* Enable alias attribute support. */
363 #define SET_ASM_OP "\t.set\t"