diff --git a/LibConf b/LibConf index 113fb09..d727b08 100644 --- a/LibConf +++ b/LibConf @@ -13,7 +13,10 @@ mijin_sources = Split(""" source/mijin/virtual_filesystem/stacked.cpp """) -lib_libbacktrace = env.Cook('libbacktrace') +dependencies = [] +if env['COMPILER_FAMILY'] in ('gcc', 'clang'): + lib_libbacktrace = env.Cook('libbacktrace') + dependencies.append(lib_libbacktrace) cppdefines = [] if env['BUILD_TYPE'] == 'debug': @@ -23,7 +26,7 @@ if env['BUILD_TYPE'] == 'debug': lib_mijin = env.UnityStaticLibrary( target = env['LIB_DIR'] + '/mijin', source = mijin_sources, - dependencies = [lib_libbacktrace], + dependencies = dependencies, CPPDEFINES = list(env['CPPDEFINES']) + cppdefines ) diff --git a/source/mijin/async/coroutine.cpp b/source/mijin/async/coroutine.cpp index 65da812..6fba277 100644 --- a/source/mijin/async/coroutine.cpp +++ b/source/mijin/async/coroutine.cpp @@ -40,10 +40,10 @@ void MultiThreadedTaskLoop::managerThread(std::stop_token stopToken) // NOLINT(p while (!stopToken.stop_requested()) { // first clear out any parked tasks that are actually finished - auto it = std::remove_if(parkedTasks_.begin(), parkedTasks_.end(), [](StoredTask& task) { + auto itRem = std::remove_if(parkedTasks_.begin(), parkedTasks_.end(), [](StoredTask& task) { return !task.task || task.task->status() == TaskStatus::FINISHED; }); - parkedTasks_.erase(it, parkedTasks_.end()); + parkedTasks_.erase(itRem, parkedTasks_.end()); // then try to push any task from the buffer into the queue, if possible for (auto it = parkedTasks_.begin(); it != parkedTasks_.end();) diff --git a/source/mijin/container/stride_span.hpp b/source/mijin/container/stride_span.hpp index 6ee5435..71bf8e7 100644 --- a/source/mijin/container/stride_span.hpp +++ b/source/mijin/container/stride_span.hpp @@ -4,6 +4,7 @@ #if !defined(MIJIN_CONTAINER_STRIDE_SPAN_HPP_INCLUDED) #define MIJIN_CONTAINER_STRIDE_SPAN_HPP_INCLUDED 1 +#include #include #include #include diff --git a/source/mijin/container/typeless_buffer.hpp b/source/mijin/container/typeless_buffer.hpp index 4b63387..bc4004a 100644 --- a/source/mijin/container/typeless_buffer.hpp +++ b/source/mijin/container/typeless_buffer.hpp @@ -4,6 +4,7 @@ #if !defined(MIJIN_CONTAINER_TYPELESS_BUFFER_HPP_INCLUDED) #define MIJIN_CONTAINER_TYPELESS_BUFFER_HPP_INCLUDED 1 +#include #include #include #include diff --git a/source/mijin/debug/stacktrace.cpp b/source/mijin/debug/stacktrace.cpp index dfca406..461af41 100644 --- a/source/mijin/debug/stacktrace.cpp +++ b/source/mijin/debug/stacktrace.cpp @@ -3,9 +3,19 @@ #include #include -#include #include "../detect.hpp" +#if MIJIN_COMPILER == MIJIN_COMPILER_CLANG || MIJIN_COMPILER == MIJIN_COMPILER_GCC +#define MIJIN_USE_LIBBACKTRACE 1 +#else +#define MIJIN_USE_LIBBACKTRACE 0 +#endif + +#if MIJIN_USE_LIBBACKTRACE +#include +#endif + + namespace mijin { namespace @@ -38,6 +48,7 @@ thread_local Optional gCurrentExceptionStackTrace; // internal functions // +#if MIJIN_USE_LIBBACKTRACE int backtraceFullCallback(void* data, std::uintptr_t programCounter, const char* filename, int lineno, const char* function) { BacktraceData& btData = *static_cast(data); @@ -57,6 +68,7 @@ void backtraceErrorCallback(void* data, const char* msg, int /* errnum */) } thread_local backtrace_state* gBacktraceState = nullptr; +#endif // MIJIN_USE_LIBBACKTRACE } // namespace // @@ -65,6 +77,7 @@ thread_local backtrace_state* gBacktraceState = nullptr; Result captureStacktrace(unsigned skipFrames) noexcept { +#if MIJIN_USE_LIBBACKTRACE BacktraceData btData; if (gBacktraceState == nullptr) { @@ -85,6 +98,10 @@ Result captureStacktrace(unsigned skipFrames) noexcept } return Stacktrace(std::move(btData.stackframes)); +#else // MIJIN_USE_LIBBACKTRACE + (void) skipFrames; + return {}; // TODO +#endif // MIJIN_USE_LIBBACKTRACE } const Optional& getExceptionStacktrace() noexcept diff --git a/source/mijin/io/process.cpp b/source/mijin/io/process.cpp index 1521856..591f2df 100644 --- a/source/mijin/io/process.cpp +++ b/source/mijin/io/process.cpp @@ -3,9 +3,11 @@ #include #include +#include "../detect.hpp" #include "../util/iterators.hpp" #include "../util/string.hpp" +#if MIJIN_TARGET_OS == MIJIN_OS_LINUX || MIJIN_TARGET_OS == MIJIN_OS_OSX namespace mijin { ProcessStream::~ProcessStream() @@ -173,3 +175,4 @@ std::string makeShellCommand(const std::vector& args) noexcept | Join(" "); } } // namespace mijin +#endif // MIJIN_TARGET_OS == MIJIN_OS_LINUX || MIJIN_TARGET_OS == MIJIN_OS_OSX diff --git a/source/mijin/io/stream.cpp b/source/mijin/io/stream.cpp index b6d2949..a26014d 100644 --- a/source/mijin/io/stream.cpp +++ b/source/mijin/io/stream.cpp @@ -2,6 +2,7 @@ #include "./stream.hpp" #include +#include #include #include @@ -143,6 +144,9 @@ StreamError FileStream::open(const char* path, FileOpenMode mode_) case FileOpenMode::READ_WRITE: modeStr = "r+b"; break; + default: + MIJIN_FATAL("Invalid value for mode."); + return StreamError::UNKNOWN_ERROR; } handle = std::fopen(path, modeStr); // NOLINT(cppcoreguidelines-owning-memory) if (!handle && mode_ == FileOpenMode::READ_WRITE) { diff --git a/source/mijin/util/os.cpp b/source/mijin/util/os.cpp index e21cd5c..621914f 100644 --- a/source/mijin/util/os.cpp +++ b/source/mijin/util/os.cpp @@ -46,6 +46,9 @@ LibraryHandle openSharedLibrary(std::string_view libraryFile) noexcept const fs::path libraryPath = fs::absolute(libraryFile); return {.data = dlopen(libraryPath.c_str(), RTLD_NOW)}; #elif MIJIN_TARGET_OS == MIJIN_OS_WINDOWS + // TODO + (void) libraryFile; + return {}; #endif } @@ -54,6 +57,9 @@ void* loadSymbolFromLibrary(const LibraryHandle library, const char* symbolName) #if MIJIN_TARGET_OS == MIJIN_OS_LINUX return dlsym(library.data, symbolName); #elif MIJIN_TARGET_OS == MIJIN_OS_WINDOWS + (void) library; + (void) symbolName; + return nullptr; #endif } @@ -62,6 +68,7 @@ void setCurrentThreadName(const char* threadName) noexcept #if MIJIN_TARGET_OS == MIJIN_OS_LINUX pthread_setname_np(pthread_self(), threadName); #elif MIJIN_TARGET_OS == MIJIN_OS_WINDOWS + (void) threadName; #endif }