summaryrefslogtreecommitdiff
path: root/main/strcompat.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2009-11-04 14:05:12 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2009-11-04 14:05:12 +0000
commitd8e0c584372c51b585a52efbe2375861bc09bdcf (patch)
treedd3bc244b8a45aacb932109dc8c12d1f21769d55 /main/strcompat.c
parent6a50e7a031f4d424aa8bd3293aa48501f7b96652 (diff)
Expand codec bitfield from 32 bits to 64 bits.
Reviewboard: https://reviewboard.asterisk.org/r/416/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@227580 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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
+