comparison mercurial/bitmanipulation.h @ 34697:ce77b0563228

bitmanipulation: reformat with clang-format Mostly un-wrapping over-wrapped definitions. Differential Revision: https://phab.mercurial-scm.org/D1069
author Augie Fackler <augie@google.com>
date Wed, 04 Oct 2017 10:52:50 -0400
parents b4356d1cf3e4
children 1fb2510cf8c8
comparison
equal deleted inserted replaced
34696:15b561fffde5 34697:ce77b0563228
7 7
8 static inline uint32_t getbe32(const char *c) 8 static inline uint32_t getbe32(const char *c)
9 { 9 {
10 const unsigned char *d = (const unsigned char *)c; 10 const unsigned char *d = (const unsigned char *)c;
11 11
12 return ((d[0] << 24) | 12 return ((d[0] << 24) | (d[1] << 16) | (d[2] << 8) | (d[3]));
13 (d[1] << 16) |
14 (d[2] << 8) |
15 (d[3]));
16 } 13 }
17 14
18 static inline int16_t getbeint16(const char *c) 15 static inline int16_t getbeint16(const char *c)
19 { 16 {
20 const unsigned char *d = (const unsigned char *)c; 17 const unsigned char *d = (const unsigned char *)c;
21 18
22 return ((d[0] << 8) | 19 return ((d[0] << 8) | (d[1]));
23 (d[1]));
24 } 20 }
25 21
26 static inline uint16_t getbeuint16(const char *c) 22 static inline uint16_t getbeuint16(const char *c)
27 { 23 {
28 const unsigned char *d = (const unsigned char *)c; 24 const unsigned char *d = (const unsigned char *)c;
29 25
30 return ((d[0] << 8) | 26 return ((d[0] << 8) | (d[1]));
31 (d[1]));
32 } 27 }
33 28
34 static inline void putbe32(uint32_t x, char *c) 29 static inline void putbe32(uint32_t x, char *c)
35 { 30 {
36 c[0] = (x >> 24) & 0xff; 31 c[0] = (x >> 24) & 0xff;
37 c[1] = (x >> 16) & 0xff; 32 c[1] = (x >> 16) & 0xff;
38 c[2] = (x >> 8) & 0xff; 33 c[2] = (x >> 8) & 0xff;
39 c[3] = (x) & 0xff; 34 c[3] = (x)&0xff;
40 } 35 }
41 36
42 static inline double getbefloat64(const char *c) 37 static inline double getbefloat64(const char *c)
43 { 38 {
44 const unsigned char *d = (const unsigned char *)c; 39 const unsigned char *d = (const unsigned char *)c;
45 double ret; 40 double ret;
46 int i; 41 int i;
47 uint64_t t = 0; 42 uint64_t t = 0;
48 for (i = 0; i < 8; i++) { 43 for (i = 0; i < 8; i++) {
49 t = (t<<8) + d[i]; 44 t = (t << 8) + d[i];
50 } 45 }
51 memcpy(&ret, &t, sizeof(t)); 46 memcpy(&ret, &t, sizeof(t));
52 return ret; 47 return ret;
53 } 48 }
54 49