aea1cebdeaea9fc5ccd8916780ff7a9a8e812253
[fw/sdcc] / support / cpp / i386 / win-nt.h
1 /* Operating system specific defines to be used when targeting GCC for
2    Windows NT 3.x on an i386.
3    Copyright (C) 1994, 1995 Free Software Foundation, Inc.
4    Contributed by Douglas B. Rupp (drupp@cs.washington.edu).
5
6 This file is part of GNU CC.
7
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)
11 any later version.
12
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.
17
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. */
22
23 #define YES_UNDERSCORES
24
25 #include "i386/gas.h"
26
27 #ifdef CPP_PREDEFINES
28 #undef CPP_PREDEFINES
29 #endif
30 #if 0
31 /* The whole configuration system should be fixed; we really shouldn't
32  * include this file at all.
33  *
34  * But at least let's not pretend we're Microsoft C version 8 running
35  * on Windows NT, eh?
36  */
37 #define CPP_PREDEFINES "-Dunix -Di386 -DWIN32 -D_WIN32 \
38   -DWINNT -D_M_IX86=300 -D_X86_=1 -D__STDC__=0 -DALMOST_STDC -D_MSC_VER=800 \
39   -D__stdcall=__attribute__((__stdcall__)) \
40   -D__cdecl=__attribute__((__cdecl__)) \
41   -D_cdecl=__attribute__((__cdecl__)) \
42   -Asystem(unix) -Asystem(winnt) -Acpu(i386) -Amachine(i386)"
43 #else
44 #define CPP_PREDEFINES "-DSDCC"
45 #endif
46 #define SIZE_TYPE "unsigned int"
47 #define PTRDIFF_TYPE "int"
48 #define WCHAR_UNSIGNED 1
49 #define WCHAR_TYPE_SIZE 16
50 #define WCHAR_TYPE "short unsigned int"
51 #undef LONG_DOUBLE_TYPE_SIZE
52 #define LONG_DOUBLE_TYPE_SIZE 64
53 #define HAVE_ATEXIT 1
54
55 #undef EXTRA_SECTIONS
56 #define EXTRA_SECTIONS in_ctor, in_dtor
57
58 #undef EXTRA_SECTION_FUNCTIONS
59 #define EXTRA_SECTION_FUNCTIONS                                 \
60   CTOR_SECTION_FUNCTION                                         \
61   DTOR_SECTION_FUNCTION
62
63 #define CTOR_SECTION_FUNCTION                                   \
64 void                                                            \
65 ctor_section ()                                                 \
66 {                                                               \
67   if (in_section != in_ctor)                                    \
68     {                                                           \
69       fprintf (asm_out_file, "\t.section .ctor\n");             \
70       in_section = in_ctor;                                     \
71     }                                                           \
72 }
73
74 #define DTOR_SECTION_FUNCTION                                   \
75 void                                                            \
76 dtor_section ()                                                 \
77 {                                                               \
78   if (in_section != in_dtor)                                    \
79     {                                                           \
80       fprintf (asm_out_file, "\t.section .dtor\n");             \
81       in_section = in_dtor;                                     \
82     }                                                           \
83 }
84
85 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)       \
86   do {                                          \
87     ctor_section ();                            \
88     fprintf (FILE, "%s\t", ASM_LONG);           \
89     assemble_name (FILE, NAME);                 \
90     fprintf (FILE, "\n");                       \
91   } while (0)
92
93 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)        \
94   do {                                          \
95     dtor_section ();                            \
96     fprintf (FILE, "%s\t", ASM_LONG);           \
97     assemble_name (FILE, NAME);                 \
98     fprintf (FILE, "\n");                       \
99   } while (0)
100
101 /* Define this macro if references to a symbol must be treated
102    differently depending on something about the variable or
103    function named by the symbol (such as what section it is in).
104
105    On i386, if using PIC, mark a SYMBOL_REF for a non-global symbol
106    so that we may access it directly in the GOT.
107
108    On i386 running Windows NT, modify the assembler name with a suffix 
109    consisting of an atsign (@) followed by string of digits that represents
110    the number of bytes of arguments passed to the function, if it has the 
111    attribute STDCALL. */
112
113 #ifdef ENCODE_SECTION_INFO
114 #undef ENCODE_SECTION_INFO
115 #define ENCODE_SECTION_INFO(DECL)                                       \
116 do                                                                      \
117   {                                                                     \
118     if (flag_pic)                                                       \
119       {                                                                 \
120         rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd'            \
121                    ? TREE_CST_RTL (DECL) : DECL_RTL (DECL));            \
122         SYMBOL_REF_FLAG (XEXP (rtl, 0))                                 \
123           = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd'                  \
124              || ! TREE_PUBLIC (DECL));                                  \
125       }                                                                 \
126     if (TREE_CODE (DECL) == FUNCTION_DECL)                              \
127       if (lookup_attribute ("stdcall",                                  \
128                             TYPE_ATTRIBUTES (TREE_TYPE (DECL))))        \
129         XEXP (DECL_RTL (DECL), 0) =                                     \
130           gen_rtx (SYMBOL_REF, Pmode, gen_stdcall_suffix (DECL));       \
131   }                                                                     \
132 while (0)
133 #endif
134
135 /* The global __fltused is necessary to cause the printf/scanf routines
136    for outputting/inputting floating point numbers to be loaded.  Since this
137    is kind of hard to detect, we just do it all the time. */
138
139 #ifdef ASM_FILE_START
140 #undef ASM_FILE_START
141 #endif
142 #define ASM_FILE_START(FILE) \
143   do {  fprintf (FILE, "\t.file\t");                            \
144         output_quoted_string (FILE, dump_base_name);            \
145         fprintf (FILE, "\n");                                   \
146         fprintf (FILE, ".global\t__fltused\n");                 \
147   } while (0)
148
149 /* if the switch "-mwindows" is passed to ld, then specify to the Microsoft
150    linker the proper switches and libraries to build a graphical program */
151
152 #undef LIB_SPEC
153 #define LIB_SPEC "%{mwindows:-subsystem windows -e _WinMainCRTStartup \
154   USER32.LIB%s GDI32.LIB%s COMDLG32.LIB%s WINSPOOL.LIB%s} \
155  %{!mwindows:-subsystem console -e _mainCRTStartup} \
156  %{mcrtmt:LIBCMT.LIB%s KERNEL32.LIB%s ADVAPI32.LIB%s} \
157  %{!mcrtmt:LIBC.LIB%s KERNEL32.LIB%s ADVAPI32.LIB%s} \
158  %{v}"
159
160 #include "winnt/win-nt.h"
161