diff options
Diffstat (limited to 'cgpt/cgpt_endian.h')
-rw-r--r-- | cgpt/cgpt_endian.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/cgpt/cgpt_endian.h b/cgpt/cgpt_endian.h new file mode 100644 index 00000000..04204e74 --- /dev/null +++ b/cgpt/cgpt_endian.h @@ -0,0 +1,49 @@ +/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef VBOOT_REFERENCE_UTILITY_CGPT_ENDIAN_H_ +#define VBOOT_REFERENCE_UTILITY_CGPT_ENDIAN_H_ + +// Newer distros already have this. For those that don't, we add it here. +#include <endian.h> + +#ifndef le16toh + +# include <byteswap.h> + +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define htobe16(x) __bswap_16 (x) +# define htole16(x) (x) +# define be16toh(x) __bswap_16 (x) +# define le16toh(x) (x) + +# define htobe32(x) __bswap_32 (x) +# define htole32(x) (x) +# define be32toh(x) __bswap_32 (x) +# define le32toh(x) (x) + +# define htobe64(x) __bswap_64 (x) +# define htole64(x) (x) +# define be64toh(x) __bswap_64 (x) +# define le64toh(x) (x) +# else +# define htobe16(x) (x) +# define htole16(x) __bswap_16 (x) +# define be16toh(x) (x) +# define le16toh(x) __bswap_16 (x) + +# define htobe32(x) (x) +# define htole32(x) __bswap_32 (x) +# define be32toh(x) (x) +# define le32toh(x) __bswap_32 (x) + +# define htobe64(x) (x) +# define htole64(x) __bswap_64 (x) +# define be64toh(x) (x) +# define le64toh(x) __bswap_64 (x) +# endif + +#endif +#endif // VBOOT_REFERENCE_UTILITY_CGPT_ENDIAN_H_ |