1 #ifndef COMPILERSPECIFIC_H
2 #define COMPILERSPECIFIC_H
4 ** $Id: CompilerSpecific.h,v 1.3 2000/01/12 20:30:24 bernie Exp $
6 ** Copyright (C) 1997-2000 Bernardo Innocenti <bernie@cosmos.it>
7 ** All rights reserved.
9 ** Defines wrappers for several compiler dependent constructs,
10 ** including function attributes and register specification for
11 ** function arguments. Supports AROS, gcc, SAS/C, egcs, Storm C, VBCC,
12 ** Maxon C, DICE and Aztec C.
14 ** You can easily add support for other compilers as well. Please
15 ** return any changes you make to me, so I can add them to my
16 ** personal copy of this file.
18 ** Here is a short description of the macros defined below:
21 ** Shared library entry point, with register args
24 ** Hook or boopsi dispatcher entry point with arguments
25 ** passed in registers
28 ** Attribute for functions to be exported to other modules for
29 ** global access within the same executable file.
30 ** Usually defined to "extern", but can be overridden for special
31 ** needs, such as compiling all modules together in a single
32 ** object module to optimize code better.
35 ** Please put function body inline to the calling code
38 ** Function uses standard C conventions for arguments
41 ** Function takes arguments in the specified 68K registers
44 ** Function takes arguments in registers choosen by the compiler
47 ** Function does not modify any global variable
49 ** FORMATCALL(archetype,string_index,first_to_check)
50 ** Function uses printf or scanf-like formatting
53 ** Function needs to reload context for small data model
56 ** Function will be called from within an interrupt
59 ** Function does never return
62 ** Variable must be aligned to longword boundaries
65 ** Variable must be stored in CHIP RAM
68 ** Attribute for symbols to be exported to other modules for
69 ** global access within the same executable file.
70 ** Usually defined to an empty value.
73 ** Attribute for symbols to be imported from other modules
74 ** within the same executable file.
75 ** Usually defined to "extern".
78 ** Explicitly specify a function parameter as being
79 ** unused to prevent a compiler warning.
82 ** Put argument <arg> in 68K register <reg>
85 ** Return the minimum between <a> and <b>
88 ** Return the maximum between <a> and <b>
91 ** Return the absolute value of <a>
94 ** A string containing the name of the compiler
98 /* AROS + GCC (not m68k native) */
100 #define INLINE static inline
101 #define STDARGS /* nothing */
102 #define ASMCALL /* nothing */
103 #define REGCALL /* nothing */
104 #define CONSTCALL __attribute__((const))
105 #define FORMATCALL(a,s,f) __attribute__((format(a,s,f)))
106 #define SAVEDS /* nothing */
107 #define INTERRUPT /* nothing */
108 #define NORETURN __attribute__((noreturn))
109 #define ALIGNED __attribute__((aligned(4)))
110 #define UNUSED(var) var __attribute__((unused))
111 #define SECTION_CHIP /* nothing */
112 #define REG(reg,arg) arg
113 #define _COMPILED_WITH "GCC"
115 #elif defined(__GNUC__)
116 /* GeekGadgets gcc 2.95.2 or better (works with 2.7.2.1 too) */
118 #define INLINE static inline
119 #define STDARGS __attribute__((stkparm))
120 #define ASMCALL /* nothing */
121 #define REGCALL /* nothing */
122 #define CONSTCALL __attribute__((const))
123 #define FORMATCALL(a,s,f) __attribute__((format(a,s,f)))
124 #define SAVEDS __attribute__((saveds))
125 #define INTERRUPT __attribute__((interrupt))
126 #define NORETURN __attribute__((noreturn))
127 #define ALIGNED __attribute__((aligned(4)))
128 #define UNUSED(var) var __attribute__((unused))
129 #if defined(__mc68000__)
130 # define SECTION_CHIP __attribute__((chip))
131 # define REG(reg,arg) arg __asm(#reg)
133 # define SECTION_CHIP /* nothing */
134 # define REG(reg,arg) arg
136 #define _COMPILED_WITH "GCC"
137 #define min(a,b) (((a)<(b))?(a):(b))
138 #define max(a,b) (((a)>(b))?(a):(b))
140 #elif defined(__SASC)
141 /* SAS/C 6.58 or better */
143 #define INLINE static __inline
144 #define STDARGS __stdargs
145 #define ASMCALL __asm
146 #define REGCALL __regcall
147 #define CONSTCALL /* unsupported */
148 #define FORMATCALL /* unsupported */
149 #define SAVEDS __saveds
150 #define INTERRUPT __interrupt
151 #define NORETURN /* unsupported */
152 #define ALIGNED __aligned
153 #define SECTION_CHIP __chip
154 #define UNUSED(var) var /* unsupported */
155 #define REG(reg,arg) register __##reg arg
156 #define _COMPILED_WITH "SAS/C"
158 /* For min(), max() and abs() */
159 #define USE_BUILTIN_MATH
162 #elif defined(__STORM__)
163 /* StormC 2.00.23 or better */
164 #define INLINE __inline
165 #define STDARGS /* nothing */
166 #define ASMCALL /* nothing */
167 #define REGCALL register
168 #define CONSTCALL /* unsupported */
169 #define FORMATCALL /* unsupported */
170 #define SAVEDS __saveds
171 #define INTERRUPT __interrupt
172 #define NORETURN /* unsupported */
173 #define ALIGNED /* unsupported */
174 #define SECTION_CHIP __chip
175 #define UNUSED(var) var /* unsupported */
176 #define REG(reg,arg) register __##reg arg
177 #define _COMPILED_WITH "StormC"
179 #define min(a,b) (((a)<(b))?(a):(b))
180 #define max(a,b) (((a)>(b))?(a):(b))
181 #define abs(a) (((a)>0)?(a):-(a))
183 #define _INLINE_INCLUDES
186 #elif defined(__VBCC__)
187 /* VBCC 0.7 (m68k) or better */
189 #define INLINE static __inline
190 #define STDARGS /* unsupported */
191 #define ASMCALL /* nothing */
192 #define REGCALL /* nothing */
193 #define CONSTCALL /* unsupported */
194 #define FORMATCALL /* unsupported */
195 #define SAVEDS __saveds
196 #define INTERRUPT /* unsupported */
197 #define NORETURN /* unsupported */
198 #define ALIGNED /* unsupported */
199 #define SECTION_CHIP __chip
200 #define UNUSED(var) var /* unsupported */
201 #define REG(reg,arg) __reg(##reg) arg
202 #define _COMPILED_WITH "VBCC"
204 #error VBCC compiler support is untested. Please check all the above definitions
206 #elif defined(__MAXON__)
207 /* Maxon C/C++ 3.0 */
209 #define INLINE static inline
210 #define STDARGS /* ? */
211 #define ASMCALL /* ? */
212 #define REGCALL /* ? */
213 #define CONSTCALL /* unsupported */
214 #define FORMATCALL /* unsupported */
215 #define SAVEDS /* unsupported */
216 #define INTERRUPT /* unsupported */
217 #define NORETURN /* unsupported */
218 #define ALIGNED /* unsupported */
219 #define UNUSED(var) var /* unsupported */
220 #define REG(reg,arg) register __##reg arg
221 #define _COMPILED_WITH "Maxon C"
223 /* For min(), max() and abs() */
224 #define USE_BUILTIN_MATH
227 #error Maxon C compiler support is untested. Please check all the above definitions
232 #define INLINE static __inline
233 #define STDARGS __stdargs
234 #define ASMCALL /* nothing */
235 #define REGCALL /* ? */
236 #define CONSTCALL /* unsupported */
237 #define FORMATCALL /* unsupported */
238 #define SAVEDS __geta4
239 #define INTERRUPT /* unsupported */
240 #define NORETURN /* unsupported */
241 #define ALIGNED __aligned
242 #define UNUSED(var) var /* unsupported */
243 #define REG(reg,arg) __##reg arg
244 #define _COMPILED_WITH "DICE"
246 #define min(a,b) (((a)<(b))?(a):(b))
247 #define max(a,b) (((a)>(b))?(a):(b))
248 #define abs(a) (((a)>0)?(a):-(a))
250 #error DICE compiler support is untested. Please check all the above definitions
252 #elif defined(AZTEC_C)
255 #define INLINE static
256 #define STDARGS /* ? */
257 #define ASMCALL /* ? */
258 #define REGCALL /* ? */
259 #define CONSTCALL /* unsupported */
260 #define FORMATCALL /* unsupported */
261 #define SAVEDS __geta4
262 #define INTERRUPT /* unsupported */
263 #define NORETURN /* unsupported */
264 #define ALIGNED __aligned
265 #define UNUSED(var) var /* unsupported */
266 #define REG(reg,arg) __##reg arg
267 #define _COMPILED_WITH "Manx C"
269 #define min(a,b) (((a)<(b))?(a):(b))
270 #define max(a,b) (((a)>(b))?(a):(b))
271 #define abs(a) (((a)>0)?(a):-(a))
273 #error Aztec/Manx C compiler support is untested. Please check all the above definitions
275 #error Please add compiler specific definitions for your compiler
279 /* CONST_STRPTR is a new typedef provided since the V44 version of
280 * <exec/types.h>. Passing "const char *" parameters will only work
281 * if the OS protos are using CONST_STRPTR accordingly, otherwise you
282 * will get a lot of compiler warnings for const to volatile conversions.
284 * Using "const" where it is appropriate helps the compiler optimizing
285 * code better, so this mess is probably worth it.
287 #if (!defined(_AROS)) && (INCLUDE_VERSION < 44)
288 typedef char *CONST_STRPTR;
292 /* Special function attributes */
294 #define LIBCALL ASMCALL SAVEDS
295 #define HOOKCALL ASMCALL SAVEDS
297 #define GLOBALCALL extern "C"
302 /* special variable attributes */
307 /* AROS Compatibility: IPTR is a type which can store a pointer
308 * as well as a long integer.
310 #if !defined(IPTR) && !defined(__typedef_IPTR)
311 #define IPTR unsigned long
315 #endif /* !COMPILERSPECIFIC_H */