1 #ifndef COMPILERSPECIFIC_H
2 #define COMPILERSPECIFIC_H
4 ** $VER: CompilerSpecific.h 2.3 (26.10.97)
6 ** Copyright (C) 1997 Bernardo Innocenti. All rights reserved.
8 ** Compiler specific definitions is here. You can add support
9 ** for other compilers in this header. Please return any changes
10 ** you make to me, so I can add them to my personal copy of this file.
12 ** Here is a short description of the macros defined below:
15 ** Shared library entry point, with register args
18 ** Hook or boopsi dispatcher entry point with arguments
19 ** passed in registers
22 ** Attribute for functions to be exported to other modules for
23 ** global access within the same executable file.
24 ** Usually defined to "extern", but can be overridden for special
25 ** needs, such as compiling all modules together in a single
26 ** object module to optimize code better.
29 ** Attribute for symbols to be exported to other modules for
30 ** global access within the same executable file.
31 ** Usually defined to an empty value.
34 ** Attribute for symbols to be imported from other modules
35 ** within the same executable file.
36 ** Usually defined to "extern".
39 ** Please put function body inline to the calling code
42 ** Function uses standard C conventions for arguments
45 ** Function takes arguments in the specified 68K registers
48 ** Function takes arguments in registers choosen by the compiler
51 ** Function does not modify any global variable
53 ** FORMATCALL(archetype,string_index,first_to_check)
54 ** Function uses printf or scanf-like formatting
57 ** Function needs to reload context for small data model
60 ** Function will be called from within an interrupt
63 ** Function does never return
66 ** Variable must be aligned to longword boundaries
69 ** Variable must be stored in CHIP RAM
72 ** Put argument <arg> in 68K register <reg>
75 ** Return the minimum between <a> and <b>
78 ** Return the maximum between <a> and <b>
81 ** Return the absolute value of <a>
84 ** A string containing the name of the compiler
88 /* SAS/C 6.58 or better */
90 #define INLINE static __inline
91 #define STDARGS __stdargs
93 #define REGCALL __regcall
94 #define CONSTCALL /* unsupported */
95 #define FORMATCALL /* unsupported */
96 #define SAVEDS __saveds
97 #define INTERRUPT __interrupt
98 #define NORETURN /* unsupported */
99 #define ALIGNED __aligned
101 #define REG(reg,arg) register __##reg arg
102 #define _COMPILED_WITH "SAS/C"
104 /* For min(), max() and abs() */
105 #define USE_BUILTIN_MATH
109 /* GeekGadgets GCC 2.7.2.1 or better */
111 #define INLINE static inline
112 #define STDARGS __attribute__((stkparm))
113 #define ASMCALL /* nothing */
114 #define REGCALL /* nothing */
115 #define CONSTCALL __attribute__((const))
116 #define FORMATCALL(a,s,f) __attribute__((format(a,s,f)))
117 #define SAVEDS __attribute__((saveds))
118 #define INTERRUPT __attribute__((interrupt))
119 #define NORETURN __attribute__((noreturn))
120 #define ALIGNED __attribute__((aligned(4)))
121 #define REG(reg,arg) arg __asm(#reg)
122 #define _COMPILED_WITH "GCC"
124 #define min(a,b) (((a)<(b))?(a):(b))
125 #define max(a,b) (((a)>(b))?(a):(b))
126 #define abs(a) (((a)>0)?(a):-(a))
128 /* Inline versions of some str*() and mem*() functions
134 INLINE STDARGS size_t strlen (const char *src)
135 { const char *tmp = src; while (*tmp) tmp++; return tmp - src; }
137 INLINE STDARGS int memcmp (const void *src, const void *dest, size_t n)
141 if (*((char *)src) != *((char *)dest))
142 return (*((char *)src) - *((char *)dest));
149 INLINE STDARGS void * memset (void *m, int c, size_t n)
154 *(((unsigned char *) m)++) = (unsigned char) c;
158 /* GCC produces code which calls these two functions
159 * to initialize and copy structures and arrays.
161 * INLINE STDARGS void bzero (void *buf, size_t len)
162 * { while (len--) *((char *)buf)++ = 0; }
164 * INLINE STDARGS void bcopy (const void *src, void *dest, size_t len)
165 * { while (len--) *((char *)dest)++ = *((const char *)src)++; }
170 /* StormC 2.00.23 or better */
171 #define INLINE __inline
172 #define STDARGS /* nothing */
173 #define ASMCALL /* nothing */
174 #define REGCALL register
175 #define CONSTCALL /* unsupported */
176 #define FORMATCALL /* unsupported */
177 #define SAVEDS __saveds
178 #define INTERRUPT __interrupt
179 #define NORETURN /* unsupported */
180 #define ALIGNED /* unsupported */
182 #define REG(reg,arg) register __##reg arg
183 #define _COMPILED_WITH "StormC"
185 #define min(a,b) (((a)<(b))?(a):(b))
186 #define max(a,b) (((a)>(b))?(a):(b))
187 #define abs(a) (((a)>0)?(a):-(a))
189 #define _INLINE_INCLUDES
193 /* Maxon C/C++ 3.0 */
195 #define INLINE static inline
196 #define STDARGS /* ? */
197 #define ASMCALL /* ? */
198 #define REGCALL /* ? */
199 #define CONSTCALL /* unsupported */
200 #define FORMATCALL /* unsupported */
201 #define SAVEDS /* unsupported */
202 #define INTERRUPT /* unsupported */
203 #define NORETURN /* unsupported */
204 #define ALIGNED /* unsupported */
205 #define REG(reg,arg) register __##reg arg
206 #define _COMPILED_WITH "Maxon C"
208 /* For min(), max() and abs() */
209 #define USE_BUILTIN_MATH
212 #error Maxon C compiler support is untested. Please check all the above definitions
217 #define INLINE static __inline
218 #define STDARGS __stdargs
219 #define ASMCALL /* nothing */
220 #define REGCALL /* ? */
221 #define CONSTCALL /* unsupported */
222 #define FORMATCALL /* unsupported */
223 #define SAVEDS __geta4
224 #define INTERRUPT /* unsupported */
225 #define NORETURN /* unsupported */
226 #define ALIGNED __aligned
227 #define REG(reg,arg) __##reg arg
228 #define _COMPILED_WITH "DICE"
230 #define min(a,b) (((a)<(b))?(a):(b))
231 #define max(a,b) (((a)>(b))?(a):(b))
232 #define abs(a) (((a)>0)?(a):-(a))
234 #error DICE compiler support is untested. Please check all the above definitions
239 #define INLINE static
240 #define STDARGS /* ? */
241 #define ASMCALL /* ? */
242 #define REGCALL /* ? */
243 #define CONSTCALL /* unsupported */
244 #define FORMATCALL /* unsupported */
245 #define SAVEDS __geta4
246 #define INTERRUPT /* unsupported */
247 #define NORETURN /* unsupported */
248 #define ALIGNED __aligned
249 #define REG(reg,arg) __##reg arg
250 #define _COMPILED_WITH "Manx C"
252 #define min(a,b) (((a)<(b))?(a):(b))
253 #define max(a,b) (((a)>(b))?(a):(b))
254 #define abs(a) (((a)>0)?(a):-(a))
256 #error Aztec/Manx C compiler support is untested. Please check all the above definitions
258 #error Please add compiler specific definitions for your compiler
267 /* CONST_STRPTR is a typedef made by a patched version of <exec/types.h>.
268 * Passing "const char *" parameters will only work if the OS protos are
269 * patched accordingly, otherwise you will get a lot of compiler warnings
270 * for const to volatile conversions.
272 * Using "const" where it is appropriate helps the compiler optimizing
273 * code better, so this mess is probably worth it. I wish one day the OS
274 * headers will come with support for the const keyword.
276 #ifndef _CONST_STRPTR_DEFINED
277 typedef char *CONST_STRPTR;
281 /* Special function attributes */
283 #define LIBCALL ASMCALL SAVEDS
284 #define HOOKCALL ASMCALL SAVEDS
286 #define GLOBALCALL extern "C"
291 /* special variable attributes */
296 /* AROS Compatibility: IPTR is a type which can store a pointer
297 * as well as a long integer.
304 #endif /* !COMPILERSPECIFIC_H */