Mercurial > public > mercurial-scm > hg-stable
diff mercurial/util.h @ 24803:e89f909edffa stable 3.4-rc
merge default into stable for 3.4 freeze
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 16 Apr 2015 20:57:51 -0500 |
parents | 1c533e23ce95 |
children | 3550ccbafca2 |
line wrap: on
line diff
--- a/mercurial/util.h Thu Apr 16 22:33:53 2015 +0900 +++ b/mercurial/util.h Thu Apr 16 20:57:51 2015 -0500 @@ -172,6 +172,22 @@ (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; @@ -180,4 +196,34 @@ c[3] = (x) & 0xff; } +static inline double getbefloat64(const char *c) +{ + const unsigned char *d = (const unsigned char *)c; + double ret; + int i; + uint64_t t = 0; + for (i = 0; i < 8; i++) { + t = (t<<8) + d[i]; + } + memcpy(&ret, &t, sizeof(t)); + return ret; +} + +/* This should be kept in sync with normcasespecs in encoding.py. */ +enum normcase_spec { + NORMCASE_LOWER = -1, + NORMCASE_UPPER = 1, + NORMCASE_OTHER = 0 +}; + +#define MIN(a, b) (((a)<(b))?(a):(b)) +/* VC9 doesn't include bool and lacks stdbool.h based on my searching */ +#ifdef _MSC_VER +#define true 1 +#define false 0 +typedef unsigned char bool; +#else +#include <stdbool.h> +#endif + #endif /* _HG_UTIL_H_ */