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

Side by Side Diff: src/base/bits.h

Issue 1365803004: [presubmit] Fix whitespace/semicolon linter violations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « src/arm64/lithium-codegen-arm64.cc ('k') | src/base/platform/condition-variable.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_BASE_BITS_H_ 5 #ifndef V8_BASE_BITS_H_
6 #define V8_BASE_BITS_H_ 6 #define V8_BASE_BITS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include "src/base/macros.h" 9 #include "src/base/macros.h"
10 #if V8_CC_MSVC 10 #if V8_CC_MSVC
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 inline unsigned CountTrailingZeros32(uint32_t value) { 98 inline unsigned CountTrailingZeros32(uint32_t value) {
99 #if V8_HAS_BUILTIN_CTZ 99 #if V8_HAS_BUILTIN_CTZ
100 return value ? __builtin_ctz(value) : 32; 100 return value ? __builtin_ctz(value) : 32;
101 #elif V8_CC_MSVC 101 #elif V8_CC_MSVC
102 unsigned long result; // NOLINT(runtime/int) 102 unsigned long result; // NOLINT(runtime/int)
103 if (!_BitScanForward(&result, value)) return 32; 103 if (!_BitScanForward(&result, value)) return 32;
104 return static_cast<unsigned>(result); 104 return static_cast<unsigned>(result);
105 #else 105 #else
106 if (value == 0) return 32; 106 if (value == 0) return 32;
107 unsigned count = 0; 107 unsigned count = 0;
108 for (value ^= value - 1; value >>= 1; ++count) 108 for (value ^= value - 1; value >>= 1; ++count) {
109 ; 109 }
110 return count; 110 return count;
111 #endif 111 #endif
112 } 112 }
113 113
114 114
115 // CountTrailingZeros64(value) returns the number of zero bits preceding the 115 // CountTrailingZeros64(value) returns the number of zero bits preceding the
116 // least significant 1 bit in |value| if |value| is non-zero, otherwise it 116 // least significant 1 bit in |value| if |value| is non-zero, otherwise it
117 // returns 64. 117 // returns 64.
118 inline unsigned CountTrailingZeros64(uint64_t value) { 118 inline unsigned CountTrailingZeros64(uint64_t value) {
119 #if V8_HAS_BUILTIN_CTZ 119 #if V8_HAS_BUILTIN_CTZ
120 return value ? __builtin_ctzll(value) : 64; 120 return value ? __builtin_ctzll(value) : 64;
121 #else 121 #else
122 if (value == 0) return 64; 122 if (value == 0) return 64;
123 unsigned count = 0; 123 unsigned count = 0;
124 for (value ^= value - 1; value >>= 1; ++count) 124 for (value ^= value - 1; value >>= 1; ++count) {
125 ; 125 }
126 return count; 126 return count;
127 #endif 127 #endif
128 } 128 }
129 129
130 130
131 // Returns true iff |value| is a power of 2. 131 // Returns true iff |value| is a power of 2.
132 inline bool IsPowerOfTwo32(uint32_t value) { 132 inline bool IsPowerOfTwo32(uint32_t value) {
133 return value && !(value & (value - 1)); 133 return value && !(value & (value - 1));
134 } 134 }
135 135
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // truncated to uint32. If |rhs| is zero, then zero is returned. 260 // truncated to uint32. If |rhs| is zero, then zero is returned.
261 inline uint32_t UnsignedMod32(uint32_t lhs, uint32_t rhs) { 261 inline uint32_t UnsignedMod32(uint32_t lhs, uint32_t rhs) {
262 return rhs ? lhs % rhs : 0u; 262 return rhs ? lhs % rhs : 0u;
263 } 263 }
264 264
265 } // namespace bits 265 } // namespace bits
266 } // namespace base 266 } // namespace base
267 } // namespace v8 267 } // namespace v8
268 268
269 #endif // V8_BASE_BITS_H_ 269 #endif // V8_BASE_BITS_H_
OLDNEW
« no previous file with comments | « src/arm64/lithium-codegen-arm64.cc ('k') | src/base/platform/condition-variable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698