Add support for win32's stdcall functions.
[gcc.git] / gcc / config / i386 / go32.h
1 /* Configuration for an i386 running MS-DOS with djgpp/go32. */
2
3 /* Don't assume anything about the header files. */
4 #define NO_IMPLICIT_EXTERN_C
5
6 #define HANDLE_SYSV_PRAGMA
7
8 #define YES_UNDERSCORES
9
10 #include "i386/gas.h"
11
12 /* Value is the number of bytes of arguments automatically
13 popped when returning from a subroutine call.
14 FUNDECL is the declaration node of the function (as a tree),
15 FUNTYPE is the data type of the function (as a tree),
16 or for a library call it is an identifier node for the subroutine name.
17 SIZE is the number of bytes of arguments passed on the stack.
18
19 This only happens if the function declaration has the STDCALL attribute and
20 the number of arguments is not variable */
21
22 #undef RETURN_POPS_ARGS
23 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \
24 ( \
25 TREE_CODE (FUNTYPE) == IDENTIFIER_NODE \
26 ? \
27 0 \
28 : \
29 ( \
30 ((FUNDECL && (TREE_CODE_CLASS (TREE_CODE (FUNDECL)) == 'd') \
31 ? \
32 lookup_attribute ("stdcall", \
33 DECL_MACHINE_ATTRIBUTES (FUNDECL)) != NULL_TREE \
34 : 0 \
35 ) \
36 ) \
37 && \
38 ( \
39 TYPE_ARG_TYPES (FUNTYPE) == 0 \
40 || \
41 TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \
42 == void_type_node \
43 ) \
44 ) \
45 ? \
46 (SIZE) \
47 : \
48 (aggregate_value_p (TREE_TYPE (FUNTYPE))) \
49 ? \
50 GET_MODE_SIZE (Pmode) \
51 : \
52 0 \
53 )
54
55 /* Value is 1 if the declaration has either of the attributes: CDECL or
56 STDCALL and 0 otherwise */
57
58 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTR, NAME, ARGS) \
59 (((TREE_CODE(DECL) == FUNCTION_DECL) \
60 || (TREE_CODE(DECL) == FIELD_DECL) \
61 || (TREE_CODE(DECL) == TYPE_DECL)) \
62 && (is_attribute_p ("stdcall", (NAME)) \
63 || is_attribute_p ("cdecl", (NAME))) \
64 && (ARGS) == NULL)
65
66 #ifdef CPP_PREDEFINES
67 #undef CPP_PREDEFINES
68 #endif
69 #define CPP_PREDEFINES "-Dunix -Di386 -DGO32 -DMSDOS \
70 -Asystem(unix) -Asystem(msdos) -Acpu(i386) -Amachine(i386)"
71
72 #undef EXTRA_SECTIONS
73 #define EXTRA_SECTIONS in_ctor, in_dtor
74
75 #undef EXTRA_SECTION_FUNCTIONS
76 #define EXTRA_SECTION_FUNCTIONS \
77 CTOR_SECTION_FUNCTION \
78 DTOR_SECTION_FUNCTION
79
80 #define CTOR_SECTION_FUNCTION \
81 void \
82 ctor_section () \
83 { \
84 if (in_section != in_ctor) \
85 { \
86 fprintf (asm_out_file, "\t.section .ctor\n"); \
87 in_section = in_ctor; \
88 } \
89 }
90
91 #define DTOR_SECTION_FUNCTION \
92 void \
93 dtor_section () \
94 { \
95 if (in_section != in_dtor) \
96 { \
97 fprintf (asm_out_file, "\t.section .dtor\n"); \
98 in_section = in_dtor; \
99 } \
100 }
101
102 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
103 do { \
104 ctor_section (); \
105 fprintf (FILE, "%s\t", ASM_LONG); \
106 assemble_name (FILE, NAME); \
107 fprintf (FILE, "\n"); \
108 } while (0)
109
110 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
111 do { \
112 dtor_section (); \
113 fprintf (FILE, "%s\t", ASM_LONG); \
114 assemble_name (FILE, NAME); \
115 fprintf (FILE, "\n"); \
116 } while (0)
117
118