aboutsummaryrefslogtreecommitdiffstats
path: root/main/strcompat.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-11-04 14:05:12 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-11-04 14:05:12 +0000
commit3bacd4082e2d3a2dd5b8b13635df956aa4f415cd (patch)
treedd3bc244b8a45aacb932109dc8c12d1f21769d55 /main/strcompat.c
parent1d3ce2ae5f81e30ec0704efe840bc2c9a24c7e8a (diff)
Expand codec bitfield from 32 bits to 64 bits.
Reviewboard: https://reviewboard.asterisk.org/r/416/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@227580 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/strcompat.c')
-rw-r--r--main/strcompat.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/main/strcompat.c b/main/strcompat.c
index 7f9d2813b..156809003 100644
--- a/main/strcompat.c
+++ b/main/strcompat.c
@@ -334,3 +334,55 @@ int getloadavg(double *list, int nelem)
#endif /* linux */
#endif /* !HAVE_GETLOADAVG */
+#ifndef HAVE_NTOHLL
+uint64_t ntohll(uint64_t net64)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ return net64;
+#elif BYTE_ORDER == LITTLE_ENDIAN
+ union {
+ unsigned char c[8];
+ uint64_t u;
+ } number;
+ number.u = net64;
+ return
+ (((uint64_t) number.c[0]) << 0) |
+ (((uint64_t) number.c[1]) << 8) |
+ (((uint64_t) number.c[2]) << 16) |
+ (((uint64_t) number.c[3]) << 24) |
+ (((uint64_t) number.c[4]) << 32) |
+ (((uint64_t) number.c[5]) << 40) |
+ (((uint64_t) number.c[6]) << 48) |
+ (((uint64_t) number.c[7]) << 56);
+#else
+ #error "Unknown byte order"
+#endif
+}
+#endif
+
+#ifndef HAVE_HTONLL
+uint64_t htonll(uint64_t host64)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ return host64;
+#elif BYTE_ORDER == LITTLE_ENDIAN
+ union {
+ unsigned char c[8];
+ uint64_t u;
+ } number;
+ number.u = host64;
+ return
+ (((uint64_t) number.c[0]) << 0) |
+ (((uint64_t) number.c[1]) << 8) |
+ (((uint64_t) number.c[2]) << 16) |
+ (((uint64_t) number.c[3]) << 24) |
+ (((uint64_t) number.c[4]) << 32) |
+ (((uint64_t) number.c[5]) << 40) |
+ (((uint64_t) number.c[6]) << 48) |
+ (((uint64_t) number.c[7]) << 56);
+#else
+ #error "Unknown byte order"
+#endif
+}
+#endif
+