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