[PATCH 2 of 8 faster-obsmarkers] util: add getbe{u, }int16 utility methods

Augie Fackler raf at durin42.com
Mon Feb 2 10:01:23 CST 2015


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1421780997 18000
#      Tue Jan 20 14:09:57 2015 -0500
# Branch stable
# Node ID 20ac130001c176b0fbc2c99d9fe3741df3b71bca
# Parent  a981174fee88c527794466a487ff07a46c329512
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