]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/GetPowerOfTwo32.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / BaseLib / GetPowerOfTwo32.c
1 /** @file
2 Math worker functions.
3
4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "BaseLibInternals.h"
10
11 /**
12 Returns the value of the highest bit set in a 32-bit value. Equivalent to
13 1 << log2(x).
14
15 This function computes the value of the highest bit set in the 32-bit value
16 specified by Operand. If Operand is zero, then zero is returned.
17
18 @param Operand The 32-bit operand to evaluate.
19
20 @return 1 << HighBitSet32(Operand)
21 @retval 0 Operand is zero.
22
23 **/
24 UINT32
25 EFIAPI
26 GetPowerOfTwo32 (
27 IN UINT32 Operand
28 )
29 {
30 if (0 == Operand) {
31 return 0;
32 }
33
34 return 1ul << HighBitSet32 (Operand);
35 }