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.
7 This file is part of GNU CC.
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)
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.
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. */
24 #define YES_UNDERSCORES
26 #define DBX_DEBUGGING_INFO
27 #define SDB_DEBUGGING_INFO
28 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
33 /* Support the __declspec keyword by turning them into attributes.
34 We currently only support: dllimport and dllexport.
35 Note that the current way we do this may result in a collision with
36 predefined attributes later on. This can be solved by using one attribute,
37 say __declspec__, and passing args to it. The problem with that approach
38 is that args are not accumulated: each new appearance would clobber any
45 #define CPP_PREDEFINES "-Di386 -D_WIN32 \
46 -D__CYGWIN32__ -DWINNT -D_X86_=1 -D__STDC__=1\
47 -D__stdcall=__attribute__((__stdcall__)) \
48 -D__cdecl=__attribute__((__cdecl__)) \
49 -D__declspec(x)=__attribute__((x)) \
50 -Asystem(winnt) -Acpu(i386) -Amachine(i386)"
53 #define CPP_SPEC "-remap %(cpp_cpu) %{posix:-D_POSIX_SOURCE}"
55 /* We have to dynamic link to get to the system DLLs. All of libc, libm and
56 the Unix stuff is in cygwin.dll. The import library is called
57 'libcygwin.a'. For Windows applications, include more libraries, but
58 always include kernel32. We'd like to specific subsystem windows to
59 ld, but that doesn't work just yet. */
62 #define LIB_SPEC "-lcygwin %{mwindows:-luser32 -lgdi32 -lcomdlg32} -lkernel32 \
65 #define LINK_SPEC "%{mwindows:--subsystem windows}"
67 /* Normally, -lgcc is not needed since everything in it is in the DLL, but we
68 want to allow things to be added to it when installing new versions of
69 GCC without making a new CYGWIN.DLL, so we leave it. */
72 #define STARTFILE_SPEC "crt0%O%s"
74 #define SIZE_TYPE "unsigned int"
75 #define PTRDIFF_TYPE "int"
76 #define WCHAR_UNSIGNED 1
77 #define WCHAR_TYPE_SIZE 16
78 #define WCHAR_TYPE "short unsigned int"
82 /* Ignore dllimport for functions. */
83 #define TARGET_NOP_FUN_DLLIMPORT (target_flags & 0x20000)
85 #undef SUBTARGET_SWITCHES
86 #define SUBTARGET_SWITCHES \
87 { "nop-fun-dllimport", 0x20000 }, \
88 { "no-nop-fun-dllimport", -0x20000 }, \
91 /* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS
92 is a valid machine specific attribute for DECL.
93 The attributes in ATTRIBUTES have previously been assigned to DECL. */
94 extern int i386_pe_valid_decl_attribute_p ();
96 #undef VALID_MACHINE_DECL_ATTRIBUTE
97 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \
98 i386_pe_valid_decl_attribute_p (DECL, ATTRIBUTES, IDENTIFIER, ARGS)
100 extern union tree_node *i386_pe_merge_decl_attributes ();
101 #define MERGE_MACHINE_DECL_ATTRIBUTES(OLD, NEW) \
102 i386_pe_merge_decl_attributes ((OLD), (NEW))
104 /* Used to implement dllexport overriding dllimport semantics. It's also used
105 to handle vtables - the first pass won't do anything because
106 DECL_CONTEXT (DECL) will be 0 so i386_pe_dll{ex,im}port_p will return 0.
107 It's also used to handle dllimport override semantics. */
109 #define REDO_SECTION_INFO_P(DECL) \
110 ((DECL_MACHINE_ATTRIBUTES (DECL) != NULL_TREE) \
111 || (TREE_CODE (DECL) == VAR_DECL && DECL_VIRTUAL_P (DECL)))
113 #define REDO_SECTION_INFO_P(DECL) 1
117 #undef EXTRA_SECTIONS
118 #define EXTRA_SECTIONS in_ctor, in_dtor, in_drectve
120 #undef EXTRA_SECTION_FUNCTIONS
121 #define EXTRA_SECTION_FUNCTIONS \
122 CTOR_SECTION_FUNCTION \
123 DTOR_SECTION_FUNCTION \
124 DRECTVE_SECTION_FUNCTION \
125 SWITCH_TO_SECTION_FUNCTION
127 #define CTOR_SECTION_FUNCTION \
131 if (in_section != in_ctor) \
133 fprintf (asm_out_file, "\t.section .ctor\n"); \
134 in_section = in_ctor; \
138 #define DTOR_SECTION_FUNCTION \
142 if (in_section != in_dtor) \
144 fprintf (asm_out_file, "\t.section .dtor\n"); \
145 in_section = in_dtor; \
149 #define DRECTVE_SECTION_FUNCTION \
153 if (in_section != in_drectve) \
155 fprintf (asm_out_file, "%s\n", "\t.section .drectve\n"); \
156 in_section = in_drectve; \
160 /* Switch to SECTION (an `enum in_section').
162 ??? This facility should be provided by GCC proper.
163 The problem is that we want to temporarily switch sections in
164 ASM_DECLARE_OBJECT_NAME and then switch back to the original section
166 #define SWITCH_TO_SECTION_FUNCTION \
168 switch_to_section (section, decl) \
169 enum in_section section; \
174 case in_text: text_section (); break; \
175 case in_data: data_section (); break; \
176 case in_named: named_section (decl, NULL, 0); break; \
177 case in_ctor: ctor_section (); break; \
178 case in_dtor: dtor_section (); break; \
179 case in_drectve: drectve_section (); break; \
180 default: abort (); break; \
184 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
187 fprintf (FILE, "%s\t", ASM_LONG); \
188 assemble_name (FILE, NAME); \
189 fprintf (FILE, "\n"); \
192 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
195 fprintf (FILE, "%s\t", ASM_LONG); \
196 assemble_name (FILE, NAME); \
197 fprintf (FILE, "\n"); \
200 /* Define this macro if references to a symbol must be treated
201 differently depending on something about the variable or
202 function named by the symbol (such as what section it is in).
204 On i386 running Windows NT, modify the assembler name with a suffix
205 consisting of an atsign (@) followed by string of digits that represents
206 the number of bytes of arguments passed to the function, if it has the
209 In addition, we must mark dll symbols specially. Definitions of
210 dllexport'd objects install some info in the .drectve section.
211 References to dllimport'd objects are fetched indirectly via
212 _imp__. If both are declared, dllexport overrides. This is also
213 needed to implement one-only vtables: they go into their own
214 section and we need to set DECL_SECTION_NAME so we do that here.
215 Note that we can be called twice on the same decl. */
217 extern void i386_pe_encode_section_info ();
219 #ifdef ENCODE_SECTION_INFO
220 #undef ENCODE_SECTION_INFO
222 #define ENCODE_SECTION_INFO(DECL) i386_pe_encode_section_info (DECL)
224 /* Utility used only in this file. */
225 #define I386_PE_STRIP_ENCODING(SYM_NAME) \
226 ((SYM_NAME) + ((SYM_NAME)[0] == '@' ? 3 : 0))
228 /* This macro gets just the user-specified name
229 out of the string in a SYMBOL_REF. Discard
230 trailing @[NUM] encoded by ENCODE_SECTION_INFO. */
231 #undef STRIP_NAME_ENCODING
232 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
235 char *_name = I386_PE_STRIP_ENCODING (SYMBOL_NAME); \
236 for (_p = _name; *_p && *_p != '@'; ++_p) \
240 int _len = _p - _name; \
241 (VAR) = (char *) alloca (_len + 1); \
242 strncpy ((VAR), _name, _len); \
243 (VAR)[_len] = '\0'; \
250 /* Output a reference to a label. */
251 #undef ASM_OUTPUT_LABELREF
252 #define ASM_OUTPUT_LABELREF(STREAM, NAME) \
253 fprintf (STREAM, "%s%s", USER_LABEL_PREFIX, \
254 I386_PE_STRIP_ENCODING (NAME)) \
256 /* Output a common block. */
257 #undef ASM_OUTPUT_COMMON
258 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \
260 if (i386_pe_dllexport_name_p (NAME)) \
262 drectve_section (); \
263 fprintf ((STREAM), "\t.ascii \" -export:%s\"\n", \
264 I386_PE_STRIP_ENCODING (NAME)); \
266 if (! i386_pe_dllimport_name_p (NAME)) \
268 fprintf ((STREAM), "\t.comm\t"); \
269 assemble_name ((STREAM), (NAME)); \
270 fprintf ((STREAM), ", %d\t%s %d\n", \
271 (ROUNDED), ASM_COMMENT_START, (SIZE)); \
275 /* Output the label for an initialized variable. */
276 #undef ASM_DECLARE_OBJECT_NAME
277 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \
279 if (i386_pe_dllexport_name_p (NAME)) \
281 enum in_section save_section = in_section; \
282 drectve_section (); \
283 fprintf ((STREAM), "\t.ascii \" -export:%s\"\n", \
284 I386_PE_STRIP_ENCODING (NAME)); \
285 switch_to_section (save_section, (DECL)); \
287 ASM_OUTPUT_LABEL ((STREAM), (NAME)); \
291 /* Emit code to check the stack when allocating more that 4000
294 #define CHECK_STACK_LIMIT 4000
296 /* By default, target has a 80387, uses IEEE compatible arithmetic,
297 and returns float values in the 387 and needs stack probes */
298 #undef TARGET_DEFAULT
300 #define TARGET_DEFAULT \
301 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE)
303 /* This is how to output an assembler line
304 that says to advance the location counter
305 to a multiple of 2**LOG bytes. */
307 #undef ASM_OUTPUT_ALIGN
308 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
309 if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
311 /* Define this macro if in some cases global symbols from one translation
312 unit may not be bound to undefined symbols in another translation unit
313 without user intervention. For instance, under Microsoft Windows
314 symbols must be explicitly imported from shared libraries (DLLs). */
315 #define MULTIPLE_SYMBOL_SPACES
317 #define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
318 extern void i386_pe_unique_section ();
319 #define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
321 #define SUPPORTS_ONE_ONLY 1
323 /* A C statement to output something to the assembler file to switch to section
324 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
325 NULL_TREE. Some target formats do not support arbitrary sections. Do not
326 define this macro in such cases. */
327 #undef ASM_OUTPUT_SECTION_NAME
328 #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
330 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
331 fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \
332 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
333 fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \
335 fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \
336 /* Functions may have been compiled at various levels of \
337 optimization so we can't use `same_size' here. Instead, \
338 have the linker pick one. */ \
339 if ((DECL) && DECL_ONE_ONLY (DECL)) \
340 fprintf (STREAM, "\t.linkonce %s\n", \
341 TREE_CODE (DECL) == FUNCTION_DECL \
342 ? "discard" : "same_size"); \
345 /* Write the extra assembler code needed to declare a function
346 properly. If we are generating SDB debugging information, this
347 will happen automatically, so we only need to handle other cases. */
348 #undef ASM_DECLARE_FUNCTION_NAME
349 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
352 if (i386_pe_dllexport_name_p (NAME)) \
354 drectve_section (); \
355 fprintf ((FILE), "\t.ascii \" -export:%s\"\n", \
356 I386_PE_STRIP_ENCODING (NAME)); \
357 function_section (DECL); \
359 if (write_symbols != SDB_DEBUG) \
360 i386_pe_declare_function_type (FILE, NAME, TREE_PUBLIC (DECL)); \
361 ASM_OUTPUT_LABEL (FILE, NAME); \
365 /* Add an external function to the list of functions to be declared at
366 the end of the file. */
367 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
370 if (TREE_CODE (DECL) == FUNCTION_DECL) \
371 i386_pe_record_external_function (NAME); \
375 /* Declare the type properly for any external libcall. */
376 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
377 i386_pe_declare_function_type (FILE, XSTR (FUN, 0), 1)
379 /* Output function declarations at the end of the file. */
380 #define ASM_FILE_END(FILE) \
381 i386_pe_asm_file_end (FILE)
383 #undef ASM_COMMENT_START
384 #define ASM_COMMENT_START " #"
386 /* DWARF2 Unwinding doesn't work with exception handling yet. */
387 #define DWARF2_UNWIND_INFO 0
389 /* Don't assume anything about the header files. */
390 #define NO_IMPLICIT_EXTERN_C
392 /* External function declarations. */
395 #if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
396 #define PROTO(ARGS) ARGS
398 #define PROTO(ARGS) ()
402 #ifdef BUFSIZ /* stdio.h has been included, ok to use FILE * */
403 #define STDIO_PROTO(ARGS) PROTO(ARGS)
405 #define STDIO_PROTO(ARGS) ()
408 extern void i386_pe_record_external_function PROTO((char *));
409 extern void i386_pe_declare_function_type STDIO_PROTO((FILE *, char *, int));
410 extern void i386_pe_asm_file_end STDIO_PROTO((FILE *));