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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 72 } |
73 | 73 |
74 template<typename T> | 74 template<typename T> |
75 static inline T* RoundUp(T* x, int n) { | 75 static inline T* RoundUp(T* x, int n) { |
76 return reinterpret_cast<T*>(RoundUp(reinterpret_cast<uword>(x), n)); | 76 return reinterpret_cast<T*>(RoundUp(reinterpret_cast<uword>(x), n)); |
77 } | 77 } |
78 | 78 |
79 static uint32_t RoundUpToPowerOfTwo(uint32_t x); | 79 static uint32_t RoundUpToPowerOfTwo(uint32_t x); |
80 static int CountOneBits(uint32_t x); | 80 static int CountOneBits(uint32_t x); |
81 | 81 |
82 static int CountTrailingZeros(uint32_t x); | 82 static int CountTrailingZeros(uword x); |
83 static int CountTrailingZeros(uint64_t x); | |
84 | 83 |
85 // Computes a hash value for the given string. | 84 // Computes a hash value for the given string. |
86 static uint32_t StringHash(const char* data, int length); | 85 static uint32_t StringHash(const char* data, int length); |
87 | 86 |
88 // Computes a hash value for the given word. | 87 // Computes a hash value for the given word. |
89 static uint32_t WordHash(word key); | 88 static uint32_t WordHash(word key); |
90 | 89 |
91 // Check whether an N-bit two's-complement representation can hold value. | 90 // Check whether an N-bit two's-complement representation can hold value. |
92 template<typename T> | 91 template<typename T> |
93 static inline bool IsInt(int N, T value) { | 92 static inline bool IsInt(int N, T value) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 #include "platform/utils_linux.h" | 176 #include "platform/utils_linux.h" |
178 #elif defined(TARGET_OS_MACOS) | 177 #elif defined(TARGET_OS_MACOS) |
179 #include "platform/utils_macos.h" | 178 #include "platform/utils_macos.h" |
180 #elif defined(TARGET_OS_WINDOWS) | 179 #elif defined(TARGET_OS_WINDOWS) |
181 #include "platform/utils_win.h" | 180 #include "platform/utils_win.h" |
182 #else | 181 #else |
183 #error Unknown target os. | 182 #error Unknown target os. |
184 #endif | 183 #endif |
185 | 184 |
186 #endif // PLATFORM_UTILS_H_ | 185 #endif // PLATFORM_UTILS_H_ |
OLD | NEW |