blob: 04204e745ef92c8e1444c00936cebd068537d8e5 [file] [log] [blame]
Randall Spanglercbaf6962010-08-05 16:42:43 -07001/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
Bill Richardsonf1372d92010-06-11 09:15:55 -07006#ifndef VBOOT_REFERENCE_UTILITY_CGPT_ENDIAN_H_
7#define VBOOT_REFERENCE_UTILITY_CGPT_ENDIAN_H_
8
9// Newer distros already have this. For those that don't, we add it here.
10#include <endian.h>
11
12#ifndef le16toh
13
14# include <byteswap.h>
15
16# if __BYTE_ORDER == __LITTLE_ENDIAN
17# define htobe16(x) __bswap_16 (x)
18# define htole16(x) (x)
19# define be16toh(x) __bswap_16 (x)
20# define le16toh(x) (x)
21
22# define htobe32(x) __bswap_32 (x)
23# define htole32(x) (x)
24# define be32toh(x) __bswap_32 (x)
25# define le32toh(x) (x)
26
27# define htobe64(x) __bswap_64 (x)
28# define htole64(x) (x)
29# define be64toh(x) __bswap_64 (x)
30# define le64toh(x) (x)
31# else
32# define htobe16(x) (x)
33# define htole16(x) __bswap_16 (x)
34# define be16toh(x) (x)
35# define le16toh(x) __bswap_16 (x)
36
37# define htobe32(x) (x)
38# define htole32(x) __bswap_32 (x)
39# define be32toh(x) (x)
40# define le32toh(x) __bswap_32 (x)
41
42# define htobe64(x) (x)
43# define htole64(x) __bswap_64 (x)
44# define be64toh(x) (x)
45# define le64toh(x) __bswap_64 (x)
46# endif
47
48#endif
49#endif // VBOOT_REFERENCE_UTILITY_CGPT_ENDIAN_H_