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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 static int CountOneBits(uint32_t x); | 80 static int CountOneBits(uint32_t x); |
81 | 81 |
82 static int HighestBit(int64_t v); | 82 static int HighestBit(int64_t v); |
83 | 83 |
84 static int CountTrailingZeros(uword x); | 84 static int CountTrailingZeros(uword x); |
85 | 85 |
86 // Computes a hash value for the given string. | 86 // Computes a hash value for the given string. |
87 static uint32_t StringHash(const char* data, int length); | 87 static uint32_t StringHash(const char* data, int length); |
88 | 88 |
89 // Computes a hash value for the given word. | 89 // Computes a hash value for the given word. |
90 static uint32_t WordHash(word key); | 90 static uint32_t WordHash(intptr_t key); |
91 | 91 |
92 // Check whether an N-bit two's-complement representation can hold value. | 92 // Check whether an N-bit two's-complement representation can hold value. |
93 template<typename T> | 93 template<typename T> |
94 static inline bool IsInt(int N, T value) { | 94 static inline bool IsInt(int N, T value) { |
95 ASSERT((0 < N) && | 95 ASSERT((0 < N) && |
96 (static_cast<unsigned int>(N) < (kBitsPerByte * sizeof(value)))); | 96 (static_cast<unsigned int>(N) < (kBitsPerByte * sizeof(value)))); |
97 T limit = static_cast<T>(1) << (N - 1); | 97 T limit = static_cast<T>(1) << (N - 1); |
98 return (-limit <= value) && (value < limit); | 98 return (-limit <= value) && (value < limit); |
99 } | 99 } |
100 | 100 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 #include "platform/utils_linux.h" | 204 #include "platform/utils_linux.h" |
205 #elif defined(TARGET_OS_MACOS) | 205 #elif defined(TARGET_OS_MACOS) |
206 #include "platform/utils_macos.h" | 206 #include "platform/utils_macos.h" |
207 #elif defined(TARGET_OS_WINDOWS) | 207 #elif defined(TARGET_OS_WINDOWS) |
208 #include "platform/utils_win.h" | 208 #include "platform/utils_win.h" |
209 #else | 209 #else |
210 #error Unknown target os. | 210 #error Unknown target os. |
211 #endif | 211 #endif |
212 | 212 |
213 #endif // PLATFORM_UTILS_H_ | 213 #endif // PLATFORM_UTILS_H_ |
OLD | NEW |