summaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@ev0ke.net>2016-01-11 11:13:04 +0100
committerDavid Goulet <dgoulet@torproject.org>2016-06-20 15:26:58 -0400
commit9744a40f7aa71f874b9f3eeb3c5e7d0899c8d409 (patch)
treebc02d01555c224e41224211f6dc6a39b3fa577bb /src/common/util.c
parent49e8f47505a64f46981e3caa8c167594ae6936ff (diff)
downloadtor-9744a40f7aa71f874b9f3eeb3c5e7d0899c8d409.tar.gz
tor-9744a40f7aa71f874b9f3eeb3c5e7d0899c8d409.zip
Add tor_htonll/ntohll functions
Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 4b6df81b7d..3c5341d460 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -5587,3 +5587,24 @@ clamp_double_to_int64(double number)
return signbit(number) ? INT64_MIN : INT64_MAX;
}
+/** Return a uint64_t value from <b>a</b> in network byte order. */
+uint64_t
+tor_htonll(uint64_t a)
+{
+#ifdef WORDS_BIGENDIAN
+ /* Big endian. */
+ return a;
+#else /* WORDS_BIGENDIAN */
+ /* Little endian. The worst... */
+ return htonl((uint32_t)(a>>32)) |
+ (((uint64_t)htonl((uint32_t)a))<<32);
+#endif /* WORDS_BIGENDIAN */
+}
+
+/** Return a uint64_t value from <b>a</b> in host byte order. */
+uint64_t
+tor_ntohll(uint64_t a)
+{
+ return tor_htonll(a);
+}
+