X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdePkg%2FLibrary%2FBaseLib%2FGetPowerOfTwo32.c;h=913efb7a9fba1d624084a35bd573460cfb0694e2;hb=de4f7f52f2003b854a754e3815f0a0c1c611118f;hp=dbf4ca65138cef6585e2c550afc359b0308e2098;hpb=4748b24d77d65a13dd2bcb0f9fa9ed83f24f9bf4;p=mirror_edk2.git diff --git a/MdePkg/Library/BaseLib/GetPowerOfTwo32.c b/MdePkg/Library/BaseLib/GetPowerOfTwo32.c index dbf4ca6513..913efb7a9f 100644 --- a/MdePkg/Library/BaseLib/GetPowerOfTwo32.c +++ b/MdePkg/Library/BaseLib/GetPowerOfTwo32.c @@ -1,22 +1,25 @@ /** @file Math worker functions. - Copyright (c) 2006, Intel Corporation
- All rights reserved. This program and the accompanying materials + Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php + http://opensource.org/licenses/bsd-license.php. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ + + + #include "BaseLibInternals.h" /** Returns the value of the highest bit set in a 32-bit value. Equivalent to - 1 << HighBitSet32(x). + 1 << log2(x). This function computes the value of the highest bit set in the 32-bit value specified by Operand. If Operand is zero, then zero is returned. @@ -33,8 +36,9 @@ GetPowerOfTwo32 ( IN UINT32 Operand ) { - INTN BitPos; - - BitPos = HighBitSet32 (Operand); - return BitPos >= 0 ? 1ul << BitPos : 0; + if (0 == Operand) { + return 0; + } + + return 1ul << HighBitSet32 (Operand); }