Add contiguous linked list type for the new file store

This commit is contained in:
2018-02-18 01:03:14 -06:00
parent 193492c518
commit 21e72a0513
6 changed files with 345 additions and 1 deletions

View File

@@ -12,6 +12,10 @@
namespace ox {
inline int8_t byteSwap(int8_t i) {
return i;
}
inline int16_t byteSwap(int16_t i) {
return (i << 8) | (i >> 8);
}
@@ -34,6 +38,10 @@ inline int64_t byteSwap(int64_t i) {
((i << 56) & 0xff00000000000000);
}
inline uint16_t byteSwap(uint8_t i) {
return i;
}
inline uint16_t byteSwap(uint16_t i) {
return (i << 8) | (i >> 8);
}
@@ -99,6 +107,70 @@ class LittleEndian {
return value != ox::bigEndianAdapt(m_value);
}
inline T operator+(T value) const {
return ox::bigEndianAdapt(m_value) + value;
}
inline T operator+=(T other) {
auto newVal = *this + other;
m_value = ox::bigEndianAdapt(newVal);
return newVal;
}
inline T operator-(T value) {
return ox::bigEndianAdapt(m_value) - value;
}
inline T operator-=(T other) {
auto newVal = *this - other;
m_value = ox::bigEndianAdapt(newVal);
return newVal;
}
inline T operator*(T value) {
return ox::bigEndianAdapt(m_value) * value;
}
inline T operator*=(T other) {
auto newVal = *this * other;
m_value = ox::bigEndianAdapt(newVal);
return newVal;
}
inline T operator/(T value) {
return ox::bigEndianAdapt(m_value) / value;
}
inline T operator/=(T other) {
auto newVal = *this / other;
m_value = ox::bigEndianAdapt(newVal);
return newVal;
}
// Prefix increment
inline T &operator++() {
return operator+=(1);
}
// Postfix increment
inline T operator++(int) {
auto old = *this;
++*this;
return old;
}
// Prefix decrement
inline T &operator--() {
return operator-=(1);
}
// Postfix decrement
inline T operator--(int) {
auto old = *this;
--*this;
return old;
}
};
}

View File

@@ -11,6 +11,6 @@
int ox_memcmp(const void *ptr1, const void *ptr2, size_t size);
void *ox_memcpy(void *src, const void *dest, int64_t size);
void *ox_memcpy(void *dest, const void *src, int64_t size);
void *ox_memset(void *ptr, int val, int64_t size);