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