[ox] Fix to build with MinGW

This commit is contained in:
Gary Talent 2018-05-05 02:34:55 -05:00
parent 1e82dacd6d
commit 610f6f4246
5 changed files with 24 additions and 27 deletions

View File

@ -17,19 +17,19 @@ set_property(
)
if(OX_BUILD_EXEC STREQUAL "ON")
add_executable(
oxfstool
toollib.cpp
oxfstool.cpp
)
set_target_properties(oxfstool PROPERTIES OUTPUT_NAME oxfs)
target_link_libraries(
oxfstool
OxFS
OxTrace
OxMetalClaw
OxStd
)
#add_executable(
# oxfstool
# toollib.cpp
# oxfstool.cpp
#)
#set_target_properties(oxfstool PROPERTIES OUTPUT_NAME oxfs)
#target_link_libraries(
# oxfstool
# OxFS
# OxTrace
# OxMetalClaw
# OxStd
#)
endif()
install(
@ -58,7 +58,7 @@ if(OX_BUILD_EXEC STREQUAL "ON")
if(OX_RUN_TESTS STREQUAL "ON")
add_subdirectory(test)
endif()
install(TARGETS oxfstool
RUNTIME DESTINATION bin
)
#install(TARGETS oxfstool
# RUNTIME DESTINATION bin
#)
endif()

View File

@ -91,7 +91,7 @@ class Directory {
Error rm(PathIterator it) noexcept;
ValErr<InodeId_t> find(PathIterator it) const noexcept;
ValErr<InodeId_t> find(const char *name) const noexcept;
};
@ -154,15 +154,12 @@ Error Directory<InodeId_t>::rm(PathIterator) noexcept {
}
template<typename InodeId_t>
ValErr<InodeId_t> Directory<InodeId_t>::find(PathIterator it) const noexcept {
ValErr<InodeId_t> Directory<InodeId_t>::find(const char *name) const noexcept {
ValErr<InodeId_t> retval = {0, 1};
auto size = it.nextSize();
auto name = ox_malloca(size + 1, char);
it.next(name, size);
auto buff = m_fs->read(m_inodeId).template to<Buffer>();
for (auto i = buff->iterator(); i.hasNext(); i.next()) {
auto data = i->data();
if (data.valid() && data->name == name.get()) {
if (data.valid() && data->name == name) {
retval = static_cast<InodeId_t>(data->inode);
}
}

View File

@ -204,7 +204,7 @@ typename NodeBuffer<size_t, Item>::ItemPtr NodeBuffer<size_t, Item>::ptr(size_t
template<typename size_t, typename Item>
typename NodeBuffer<size_t, Item>::ItemPtr NodeBuffer<size_t, Item>::malloc(size_t size) {
auto fullSize = size + sizeof(Item);
size_t fullSize = size + sizeof(Item);
if (m_header.size - m_header.bytesUsed >= fullSize) {
auto last = lastItem();
size_t addr = 0;

View File

@ -88,7 +88,7 @@ inline Ptr<T, size_t, minOffset>::Ptr(void *dataStart, size_t dataSize, size_t i
if (itemSize >= sizeof(T) and
dataStart and
itemStart >= minOffset and
itemStart + itemSize <= dataSize) {
static_cast<std::size_t>(itemStart + itemSize) <= dataSize) {
m_dataStart = reinterpret_cast<uint8_t*>(dataStart);
m_dataSize = dataSize;
m_itemOffset = itemStart;

View File

@ -12,14 +12,14 @@
#include "types.hpp"
#if !defined(OX_USE_STDLIB)
#define ox_alloca(size) __builtin_alloca(size)
#elif defined(_MSC_VER)
#if defined(_MSC_VER)
#include <malloc.h>
#define ox_alloca(size) _alloca(size)
#elif __has_include(<alloca.h>)
#include <alloca.h>
#define ox_alloca(size) alloca(size)
#else
#define ox_alloca(size) __builtin_alloca(size)
#endif