Patchwork [2,of,6,faster-obsmarkers,v2] util: add getbe{u, }int16 utility methods

login
register
mail settings
Submitter Augie Fackler
Date Feb. 3, 2015, 6:31 p.m.
Message ID <0c18599df5197890d37f.1422988270@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/7637/
State Accepted
Headers show

Comments

Augie Fackler - Feb. 3, 2015, 6:31 p.m.
# HG changeset patch
# User Augie Fackler <augie@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

Patch

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;