1 #ifndef LIBCORE_COMPILER_H
2 #define LIBCORE_COMPILER_H
4 ** $VER: compiler.h 37.15 (14.8.97)
6 ** Compiler independent register (and SAS/C extensions) handling
8 ** (C) Copyright 1997 Andreas R. Kleinert
9 ** All Rights Reserved.
11 /* This might define __AROS__ */
13 # include <exec/types.h>
16 /*#warning libcore/compiler.h is deprecated. Please use aros/asmcall.h and the AROS_ macros*/
18 /* Basically, Amiga C compilers must reach the goal to be
19 as SAS/C compatible as possible. But on the other hand,
20 when porting AmigaOS to other platforms, one perhaps
21 can't expect GCC becoming fully SAS/C compatible...
23 There are two ways to make your sources portable:
25 - using non ANSI SAS/C statements and making these
26 "available" to the other compilers (re- or undefining)
27 - using replacements for SAS/C statements and smartly
28 redefining these for any compiler
30 The last mentioned is the most elegant, but may require to
31 rewrite your source codes, so this compiler include file
32 basically does offer both.
34 For some compilers, this may have been done fromout project or
35 makefiles for the first method (e.g. StormC) to ensure compileablity.
37 Basically, you should include this header file BEFORE any other stuff.
40 /* ********************************************************************* */
41 /* Method 1: redefining SAS/C keywords */
43 /* Sorry, this method does not work with register definitions for the current
44 gcc version (V2.7.2.1), as it expects register attributes after the parameter
45 description. (This is announced to be fixed with gcc V2.8.0).
46 Moreover the __asm keyword has another meaning with GCC.
47 Therefore ASM must be used. */
49 #ifdef __MAXON__ // ignore this switches of SAS/Storm
58 /* for SAS/C we don't need this, for StormC this is done in the
59 makefile or projectfile */
62 /* ********************************************************************* */
65 /* ********************************************************************* */
66 /* Method 2: defining our own keywords */
70 # define REG(r) register __ ## r
72 # define SAVEDS __saveds
74 # define REGARGS __regargs
75 # define STDARGS __stdargs
76 # define ALIGNED __aligned
81 # define REG(r) register __ ## r
92 # define REG(r) register __ ## r
94 # define SAVEDS __saveds
103 # define TEXT_SECTION __attribute__((section(".text")))
105 # ifndef __AROS__ /* No AROS ? */
108 # define GNUCREG(r) __asm( ## r)
109 # define SAVEDS __saveds
111 # define REGARGS __regargs
112 # define STDARGS __stdargs
113 # define ALIGNED __aligned
115 # else /* __AROS__ */
125 # endif /* __AROS__ */
127 # else /* any other compiler, to be added here */
137 # endif /* __GNUC__ */
138 # endif /* __STORM__ */
139 # endif /* __MAXON__ */
147 # include <aros/libcall.h>
148 # include <aros/asmcall.h>
167 # define _AROS_LHA(t,n,r) REG(r) t n GNUCREG (# r)
168 # define AROS_LHA(t,n,r) _AROS_LHA(t,n,r)
169 # define _AROS_UFHA(t,n,r) REG(r) t n GNUCREG (# r)
170 # define AROS_UFHA(t,n,r) _AROS_UFHA(t,n,r)
172 # define AROS_LH0(rettype,name,libBaseType,libBase,offset,libName) \
173 rettype SAVEDS ASM name (\
174 AROS_LHA(libBaseType,libBase,A6) \
177 # define AROS_LH1(rettype,name,a1,libBaseType,libBase,offset,libName) \
178 rettype SAVEDS ASM name (\
180 AROS_LHA(libBaseType,libBase,A6) \
183 # define AROS_LH2(rettype,name,a1,a2,libBaseType,libBase,offset,libName) \
184 rettype SAVEDS ASM name (\
187 AROS_LHA(libBaseType,libBase,A6) \
190 # define AROS_LH3(rettype,name,a1,a2,a3,libBaseType,libBase,offset,libName) \
191 rettype SAVEDS ASM name (\
195 AROS_LHA(libBaseType,libBase,A6) \
198 # define AROS_LP0 AROS_LH0
199 # define AROS_LP1 AROS_LH1
200 # define AROS_LP2 AROS_LH2
201 # define AROS_LP3 AROS_LH3
202 # define AROS_UFP0 AROS_UFH0
203 # define AROS_UFP1 AROS_UFH1
204 # define AROS_UFP2 AROS_UFH2
205 # define AROS_UFP3 AROS_UFH3
207 # define AROS_UFH0(rettype,name) \
208 rettype SAVEDS ASM name ( \
211 # define AROS_UFH1(rettype,name,a1) \
212 rettype SAVEDS ASM name (\
216 # define AROS_UFH2(rettype,name,a1,a2) \
217 rettype SAVEDS ASM name (\
222 # define AROS_UFH3(rettype,name,a1,a2,a3) \
223 rettype SAVEDS ASM name (\
229 # define AROS_LP0 AROS_LH0
230 # define AROS_LP1 AROS_LH1
231 # define AROS_LP2 AROS_LH2
232 # define AROS_LP3 AROS_LH3
233 # define AROS_UFP0 AROS_UFH0
234 # define AROS_UFP1 AROS_UFH1
235 # define AROS_UFP2 AROS_UFH2
236 # define AROS_UFP3 AROS_UFH3
238 # define AROS_SLIB_ENTRY(n,s,o) n
244 /* ********************************************************************* */
245 #endif /* LIBCORE_COMPILER_H */