aboutsummaryrefslogtreecommitdiff
path: root/compat/endian.h
diff options
context:
space:
mode:
Diffstat (limited to 'compat/endian.h')
-rw-r--r--compat/endian.h113
1 files changed, 4 insertions, 109 deletions
diff --git a/compat/endian.h b/compat/endian.h
index 6ef1d15b3d54..d01c7d4b2340 100644
--- a/compat/endian.h
+++ b/compat/endian.h
@@ -25,7 +25,7 @@
* SUCH DAMAGE.
*
* Derived from FreeBSD src/sys/sys/endian.h:1.6.
- * $P4: //depot/projects/trustedbsd/openbsm/compat/endian.h#8 $
+ * $P4: //depot/projects/trustedbsd/openbsm/compat/endian.h#10 $
*/
#ifndef _COMPAT_ENDIAN_H_
@@ -116,6 +116,8 @@ bswap64(uint64_t int64)
#define _LITTLE_ENDIAN LITTLE_ENDIAN
#endif
+/* XXX: Hack. */
+#ifndef htobe16
/*
* Host to big endian, host to little endian, big endian to host, and little
* endian to host byte order functions as detailed in byteorder(9).
@@ -149,113 +151,6 @@ bswap64(uint64_t int64)
#define le32toh(x) bswap32((x))
#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)
-{
- unsigned char const *p = (unsigned char const *)pp;
-
- return ((p[0] << 8) | p[1]);
-}
-
-static __inline uint32_t
-be32dec(const void *pp)
-{
- unsigned char const *p = (unsigned char const *)pp;
-
- return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
-}
-
-static __inline uint64_t
-be64dec(const void *pp)
-{
- unsigned char const *p = (unsigned char const *)pp;
-
- return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4));
-}
-
-static __inline uint16_t
-le16dec(const void *pp)
-{
- unsigned char const *p = (unsigned char const *)pp;
-
- return ((p[1] << 8) | p[0]);
-}
-
-static __inline uint32_t
-le32dec(const void *pp)
-{
- unsigned char const *p = (unsigned char const *)pp;
-
- return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
-}
-
-static __inline uint64_t
-le64dec(const void *pp)
-{
- unsigned char const *p = (unsigned char const *)pp;
-
- return (((uint64_t)le32dec(p + 4) << 32) | le32dec(p));
-}
-
-static __inline void
-be16enc(void *pp, uint16_t u)
-{
- unsigned char *p = (unsigned char *)pp;
-
- p[0] = (u >> 8) & 0xff;
- p[1] = u & 0xff;
-}
-
-static __inline void
-be32enc(void *pp, uint32_t u)
-{
- unsigned char *p = (unsigned char *)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)
-{
- unsigned char *p = (unsigned char *)pp;
-
- be32enc(p, u >> 32);
- be32enc(p + 4, u & 0xffffffff);
-}
-
-static __inline void
-le16enc(void *pp, uint16_t u)
-{
- unsigned char *p = (unsigned char *)pp;
-
- p[0] = u & 0xff;
- p[1] = (u >> 8) & 0xff;
-}
-
-static __inline void
-le32enc(void *pp, uint32_t u)
-{
- unsigned char *p = (unsigned char *)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)
-{
- unsigned char *p = (unsigned char *)pp;
-
- le32enc(p, u & 0xffffffff);
- le32enc(p + 4, u >> 32);
-}
+#endif
#endif /* _COMPAT_ENDIAN_H_ */