2008-04-25 Kai Tietz <kai.tietz@onevision.com>
[official-gcc.git] / gcc / config / i386 / mingw32.h
blob19b57dbecc8d4e1d3cf2f1b18be8d48a5e48751e
1 /* Operating system specific defines to be used when targeting GCC for
2 hosting on Windows32, using GNU tools and the Windows32 API Library.
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007
4 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC 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 3, or (at your option)
11 any later version.
13 GCC 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 GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #undef TARGET_VERSION
23 #if TARGET_64BIT_DEFAULT
24 #define TARGET_VERSION fprintf (stderr,"(x86_64 MinGW");
25 #else
26 #define TARGET_VERSION fprintf (stderr," (x86 MinGW)");
27 #endif
29 /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS
30 is for compatibility with native compiler. */
31 #define EXTRA_OS_CPP_BUILTINS() \
32 do \
33 { \
34 builtin_define ("__MSVCRT__"); \
35 builtin_define ("__MINGW32__"); \
36 builtin_define ("_WIN32"); \
37 builtin_define_std ("WIN32"); \
38 builtin_define_std ("WINNT"); \
39 builtin_define_with_int_value ("_INTEGRAL_MAX_BITS", \
40 TYPE_PRECISION (intmax_type_node));\
41 if (TARGET_64BIT_MS_ABI) \
42 { \
43 builtin_define ("__MINGW64__"); \
44 builtin_define_std ("WIN64"); \
45 builtin_define_std ("_WIN64"); \
46 } \
47 } \
48 while (0)
50 /* Override the standard choice of /usr/include as the default prefix
51 to try when searching for header files. */
52 #undef STANDARD_INCLUDE_DIR
53 #if TARGET_64BIT_DEFAULT
54 #define STANDARD_INCLUDE_DIR "/mingw/include64"
55 #else
56 #define STANDARD_INCLUDE_DIR "/mingw/include"
57 #endif
58 #undef STANDARD_INCLUDE_COMPONENT
59 #define STANDARD_INCLUDE_COMPONENT "MINGW"
61 #undef CPP_SPEC
62 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT}"
64 /* For Windows applications, include more libraries, but always include
65 kernel32. */
66 #undef LIB_SPEC
67 #define LIB_SPEC "%{pg:-lgmon} %{mwindows:-lgdi32 -lcomdlg32} \
68 -luser32 -lkernel32 -ladvapi32 -lshell32"
70 /* Include in the mingw32 libraries with libgcc */
71 #undef LINK_SPEC
72 #define LINK_SPEC "%{mwindows:--subsystem windows} \
73 %{mconsole:--subsystem console} \
74 %{shared: %{mdll: %eshared and mdll are not compatible}} \
75 %{shared: --shared} %{mdll:--dll} \
76 %{static:-Bstatic} %{!static:-Bdynamic} \
77 %{shared|mdll: -e _DllMainCRTStartup@12}"
79 /* Include in the mingw32 libraries with libgcc */
80 #undef LIBGCC_SPEC
81 #define LIBGCC_SPEC \
82 "%{mthreads:-lmingwthrd} -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt"
84 #undef STARTFILE_SPEC
85 #define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
86 %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s} \
87 crtbegin.o%s"
89 #undef ENDFILE_SPEC
90 #define ENDFILE_SPEC \
91 "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
92 crtend.o%s"
94 /* Override startfile prefix defaults. */
95 #ifndef STANDARD_STARTFILE_PREFIX_1
96 #if TARGET_64BIT_DEFAULT
97 #define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib64/"
98 #else
99 #define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/"
100 #endif
101 #endif
102 #ifndef STANDARD_STARTFILE_PREFIX_2
103 #define STANDARD_STARTFILE_PREFIX_2 ""
104 #endif
106 /* Output STRING, a string representing a filename, to FILE.
107 We canonicalize it to be in Unix format (backslashes are replaced
108 forward slashes. */
109 #undef OUTPUT_QUOTED_STRING
110 #define OUTPUT_QUOTED_STRING(FILE, STRING) \
111 do { \
112 char c; \
114 putc ('\"', asm_file); \
116 while ((c = *string++) != 0) \
118 if (c == '\\') \
119 c = '/'; \
121 if (ISPRINT (c)) \
123 if (c == '\"') \
124 putc ('\\', asm_file); \
125 putc (c, asm_file); \
127 else \
128 fprintf (asm_file, "\\%03o", (unsigned char) c); \
131 putc ('\"', asm_file); \
132 } while (0)
134 /* Define as short unsigned for compatibility with MS runtime. */
135 #undef WINT_TYPE
136 #define WINT_TYPE "short unsigned int"
138 /* mingw32 uses the -mthreads option to enable thread support. */
139 #undef GOMP_SELF_SPECS
140 #define GOMP_SELF_SPECS "%{fopenmp: -mthreads}"
142 /* mingw32 atexit function is safe to use in shared libraries. Use it
143 to register C++ static destructors. */
144 #define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true
146 /* Contains a pointer to type target_ovr_attr defining the target specific
147 overrides of format attributes. See c-format.h for structure
148 definition. */
149 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
150 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides
152 /* Specify the count of elements in TARGET_OVERRIDES_ATTRIBUTE. */
153 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
154 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3
156 /* MS specific format attributes for ms_printf, ms_scanf, ms_strftime. */
157 #undef TARGET_FORMAT_TYPES
158 #define TARGET_FORMAT_TYPES mingw_format_attributes
160 #undef TARGET_N_FORMAT_TYPES
161 #define TARGET_N_FORMAT_TYPES 3
163 /* JCR_SECTION works on mingw32. */
164 #undef TARGET_USE_JCR_SECTION
165 #define TARGET_USE_JCR_SECTION 1
167 #undef MINGW_ENABLE_EXECUTE_STACK
168 #define MINGW_ENABLE_EXECUTE_STACK \
169 extern void __enable_execute_stack (void *); \
170 void \
171 __enable_execute_stack (void *addr) \
173 MEMORY_BASIC_INFORMATION b; \
174 if (!VirtualQuery (addr, &b, sizeof(b))) \
175 abort (); \
176 VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE, \
177 &b.Protect); \
180 #undef ENABLE_EXECUTE_STACK
181 #define ENABLE_EXECUTE_STACK MINGW_ENABLE_EXECUTE_STACK
183 #define SUBTARGET_INIT_BUILTINS \
184 do { \
185 if (TARGET_64BIT_MS_ABI) \
187 /* These builtin functions have a different return \
188 type (intptr_t) on 64-bit MS Windows. */ \
189 disable_builtin_function ("execl"); \
190 disable_builtin_function ("execlp"); \
191 disable_builtin_function ("execle"); \
192 disable_builtin_function ("execv"); \
193 disable_builtin_function ("execvp"); \
194 disable_builtin_function ("execve"); \
196 /* Second argument of MS scalb is long, not double. */ \
197 disable_builtin_function ("scalb"); \
198 } while (0) \
200 #ifdef IN_LIBGCC2
201 #include <windows.h>
202 #endif
204 #if !TARGET_64BIT
205 #define MD_UNWIND_SUPPORT "config/i386/w32-unwind.h"
206 #endif