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-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 /* Enable parsing of #pragma pack(push,<n>) and #pragma pack(pop). */
27 #define HANDLE_PRAGMA_PACK_PUSH_POP 1
29 #define DBX_DEBUGGING_INFO
30 #define SDB_DEBUGGING_INFO
31 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
36 /* Augment TARGET_SWITCHES with the cygwin/win32 options. */
37 #define MASK_WIN32 0x40000000 /* Use -lming32 interface */
38 #define MASK_CYGWIN 0x20000000 /* Use -lcygwin interface */
39 #define MASK_WINDOWS 0x10000000 /* Use windows interface */
40 #define MASK_DLL 0x08000000 /* Use dll interface */
41 #define MASK_NOP_FUN_DLLIMPORT 0x20000 /* Ignore dllimport for functions */
43 #define TARGET_WIN32 (target_flags & MASK_WIN32)
44 #define TARGET_CYGWIN (target_flags & MASK_CYGWIN)
45 #define TARGET_WINDOWS (target_flags & MASK_WINDOWS)
46 #define TARGET_DLL (target_flags & MASK_DLL)
47 #define TARGET_NOP_FUN_DLLIMPORT (target_flags & MASK_NOP_FUN_DLLIMPORT)
49 #undef SUBTARGET_SWITCHES
50 #define SUBTARGET_SWITCHES \
51 { "win32", MASK_WIN32, "Use Mingw32 interface" }, \
52 { "cygwin", MASK_CYGWIN, "Use Cygwin interface" }, \
53 { "windows", MASK_WINDOWS, "Use bare Windows interface" }, \
54 { "dll", MASK_DLL, "Generate code for a DLL" }, \
55 { "nop-fun-dllimport", MASK_NOP_FUN_DLLIMPORT, "Ignore dllimport for functions" }, \
56 { "no-nop-fun-dllimport", MASK_NOP_FUN_DLLIMPORT, "" },
60 #define CPP_PREDEFINES "-D_WIN32 \
61 -DWINNT -D_X86_=1 -D__STDC__=1\
62 -D__stdcall=__attribute__((__stdcall__)) \
63 -D__cdecl=__attribute__((__cdecl__)) \
68 #define STARTFILE_SPEC "%{mdll:dllcrt0%O%s} %{!mdll: %{!mcygwin:mcrt0%O%s} \
69 %{mcygwin:crt0%O%s} %{pg:gcrt0%O%s}}"
72 #define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
73 %{!mcygwin:-iwithprefixbefore include/mingw32 -D__MINGW32__} \
74 %{mcygwin:-D__CYGWIN32__ -D__CYGWIN__}"
76 /* We have to dynamic link to get to the system DLLs. All of libc, libm and
77 the Unix stuff is in cygwin.dll. The import library is called
78 'libcygwin.a'. For Windows applications, include more libraries, but
79 always include kernel32. We'd like to specific subsystem windows to
80 ld, but that doesn't work just yet. */
83 #define LIB_SPEC "%{pg:-lgmon} \
84 %{!mcygwin:-lmingw32 -lmoldname -lmsvcrt -lcrtdll} \
85 %{mcygwin:-lcygwin} %{mwindows:-luser32 -lgdi32 -lcomdlg32} \
86 -lkernel32 -ladvapi32 -lshell32"
88 #define LINK_SPEC "%{mwindows:--subsystem windows} \
89 %{mdll:--dll -e _DllMainCRTStartup@12}"
91 #define SIZE_TYPE "unsigned int"
92 #define PTRDIFF_TYPE "int"
93 #define WCHAR_UNSIGNED 1
94 #define WCHAR_TYPE_SIZE 16
95 #define WCHAR_TYPE "short unsigned int"
96 /* Currently we do not have the atexit() function,
97 so take that from libgcc2.c */
100 #define HAVE_ATEXIT 1
102 #undef EXTRA_SECTIONS
103 #define EXTRA_SECTIONS in_ctor, in_dtor
105 #undef EXTRA_SECTION_FUNCTIONS
106 #define EXTRA_SECTION_FUNCTIONS \
107 CTOR_SECTION_FUNCTION \
108 DTOR_SECTION_FUNCTION
110 #define CTOR_SECTION_FUNCTION \
114 if (in_section != in_ctor) \
116 fprintf (asm_out_file, "\t.section .ctor\n"); \
117 in_section = in_ctor; \
121 #define DTOR_SECTION_FUNCTION \
125 if (in_section != in_dtor) \
127 fprintf (asm_out_file, "\t.section .dtor\n"); \
128 in_section = in_dtor; \
132 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
135 fprintf (FILE, "%s\t", ASM_LONG); \
136 assemble_name (FILE, NAME); \
137 fprintf (FILE, "\n"); \
140 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
143 fprintf (FILE, "%s\t", ASM_LONG); \
144 assemble_name (FILE, NAME); \
145 fprintf (FILE, "\n"); \
148 /* Define this macro if references to a symbol must be treated
149 differently depending on something about the variable or
150 function named by the symbol (such as what section it is in).
152 On i386, if using PIC, mark a SYMBOL_REF for a non-global symbol
153 so that we may access it directly in the GOT.
155 On i386 running Windows NT, modify the assembler name with a suffix
156 consisting of an atsign (@) followed by string of digits that represents
157 the number of bytes of arguments passed to the function, if it has the
158 attribute STDCALL. */
160 #ifdef ENCODE_SECTION_INFO
161 #undef ENCODE_SECTION_INFO
162 #define ENCODE_SECTION_INFO(DECL) \
167 rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
168 ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \
169 SYMBOL_REF_FLAG (XEXP (rtl, 0)) \
170 = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
171 || ! TREE_PUBLIC (DECL)); \
173 if (TREE_CODE (DECL) == FUNCTION_DECL) \
174 if (lookup_attribute ("stdcall", \
175 TYPE_ATTRIBUTES (TREE_TYPE (DECL)))) \
176 XEXP (DECL_RTL (DECL), 0) = \
177 gen_rtx (SYMBOL_REF, Pmode, gen_stdcall_suffix (DECL)); \
182 /* This macro gets just the user-specified name
183 out of the string in a SYMBOL_REF. Discard
184 trailing @[NUM] encoded by ENCODE_SECTION_INFO.
185 Do we need the stripping of leading '*'? */
186 #undef STRIP_NAME_ENCODING
187 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
190 char *_name = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*')); \
191 for (_p = _name; *_p && *_p != '@'; ++_p) \
195 int _len = _p - _name; \
196 (VAR) = (char *) alloca (_len + 1); \
197 strncpy ((VAR), _name, _len); \
198 (VAR)[_len] = '\0'; \
205 /* Emit code to check the stack when allocating more that 4000
208 #define CHECK_STACK_LIMIT 4000
210 /* By default, target has a 80387, uses IEEE compatible arithmetic,
211 and returns float values in the 387 and needs stack probes */
212 #undef TARGET_DEFAULT
214 #define TARGET_DEFAULT \
215 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE)
217 /* This is how to output an assembler line
218 that says to advance the location counter
219 to a multiple of 2**LOG bytes. */
221 #undef ASM_OUTPUT_ALIGN
222 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
223 if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
225 /* Define this macro if in some cases global symbols from one translation
226 unit may not be bound to undefined symbols in another translation unit
227 without user intervention. For instance, under Microsoft Windows
228 symbols must be explicitly imported from shared libraries (DLLs). */
229 #define MULTIPLE_SYMBOL_SPACES
231 #define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
232 extern void i386_pe_unique_section ();
233 #define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
235 #define SUPPORTS_ONE_ONLY 1
237 /* A C statement to output something to the assembler file to switch to section
238 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
239 NULL_TREE. Some target formats do not support arbitrary sections. Do not
240 define this macro in such cases. */
241 #undef ASM_OUTPUT_SECTION_NAME
242 #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
244 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
245 fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \
246 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
247 fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \
249 fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \
250 /* Functions may have been compiled at various levels of \
251 optimization so we can't use `same_size' here. Instead, \
252 have the linker pick one. */ \
253 if ((DECL) && DECL_ONE_ONLY (DECL)) \
254 fprintf (STREAM, "\t.linkonce %s\n", \
255 TREE_CODE (DECL) == FUNCTION_DECL \
256 ? "discard" : "same_size"); \
259 #undef ASM_COMMENT_START
260 #define ASM_COMMENT_START " #"
262 /* DWARF2 Unwinding doesn't work with exception handling yet. */
263 #define DWARF2_UNWIND_INFO 0
265 /* Don't assume anything about the header files. */
266 #define NO_IMPLICIT_EXTERN_C
268 #define SUBTARGET_PROLOGUE \
270 && strcmp (IDENTIFIER_POINTER (DECL_NAME (current_function_decl)),\
274 xops[0] = gen_rtx_MEM (FUNCTION_MODE, \
275 gen_rtx (SYMBOL_REF, Pmode, "_monstartup")); \
277 emit_call_insn (gen_rtx (CALL, VOIDmode, xops[0], const0_rtx)); \
279 output_asm_insn (AS1 (call,%P1), xops); \