]>
Commit | Line | Data |
---|---|---|
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 bit position of the lowest bit set in a 32-bit value.\r | |
16 | \r | |
17 | This function computes the bit position of the lowest bit set in the 32-bit\r | |
18 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
19 | Otherwise, a value between 0 and 31 is returned.\r | |
20 | \r | |
21 | @param Operand The 32-bit operand to evaluate.\r | |
22 | \r | |
9aa049d9 | 23 | @retval 0..31 The lowest bit set in Operand was found.\r |
127010dd | 24 | @retval -1 Operand is zero.\r |
e1f414b6 | 25 | \r |
26 | **/\r | |
27 | INTN\r | |
28 | EFIAPI\r | |
29 | LowBitSet32 (\r | |
30 | IN UINT32 Operand\r | |
31 | )\r | |
32 | {\r | |
33 | INTN BitIndex;\r | |
34 | \r | |
35 | if (Operand == 0) {\r | |
36 | return -1;\r | |
37 | }\r | |
38 | \r | |
38bbd3d9 | 39 | for (BitIndex = 0; 0 == (Operand & 1); BitIndex++, Operand >>= 1);\r |
e1f414b6 | 40 | return BitIndex;\r |
41 | }\r |