grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / popupmenu / compiler.h
blobafa69269113833b8b7593061ded5fd6fa52afd37
1 /*
2 ** $VER: compiler.h 37.31 (18.3.98)
3 **
4 ** Compiler independent register (and SAS/C extensions) handling
5 **
6 ** (C) Copyright 1997-98 Andreas R. Kleinert
7 ** All Rights Reserved.
8 */
10 #ifndef COMPILER_H
11 #define COMPILER_H
13 /* ============================================================
14 There have been problems how to define the seglist pointer
15 under AROS, AmigaOS or elsewhere in a unique (and still
16 working!) way. It seems to make sense to use a new, global
17 type definition for it. This is done here. */
19 #ifndef _AROS
20 # ifdef VBCC
21 # define SEGLISTPTR APTR
22 # else /* !VBCC */
23 # include <dos/dos.h>
24 # define SEGLISTPTR BPTR
25 # endif /* VBCC */
26 #else /* !_AROS */
27 typedef struct SegList * SEGLISTPTR;
28 #endif /* _AROS */
30 /* ============================================================ */
32 /* Basically, Amiga C compilers must try to reach the goal to be
33 as SAS/C compatible as possible. But on the other hand,
34 when porting AmigaOS to other platforms, one perhaps
35 can't expect GCC becoming fully SAS/C compatible...
37 There are two ways to make your sources portable:
39 - using non ANSI SAS/C statements and making these
40 "available" to the other compilers (re- or undefining)
41 - using replacements for SAS/C statements and smartly
42 redefining these for any compiler
44 The last mentioned is the most elegant, but may require to
45 rewrite your source codes, so this compiler include file
46 basically does offer both.
48 For some compilers, this may have been done fromout project or
49 makefiles for the first method (e.g. StormC) to ensure compileablity.
51 Basically, you should include this header file BEFORE any other stuff.
54 /* ********************************************************************* */
55 /* Method 1: redefining SAS/C keywords */
56 /* */
57 /* Sorry, this method does not work with register definitions for the current
58 gcc version (V2.7.2.1), as it expects register attributes after the parameter
59 description. (This is announced to be fixed with gcc V2.8.0).
60 Moreover the __asm keyword has another meaning with GCC.
61 Therefore ASM must be used. */
63 #ifdef __MAXON__ // ignore this switches of SAS/Storm
64 #define __aligned
65 #define __asm
66 #define __regargs
67 #define __saveds
68 #define __stdargs
69 #endif
71 #ifdef __GNUC__ // ignore this switches of SAS/Storm
72 #define __d0
73 #define __d1
74 #define __d2
75 #define __d3
76 #define __d4
77 #define __d5
78 #define __d6
79 #define __d7
80 #define __a0
81 #define __a1
82 #define __a2
83 #define __a3
84 #define __a4
85 #define __a5
86 #define __a6
87 #define __a7
88 #endif
90 #ifdef VBCC
91 #define __d0 __reg("d0")
92 #define __d1 __reg("d1")
93 #define __d2 __reg("d2")
94 #define __d3 __reg("d3")
95 #define __d4 __reg("d4")
96 #define __d5 __reg("d5")
97 #define __d6 __reg("d6")
98 #define __d7 __reg("d7")
99 #define __a0 __reg("a0")
100 #define __a1 __reg("a1")
101 #define __a2 __reg("a2")
102 #define __a3 __reg("a3")
103 #define __a4 __reg("a4")
104 #define __a5 __reg("a5")
105 #define __a6 __reg("a6")
106 #define __a7 __reg("a7")
107 #endif
109 /* for SAS/C we don't need this, for StormC this is done in the
110 makefile or projectfile */
112 /* */
113 /* ********************************************************************* */
116 /* ********************************************************************* */
117 /* Method 2: defining our own keywords */
118 /* */
119 #ifdef __SASC
121 # define REG(r) register __ ## r
122 # define GNUCREG(r)
123 # define SAVEDS __saveds
124 # define ASM __asm
125 # define REGARGS __regargs
126 # define STDARGS __stdargs
127 # define ALIGNED __aligned
129 #else
130 # ifdef __MAXON__
132 # define REG(r) register __ ## r
133 # define GNUCREG(r)
134 # define SAVEDS
135 # define ASM
136 # define REGARGS
137 # define STDARGS
138 # define ALIGNED
140 # else
141 # ifdef __STORM__
143 # define REG(r) register __ ## r
144 # define GNUCREG(r)
145 # define SAVEDS __saveds
146 # define ASM
147 # define REGARGS
148 # define STDARGS
149 # define ALIGNED
151 # else
152 # ifdef __GNUC__
154 # ifdef __AROS__
155 # define REG(r)
156 # define GNUCREG(r)
157 # define SAVEDS
158 # define ASM
159 # define REGARGS
160 # define STDARGS
161 # define ALIGNED
162 # define __saveds
163 # define __asm
164 # define chip
165 # else
166 # define REG(r)
167 # define GNUCREG(r) __asm( #r )
168 # define SAVEDS __saveds
169 # define ASM
170 # define REGARGS __regargs
171 # define STDARGS __stdargs
172 # define ALIGNED __aligned
173 # endif
175 # else
176 # ifdef VBCC
177 /* VBCC ignore this switch */
178 # define __aligned
179 # define __asm
180 # define __regargs
181 # define __saveds
182 # define __stdargs
183 # define __register
184 # define GNUCREG(r)
185 # define REG(r)
186 # define SAVEDS
187 # define ASM
188 # define REGARGS
189 # define STDARGS
190 # define ALIGNED
192 # else
193 # ifdef _DCC
194 # define __aligned
195 # define __stdargs
196 # define GNUCREG(r)
197 # define ASM
199 # else /* any other compiler, to be added here */
201 # define REG(r)
202 # define GNUCREG(r)
203 # define SAVEDS
204 # define ASM
205 # define REGARGS
206 # define STDARGS
207 # define ALIGNED
209 # endif /* _DCC */
210 # endif /* VBCC */
211 # endif /* __GNUC__ */
212 # endif /* __STORM__ */
213 # endif /* __MAXON__ */
214 #endif /* __SASC */
215 /* */
216 /* ********************************************************************* */
218 #endif /* COMPILER_H */