diff --git a/CMath.h b/CMath.h new file mode 100644 index 0000000..238a5f3 --- /dev/null +++ b/CMath.h @@ -0,0 +1 @@ +#include "varint.h" diff --git a/bits.h b/bits.h new file mode 100644 index 0000000..50a360b --- /dev/null +++ b/bits.h @@ -0,0 +1,36 @@ +#ifndef BITS_H +#define BITS_H + +#if defined(TYPES_64) || defined(TYPES_32) || !defined(TYPES_CUSTOM) +#define SIZE_LL 64 +#define SIZE_L 64 +#define SIZE_I 32 +#endif + + +union sig_ll { + signed long long value : SIZE_LL; + struct { + unsigned long long value : SIZE_LL - 1; + unsigned char sig : 1; + } signature; +}; + + +union sig_l { + signed long value : SIZE_L; + struct { + unsigned long value : SIZE_L - 1; + unsigned char sig : 1; + } signature; +}; + +union sig_i { + signed int value : SIZE_I; + struct { + unsigned int value : SIZE_I - 1; + unsigned char sig : 1; + } signature; +}; + +#endif diff --git a/varint.c b/varint.c new file mode 100644 index 0000000..13c2d6d --- /dev/null +++ b/varint.c @@ -0,0 +1,18 @@ +#include "varint.h" + + +varint varint_encode(unsigned long long value){ + +} + +unsigned long long varint_decode(varint varint){ + +} + +unsigned long long zigzag_encode(signed long long value){ + return ((unsigned long long)value << 1) ^ (value >> 63); +} + +signed long long zigzag_decode(unsigned long long value){ + +} diff --git a/varint.h b/varint.h new file mode 100644 index 0000000..12d62e6 --- /dev/null +++ b/varint.h @@ -0,0 +1,13 @@ +#ifndef VARINT_H +#define VARINT_H + +#include "bits.h" + +typedef char * varint; + +varint varint_encode(unsigned long long); +unsigned long long varint_decode(varint); +unsigned long long zigzag_encode(long long); +long long zigzag_decode(unsigned long long); + +#endif