5 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
8 Desc: Analyse the current kind of system and compiler.
13 # include <aros/cpu.h>
16 /**************************************
18 **************************************/
19 /* 1. Analyze system: Specify a definitive define for each system */
20 #if defined(_AMIGA) || defined(AMIGA)
29 #if defined __GNUC__ && defined __GNUC_MINOR__
30 # define __GNUC_PREREQ(maj, min) \
31 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
33 # define __GNUC_PREREQ(maj, min) 0
38 * 2. Analyze compiler for STD C/C++.
40 * We test for the following:
41 * a. extern "C" linkage required for programs.
42 * b. inline, const, volatile, restrict keywords defined in
43 * newer C/C++ standards.
44 * c. throw() being available, which lets the compiler better
48 #if defined(__cplusplus)
49 # define __EXTERN extern "C"
50 # define __BEGIN_DECLS extern "C" {
51 # define __BEGIN_EXTERN extern "C" {
52 # define __END_DECLS };
53 # define __END_EXTERN };
55 # define __EXTERN extern
56 # define __BEGIN_DECLS
57 # define __BEGIN_EXTERN
62 #if defined(__STDC__) || defined(__cplusplus)
63 # if !defined(__GNUC__)
64 # define __const__ const
65 # define __inline__ inline
66 # define __volatile__ volatile
70 * C99 defines a new keyword restrict that can help do optimisation where
71 * pointers are used in programs. We'd like to support optimisation :-)
73 # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
74 # define __restrict__ restrict
91 #if defined(__GNUC__) && !defined(__THROW)
92 # if defined __cplusplus && __GNUC_PREREQ (2,8)
93 # define __THROW throw ()
99 /* 3. Macros for making things more efficient */
101 #if __GNUC_PREREQ(2,5)
102 # define __packed __attribute__((__packed__))
107 #if __GNUC_PREREQ(2,5)
108 # define __noreturn __attribute__((__noreturn__))
115 #if __GNUC_PREREQ(2,5) && !(__GNUC_PREREQ(2,6) && defined __cplusplus)
116 # define __noeffect __attribute__((__const__))
123 # if __GNUC_PREREQ(2,7)
124 # define __unused __attribute__((__unused__))
131 # if __GNUC_PREREQ(3,3)
132 # define __used __attribute__((__used__))
134 # define __used __unused
139 #if __GNUC_PREREQ(2,96)
140 # define __pure __attribute__((__pure__))
147 #if __GNUC_PREREQ(2,5)
148 # define __const __attribute__((__const__))
155 #if __GNUC_PREREQ(3,3)
156 # define __mayalias __attribute__((__may_alias__))
162 #define __pure2 __const
164 /* 4. Macros for debugging and development */
165 #if defined(__GNUC__) || defined(__INTEL_COMPILER) || (defined(__STDC__) && __STDC_VERSION__ >= 199901L)
166 #if !defined(AROS_64BIT_TYPE)
167 # define AROS_64BIT_TYPE long long
169 # define AROS_HAVE_LONG_LONG
172 #if defined(__INTEL_COMPILER)
180 # define __deprecated
181 # define __section(x)
184 # define __deprecated __attribute__((__deprecated__))
185 # define __section(x) __attribute__((__section__(x)))
188 #if __GNUC_PREREQ(3,3)
189 #define __startup __section(".aros.startup") __used
191 #define __startup __used
194 /* 5. Calculated #defines */
195 #if !AROS_STACK_GROWS_DOWNWARDS
196 # define AROS_SLOWSTACKTAGS
197 # define AROS_SLOWSTACKMETHODS
198 #endif /* !AROS_STACK_GROWS_DOWNWARDS */
200 #if !defined(__CONCAT)
201 # if defined(__STDC__) || defined(__cplusplus)
202 # define __CONCAT1(a,b) a ## b
203 # define __CONCAT(a,b) __CONCAT1(a,b)
205 # define __CONCAT(a,b) a/**/b
209 #ifndef AROS_ASMSYMNAME
210 # define AROS_ASMSYMNAME(n) n
213 #ifndef AROS_CSYM_FROM_ASM_NAME
214 # if defined(__ELF__) || defined(__MACH__) || defined(_WIN32) || defined(__CYGWIN__)
215 # define AROS_CSYM_FROM_ASM_NAME(n) n
217 # error define AROS_CSYM_FROM_ASM_NAME for your architecture
221 #define ___AROS_STR(x) #x
222 #define __AROS_STR(x) ___AROS_STR(x)
225 /* Makes a 'new' symbol which occupies the same memory location as the 'old' symbol */
226 #if !defined AROS_MAKE_ALIAS
227 # define AROS_MAKE_ALIAS(old, new) \
228 AROS_MAKE_ASM_SYM(typeof(old), new, AROS_CSYM_FROM_ASM_NAME(new), AROS_CSYM_FROM_ASM_NAME(old)); \
229 AROS_EXPORT_ASM_SYM(AROS_CSYM_FROM_ASM_NAME(new))
232 /* define an asm symbol 'asym' with a C name 'csym', type 'type' and with value 'value'.
233 'value' has to be an asm constant, thus either an address number or an asm symbol name, */
234 #if !defined AROS_MAKE_ASM_SYM
235 # define AROS_MAKE_ASM_SYM(type, csym, asym, value) \
236 extern type csym asm(__AROS_STR(asym)); \
237 typedef int __CONCAT(__you_must_first_make_asym_, asym); \
238 asm(".set " __AROS_STR(asym) ", " __AROS_STR(value) "\n")
241 /* Makes an ASM symbol 'asym' available for use in the compilation unit this
242 macro is used, with a C name 'csym'. This has also the side effect of
243 triggering the inclusion, by the linker, of all code and data present in the
244 module where the ASM symbol is actually defined. */
245 #if !defined AROS_IMPORT_ASM_SYM
246 # define AROS_IMPORT_ASM_SYM(type, csym, asym) \
247 extern type csym asm(__AROS_STR(asym)); \
248 asm("\n.globl " __AROS_STR(asym) "\n")
251 /* Make sure other compilation units can see the symbol 'asym' created with AROS_MAKE_ASM_SYM.
252 This macro results in a compile-time error in case it's used BEFORE the symbol has been
253 made with AROS_MAKE_ASM_SYM. */
254 #if !defined AROS_EXPORT_ASM_SYM
255 # define AROS_EXPORT_ASM_SYM(asym) \
256 struct __CONCAT(___you_must_first_make_asym_, asym) \
258 int a[sizeof(__CONCAT(__you_must_first_make_asym_, asym))]; \
260 asm("\n.globl " __AROS_STR(asym) "\n")
263 #endif /* AROS_SYSTEM_H */