application.mui: implemented MUIM_Application_UnpushMethod
[AROS.git] / compiler / arossupport / include / system.h
blobb35bdbc33b2dd589317d9e7b11a9564874e9b299
1 #ifndef AROS_SYSTEM_H
2 #define AROS_SYSTEM_H
4 /*
5 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Analyse the current kind of system and compiler.
9 Lang: english
12 #ifndef AROS_CPU_H
13 # include <aros/cpu.h>
14 #endif
16 /**************************************
17 Defines
18 **************************************/
19 /* 1. Analyze system: Specify a definitive define for each system */
20 #if defined(_AMIGA) || defined(AMIGA)
21 # ifndef _AMIGA
22 # define _AMIGA
23 # endif
24 # ifndef AMIGA
25 # define AMIGA
26 # endif
27 #endif
29 #if defined __GNUC__ && defined __GNUC_MINOR__
30 # define __GNUC_PREREQ(maj, min) \
31 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
32 #else
33 # define __GNUC_PREREQ(maj, min) 0
34 #endif
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
45 * optimize stuff
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 };
54 #else
55 # define __EXTERN extern
56 # define __BEGIN_DECLS
57 # define __BEGIN_EXTERN
58 # define __END_DECLS
59 # define __END_EXTERN
60 #endif
62 #if defined(__STDC__) || defined(__cplusplus)
63 # if !defined(__GNUC__)
64 # define __const__ const
65 # define __inline__ inline
66 # define __volatile__ volatile
67 # endif
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
75 # else
76 # define __restrict__
77 # define restrict
78 # endif
80 #else
81 # define __const__
82 # define const
83 # define __inline__
84 # define inline
85 # define __volatile__
86 # define volatile
87 # define __restrict__
88 # define restrict
89 #endif
91 #if defined(__GNUC__) && !defined(__THROW)
92 # if defined __cplusplus && __GNUC_PREREQ (2,8)
93 # define __THROW throw ()
94 # else
95 # define __THROW
96 # endif
97 #endif
99 /* 3. Macros for making things more efficient */
100 #if __GNUC_PREREQ(2,5)
101 # define __noreturn __attribute__((__noreturn__))
102 #else
103 # define __noreturn
104 #endif
106 #if __GNUC_PREREQ(2,5) && !(__GNUC_PREREQ(2,6) && defined __cplusplus)
107 # define __noeffect __attribute__((__const__))
108 #else
109 # define __noeffect
110 #endif
112 #if __GNUC_PREREQ(2,7)
113 # define __unused __attribute__((__unused__))
114 #else
115 # define __unused
116 #endif
118 #if __GNUC_PREREQ(3,3)
119 # define __used __attribute__((__used__))
120 #else
121 # define __used __unused
122 #endif
124 #if __GNUC_PREREQ(2,96)
125 # define __pure __attribute__((__pure__))
126 #else
127 # define __pure
128 #endif
130 #if __GNUC_PREREQ(2,5)
131 # define __const __attribute__((__const__))
132 #else
133 # define __const
134 #endif
136 #if __GNUC_PREREQ(3,3)
137 # define __mayalias __attribute__((__may_alias__))
138 #else
139 # define __mayalias
140 #endif
142 #define __pure2 __const
144 /* 4. Macros for debugging and development */
145 #if defined(__GNUC__) || defined(__INTEL_COMPILER) || (defined(__STDC__) && __STDC_VERSION__ >= 199901L)
146 #if !defined(AROS_64BIT_TYPE)
147 # define AROS_64BIT_TYPE long long
148 #endif
149 # define AROS_HAVE_LONG_LONG
150 #endif
152 #if defined(__INTEL_COMPILER)
153 # ifdef inline
154 # undef inline
155 # endif
156 # define inline
157 #endif
159 #if __GNUC__ <= 2
160 # define __deprecated
161 # define __section(x)
162 #endif
163 #if __GNUC__ > 2
164 # define __deprecated __attribute__((__deprecated__))
165 # define __section(x) __attribute__((__section__(x)))
166 #endif
168 #if __GNUC_PREREQ(3,3)
169 #define __startup __section(".aros.startup") __used
170 #else
171 #define __startup __used
172 #endif
174 /* 5. Calculated #defines */
175 #if !AROS_STACK_GROWS_DOWNWARDS
176 # define AROS_SLOWSTACKTAGS
177 # define AROS_SLOWSTACKMETHODS
178 #endif /* !AROS_STACK_GROWS_DOWNWARDS */
180 #if !defined(__CONCAT)
181 # if defined(__STDC__) || defined(__cplusplus)
182 # define __CONCAT1(a,b) a ## b
183 # define __CONCAT(a,b) __CONCAT1(a,b)
184 # else
185 # define __CONCAT(a,b) a/**/b
186 # endif
187 #endif
189 #ifndef AROS_ASMSYMNAME
190 # define AROS_ASMSYMNAME(n) n
191 #endif
193 #ifndef AROS_CSYM_FROM_ASM_NAME
194 # if defined(__ELF__) || defined(__MACH__) || defined(_WIN32) || defined(__CYGWIN__)
195 # define AROS_CSYM_FROM_ASM_NAME(n) n
196 # else
197 # error define AROS_CSYM_FROM_ASM_NAME for your architecture
198 # endif
199 #endif
201 #define ___AROS_STR(x) #x
202 #define __AROS_STR(x) ___AROS_STR(x)
205 /* Makes a 'new' symbol which occupies the same memory location as the 'old' symbol */
206 #if !defined AROS_MAKE_ALIAS
207 # define AROS_MAKE_ALIAS(old, new) \
208 AROS_MAKE_ASM_SYM(typeof(old), new, AROS_CSYM_FROM_ASM_NAME(new), AROS_CSYM_FROM_ASM_NAME(old)); \
209 AROS_EXPORT_ASM_SYM(AROS_CSYM_FROM_ASM_NAME(new))
210 #endif
212 /* define an asm symbol 'asym' with a C name 'csym', type 'type' and with value 'value'.
213 'value' has to be an asm constant, thus either an address number or an asm symbol name, */
214 #if !defined AROS_MAKE_ASM_SYM
215 # define AROS_MAKE_ASM_SYM(type, csym, asym, value) \
216 extern type csym asm(__AROS_STR(asym)); \
217 typedef int __CONCAT(__you_must_first_make_asym_, asym); \
218 asm(".set " __AROS_STR(asym) ", " __AROS_STR(value) "\n")
219 #endif
221 /* Makes an ASM symbol 'asym' available for use in the compilation unit this
222 macro is used, with a C name 'csym'. This has also the side effect of
223 triggering the inclusion, by the linker, of all code and data present in the
224 module where the ASM symbol is actually defined. */
225 #if !defined AROS_IMPORT_ASM_SYM
226 # define AROS_IMPORT_ASM_SYM(type, csym, asym) \
227 extern type csym asm(__AROS_STR(asym)); \
228 asm("\n.globl " __AROS_STR(asym) "\n")
229 #endif
231 /* Make sure other compilation units can see the symbol 'asym' created with AROS_MAKE_ASM_SYM.
232 This macro results in a compile-time error in case it's used BEFORE the symbol has been
233 made with AROS_MAKE_ASM_SYM. */
234 #if !defined AROS_EXPORT_ASM_SYM
235 # define AROS_EXPORT_ASM_SYM(asym) \
236 struct __CONCAT(___you_must_first_make_asym_, asym) \
238 int a[sizeof(__CONCAT(__you_must_first_make_asym_, asym))]; \
239 }; \
240 asm("\n.globl " __AROS_STR(asym) "\n")
241 #endif
243 #endif /* AROS_SYSTEM_H */