OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 #ifndef BIN_GLOBALS_H_ | |
6 #define BIN_GLOBALS_H_ | |
7 | |
8 #if defined(_WIN32) | |
9 // Cut down on the amount of stuff that gets included via windows.h. | |
10 #define WIN32_LEAN_AND_MEAN | |
11 #define NOMINMAX | |
12 #define NOKERNEL | |
13 #define NOUSER | |
14 #define NOSERVICE | |
15 #define NOSOUND | |
16 #define NOMCX | |
17 | |
18 #include <windows.h> | |
19 #include <Rpc.h> | |
20 #endif | |
21 | |
22 // Processor architecture detection. For more info on what's defined, see: | |
23 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx | |
24 // http://www.agner.org/optimize/calling_conventions.pdf | |
25 // or with gcc, run: "echo | gcc -E -dM -" | |
26 #if defined(_M_X64) || defined(__x86_64__) | |
27 #define HOST_ARCH_X64 1 | |
28 #define ARCH_IS_64_BIT 1 | |
29 #elif defined(_M_IX86) || defined(__i386__) | |
30 #define HOST_ARCH_IA32 1 | |
31 #define ARCH_IS_32_BIT 1 | |
32 #elif defined(__ARMEL__) | |
33 #define HOST_ARCH_ARM 1 | |
34 #define ARCH_IS_32_BIT 1 | |
35 #else | |
36 #error Architecture was not detected as supported by Dart. | |
37 #endif | |
38 | |
39 | |
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. | |
72 // for more information on predefined macros: | |
73 // - http://msdn.microsoft.com/en-us/library/b0084kay.aspx | |
74 // - with gcc, run: "echo | gcc -E -dM -" | |
75 #if defined(__linux__) || defined(__FreeBSD__) | |
76 #define TARGET_OS_LINUX 1 | |
77 #elif defined(__APPLE__) | |
78 #define TARGET_OS_MACOS 1 | |
79 #elif defined(_WIN32) | |
80 #define TARGET_OS_WINDOWS 1 | |
81 #else | |
82 #error Automatic target os detection failed. | |
83 #endif | |
84 | |
85 | |
86 // A macro to disallow the copy constructor and operator= functions. | |
87 // This should be used in the private: declarations for a class. | |
88 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ | |
89 private: \ | |
90 TypeName(const TypeName&); \ | |
91 void operator=(const TypeName&) | |
92 | |
93 | |
94 // A macro to disallow all the implicit constructors, namely the default | |
95 // constructor, copy constructor and operator= functions. This should be | |
96 // used in the private: declarations for a class that wants to prevent | |
97 // anyone from instantiating it. This is especially useful for classes | |
98 // containing only static methods. | |
99 #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ | |
100 private: \ | |
101 TypeName(); \ | |
102 DISALLOW_COPY_AND_ASSIGN(TypeName) | |
103 | |
104 | |
105 // Macro to disallow allocation in the C++ heap. This should be used | |
106 // in the private section for a class. | |
107 #define DISALLOW_ALLOCATION() \ | |
108 public: \ | |
109 void operator delete(void* pointer) { UNREACHABLE(); } \ | |
110 private: \ | |
111 void* operator new(size_t size); | |
112 | |
113 | |
114 // The USE(x) template is used to silence C++ compiler warnings issued | |
115 // for unused variables. | |
116 template <typename T> | |
117 static inline void USE(T) { } | |
118 | |
119 | |
120 // On Windows the reentrent version of strtok is called | |
121 // strtok_s. Unify on the posix name strtok_r. | |
122 #if defined(TARGET_OS_WINDOWS) | |
123 #define snprintf _snprintf | |
124 #define strtok_r strtok_s | |
125 #endif | |
126 | |
127 #endif // BIN_GLOBALS_H_ | |
OLD | NEW |