# Correct the needed linklibs in curl-config also.
[AROS-Contrib.git] / bgui / include / bgui_compilerspecific.h
blobe4feaba0636cf7f847d2b883213b57d2712c8f06
1 #ifndef BGUI_COMPILERSPECIFIC_H
2 #define BGUI_COMPILERSPECIFIC_H
3 /*
4 ** $Id$
5 **
6 ** Copyright (C) 1997 Bernardo Innocenti <bernie@cosmos.it>
7 ** All rights reserved.
8 **
9 ** Defines wrappers for several compiler dependent constructs,
10 ** including function attributes and register specification for
11 ** function arguments. Supports SAS/C, gcc, 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:
20 ** LIBCALL
21 ** Shared library entry point, with register args
23 ** HOOKCALL
24 ** Hook or boopsi dispatcher entry point with arguments
25 ** passed in registers
27 ** GLOBALCALL
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.
34 ** XDEF
35 ** Attribute for symbols to be exported to other modules for
36 ** global access within the same executable file.
37 ** Usually defined to an empty value.
39 ** XREF
40 ** Attribute for symbols to be imported from other modules
41 ** within the same executable file.
42 ** Usually defined to "extern".
44 ** INLINE
45 ** Please put function body inline to the calling code
47 ** STDARGS
48 ** Function uses standard C conventions for arguments
50 ** ASMCALL
51 ** Function takes arguments in the specified 68K registers
53 ** REGCALL
54 ** Function takes arguments in registers choosen by the compiler
56 ** CONSTCALL
57 ** Function does not modify any global variable
59 ** FORMATCALL(archetype,string_index,first_to_check)
60 ** Function uses printf or scanf-like formatting
62 ** SAVEDS
63 ** Function needs to reload context for small data model
65 ** INTERRUPT
66 ** Function will be called from within an interrupt
68 ** NORETURN
69 ** Function does never return
71 ** ALIGNED
72 ** Variable must be aligned to longword boundaries
74 ** UNUSED(var)
75 ** Eclicitly specify a function parameter as being
76 ** unused to prevent a compiler warning.
78 ** CHIP
79 ** Variable must be stored in CHIP RAM
81 ** REG(reg,arg)
82 ** Put argument <arg> in 68K register <reg>
84 ** min(a,b)
85 ** Return the minimum between <a> and <b>
87 ** max(a,b)
88 ** Return the maximum between <a> and <b>
90 ** abs(a)
91 ** Return the absolute value of <a>
93 ** _COMPILED_WITH
94 ** A string containing the name of the compiler
97 #ifdef REG
98 #undef REG
99 #endif
101 #ifdef ASM
102 #undef ASM
103 #endif
105 #ifdef SAVEDS
106 #undef SAVEDS
107 #endif
109 #ifdef __SASC
110 /* SAS/C 6.58 or better */
112 #define INLINE static __inline
113 #define STDARGS __stdargs
114 #define ASMCALL __asm
115 #define ASM ASMCALL
116 #define REGCALL __regcall
117 #define CONSTCALL /* unsupported */
118 #define FORMATCALL /* unsupported */
119 #define SAVEDS __saveds
120 #define INTERRUPT __interrupt
121 #define NORETURN /* unsupported */
122 #define ALIGNED __aligned
123 #define UNUSED(var) var /* unsupported */
124 #define CHIP __chip
125 #define REG(reg) register __##reg
126 #define _COMPILED_WITH "SAS/C"
128 #define __D0 __d0
129 #define __D1 __d1
130 #define __D2 __d2
131 #define __D3 __d3
132 #define __D4 __d4
133 #define __D5 __d5
134 #define __D6 __d6
135 #define __D7 __d7
136 #define __A0 __a0
137 #define __A1 __a1
138 #define __A2 __a2
139 #define __A3 __a3
140 #define __A4 __a4
141 #define __A5 __a5
142 #define __A6 __a6
143 #define __A7 __a7
146 /* For min(), max() and abs() */
147 //#define USE_BUILTIN_MATH
148 //#include <string.h>
149 #else
150 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
151 /* GeekGadgets GCC 2.7.2.1 or better */
153 // #define INLINE static inline
154 // #define STDARGS __attribute__((stkparm))
155 // #define ASMCALL /* nothing */
156 // #define REGCALL /* nothing */
157 // #define CONSTCALL __attribute__((const))
158 // #define FORMATCALL(a,s,f) __attribute__((format(a,s,f)))
159 // #define SAVEDS __attribute__((saveds))
160 #define SAVEDS
161 // #define INTERRUPT __attribute__((interrupt))
162 // #define NORETURN __attribute__((noreturn))
163 // #define ALIGNED __attribute__((aligned(4)))
164 // #define UNUSED(var) var __attribute__((unused))
165 // #define REG(reg,arg) arg __asm(#reg)
167 #ifdef __AROS__
169 #define makearosproto
171 #define REG(reg)
172 #define ASM
173 #define __stdargs
174 #define __chip
175 #define __saveds
176 #endif
177 #define _COMPILED_WITH "GCC"
179 // #define min(a,b) (((a)<(b))?(a):(b))
180 // #define max(a,b) (((a)>(b))?(a):(b))
181 #else
182 #ifdef __STORM__
183 /* StormC 2.00.23 or better */
184 #define INLINE __inline
185 #define STDARGS /* nothing */
186 #define ASMCALL /* nothing */
187 #define REGCALL register
188 #define CONSTCALL /* unsupported */
189 #define FORMATCALL /* unsupported */
190 #define SAVEDS __saveds
191 #define INTERRUPT __interrupt
192 #define NORETURN /* unsupported */
193 #define ALIGNED /* unsupported */
194 #define UNUSED(var) var /* unsupported */
195 #define CHIP __chip
196 #define REG(reg) register __##reg
197 #define _COMPILED_WITH "StormC"
199 #define min(a,b) (((a)<(b))?(a):(b))
200 #define max(a,b) (((a)>(b))?(a):(b))
201 #define abs(a) (((a)>0)?(a):-(a))
203 #define _INLINE_INCLUDES
204 #include <string.h>
205 #else
206 #ifdef __VBCC__
207 /* VBCC 0.7 (m68k) or better */
209 #define INLINE static __inline
210 #define STDARGS /* unsupported */
211 #define ASMCALL /* nothing */
212 #define REGCALL /* nothing */
213 #define CONSTCALL /* unsupported */
214 #define FORMATCALL /* unsupported */
215 #define SAVEDS __saveds
216 #define INTERRUPT /* unsupported */
217 #define NORETURN /* unsupported */
218 #define ALIGNED /* unsupported */
219 #define UNUSED(var) var /* unsupported */
220 #define CHIP __chip
221 #define REG(reg) __reg(##reg)
222 #define _COMPILED_WITH "VBCC"
224 #error VBCC compiler support is untested. Please check all the above definitions
225 #else
226 #ifdef __MAXON__
227 /* Maxon C/C++ 3.0 */
229 #define INLINE static inline
230 #define STDARGS /* ? */
231 #define ASMCALL /* ? */
232 #define REGCALL /* ? */
233 #define CONSTCALL /* unsupported */
234 #define FORMATCALL /* unsupported */
235 #define SAVEDS /* unsupported */
236 #define INTERRUPT /* unsupported */
237 #define NORETURN /* unsupported */
238 #define ALIGNED /* unsupported */
239 #define UNUSED(var) var /* unsupported */
240 #define REG(reg) register __##reg
241 #define _COMPILED_WITH "Maxon C"
243 /* For min(), max() and abs() */
244 #define USE_BUILTIN_MATH
245 #include <string.h>
247 #error Maxon C compiler support is untested. Please check all the above definitions
248 #else
249 #ifdef _DCC
250 /* DICE C 3.15 */
252 #define INLINE static __inline
253 #define STDARGS __stdargs
254 #define ASMCALL /* nothing */
255 #define REGCALL /* ? */
256 #define CONSTCALL /* unsupported */
257 #define FORMATCALL /* unsupported */
258 #define SAVEDS __geta4
259 #define INTERRUPT /* unsupported */
260 #define NORETURN /* unsupported */
261 #define ALIGNED __aligned
262 #define UNUSED(var) var /* unsupported */
263 #define REG(reg) __##reg
264 #define _COMPILED_WITH "DICE"
266 #define min(a,b) (((a)<(b))?(a):(b))
267 #define max(a,b) (((a)>(b))?(a):(b))
268 #define abs(a) (((a)>0)?(a):-(a))
270 #error DICE compiler support is untested. Please check all the above definitions
271 #else
272 #ifdef AZTEC_C
273 /* Aztec/Manx C */
275 #define INLINE static
276 #define STDARGS /* ? */
277 #define ASMCALL /* ? */
278 #define REGCALL /* ? */
279 #define CONSTCALL /* unsupported */
280 #define FORMATCALL /* unsupported */
281 #define SAVEDS __geta4
282 #define INTERRUPT /* unsupported */
283 #define NORETURN /* unsupported */
284 #define ALIGNED __aligned
285 #define UNUSED(var) var /* unsupported */
286 #define REG(reg) __ ##reg
287 #define _COMPILED_WITH "Manx C"
289 #define min(a,b) (((a)<(b))?(a):(b))
290 #define max(a,b) (((a)>(b))?(a):(b))
291 #define abs(a) (((a)>0)?(a):-(a))
293 #error Aztec/Manx C compiler support is untested. Please check all the above definitions
294 #else
295 #error Please add compiler specific definitions for your compiler
296 #endif
297 #endif
298 #endif
299 #endif
300 #endif
301 #endif
302 #endif
305 /* CONST_STRPTR is a new typedef provided since the V44 version of
306 * <exec/types.h>. Passing "const char *" parameters will only work
307 * if the OS protos are using CONST_STRPTR accordingly, otherwise you
308 * will get a lot of compiler warnings for const to volatile conversions.
310 * Using "const" where it is appropriate helps the compiler optimizing
311 * code better, so this mess is probably worth it.
313 //#if INCLUDE_VERSION < 44
314 //typedef char *CONST_STRPTR;
315 //#endif
318 /* Special function attributes */
320 #define LIBCALL ASMCALL SAVEDS
321 #define HOOKCALL ASMCALL SAVEDS
322 #ifdef __cplusplus
323 #define GLOBALCALL extern "C"
324 #else
325 #define GLOBALCALL
326 #endif
328 /* special variable attributes */
330 #define XDEF
331 #define XREF extern
333 /*** AROS/AmigaOS compatability *********************************/
335 #ifdef __AROS__
336 #define REG_A4 4
337 static inline IPTR getreg(int reg) { return 0xDEADCAFE; }
338 static inline VOID putreg(int reg, IPTR val) { }
339 static inline VOID geta4(void) { }
340 #else
341 typedef IPTR ULONG
342 #define BNULL 0
343 #endif
345 /*** Disable these macros when not building on AROS *****************/
347 #ifndef __AROS__
348 #define AROS_LIBFUNC_INIT
349 #define AROS_LIBFUNC_EXIT
350 #endif
352 /*** METHOD macro ***************************************************/
354 #ifdef __AROS__
356 #define METHOD(f,mtype,m) ASM AROS_UFH4(IPTR, f, \
357 AROS_UFHA(Class *, cl, A0), \
358 AROS_UFHA(Object *, obj, A2), \
359 AROS_UFHA(Msg, _msg, A1), \
360 AROS_UFHA(APTR, _global, A4)) \
361 {AROS_USERFUNC_INIT \
362 mtype __attribute__((unused)) m = (mtype)_msg;
363 #define METHODPROTO(f,mtype,m) ASM AROS_UFP4(IPTR, f, \
364 AROS_UFPA(Class *, cl, A0), \
365 AROS_UFPA(Object *, obj, A2), \
366 AROS_UFPA(Msg, msg, A1), \
367 AROS_UFPA(APTR, _global, A4));
369 #define METHOD_END AROS_USERFUNC_EXIT}
370 #define METHOD_CALL(f,cl,obj,m,g) \
371 AROS_UFC4(IPTR, f, \
372 AROS_UFCA(Class *, cl, A0), \
373 AROS_UFCA(Object *, obj, A2), \
374 AROS_UFCA(Msg, m, A1), \
375 AROS_UFCA(APTR, g, A4))
377 #else
378 #define METHOD(f,mtype,m) SAVEDS ASM IPTR f(REG(a0) Class *cl, REG(a2) Object *obj, REG(a1) Msg _msg, REG(a4) APTR _global) \
379 { mtype __attribute__((unused)) m = (mtype)_msg;
380 #define METHODPROTO(f,mtype,m) SAVEDS ASM IPTR f(REG(a0) Class *cl, REG(a2) Object *obj, REG(a1) Msg m, REG(a4) APTR _global)
381 #define METHOD_END }
382 #define METHOD_CALL(f,cl,obj,m,g) f(cl, obj, (Msg)m, (APTR)g)
383 #endif
385 /*** REGFUNC and REGPARAM macros ************************************/
387 #ifdef __AROS__
389 #ifndef AROS_ASMCALL_H
390 #include <aros/asmcall.h>
391 #endif
393 #define ASM
394 #define SAVEDS
396 #ifndef REGPARAM
397 #define REGPARAM(reg,type,name) type,name,reg
399 #define REGFUNC2(r,n,a1,a2) AROS_UFH2(r,n,AROS_UFHA(a1),AROS_UFHA(a2)) {AROS_USERFUNC_INIT
400 #define REGFUNC3(r,n,a1,a2,a3) AROS_UFH3(r,n,AROS_UFHA(a1),AROS_UFHA(a2),AROS_UFHA(a3)) {AROS_USERFUNC_INIT
402 #define REGCALL2(r,n,a1,a2) AROS_UFC2(r,n,AROS_UFCA(a1),AROS_UFCA(a2))
403 #define REGCALL3(r,n,a1,a2,a3) AROS_UFC3(r,n,AROS_UFCA(a1),AROS_UFCA(a2),AROS_UFCA(a3))
405 #define REGFUNCPROTO2(r,n,a1,a2) AROS_UFP2(r,n,AROS_UFHA(a1),AROS_UFHA(a2))
406 #define REGFUNCPROTO3(r,n,a1,a2,a3) AROS_UFP3(r,n,AROS_UFHA(a1),AROS_UFHA(a2),AROS_UFHA(a3))
408 #define REGFUNC_END AROS_USERFUNC_EXIT}
409 #endif
411 #else
413 #ifndef REGPARAM
414 #define REGPARAM(reg,type,name) REG(reg) type name
415 #define REGVALUE(reg,type,name) name
417 #define REGFUNC2(r,n,a1,a2) r n(a1,a2)
418 #define REGFUNC3(r,n,a1,a2,a3) r n(a1,a2,a3)
420 #define REGCALL2(r,n,a1,a2) \
421 r n(a1,a2)
422 #define REGCALL3(r,n,a1,a2,a3) \
423 r n(a1,a2,a3)
425 #define REGFUNCPROTO2(r,n,a1,a2) r n(a1,a2)
426 #define REGFUNCPROTO3(r,n,a1,a2,a3) r n(a1,a2,a3)
428 #define REGFUNC_END
429 #endif
431 #endif
433 #endif /* !BGUI_COMPILERSPECIFIC_H */