config: fix build with external compiler by passing the sysroot where needed
[AROS.git] / arch / .unmaintained / morphos / Include / libcore / compiler.h
blob02587039faa7a2672f3d7f721390cc9191ba9c97
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 /* Basically, Amiga C compilers must reach the goal to be
17 as SAS/C compatible as possible. But on the other hand,
18 when porting AmigaOS to other platforms, one perhaps
19 can't expect GCC becoming fully SAS/C compatible...
21 There are two ways to make your sources portable:
23 - using non ANSI SAS/C statements and making these
24 "available" to the other compilers (re- or undefining)
25 - using replacements for SAS/C statements and smartly
26 redefining these for any compiler
28 The last mentioned is the most elegant, but may require to
29 rewrite your source codes, so this compiler include file
30 basically does offer both.
32 For some compilers, this may have been done fromout project or
33 makefiles for the first method (e.g. StormC) to ensure compileablity.
35 Basically, you should include this header file BEFORE any other stuff.
38 /* ********************************************************************* */
39 /* Method 1: redefining SAS/C keywords */
40 /* */
41 /* Sorry, this method does not work with register definitions for the current
42 gcc version (V2.7.2.1), as it expects register attributes after the parameter
43 description. (This is announced to be fixed with gcc V2.8.0).
44 Moreover the __asm keyword has another meaning with GCC.
45 Therefore ASM must be used. */
47 #ifdef __MAXON__ // ignore this switches of SAS/Storm
48 #define __aligned
49 #define __asm
50 #define __regargs
51 #define __saveds
52 #define __stdargs
53 #endif
56 /* for SAS/C we don't need this, for StormC this is done in the
57 makefile or projectfile */
59 /* */
60 /* ********************************************************************* */
63 /* ********************************************************************* */
64 /* Method 2: defining our own keywords */
65 /* */
66 #ifdef __SASC
68 # define REG(r) register __ ## r
69 # define GNUCREG(r)
70 # define SAVEDS __saveds
71 # define ASM __asm
72 # define REGARGS __regargs
73 # define STDARGS __stdargs
74 # define ALIGNED __aligned
76 #else
77 # ifdef __MAXON__
79 # define REG(r) register __ ## r
80 # define GNUCREG(r)
81 # define SAVEDS
82 # define ASM
83 # define REGARGS
84 # define STDARGS
85 # define ALIGNED
87 # else
88 # ifdef __STORM__
90 # define REG(r) register __ ## r
91 # define GNUCREG(r)
92 # define SAVEDS __saveds
93 # define ASM
94 # define REGARGS
95 # define STDARGS
96 # define ALIGNED
98 # else
99 # ifdef __GNUC__
101 # ifndef __AROS__ /* No AROS ? */
103 # define REG(r)
104 # define GNUCREG(r) __asm( ## r)
105 # define SAVEDS __saveds
106 # define ASM
107 # define REGARGS __regargs
108 # define STDARGS __stdargs
109 # define ALIGNED __aligned
111 # else /* __AROS__ */
113 # define REG(r)
114 # define GNUCREG(r)
115 # define SAVEDS
116 # define ASM
117 # define REGARGS
118 # define STDARGS
119 # define ALIGNED
121 # endif /* __AROS__ */
123 # else /* any other compiler, to be added here */
125 # define REG(r)
126 # define GNUCREG(r)
127 # define SAVEDS
128 # define ASM
129 # define REGARGS
130 # define STDARGS
131 # define ALIGNED
133 # endif /* __GNUC__ */
134 # endif /* __STORM__ */
135 # endif /* __MAXON__ */
136 #endif /* __SASC */
138 #ifdef __AROS__
139 # include <aros/libcall.h>
140 #else
141 # define D0 d0
142 # define D1 d1
143 # define D2 d2
144 # define D3 d3
145 # define D4 d4
146 # define D5 d5
147 # define D6 d6
148 # define D7 d7
149 # define A0 a0
150 # define A1 a1
151 # define A2 a2
152 # define A3 a3
153 # define A4 a4
154 # define A5 a5
155 # define A6 a6
156 # define A7 a7
158 # define _AROS_LHA(t,n,r) REG(r) t n GNUCREG (# r)
159 # define AROS_LHA(t,n,r) _AROS_LHA(t,n,r)
161 # define AROS_LH0(rettype,name,libBaseType,libBase,offset,libName) \
162 rettype SAVEDS ASM name (\
163 AROS_LHA(libBaseType,libBase,A6) \
166 # define AROS_LH1(rettype,name,a1,libBaseType,libBase,offset,libName) \
167 rettype SAVEDS ASM name (\
168 a1, \
169 AROS_LHA(libBaseType,libBase,A6) \
172 # define AROS_LH2(rettype,name,a1,a2,libBaseType,libBase,offset,libName) \
173 rettype SAVEDS ASM name (\
174 a1, \
175 a2, \
176 AROS_LHA(libBaseType,libBase,A6) \
179 # define AROS_LH3(rettype,name,a1,a2,a3,libBaseType,libBase,offset,libName) \
180 rettype SAVEDS ASM name (\
181 a1, \
182 a2, \
183 a3, \
184 AROS_LHA(libBaseType,libBase,A6) \
187 # define AROS_LP3 AROS_LH3
189 # define AROS_SLIB_ENTRY(n,s) n
191 #endif
194 /* */
195 /* ********************************************************************* */
196 #endif /* LIBCORE_COMPILER_H */