#ifndef _UCW_VARINT_H
#define _UCW_VARINT_H
+#ifdef CONFIG_UCW_CLEAN_ABI
+#define varint_get_big ucw_varint_get_big
+#define varint_put_big ucw_varint_put_big
+#endif
+
/***
* The encoding works in the following way:
*
- * First byte Stored values
+ * First byte Stored values
*
- * 0xxxxxxx 7 bits
- * 10xxxxxx +1 byte 14 bits, value shifted by 2^7
- * 110xxxxx +2 bytes 21 bits, value shifted by 2^7+2^14
- * 1110xxxx +3 bytes 28 bits, value shifted by 2^7+2^14+2^21
+ * 0xxxxxxx 7 bits
+ * 10xxxxxx +1 byte 14 bits, value shifted by 2^7
+ * 110xxxxx +2 bytes 21 bits, value shifted by 2^7+2^14
+ * 1110xxxx +3 bytes 28 bits, value shifted by 2^7+2^14+2^21
* ....
- * 11111110 +7 bytes 56 bits, value shifted by 2^7+2^14+2^21+2^28+2^35+2^42
- * 11111111 +8 bytes full 64 bits, value shifted by 2^7+2^14+2^21+2^28+2^35+2^42+2^56
+ * 11111110 +7 bytes 56 bits, value shifted by 2^7+2^14+2^21+2^28+2^35+2^42
+ * 11111111 +8 bytes full 64 bits, value shifted by 2^7+2^14+2^21+2^28+2^35+2^42+2^56
*
* The values are stored in bigendian to allow lexicographic sorting.
* The encoding and algorithms are aimed to be optimised for storing shorter numbers.
#define PUTB4(b) PUTB(0,b-1) PUTB(1,b-2) PUTB(2,b-3) PUTB(3,b-4)
/* for internal use only, need the length > 4 */
-uns varint_put_big(byte *p, u64 u);
+uint varint_put_big(byte *p, u64 u);
const byte *varint_get_big(const byte *p, u64 *r);
/**
* Encode u64 value u into byte sequence p.
* Returns the number of bytes used (at least 1 and at most 9).
**/
-static inline uns varint_put(byte *p, u64 u)
+static inline uint varint_put(byte *p, u64 u)
{
if (u < VARINT_SHIFT_L1) {
p[0] = (byte)u;
* Store the invalid sequence.
* Returns always 2 (2 bytes were used, to be consistent with varint_put).
**/
-static inline uns varint_put_invalid(byte *p)
+static inline uint varint_put_invalid(byte *p)
{
p[0] = p[1] = 0xff;
return 2;
}
/** Compute the length of encoding in bytes from the first byte hdr of the encoding. **/
-static inline uns varint_len(const byte hdr)
+static inline uint varint_len(const byte hdr)
{
byte b = ~hdr;
- uns l = 0;
+ uint l = 0;
if (!b)
l = -1;
else {
}
/** Compute the number of bytes needed to store the value u. **/
-static inline uns varint_space(u64 u)
+static inline uint varint_space(u64 u)
{
if (u < VARINT_SHIFT_L1)
return 1;