diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-07-01 15:29:05 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-07-01 15:29:05 -0400 |
commit | aaa31290431ea2cd1d1e8498dbe271eb53d2389d (patch) | |
tree | d7ff38ffee26c5ab4571f089e8cf06d9e687a14c /src/common/util.c | |
parent | 738a8c655a1f8067b330b132164fa8879ef102c3 (diff) | |
parent | 36e201dffc5d57d92113e1e68ad4b6a0a7b3471e (diff) | |
download | tor-aaa31290431ea2cd1d1e8498dbe271eb53d2389d.tar.gz tor-aaa31290431ea2cd1d1e8498dbe271eb53d2389d.zip |
Merge remote-tracking branch 'dgoulet/ticket16943_029_05-squashed'
Trivial Conflicts:
src/or/or.h
src/or/routerparse.c
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index 8a4fa1d710..538aeb108d 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -5687,3 +5687,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); +} + |