[ox] Fix GCC errors

This commit is contained in:
Gary Talent 2019-06-06 18:50:06 -05:00
parent 23b662c2aa
commit 096509c2be
9 changed files with 34 additions and 28 deletions

4
deps/ox/.gitignore vendored
View File

@ -4,3 +4,7 @@ build/*-asan
build/*-debug
build/*-release
tags
conanbuildinfo.cmake
conanbuildinfo.txt
conaninfo.txt
graph_info.json

View File

@ -3,6 +3,7 @@ if(OX_USE_STDLIB STREQUAL "ON")
endif(OX_USE_STDLIB STREQUAL "ON")
add_subdirectory(fs)
add_subdirectory(mc)
add_subdirectory(oc)
add_subdirectory(ptrarith)
add_subdirectory(model)
add_subdirectory(std)

View File

@ -369,14 +369,14 @@ Error FileStoreTemplate<size_t>::read(InodeId_t id, FsSize_t readStart,
if (src.valid()) {
auto srcData = src->data();
if (srcData.valid()) {
auto sub = srcData.template subPtr<T>(readStart, readSize);
auto sub = srcData.template subPtr<uint8_t>(readStart, readSize);
if (sub.valid() && sub.size() % sizeof(T)) {
for (FsSize_t i = 0; i < sub.size() / sizeof(T); i++) {
// do byte-by-byte copy to ensure alignment is right when
// copying to final destination
T tmp;
for (size_t i = 0; i < sizeof(T); i++) {
reinterpret_cast<uint8_t*>(&tmp)[i] = *(reinterpret_cast<const uint8_t*>(sub.get()) + i);
reinterpret_cast<uint8_t*>(&tmp)[i] = *(sub.get() + i);
}
*(data + i) = tmp;
}

View File

@ -124,7 +124,7 @@ template<typename I>
const auto bytes = countBytes(buff[0]);
if (bytes == 9) {
*bytesRead = bytes;
I out;
I out = 0;
ox_memcpy(&out, &buff[1], sizeof(I));
return {LittleEndian<I>(out), 0};
} else if (buffLen >= bytes) {

View File

@ -38,4 +38,20 @@ Error FieldPresenceIndicator::set(int i, bool on) {
}
}
void FieldPresenceIndicator::setFields(int fields) noexcept {
m_fields = fields;
}
int FieldPresenceIndicator::getFields() const noexcept {
return m_fields;
}
void FieldPresenceIndicator::setMaxLen(int maxLen) noexcept {
m_maskLen = maxLen;
}
int FieldPresenceIndicator::getMaxLen() const noexcept {
return m_maskLen;
}
}

View File

@ -26,30 +26,14 @@ class FieldPresenceIndicator {
Error set(int i, bool on);
constexpr void setFields(int) noexcept;
void setFields(int) noexcept;
constexpr int getFields() const noexcept;
int getFields() const noexcept;
constexpr void setMaxLen(int) noexcept;
void setMaxLen(int) noexcept;
constexpr int getMaxLen() const noexcept;
int getMaxLen() const noexcept;
};
constexpr void FieldPresenceIndicator::setFields(int fields) noexcept {
m_fields = fields;
}
constexpr int FieldPresenceIndicator::getFields() const noexcept {
return m_fields;
}
constexpr void FieldPresenceIndicator::setMaxLen(int maxLen) noexcept {
m_maskLen = maxLen;
}
constexpr int FieldPresenceIndicator::getMaxLen() const noexcept {
return m_maskLen;
}
}

View File

@ -77,7 +77,7 @@ struct DescriptorField {
~DescriptorField();
constexpr const DescriptorField &operator=(DescriptorField &&other) noexcept {
const DescriptorField &operator=(DescriptorField &&other) noexcept {
type = other.type;
fieldName = other.fieldName;
subscriptLevels = other.subscriptLevels;

View File

@ -9,6 +9,7 @@
#pragma once
#include "typetraits.hpp"
#include "utility.hpp"
#ifdef DEBUG
#define OxError(x) ox::_error(__FILE__, __LINE__, x)
@ -59,7 +60,7 @@ struct ValErr {
inline constexpr ValErr() = default;
inline constexpr ValErr(T value, Error error = 0): value(value), error(error) {
inline constexpr ValErr(T value, Error error = 0): value(ox::move(value)), error(error) {
}
inline constexpr operator const T&() const {

View File

@ -53,7 +53,7 @@ class HashMap {
/**
* K is assumed to be a null terminated string.
*/
static std::uint64_t hash(K, int len = 0xFFFF) noexcept;
static uint64_t hash(K, int len = 0xFFFF) noexcept;
/**
* K is assumed to be a null terminated string.
@ -126,8 +126,8 @@ void HashMap<K, T>::expand() {
}
template<typename K, typename T>
std::uint64_t HashMap<K, T>::hash(K k, int len) noexcept {
std::uint64_t sum = 1;
uint64_t HashMap<K, T>::hash(K k, int len) noexcept {
uint64_t sum = 1;
for (int i = 0; i < len && k[i]; i++) {
sum += ((sum + k[i]) * 7) * sum;
}