2007-06-22 05:21:45 +02:00
|
|
|
/** @file
|
|
|
|
Math worker functions.
|
|
|
|
|
2010-04-23 18:00:47 +02:00
|
|
|
Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
|
2019-04-04 01:06:00 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2007-06-22 05:21:45 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "BaseLibInternals.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the bit position of the lowest bit set in a 64-bit value.
|
|
|
|
|
|
|
|
This function computes the bit position of the lowest bit set in the 64-bit
|
|
|
|
value specified by Operand. If Operand is zero, then -1 is returned.
|
|
|
|
Otherwise, a value between 0 and 63 is returned.
|
|
|
|
|
|
|
|
@param Operand The 64-bit operand to evaluate.
|
|
|
|
|
2008-11-25 04:19:49 +01:00
|
|
|
@retval 0..63 The lowest bit set in Operand was found.
|
2010-06-24 02:20:35 +02:00
|
|
|
@retval -1 Operand is zero.
|
2008-11-25 04:19:49 +01:00
|
|
|
|
2007-06-22 05:21:45 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
INTN
|
|
|
|
EFIAPI
|
|
|
|
LowBitSet64 (
|
|
|
|
IN UINT64 Operand
|
|
|
|
)
|
|
|
|
{
|
|
|
|
INTN BitIndex;
|
|
|
|
|
|
|
|
if (Operand == 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (BitIndex = 0;
|
|
|
|
(Operand & 1) == 0;
|
|
|
|
BitIndex++, Operand = RShiftU64 (Operand, 1))
|
2021-12-05 23:54:05 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-06-22 05:21:45 +02:00
|
|
|
return BitIndex;
|
|
|
|
}
|