[PATCH 2 of 6 faster-obsmarkers v2] util: add getbe{u, }int16 utility methods
Augie Fackler
raf at durin42.com
Tue Feb 3 12:31:10 CST 2015
# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1421780997 18000
# Tue Jan 20 14:09:57 2015 -0500
# Node ID 0c18599df5197890d37fcb9397c5f9cfe7d770a8
# Parent 5e1e659995943100cfaf76135f8df2b43bfe05ce
util: add getbe{u,}int16 utility methods
diff --git a/mercurial/util.h b/mercurial/util.h
--- a/mercurial/util.h
+++ b/mercurial/util.h
@@ -172,6 +172,22 @@ static inline uint32_t getbe32(const cha
(d[3]));
}
+static inline int16_t getbeint16(const char *c)
+{
+ const unsigned char *d = (const unsigned char *)c;
+
+ return ((d[0] << 8) |
+ (d[1]));
+}
+
+static inline uint16_t getbeuint16(const char *c)
+{
+ const unsigned char *d = (const unsigned char *)c;
+
+ return ((d[0] << 8) |
+ (d[1]));
+}
+
static inline void putbe32(uint32_t x, char *c)
{
c[0] = (x >> 24) & 0xff;
More information about the Mercurial-devel
mailing list