- Removed unused HandleEvent method.
[AROS.git] / compiler / include / libcore / compiler.h
blobc44b6a23c81865fc910142a79dde8b83450629a8
1 #ifndef LIBCORE_COMPILER_H
2 #define LIBCORE_COMPILER_H
3 /*
4 ** $VER: compiler.h 37.15 (14.8.97)
5 **
6 ** Compiler independent register (and SAS/C extensions) handling
7 **
8 ** (C) Copyright 1997 Andreas R. Kleinert
9 ** All Rights Reserved.
11 /* This might define __AROS__ */
12 #ifndef EXEC_TYPE_H
13 # include <exec/types.h>
14 #endif
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 */
42 /* */
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
50 #define __aligned
51 #define __asm
52 #define __regargs
53 #define __saveds
54 #define __stdargs
55 #endif
58 /* for SAS/C we don't need this, for StormC this is done in the
59 makefile or projectfile */
61 /* */
62 /* ********************************************************************* */
65 /* ********************************************************************* */
66 /* Method 2: defining our own keywords */
67 /* */
68 #ifdef __SASC
70 # define REG(r) register __ ## r
71 # define GNUCREG(r)
72 # define SAVEDS __saveds
73 # define ASM __asm
74 # define REGARGS __regargs
75 # define STDARGS __stdargs
76 # define ALIGNED __aligned
78 #else
79 # ifdef __MAXON__
81 # define REG(r) register __ ## r
82 # define GNUCREG(r)
83 # define SAVEDS
84 # define ASM
85 # define REGARGS
86 # define STDARGS
87 # define ALIGNED
89 # else
90 # ifdef __STORM__
92 # define REG(r) register __ ## r
93 # define GNUCREG(r)
94 # define SAVEDS __saveds
95 # define ASM
96 # define REGARGS
97 # define STDARGS
98 # define ALIGNED
100 # else
101 # ifdef __GNUC__
103 # define TEXT_SECTION __attribute__((section(".text")))
105 # ifndef __AROS__ /* No AROS ? */
107 # define REG(r)
108 # define GNUCREG(r) __asm( ## r)
109 # define SAVEDS __saveds
110 # define ASM
111 # define REGARGS __regargs
112 # define STDARGS __stdargs
113 # define ALIGNED __aligned
115 # else /* __AROS__ */
117 # define REG(r)
118 # define GNUCREG(r)
119 # define SAVEDS
120 # define ASM
121 # define REGARGS
122 # define STDARGS
123 # define ALIGNED
125 # endif /* __AROS__ */
127 # else /* any other compiler, to be added here */
129 # define REG(r)
130 # define GNUCREG(r)
131 # define SAVEDS
132 # define ASM
133 # define REGARGS
134 # define STDARGS
135 # define ALIGNED
137 # endif /* __GNUC__ */
138 # endif /* __STORM__ */
139 # endif /* __MAXON__ */
140 #endif /* __SASC */
142 #ifndef TEXT_SECTION
143 #define TEXT_SECTION
144 #endif
146 #ifdef __AROS__
147 # include <aros/libcall.h>
148 # include <aros/asmcall.h>
149 #else
150 # define D0 d0
151 # define D1 d1
152 # define D2 d2
153 # define D3 d3
154 # define D4 d4
155 # define D5 d5
156 # define D6 d6
157 # define D7 d7
158 # define A0 a0
159 # define A1 a1
160 # define A2 a2
161 # define A3 a3
162 # define A4 a4
163 # define A5 a5
164 # define A6 a6
165 # define A7 a7
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 (\
179 a1, \
180 AROS_LHA(libBaseType,libBase,A6) \
183 # define AROS_LH2(rettype,name,a1,a2,libBaseType,libBase,offset,libName) \
184 rettype SAVEDS ASM name (\
185 a1, \
186 a2, \
187 AROS_LHA(libBaseType,libBase,A6) \
190 # define AROS_LH3(rettype,name,a1,a2,a3,libBaseType,libBase,offset,libName) \
191 rettype SAVEDS ASM name (\
192 a1, \
193 a2, \
194 a3, \
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 (\
213 a1 \
216 # define AROS_UFH2(rettype,name,a1,a2) \
217 rettype SAVEDS ASM name (\
218 a1, \
219 a2 \
222 # define AROS_UFH3(rettype,name,a1,a2,a3) \
223 rettype SAVEDS ASM name (\
224 a1, \
225 a2, \
226 a3 \
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
240 #endif
243 /* */
244 /* ********************************************************************* */
245 #endif /* LIBCORE_COMPILER_H */