fe404e0d0ef2f9af3a2ceeb298ae261a7eeec8b1
[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 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 -DPOSIX -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 /* We have to dynamic link to get to the system DLLs. All of libc, libm and
45 the Unix stuff is in cygwin.dll. The import library is called
46 'libcygwin.a'. For Windows applications, include more libraries, but
47 always include kernel32. We'd like to specific subsystem windows to
48 ld, but that doesn't work just yet. */
49
50 #undef LIB_SPEC
51 #define LIB_SPEC "-lcygwin %{mwindows:-luser32 -lgdi32 -lcomdlg32} -lkernel32"
52
53 #define LINK_SPEC "%{mwindows:--subsystem windows}"
54
55 /* Normally, -lgcc is not needed since everything in it is in the DLL, but we
56 want to allow things to be added to it when installing new versions of
57 GCC without making a new CYGWIN.DLL, so we leave it. */
58
59 #undef STARTFILE_SPEC
60 #define STARTFILE_SPEC "crt0%O%s"
61
62 #define SIZE_TYPE "unsigned int"
63 #define PTRDIFF_TYPE "int"
64 #define WCHAR_UNSIGNED 1
65 #define WCHAR_TYPE_SIZE 16
66 #define WCHAR_TYPE "short unsigned int"
67 #define HAVE_ATEXIT 1
68
69 #undef EXTRA_SECTIONS
70 #define EXTRA_SECTIONS in_ctor, in_dtor
71
72 #undef EXTRA_SECTION_FUNCTIONS
73 #define EXTRA_SECTION_FUNCTIONS \
74 CTOR_SECTION_FUNCTION \
75 DTOR_SECTION_FUNCTION
76
77 #define CTOR_SECTION_FUNCTION \
78 void \
79 ctor_section () \
80 { \
81 if (in_section != in_ctor) \
82 { \
83 fprintf (asm_out_file, "\t.section .ctor\n"); \
84 in_section = in_ctor; \
85 } \
86 }
87
88 #define DTOR_SECTION_FUNCTION \
89 void \
90 dtor_section () \
91 { \
92 if (in_section != in_dtor) \
93 { \
94 fprintf (asm_out_file, "\t.section .dtor\n"); \
95 in_section = in_dtor; \
96 } \
97 }
98
99 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
100 do { \
101 ctor_section (); \
102 fprintf (FILE, "%s\t", ASM_LONG); \
103 assemble_name (FILE, NAME); \
104 fprintf (FILE, "\n"); \
105 } while (0)
106
107 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
108 do { \
109 dtor_section (); \
110 fprintf (FILE, "%s\t", ASM_LONG); \
111 assemble_name (FILE, NAME); \
112 fprintf (FILE, "\n"); \
113 } while (0)
114
115 /* Define this macro if references to a symbol must be treated
116 differently depending on something about the variable or
117 function named by the symbol (such as what section it is in).
118
119 On i386, if using PIC, mark a SYMBOL_REF for a non-global symbol
120 so that we may access it directly in the GOT.
121
122 On i386 running Windows NT, modify the assembler name with a suffix
123 consisting of an atsign (@) followed by string of digits that represents
124 the number of bytes of arguments passed to the function, if it has the
125 attribute STDCALL. */
126
127 #ifdef ENCODE_SECTION_INFO
128 #undef ENCODE_SECTION_INFO
129 #define ENCODE_SECTION_INFO(DECL) \
130 do \
131 { \
132 if (flag_pic) \
133 { \
134 rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
135 ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \
136 SYMBOL_REF_FLAG (XEXP (rtl, 0)) \
137 = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
138 || ! TREE_PUBLIC (DECL)); \
139 } \
140 if (TREE_CODE (DECL) == FUNCTION_DECL) \
141 if (lookup_attribute ("stdcall", \
142 TYPE_ATTRIBUTES (TREE_TYPE (DECL)))) \
143 XEXP (DECL_RTL (DECL), 0) = \
144 gen_rtx (SYMBOL_REF, Pmode, gen_stdcall_suffix (DECL)); \
145 } \
146 while (0)
147 #endif
148
149 /* Emit code to check the stack when allocating more that 4000
150 bytes in one go. */
151
152 #define CHECK_STACK_LIMIT 4000
153
154 /* By default, target has a 80387, uses IEEE compatible arithmetic,
155 and returns float values in the 387 and needs stack probes */
156 #undef TARGET_DEFAULT
157
158 #define TARGET_DEFAULT \
159 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE)
160
161 /* This is how to output an assembler line
162 that says to advance the location counter
163 to a multiple of 2**LOG bytes. */
164
165 #undef ASM_OUTPUT_ALIGN
166 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
167 if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
168
169 /* For objects going into their own sections, a C expression of name of the
170 section, expressed as a STRING_CST node, to put DECL into. The
171 STRING_CST node must be allocated in the saveable obstack. Function
172 build_string can be used to do this. Define this macro if the name of a
173 symbol cannot be used as its section name. */
174 extern union tree_node *i386_pe_unique_section ();
175 #define UNIQUE_SECTION(DECL) i386_pe_unique_section (DECL)
176
177 #define MAKE_DECL_ONE_ONLY(DECL) \
178 DECL_SECTION_NAME (DECL) = UNIQUE_SECTION (DECL)
179
180 /* A C statement to output something to the assembler file to switch to section
181 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
182 NULL_TREE. Some target formats do not support arbitrary sections. Do not
183 define this macro in such cases. */
184 #undef ASM_OUTPUT_SECTION_NAME
185 #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME) \
186 do { \
187 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
188 fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \
189 else if ((DECL) && TREE_READONLY (DECL)) \
190 fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \
191 else \
192 fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \
193 /* Functions may have been compiled at various levels of \
194 optimization so we can't use `same_size' here. Instead, \
195 have the linker pick one. */ \
196 if ((DECL) && DECL_ONE_ONLY (DECL)) \
197 fprintf (STREAM, "\t.linkonce %s\n", \
198 TREE_CODE (DECL) == FUNCTION_DECL \
199 ? "discard" : "same_size"); \
200 } while (0)