Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: runtime/platform/globals.h

Issue 9209001: Move utils.h and utils.cc from runtime/vm to runtime/platform (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/platform/platform_headers.gypi » ('j') | runtime/vm/assembler.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, 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 PLATFORM_GLOBALS_H_ 5 #ifndef PLATFORM_GLOBALS_H_
6 #define PLATFORM_GLOBALS_H_ 6 #define PLATFORM_GLOBALS_H_
7 7
8 // __STDC_FORMAT_MACROS has to be defined to enable platform independent printf. 8 // __STDC_FORMAT_MACROS has to be defined to enable platform independent printf.
9 #ifndef __STDC_FORMAT_MACROS 9 #ifndef __STDC_FORMAT_MACROS
10 #define __STDC_FORMAT_MACROS 10 #define __STDC_FORMAT_MACROS
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #if defined(__linux__) || defined(__FreeBSD__) 54 #if defined(__linux__) || defined(__FreeBSD__)
55 #define TARGET_OS_LINUX 1 55 #define TARGET_OS_LINUX 1
56 #elif defined(__APPLE__) 56 #elif defined(__APPLE__)
57 #define TARGET_OS_MACOS 1 57 #define TARGET_OS_MACOS 1
58 #elif defined(_WIN32) 58 #elif defined(_WIN32)
59 #define TARGET_OS_WINDOWS 1 59 #define TARGET_OS_WINDOWS 1
60 #else 60 #else
61 #error Automatic target os detection failed. 61 #error Automatic target os detection failed.
62 #endif 62 #endif
63 63
64 // Processor architecture detection. For more info on what's defined, see:
65 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx
66 // http://www.agner.org/optimize/calling_conventions.pdf
67 // or with gcc, run: "echo | gcc -E -dM -"
68 #if defined(_M_X64) || defined(__x86_64__)
69 #define HOST_ARCH_X64 1
70 #define ARCH_IS_64_BIT 1
71 #elif defined(_M_IX86) || defined(__i386__)
72 #define HOST_ARCH_IA32 1
73 #define ARCH_IS_32_BIT 1
74 #elif defined(__ARMEL__)
75 #define HOST_ARCH_ARM 1
76 #define ARCH_IS_32_BIT 1
77 #else
78 #error Architecture was not detected as supported by Dart.
79 #endif
80
81 #if !defined(TARGET_ARCH_ARM)
82 #if !defined(TARGET_ARCH_X64)
83 #if !defined(TARGET_ARCH_IA32)
84 // No target architecture specified pick the one matching the host architecture.
85 #if defined(HOST_ARCH_ARM)
86 #define TARGET_ARCH_ARM 1
87 #elif defined(HOST_ARCH_X64)
88 #define TARGET_ARCH_X64 1
89 #elif defined(HOST_ARCH_IA32)
90 #define TARGET_ARCH_IA32 1
91 #else
92 #error Automatic target architecture detection failed.
93 #endif
94 #endif
95 #endif
96 #endif
97
98 // Verify that host and target architectures match, we cannot
99 // have a 64 bit Dart VM generating 32 bit code or vice-versa.
100 #if defined(TARGET_ARCH_X64)
101 #if !defined(ARCH_IS_64_BIT)
102 #error Mismatched Host/Target architectures.
103 #endif
104 #elif defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_ARM)
105 #if !defined(ARCH_IS_32_BIT)
106 #error Mismatched Host/Target architectures.
107 #endif
108 #endif
109
110
111 // Printf format for intptr_t on Windows.
112 #if !defined(PRIxPTR) && defined(TARGET_OS_WINDOWS)
113 #if defined(ARCH_IS_32_BIT)
114 #define PRIxPTR "x"
115 #else
116 #define PRIxPTR "llx"
117 #endif // defined(ARCH_IS_32_BIT)
118 #endif // !defined(PRIxPTR) && defined(TARGET_OS_WINDOWS)
119
120
121 // Suffixes for 64-bit integer literals.
122 #ifdef _MSC_VER
123 #define DART_INT64_C(x) x##I64
124 #define DART_UINT64_C(x) x##UI64
125 #else
126 #define DART_INT64_C(x) x##LL
127 #define DART_UINT64_C(x) x##ULL
128 #endif
129
130
131 // The following macro works on both 32 and 64-bit platforms.
132 // Usage: instead of writing 0x1234567890123456
133 // write DART_2PART_UINT64_C(0x12345678,90123456);
134 #define DART_2PART_UINT64_C(a, b) \
135 (((static_cast<uint64_t>(a) << 32) + 0x##b##u))
136
137
138 // Types for native machine words. Guaranteed to be able to hold pointers and
139 // integers.
140 typedef intptr_t word;
141 typedef uintptr_t uword;
142
143 // A type large enough to contain the value of the C++ vtable. This is needed
144 // to support the handle operations.
Ivan Posva 2012/01/13 23:51:01 This is not needed in platform/globals.h.
Søren Gjesse 2012/01/16 10:53:00 Moved back to vm/globals.h
145 typedef uword cpp_vtable;
146
147 // Byte sizes.
148 const int kWordSize = sizeof(word);
149 #ifdef ARCH_IS_32_BIT
150 const int kWordSizeLog2 = 2;
151 #else
152 const int kWordSizeLog2 = 3;
153 #endif
154
155 // Bit sizes.
156 const int kBitsPerByte = 8;
157 const int kBitsPerByteLog2 = 3;
158 const int kBitsPerWord = kWordSize * kBitsPerByte;
159
160 // System-wide named constants.
161 const int KB = 1024;
162 const int MB = KB * KB;
163 const int GB = KB * KB * KB;
164 const intptr_t kIntptrOne = 1;
165 const intptr_t kIntptrMin = (kIntptrOne << (kBitsPerWord - 1));
166 const intptr_t kIntptrMax = ~kIntptrMin;
167
168 // Time constants.
169 const int kMillisecondsPerSecond = 1000;
170 const int kMicrosecondsPerMillisecond = 1000;
171 const int kMicrosecondsPerSecond = (kMicrosecondsPerMillisecond *
172 kMillisecondsPerSecond);
173 const int kNanosecondsPerMicrosecond = 1000;
174 const int kNanosecondsPerMillisecond = (kNanosecondsPerMicrosecond *
175 kMicrosecondsPerMillisecond);
176 const int kNanosecondsPerSecond = (kNanosecondsPerMicrosecond *
177 kMicrosecondsPerSecond);
64 178
65 // A macro to disallow the copy constructor and operator= functions. 179 // A macro to disallow the copy constructor and operator= functions.
66 // This should be used in the private: declarations for a class. 180 // This should be used in the private: declarations for a class.
67 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ 181 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
68 private: \ 182 private: \
69 TypeName(const TypeName&); \ 183 TypeName(const TypeName&); \
70 void operator=(const TypeName&) 184 void operator=(const TypeName&)
71 185
72 186
73 // A macro to disallow all the implicit constructors, namely the default 187 // A macro to disallow all the implicit constructors, namely the default
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // separate lines with body in {}s). 224 // separate lines with body in {}s).
111 # define TEMP_FAILURE_RETRY(expression) \ 225 # define TEMP_FAILURE_RETRY(expression) \
112 ({ int64_t __result; \ 226 ({ int64_t __result; \
113 do { \ 227 do { \
114 __result = (int64_t) (expression); \ 228 __result = (int64_t) (expression); \
115 } while (__result == -1L && errno == EINTR); \ 229 } while (__result == -1L && errno == EINTR); \
116 __result; }) 230 __result; })
117 #endif 231 #endif
118 232
119 #endif // PLATFORM_GLOBALS_H_ 233 #endif // PLATFORM_GLOBALS_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/platform/platform_headers.gypi » ('j') | runtime/vm/assembler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698