Fixed Windows/MSVC compilation.
This commit is contained in:
parent
b10f250945
commit
b1fa99428e
7
LibConf
7
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
|
||||
)
|
||||
|
||||
|
||||
@ -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();)
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#if !defined(MIJIN_CONTAINER_STRIDE_SPAN_HPP_INCLUDED)
|
||||
#define MIJIN_CONTAINER_STRIDE_SPAN_HPP_INCLUDED 1
|
||||
|
||||
#include <bit>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#if !defined(MIJIN_CONTAINER_TYPELESS_BUFFER_HPP_INCLUDED)
|
||||
#define MIJIN_CONTAINER_TYPELESS_BUFFER_HPP_INCLUDED 1
|
||||
|
||||
#include <bit>
|
||||
#include <cstddef>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
@ -3,9 +3,19 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <backtrace.h>
|
||||
#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 <backtrace.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace mijin
|
||||
{
|
||||
namespace
|
||||
@ -38,6 +48,7 @@ thread_local Optional<Stacktrace> 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<BacktraceData*>(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<Stacktrace> captureStacktrace(unsigned skipFrames) noexcept
|
||||
{
|
||||
#if MIJIN_USE_LIBBACKTRACE
|
||||
BacktraceData btData;
|
||||
if (gBacktraceState == nullptr)
|
||||
{
|
||||
@ -85,6 +98,10 @@ Result<Stacktrace> captureStacktrace(unsigned skipFrames) noexcept
|
||||
}
|
||||
|
||||
return Stacktrace(std::move(btData.stackframes));
|
||||
#else // MIJIN_USE_LIBBACKTRACE
|
||||
(void) skipFrames;
|
||||
return {}; // TODO
|
||||
#endif // MIJIN_USE_LIBBACKTRACE
|
||||
}
|
||||
|
||||
const Optional<Stacktrace>& getExceptionStacktrace() noexcept
|
||||
|
||||
@ -3,9 +3,11 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#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<std::string>& args) noexcept
|
||||
| Join(" ");
|
||||
}
|
||||
} // namespace mijin
|
||||
#endif // MIJIN_TARGET_OS == MIJIN_OS_LINUX || MIJIN_TARGET_OS == MIJIN_OS_OSX
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include "./stream.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user