1/*++
2
3Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
4This program and the accompanying materials
5are licensed and made available under the terms and conditions of the BSD License
6which accompanies this distribution.  The full text of the license may be found at
7http://opensource.org/licenses/bsd-license.php
8
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12Module Name:
13
14  GetPowerOfTwo32.c
15
16Abstract:
17
18  Math worker functions.
19
20--*/
21
22#include "BaseLibInternals.h"
23
24/**
25  Returns the value of the highest bit set in a 32-bit value. Equivalent to
26  1 << HighBitSet32(x).
27
28  This function computes the value of the highest bit set in the 32-bit value
29  specified by Operand. If Operand is zero, then zero is returned.
30
31  @param  Operand The 32-bit operand to evaluate.
32
33  @return 1 << HighBitSet32(Operand)
34  @retval 0 Operand is zero.
35
36**/
37UINT32
38EFIAPI
39GetPowerOfTwo32 (
40  IN      UINT32                    Operand
41  )
42{
43  if (Operand == 0) {
44    return 0;
45  }
46
47  return 1ul << HighBitSet32 (Operand);
48}
49