diff options
author | Greg Hackmann <ghackmann@google.com> | 2015-04-14 12:51:28 -0700 |
---|---|---|
committer | Greg Hackmann <ghackmann@google.com> | 2015-04-14 14:32:24 -0700 |
commit | 7eadfc787302f69feaa8b2939deb41d9794dd854 (patch) | |
tree | c616926049a69e307a126f9c4b593dc157ea2c89 /firmware/external | |
parent | 410fe89964d6751d4f26e54f6e27ca72aa9b4f5f (diff) | |
download | contexthub-7eadfc787302f69feaa8b2939deb41d9794dd854.tar.gz |
external/freebsd: remove generic encoding/decoding functions from endian.h
Change-Id: I341c9b8508b107af7fb743f0be41bb68721242de
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Diffstat (limited to 'firmware/external')
-rw-r--r-- | firmware/external/freebsd/inc/sys/endian.h | 112 |
1 files changed, 5 insertions, 107 deletions
diff --git a/firmware/external/freebsd/inc/sys/endian.h b/firmware/external/freebsd/inc/sys/endian.h index d50110ca..356bfcdf 100644 --- a/firmware/external/freebsd/inc/sys/endian.h +++ b/firmware/external/freebsd/inc/sys/endian.h @@ -94,112 +94,10 @@ typedef __uint64_t uint64_t; #define le64toh(x) bswap64((x)) #endif /* _BYTE_ORDER == _LITTLE_ENDIAN */ -/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */ - -static __inline uint16_t -be16dec(const void *pp) -{ - uint8_t const *p = (uint8_t const *)pp; - - return ((p[0] << 8) | p[1]); -} - -static __inline uint32_t -be32dec(const void *pp) -{ - uint8_t const *p = (uint8_t const *)pp; - - return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); -} - -static __inline uint64_t -be64dec(const void *pp) -{ - uint8_t const *p = (uint8_t const *)pp; - - return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4)); -} - -static __inline uint16_t -le16dec(const void *pp) -{ - uint8_t const *p = (uint8_t const *)pp; - - return ((p[1] << 8) | p[0]); -} - -static __inline uint32_t -le32dec(const void *pp) -{ - uint8_t const *p = (uint8_t const *)pp; - - return (((unsigned)p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]); -} - -static __inline uint64_t -le64dec(const void *pp) -{ - uint8_t const *p = (uint8_t const *)pp; - - return (((uint64_t)le32dec(p + 4) << 32) | le32dec(p)); -} - -static __inline void -be16enc(void *pp, uint16_t u) -{ - uint8_t *p = (uint8_t *)pp; - - p[0] = (u >> 8) & 0xff; - p[1] = u & 0xff; -} - -static __inline void -be32enc(void *pp, uint32_t u) -{ - uint8_t *p = (uint8_t *)pp; - - p[0] = (u >> 24) & 0xff; - p[1] = (u >> 16) & 0xff; - p[2] = (u >> 8) & 0xff; - p[3] = u & 0xff; -} - -static __inline void -be64enc(void *pp, uint64_t u) -{ - uint8_t *p = (uint8_t *)pp; - - be32enc(p, (uint32_t)(u >> 32)); - be32enc(p + 4, (uint32_t)(u & 0xffffffffU)); -} - -static __inline void -le16enc(void *pp, uint16_t u) -{ - uint8_t *p = (uint8_t *)pp; - - p[0] = u & 0xff; - p[1] = (u >> 8) & 0xff; -} - -static __inline void -le32enc(void *pp, uint32_t u) -{ - uint8_t *p = (uint8_t *)pp; - - p[0] = u & 0xff; - p[1] = (u >> 8) & 0xff; - p[2] = (u >> 16) & 0xff; - p[3] = (u >> 24) & 0xff; -} - -static __inline void -le64enc(void *pp, uint64_t u) -{ - uint8_t *p = (uint8_t *)pp; - - le32enc(p, (uint32_t)(u & 0xffffffffU)); - le32enc(p + 4, (uint32_t)(u >> 32)); -} +/* + * The generic encoding and decoding functions have been removed since they're + * rarely used and generate suboptimal code on platforms that allow unaligned + * accesses + */ #endif /* _SYS_ENDIAN_H_ */ |