VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Library/BaseLib/HighBitSet64.c

Last change on this file was 99404, checked in by vboxsync, 2 years ago

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 1.1 KB
Line 
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 bit position of the highest bit set in a 64-bit value. Equivalent
13 to log2(x).
14
15 This function computes the bit position of the highest bit set in the 64-bit
16 value specified by Operand. If Operand is zero, then -1 is returned.
17 Otherwise, a value between 0 and 63 is returned.
18
19 @param Operand The 64-bit operand to evaluate.
20
21 @retval 0..63 Position of the highest bit set in Operand if found.
22 @retval -1 Operand is zero.
23
24**/
25INTN
26EFIAPI
27HighBitSet64 (
28 IN UINT64 Operand
29 )
30{
31 if (Operand == (UINT32)Operand) {
32 //
33 // Operand is just a 32-bit integer
34 //
35 return HighBitSet32 ((UINT32)Operand);
36 }
37
38 //
39 // Operand is really a 64-bit integer
40 //
41 if (sizeof (UINTN) == sizeof (UINT32)) {
42 return HighBitSet32 (((UINT32 *)&Operand)[1]) + 32;
43 } else {
44 return HighBitSet32 ((UINT32)RShiftU64 (Operand, 32)) + 32;
45 }
46}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette