OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef BIN_GLOBALS_H_ | 5 #ifndef PLATFORM_GLOBALS_H_ |
6 #define BIN_GLOBALS_H_ | 6 #define PLATFORM_GLOBALS_H_ |
7 | |
8 // __STDC_FORMAT_MACROS has to be defined to enable platform independent printf. | |
9 #ifndef __STDC_FORMAT_MACROS | |
10 #define __STDC_FORMAT_MACROS | |
11 #endif | |
7 | 12 |
8 #if defined(_WIN32) | 13 #if defined(_WIN32) |
9 // Cut down on the amount of stuff that gets included via windows.h. | 14 // Cut down on the amount of stuff that gets included via windows.h. |
10 #define WIN32_LEAN_AND_MEAN | 15 #define WIN32_LEAN_AND_MEAN |
11 #define NOMINMAX | 16 #define NOMINMAX |
12 #define NOKERNEL | 17 #define NOKERNEL |
13 #define NOUSER | 18 #define NOUSER |
14 #define NOSERVICE | 19 #define NOSERVICE |
15 #define NOSOUND | 20 #define NOSOUND |
16 #define NOMCX | 21 #define NOMCX |
17 | 22 |
18 #include <windows.h> | 23 #include <windows.h> |
19 #include <Rpc.h> | 24 #include <Rpc.h> |
20 #endif | 25 #endif |
21 | 26 |
22 // Processor architecture detection. For more info on what's defined, see: | 27 #if !defined(_WIN32) |
23 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx | 28 #include <inttypes.h> |
24 // http://www.agner.org/optimize/calling_conventions.pdf | 29 #include <stdint.h> |
25 // or with gcc, run: "echo | gcc -E -dM -" | 30 #endif |
26 #if defined(_M_X64) || defined(__x86_64__) | 31 |
27 #define HOST_ARCH_X64 1 | 32 #include <float.h> |
28 #define ARCH_IS_64_BIT 1 | 33 #include <limits.h> |
29 #elif defined(_M_IX86) || defined(__i386__) | 34 #include <math.h> |
30 #define HOST_ARCH_IA32 1 | 35 #include <openssl/bn.h> |
31 #define ARCH_IS_32_BIT 1 | 36 #include <stdarg.h> |
32 #elif defined(__ARMEL__) | 37 #include <stddef.h> |
33 #define HOST_ARCH_ARM 1 | 38 #include <stdio.h> |
34 #define ARCH_IS_32_BIT 1 | 39 #include <stdlib.h> |
35 #else | 40 #include <string.h> |
36 #error Architecture was not detected as supported by Dart. | 41 #include <sys/types.h> |
42 | |
43 #if defined(_WIN32) | |
44 #include "vm/c99_support_win.h" | |
Søren Gjesse
2012/01/05 13:15:32
Move these .h files to platform/ as well.
Mads Ager (google)
2012/01/05 14:42:27
Yes! Thank you!
| |
45 #include "vm/inttypes_support_win.h" | |
37 #endif | 46 #endif |
38 | 47 |
39 | 48 |
40 #if !defined(TARGET_ARCH_ARM) | |
41 #if !defined(TARGET_ARCH_X64) | |
42 #if !defined(TARGET_ARCH_IA32) | |
43 // No target architecture specified pick the one matching the host architecture. | |
44 #if defined(HOST_ARCH_ARM) | |
45 #define TARGET_ARCH_ARM 1 | |
46 #elif defined(HOST_ARCH_X64) | |
47 #define TARGET_ARCH_X64 1 | |
48 #elif defined(HOST_ARCH_IA32) | |
49 #define TARGET_ARCH_IA32 1 | |
50 #else | |
51 #error Automatic target architecture detection failed. | |
52 #endif | |
53 #endif | |
54 #endif | |
55 #endif | |
56 | |
57 | |
58 // Verify that host and target architectures match, we cannot | |
59 // have a 64 bit Dart VM generating 32 bit code or vice-versa. | |
60 #if defined(TARGET_ARCH_X64) | |
61 #if !defined(ARCH_IS_64_BIT) | |
62 #error Mismatched Host/Target architectures. | |
63 #endif | |
64 #elif defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM) | |
65 #if !defined(ARCH_IS_32_BIT) | |
66 #error Mismatched Host/Target architectures. | |
67 #endif | |
68 #endif | |
69 | |
70 | |
71 // Target OS detection. | 49 // Target OS detection. |
72 // for more information on predefined macros: | 50 // for more information on predefined macros: |
73 // - http://msdn.microsoft.com/en-us/library/b0084kay.aspx | 51 // - http://msdn.microsoft.com/en-us/library/b0084kay.aspx |
74 // - with gcc, run: "echo | gcc -E -dM -" | 52 // - with gcc, run: "echo | gcc -E -dM -" |
75 #if defined(__linux__) || defined(__FreeBSD__) | 53 #if defined(__linux__) || defined(__FreeBSD__) |
76 #define TARGET_OS_LINUX 1 | 54 #define TARGET_OS_LINUX 1 |
77 #elif defined(__APPLE__) | 55 #elif defined(__APPLE__) |
78 #define TARGET_OS_MACOS 1 | 56 #define TARGET_OS_MACOS 1 |
79 #elif defined(_WIN32) | 57 #elif defined(_WIN32) |
80 #define TARGET_OS_WINDOWS 1 | 58 #define TARGET_OS_WINDOWS 1 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 static inline void USE(T) { } | 95 static inline void USE(T) { } |
118 | 96 |
119 | 97 |
120 // On Windows the reentrent version of strtok is called | 98 // On Windows the reentrent version of strtok is called |
121 // strtok_s. Unify on the posix name strtok_r. | 99 // strtok_s. Unify on the posix name strtok_r. |
122 #if defined(TARGET_OS_WINDOWS) | 100 #if defined(TARGET_OS_WINDOWS) |
123 #define snprintf _snprintf | 101 #define snprintf _snprintf |
124 #define strtok_r strtok_s | 102 #define strtok_r strtok_s |
125 #endif | 103 #endif |
126 | 104 |
127 #endif // BIN_GLOBALS_H_ | 105 #endif // PLATFORM_GLOBALS_H_ |
OLD | NEW |