diff options
author | Hung-Te Lin <hungte@chromium.org> | 2013-03-13 18:08:29 +0800 |
---|---|---|
committer | Ronald G. Minnich <rminnich@gmail.com> | 2013-03-13 17:37:09 +0100 |
commit | e112b746e0559a4a31bfe0eccbf0cabef89630c8 (patch) | |
tree | e174bc64ecf8c92b2d20ec99091c18b66f238eac /payloads | |
parent | a0996a9c7c445b891ce9e87ba63b16f2fe271582 (diff) |
libpayloads: Provide BSD/glibc style endian functions.
The functions in endian.h (betoh{l,w,ll} and others) were named differently from
the well-known BSD/glibc style endian functions (ex, betoh{16,32,64}). We should
provide the BSD/glibc style functions to prevent confusion.
Change-Id: Ia3bee481ba7989ac25b79ddb89bc6819d52fd8c3
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: http://review.coreboot.org/2705
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'payloads')
-rw-r--r-- | payloads/libpayload/include/endian.h | 69 |
1 files changed, 42 insertions, 27 deletions
diff --git a/payloads/libpayload/include/endian.h b/payloads/libpayload/include/endian.h index cd805e0f4e..941dd1012f 100644 --- a/payloads/libpayload/include/endian.h +++ b/payloads/libpayload/include/endian.h @@ -32,26 +32,27 @@ #define swap_bytes64(in) (((uint64_t)swap_bytes32((uint32_t)(in)) << 32) | \ ((uint64_t)swap_bytes32((uint32_t)((in) >> 32)))) +/* Endian functions from glibc 2.9 / BSD "endian.h" */ #if defined CONFIG_BIG_ENDIAN -#define htobew(in) (in) -#define htobel(in) (in) -#define htobell(in) (in) +#define htobe16(in) (in) +#define htobe32(in) (in) +#define htobe64(in) (in) -#define htolew(in) swap_bytes16(in) -#define htolel(in) swap_bytes32(in) -#define htolell(in) swap_bytes64(in) +#define htole16(in) swap_bytes16(in) +#define htole32(in) swap_bytes32(in) +#define htole64(in) swap_bytes64(in) #elif defined CONFIG_LITTLE_ENDIAN -#define htobew(in) swap_bytes16(in) -#define htobel(in) swap_bytes32(in) -#define htobell(in) swap_bytes64(in) +#define htobe16(in) swap_bytes16(in) +#define htobe32(in) swap_bytes32(in) +#define htobe64(in) swap_bytes64(in) -#define htolew(in) (in) -#define htolel(in) (in) -#define htolell(in) (in) +#define htole16(in) (in) +#define htole32(in) (in) +#define htole64(in) (in) #else @@ -59,20 +60,34 @@ #endif -#define betohw(in) htobew(in) -#define betohl(in) htobel(in) -#define betohll(in) htobell(in) - -#define letohw(in) htolew(in) -#define letohl(in) htolel(in) -#define letohll(in) htolell(in) - -#define htonw(in) htobew(in) -#define htonl(in) htobel(in) -#define htonll(in) htobell(in) - -#define ntohw(in) htonw(in) -#define ntohl(in) htonl(in) -#define ntohll(in) htonll(in) +#define be16toh(in) htobe16(in) +#define be32toh(in) htobe32(in) +#define be64toh(in) htobe64(in) + +#define le16toh(in) htole16(in) +#define le32toh(in) htole32(in) +#define le64toh(in) htole64(in) + +#define htonw(in) htobe16(in) +#define htonl(in) htobe32(in) +#define htonll(in) htobe64(in) + +#define ntohw(in) be16toh(in) +#define ntohl(in) be32toh(in) +#define ntohll(in) be64toh(in) + +/* Deprecated names (not in glibc / BSD) */ +#define htobew(in) htobe16(in) +#define htobel(in) htobe32(in) +#define htobell(in) htobe64(in) +#define htolew(in) htole16(in) +#define htolel(in) htole32(in) +#define htolell(in) htole64(in) +#define betohw(in) be16toh(in) +#define betohl(in) be32toh(in) +#define betohll(in) be64toh(in) +#define letohw(in) le16toh(in) +#define letohl(in) le32toh(in) +#define letohll(in) le64toh(in) #endif |