Home | History | Annotate | Download | only in base
      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
      3 // found in the LICENSE file.
      4 
      5 #include "src/base/bits.h"
      6 #include "src/base/logging.h"
      7 
      8 namespace v8 {
      9 namespace base {
     10 namespace bits {
     11 
     12 uint32_t RoundUpToPowerOfTwo32(uint32_t value) {
     13   DCHECK_LE(value, 0x80000000u);
     14   value = value - 1;
     15   value = value | (value >> 1);
     16   value = value | (value >> 2);
     17   value = value | (value >> 4);
     18   value = value | (value >> 8);
     19   value = value | (value >> 16);
     20   return value + 1;
     21 }
     22 
     23 }  // namespace bits
     24 }  // namespace base
     25 }  // namespace v8
     26