]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/Main/ByteSwap.c
2 Byte Swap routines for endian-nes conversions.
4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 #include <Library/BaseLib.h>
14 #include <LibConfig.h>
16 #include <sys/bswap.h>
18 // Undefine macro versions of the functions to be defined below.
24 Switches the endianness of a 16-bit integer.
26 This function swaps the bytes in a 16-bit unsigned value to switch the value
27 from little endian to big endian or vice versa. The byte swapped value is
30 @param Value A 16-bit unsigned value.
32 @return The byte swapped Value.
35 uint16_t bswap16(uint16_t Value
)
37 return SwapBytes16(Value
);
41 Switches the endianness of a 32-bit integer.
43 This function swaps the bytes in a 32-bit unsigned value to switch the value
44 from little endian to big endian or vice versa. The byte swapped value is
47 @param Value A 32-bit unsigned value.
49 @return The byte swapped Value.
52 uint32_t bswap32(uint32_t Value
)
54 return SwapBytes32(Value
);
58 Switches the endianness of a 64-bit integer.
60 This function swaps the bytes in a 64-bit unsigned value to switch the value
61 from little endian to big endian or vice versa. The byte swapped value is
64 @param Value A 64-bit unsigned value.
66 @return The byte swapped Value.
69 uint64_t bswap64(uint64_t Value
)
71 return SwapBytes64(Value
);