Mercurial > hg
comparison mercurial/util.h @ 24015:e2bf959a5a0d
util: add getbe{u,}int16 utility methods
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 20 Jan 2015 14:09:57 -0500 |
parents | 0022ee690446 |
children | fb93721cc229 |
comparison
equal
deleted
inserted
replaced
24014:7d9367de2654 | 24015:e2bf959a5a0d |
---|---|
170 (d[1] << 16) | | 170 (d[1] << 16) | |
171 (d[2] << 8) | | 171 (d[2] << 8) | |
172 (d[3])); | 172 (d[3])); |
173 } | 173 } |
174 | 174 |
175 static inline int16_t getbeint16(const char *c) | |
176 { | |
177 const unsigned char *d = (const unsigned char *)c; | |
178 | |
179 return ((d[0] << 8) | | |
180 (d[1])); | |
181 } | |
182 | |
183 static inline uint16_t getbeuint16(const char *c) | |
184 { | |
185 const unsigned char *d = (const unsigned char *)c; | |
186 | |
187 return ((d[0] << 8) | | |
188 (d[1])); | |
189 } | |
190 | |
175 static inline void putbe32(uint32_t x, char *c) | 191 static inline void putbe32(uint32_t x, char *c) |
176 { | 192 { |
177 c[0] = (x >> 24) & 0xff; | 193 c[0] = (x >> 24) & 0xff; |
178 c[1] = (x >> 16) & 0xff; | 194 c[1] = (x >> 16) & 0xff; |
179 c[2] = (x >> 8) & 0xff; | 195 c[2] = (x >> 8) & 0xff; |