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_UTILS_H_ | 5 #ifndef PLATFORM_UTILS_H_ |
6 #define PLATFORM_UTILS_H_ | 6 #define PLATFORM_UTILS_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
10 | 10 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 static uint16_t HostToBigEndian16(uint16_t host_value); | 194 static uint16_t HostToBigEndian16(uint16_t host_value); |
195 static uint32_t HostToBigEndian32(uint32_t host_value); | 195 static uint32_t HostToBigEndian32(uint32_t host_value); |
196 static uint64_t HostToBigEndian64(uint64_t host_value); | 196 static uint64_t HostToBigEndian64(uint64_t host_value); |
197 static uint16_t HostToLittleEndian16(uint16_t host_value); | 197 static uint16_t HostToLittleEndian16(uint16_t host_value); |
198 static uint32_t HostToLittleEndian32(uint32_t host_value); | 198 static uint32_t HostToLittleEndian32(uint32_t host_value); |
199 static uint64_t HostToLittleEndian64(uint64_t host_value); | 199 static uint64_t HostToLittleEndian64(uint64_t host_value); |
200 | 200 |
201 static bool DoublesBitEqual(const double a, const double b) { | 201 static bool DoublesBitEqual(const double a, const double b) { |
202 return bit_cast<int64_t, double>(a) == bit_cast<int64_t, double>(b); | 202 return bit_cast<int64_t, double>(a) == bit_cast<int64_t, double>(b); |
203 } | 203 } |
| 204 |
| 205 // dart2js represents integers as double precision floats, which can |
| 206 // represent anything in the range -2^53 ... 2^53. |
| 207 static bool IsJavascriptInt(int64_t value) { |
| 208 return ((-0x20000000000000LL <= value) && (value <= 0x20000000000000LL)); |
| 209 } |
| 210 static bool IsJavascriptInt(intptr_t value) { |
| 211 #if defined(ARCH_IS_64BIT) |
| 212 return ((-0x20000000000000LL <= value) && (value <= 0x20000000000000LL)); |
| 213 #else |
| 214 return true; |
| 215 #endif |
| 216 } |
204 }; | 217 }; |
205 | 218 |
206 } // namespace dart | 219 } // namespace dart |
207 | 220 |
208 #if defined(TARGET_OS_ANDROID) | 221 #if defined(TARGET_OS_ANDROID) |
209 #include "platform/utils_android.h" | 222 #include "platform/utils_android.h" |
210 #elif defined(TARGET_OS_LINUX) | 223 #elif defined(TARGET_OS_LINUX) |
211 #include "platform/utils_linux.h" | 224 #include "platform/utils_linux.h" |
212 #elif defined(TARGET_OS_MACOS) | 225 #elif defined(TARGET_OS_MACOS) |
213 #include "platform/utils_macos.h" | 226 #include "platform/utils_macos.h" |
214 #elif defined(TARGET_OS_WINDOWS) | 227 #elif defined(TARGET_OS_WINDOWS) |
215 #include "platform/utils_win.h" | 228 #include "platform/utils_win.h" |
216 #else | 229 #else |
217 #error Unknown target os. | 230 #error Unknown target os. |
218 #endif | 231 #endif |
219 | 232 |
220 #endif // PLATFORM_UTILS_H_ | 233 #endif // PLATFORM_UTILS_H_ |
OLD | NEW |