1 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
2 /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is [Open Source Virtual Machine.].
18 * The Initial Developer of the Original Code is
19 * Adobe System Incorporated.
20 * Portions created by the Initial Developer are Copyright (C) 1993-2006
21 * the Initial Developer. All Rights Reserved.
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef __avmplus_system_selection__
41 #define __avmplus_system_selection__
43 // Standard operating system, CPU, word size, and endianness selection
44 // for tier-one AVM platforms. This file defines all the AVMSYSTEM_
45 // names. It would normally be included into a feature definition file.
50 #define AVMSYSTEM_UNIX 1
52 #define AVMSYSTEM_UNIX 0
55 #define AVMSYSTEM_MAC 1
57 #define AVMSYSTEM_MAC 0
60 #define AVMSYSTEM_WIN32 1
62 #define AVMSYSTEM_WIN32 0
64 #ifdef __SYMBIAN32__ // defined by Symbian S60 tool chain
65 #define AVMSYSTEM_SYMBIAN 1
67 #define AVMSYSTEM_SYMBIAN 0
71 #define AVMSYSTEM_WEBOS 1
73 #define AVMSYSTEM_WEBOS 0
80 #if AVMSYSTEM_MAC || AVMSYSTEM_UNIX
82 #if defined(__i386__) || defined(__i386)
83 #define AVMSYSTEM_IA32 1
85 #define AVMSYSTEM_IA32 0
88 #if defined(__x86_64__)
89 #define AVMSYSTEM_AMD64 1
92 #define AVMSYSTEM_AMD64 0
95 #if defined(__ppc__) || defined(__powerpc__) || (__ppc64__) || (__powerpc64__)
96 #define AVMSYSTEM_PPC 1
97 #if (__ppc64__) || (__powerpc64__)
101 #define AVMSYSTEM_PPC 0
104 #if defined(__arm__) || defined(__ARM__)
105 #define AVMSYSTEM_ARM 1
107 #define AVMSYSTEM_ARM 0
110 #if defined(__sparc__) || defined(__sparc)
111 #define AVMSYSTEM_SPARC 1
113 #define AVMSYSTEM_SPARC 0
116 #if defined(__mips__) || defined(__MIPS__)
117 #define AVMSYSTEM_MIPS 1
119 #define AVMSYSTEM_MIPS 0
123 #define AVMSYSTEM_SH4 1
125 #define AVMSYSTEM_SH4 0
128 #endif // mac || unix
133 #define AVMSYSTEM_AMD64 1
136 #define AVMSYSTEM_AMD64 0
140 #define AVMSYSTEM_ARM 1
142 #define AVMSYSTEM_ARM 0
145 #if !AVMSYSTEM_AMD64 && !AVMSYSTEM_ARM
146 #define AVMSYSTEM_IA32 1
148 #define AVMSYSTEM_IA32 0
151 #define AVMSYSTEM_PPC 0
152 #define AVMSYSTEM_SPARC 0
153 #define AVMSYSTEM_SH4 0
154 #define AVMSYSTEM_MIPS 0
158 #if AVMSYSTEM_SYMBIAN
160 #define AVMSYSTEM_PPC 0
161 #define AVMSYSTEM_AMD64 0
162 #define AVMSYSTEM_SPARC 0
163 #define AVMSYSTEM_MIPS 0
164 #define AVMSYSTEM_SH4 0
166 #if defined(__ARMCC__)
167 #define AVMSYSTEM_ARM 1
169 #define AVMSYSTEM_ARM 0
173 #define AVMSYSTEM_IA32 1
175 #define AVMSYSTEM_IA32 0
179 #define AVMTWEAK_EPOC_EMULATOR 1
185 #define AVMSYSTEM_32BIT 0
186 #define AVMSYSTEM_64BIT 1
188 #define AVMSYSTEM_32BIT 1
189 #define AVMSYSTEM_64BIT 0
196 #if AVMSYSTEM_IA32 || AVMSYSTEM_AMD64
197 #define AVMSYSTEM_LITTLE_ENDIAN 1
198 #define AVMSYSTEM_BIG_ENDIAN 0
201 #define AVMSYSTEM_LITTLE_ENDIAN 1
202 #define AVMSYSTEM_BIG_ENDIAN 0
203 #elif defined __GNUC__
204 #if AVMSYSTEM_MAC && AVMSYSTEM_ARM
205 #include <machine/endian.h>
206 #define __BYTE_ORDER BYTE_ORDER
210 #if __BYTE_ORDER == LITTLE_ENDIAN
211 #define AVMSYSTEM_LITTLE_ENDIAN 1
212 #define AVMSYSTEM_BIG_ENDIAN 0
213 #if __FLOAT_WORD_ORDER == BIG_ENDIAN
214 #define AVMSYSTEM_DOUBLE_MSW_FIRST 1
217 #define AVMSYSTEM_LITTLE_ENDIAN 0
218 #define AVMSYSTEM_BIG_ENDIAN 1
220 #elif defined __ARMCC__
221 #define AVMSYSTEM_LITTLE_ENDIAN 1
222 #define AVMSYSTEM_BIG_ENDIAN 0
224 #elif AVMSYSTEM_PPC || AVMSYSTEM_SPARC
225 #define AVMSYSTEM_LITTLE_ENDIAN 0
226 #define AVMSYSTEM_BIG_ENDIAN 1
227 #elif AVMSYSTEM_MIPS || AVMSYSTEM_SH4
230 #if __BYTE_ORDER == LITTLE_ENDIAN
231 #define AVMSYSTEM_LITTLE_ENDIAN 1
232 #define AVMSYSTEM_BIG_ENDIAN 0
234 #define AVMSYSTEM_LITTLE_ENDIAN 0
235 #define AVMSYSTEM_BIG_ENDIAN 1
239 #error "Error in test to determine endianness"
244 // currently used only by the AVMSYSTEM_ARM case, but we include
245 // it on all platforms to ensure consistent build system failures
246 #include "../nanojit/njcpudetect.h"
248 #if AVMSYSTEM_IA32 || AVMSYSTEM_AMD64
249 #define AVMSYSTEM_UNALIGNED_INT_ACCESS 1
250 #define AVMSYSTEM_UNALIGNED_FP_ACCESS 1
253 // At the time of this writing (Feb 2010), Palm's webOS deliberately enables software interrupts
254 // for all unaligned accesses, apparently in the name of promoting "clean code", making unaligned
255 // accesses vastly slower than aligned (reportedly on the order of 1000x). Unless they change this
256 // policy (or give us a way to change it selectively) we will consider all webOS builds not to
257 // support unaligned access, regardless of the processor variant.
258 #define AVMSYSTEM_UNALIGNED_INT_ACCESS 0
261 // ARM is a little complicated:
263 // ARMv5 (e.g. ARM926): No support for unaligned accesses.
264 // ARMv6 (e.g. ARM1176): Optional support that must be enabled by the OS.
265 // ARMv7 (e.g. Cortex-A8): Unaligned access support cannot be disabled; you always have it.
267 #if NJ_COMPILER_ARM_ARCH >= 7
268 #define AVMSYSTEM_UNALIGNED_INT_ACCESS 1
270 #define AVMSYSTEM_UNALIGNED_INT_ACCESS 0
273 // VFP rules are different from int rules on ARM
274 #define AVMSYSTEM_UNALIGNED_FP_ACCESS 0
275 #elif AVMSYSTEM_PPC || AVMSYSTEM_SPARC || AVMSYSTEM_MIPS || AVMSYSTEM_SH4
276 #define AVMSYSTEM_UNALIGNED_INT_ACCESS 0
277 #define AVMSYSTEM_UNALIGNED_FP_ACCESS 0
279 #error "Error in test to determine endianness"
282 #ifndef AVMSYSTEM_DOUBLE_MSW_FIRST
283 #define AVMSYSTEM_DOUBLE_MSW_FIRST 0