OLD | NEW |
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 #ifdef _MSC_VER | 123 #ifdef _MSC_VER |
124 #define DART_INT64_C(x) x##I64 | 124 #define DART_INT64_C(x) x##I64 |
125 #define DART_UINT64_C(x) x##UI64 | 125 #define DART_UINT64_C(x) x##UI64 |
126 #else | 126 #else |
127 #define DART_INT64_C(x) x##LL | 127 #define DART_INT64_C(x) x##LL |
128 #define DART_UINT64_C(x) x##ULL | 128 #define DART_UINT64_C(x) x##ULL |
129 #endif | 129 #endif |
130 | 130 |
131 | 131 |
132 // The following macro works on both 32 and 64-bit platforms. | 132 // The following macro works on both 32 and 64-bit platforms. |
133 // Usage: instead of writing 0x1234567890123456 | 133 // Usage: instead of writing 0x1234567890123456ULL |
134 // write DART_2PART_UINT64_C(0x12345678,90123456); | 134 // write DART_2PART_UINT64_C(0x12345678,90123456); |
135 #define DART_2PART_UINT64_C(a, b) \ | 135 #define DART_2PART_UINT64_C(a, b) \ |
136 (((static_cast<uint64_t>(a) << 32) + 0x##b##u)) | 136 (((static_cast<uint64_t>(a) << 32) + 0x##b##u)) |
137 | 137 |
| 138 // Integer constants. |
| 139 const int32_t kMinInt32 = 0x80000000; |
| 140 const int32_t kMaxInt32 = 0x7FFFFFFF; |
| 141 const uint32_t kMaxUint32 = 0xFFFFFFFF; |
| 142 const int64_t kMinInt64 = DART_INT64_C(0x8000000000000000); |
| 143 const int64_t kMaxInt64 = DART_INT64_C(0x7FFFFFFFFFFFFFFF); |
| 144 const uint64_t kMaxUint64 = DART_2PART_UINT64_C(0xFFFFFFFF, FFFFFFFF); |
138 | 145 |
139 // Types for native machine words. Guaranteed to be able to hold pointers and | 146 // Types for native machine words. Guaranteed to be able to hold pointers and |
140 // integers. | 147 // integers. |
141 typedef intptr_t word; | 148 typedef intptr_t word; |
142 typedef uintptr_t uword; | 149 typedef uintptr_t uword; |
143 | 150 |
144 // Byte sizes. | 151 // Byte sizes. |
145 const int kWordSize = sizeof(word); | 152 const int kWordSize = sizeof(word); |
146 #ifdef ARCH_IS_32_BIT | 153 #ifdef ARCH_IS_32_BIT |
147 const int kWordSizeLog2 = 2; | 154 const int kWordSizeLog2 = 2; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 // separate lines with body in {}s). | 338 // separate lines with body in {}s). |
332 # define TEMP_FAILURE_RETRY(expression) \ | 339 # define TEMP_FAILURE_RETRY(expression) \ |
333 ({ int64_t __result; \ | 340 ({ int64_t __result; \ |
334 do { \ | 341 do { \ |
335 __result = (int64_t) (expression); \ | 342 __result = (int64_t) (expression); \ |
336 } while (__result == -1L && errno == EINTR); \ | 343 } while (__result == -1L && errno == EINTR); \ |
337 __result; }) | 344 __result; }) |
338 #endif | 345 #endif |
339 | 346 |
340 #endif // PLATFORM_GLOBALS_H_ | 347 #endif // PLATFORM_GLOBALS_H_ |
OLD | NEW |