From 610f6f4246a425282420c324251b612bec8891d3 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 5 May 2018 02:34:55 -0500 Subject: [PATCH] [ox] Fix to build with MinGW --- deps/ox/src/ox/fs/CMakeLists.txt | 32 ++++++++++----------- deps/ox/src/ox/fs/filesystem2/directory.hpp | 9 ++---- deps/ox/src/ox/ptrarith/nodebuffer.hpp | 2 +- deps/ox/src/ox/ptrarith/ptr.hpp | 2 +- deps/ox/src/ox/std/new.hpp | 6 ++-- 5 files changed, 24 insertions(+), 27 deletions(-) diff --git a/deps/ox/src/ox/fs/CMakeLists.txt b/deps/ox/src/ox/fs/CMakeLists.txt index f4dd4c3f..ec1065b7 100644 --- a/deps/ox/src/ox/fs/CMakeLists.txt +++ b/deps/ox/src/ox/fs/CMakeLists.txt @@ -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() diff --git a/deps/ox/src/ox/fs/filesystem2/directory.hpp b/deps/ox/src/ox/fs/filesystem2/directory.hpp index 74fed0c6..6f6122ad 100644 --- a/deps/ox/src/ox/fs/filesystem2/directory.hpp +++ b/deps/ox/src/ox/fs/filesystem2/directory.hpp @@ -91,7 +91,7 @@ class Directory { Error rm(PathIterator it) noexcept; - ValErr find(PathIterator it) const noexcept; + ValErr find(const char *name) const noexcept; }; @@ -154,15 +154,12 @@ Error Directory::rm(PathIterator) noexcept { } template -ValErr Directory::find(PathIterator it) const noexcept { +ValErr Directory::find(const char *name) const noexcept { ValErr 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(); 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(data->inode); } } diff --git a/deps/ox/src/ox/ptrarith/nodebuffer.hpp b/deps/ox/src/ox/ptrarith/nodebuffer.hpp index 4ab16e7d..77ddff03 100644 --- a/deps/ox/src/ox/ptrarith/nodebuffer.hpp +++ b/deps/ox/src/ox/ptrarith/nodebuffer.hpp @@ -204,7 +204,7 @@ typename NodeBuffer::ItemPtr NodeBuffer::ptr(size_t template typename NodeBuffer::ItemPtr NodeBuffer::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; diff --git a/deps/ox/src/ox/ptrarith/ptr.hpp b/deps/ox/src/ox/ptrarith/ptr.hpp index d406f8bb..6d31f6eb 100644 --- a/deps/ox/src/ox/ptrarith/ptr.hpp +++ b/deps/ox/src/ox/ptrarith/ptr.hpp @@ -88,7 +88,7 @@ inline Ptr::Ptr(void *dataStart, size_t dataSize, size_t i if (itemSize >= sizeof(T) and dataStart and itemStart >= minOffset and - itemStart + itemSize <= dataSize) { + static_cast(itemStart + itemSize) <= dataSize) { m_dataStart = reinterpret_cast(dataStart); m_dataSize = dataSize; m_itemOffset = itemStart; diff --git a/deps/ox/src/ox/std/new.hpp b/deps/ox/src/ox/std/new.hpp index f0175868..7875e4f4 100644 --- a/deps/ox/src/ox/std/new.hpp +++ b/deps/ox/src/ox/std/new.hpp @@ -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 #define ox_alloca(size) _alloca(size) #elif __has_include() #include #define ox_alloca(size) alloca(size) +#else +#define ox_alloca(size) __builtin_alloca(size) #endif