Mercurial > hg
view mercurial/bitmanipulation.h @ 35491:ded3a63f305b
streamclone: move wire protocol status code from wireproto command
This consolidates the code for the streaming clone wire protocol format
into streamclone.py. It also eliminates a generator wrapper, which might
make streaming clones slightly faster.
Differential Revision: https://phab.mercurial-scm.org/D1754
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 24 Dec 2017 11:46:13 -0700 |
parents | ce77b0563228 |
children | 1fb2510cf8c8 |
line wrap: on
line source
#ifndef _HG_BITMANIPULATION_H_ #define _HG_BITMANIPULATION_H_ #include <string.h> #include "compat.h" static inline uint32_t getbe32(const char *c) { const unsigned char *d = (const unsigned char *)c; return ((d[0] << 24) | (d[1] << 16) | (d[2] << 8) | (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; c[1] = (x >> 16) & 0xff; c[2] = (x >> 8) & 0xff; 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; } #endif