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
|
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 = []
|
cppdefines = []
|
||||||
if env['BUILD_TYPE'] == 'debug':
|
if env['BUILD_TYPE'] == 'debug':
|
||||||
@ -23,7 +26,7 @@ if env['BUILD_TYPE'] == 'debug':
|
|||||||
lib_mijin = env.UnityStaticLibrary(
|
lib_mijin = env.UnityStaticLibrary(
|
||||||
target = env['LIB_DIR'] + '/mijin',
|
target = env['LIB_DIR'] + '/mijin',
|
||||||
source = mijin_sources,
|
source = mijin_sources,
|
||||||
dependencies = [lib_libbacktrace],
|
dependencies = dependencies,
|
||||||
CPPDEFINES = list(env['CPPDEFINES']) + cppdefines
|
CPPDEFINES = list(env['CPPDEFINES']) + cppdefines
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -40,10 +40,10 @@ void MultiThreadedTaskLoop::managerThread(std::stop_token stopToken) // NOLINT(p
|
|||||||
while (!stopToken.stop_requested())
|
while (!stopToken.stop_requested())
|
||||||
{
|
{
|
||||||
// first clear out any parked tasks that are actually finished
|
// 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;
|
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
|
// then try to push any task from the buffer into the queue, if possible
|
||||||
for (auto it = parkedTasks_.begin(); it != parkedTasks_.end();)
|
for (auto it = parkedTasks_.begin(); it != parkedTasks_.end();)
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#if !defined(MIJIN_CONTAINER_STRIDE_SPAN_HPP_INCLUDED)
|
#if !defined(MIJIN_CONTAINER_STRIDE_SPAN_HPP_INCLUDED)
|
||||||
#define MIJIN_CONTAINER_STRIDE_SPAN_HPP_INCLUDED 1
|
#define MIJIN_CONTAINER_STRIDE_SPAN_HPP_INCLUDED 1
|
||||||
|
|
||||||
|
#include <bit>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#if !defined(MIJIN_CONTAINER_TYPELESS_BUFFER_HPP_INCLUDED)
|
#if !defined(MIJIN_CONTAINER_TYPELESS_BUFFER_HPP_INCLUDED)
|
||||||
#define MIJIN_CONTAINER_TYPELESS_BUFFER_HPP_INCLUDED 1
|
#define MIJIN_CONTAINER_TYPELESS_BUFFER_HPP_INCLUDED 1
|
||||||
|
|
||||||
|
#include <bit>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
@ -3,9 +3,19 @@
|
|||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <backtrace.h>
|
|
||||||
#include "../detect.hpp"
|
#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 mijin
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
@ -38,6 +48,7 @@ thread_local Optional<Stacktrace> gCurrentExceptionStackTrace;
|
|||||||
// internal functions
|
// internal functions
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#if MIJIN_USE_LIBBACKTRACE
|
||||||
int backtraceFullCallback(void* data, std::uintptr_t programCounter, const char* filename, int lineno, const char* function)
|
int backtraceFullCallback(void* data, std::uintptr_t programCounter, const char* filename, int lineno, const char* function)
|
||||||
{
|
{
|
||||||
BacktraceData& btData = *static_cast<BacktraceData*>(data);
|
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;
|
thread_local backtrace_state* gBacktraceState = nullptr;
|
||||||
|
#endif // MIJIN_USE_LIBBACKTRACE
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -65,6 +77,7 @@ thread_local backtrace_state* gBacktraceState = nullptr;
|
|||||||
|
|
||||||
Result<Stacktrace> captureStacktrace(unsigned skipFrames) noexcept
|
Result<Stacktrace> captureStacktrace(unsigned skipFrames) noexcept
|
||||||
{
|
{
|
||||||
|
#if MIJIN_USE_LIBBACKTRACE
|
||||||
BacktraceData btData;
|
BacktraceData btData;
|
||||||
if (gBacktraceState == nullptr)
|
if (gBacktraceState == nullptr)
|
||||||
{
|
{
|
||||||
@ -85,6 +98,10 @@ Result<Stacktrace> captureStacktrace(unsigned skipFrames) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Stacktrace(std::move(btData.stackframes));
|
return Stacktrace(std::move(btData.stackframes));
|
||||||
|
#else // MIJIN_USE_LIBBACKTRACE
|
||||||
|
(void) skipFrames;
|
||||||
|
return {}; // TODO
|
||||||
|
#endif // MIJIN_USE_LIBBACKTRACE
|
||||||
}
|
}
|
||||||
|
|
||||||
const Optional<Stacktrace>& getExceptionStacktrace() noexcept
|
const Optional<Stacktrace>& getExceptionStacktrace() noexcept
|
||||||
|
|||||||
@ -3,9 +3,11 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include "../detect.hpp"
|
||||||
#include "../util/iterators.hpp"
|
#include "../util/iterators.hpp"
|
||||||
#include "../util/string.hpp"
|
#include "../util/string.hpp"
|
||||||
|
|
||||||
|
#if MIJIN_TARGET_OS == MIJIN_OS_LINUX || MIJIN_TARGET_OS == MIJIN_OS_OSX
|
||||||
namespace mijin
|
namespace mijin
|
||||||
{
|
{
|
||||||
ProcessStream::~ProcessStream()
|
ProcessStream::~ProcessStream()
|
||||||
@ -173,3 +175,4 @@ std::string makeShellCommand(const std::vector<std::string>& args) noexcept
|
|||||||
| Join(" ");
|
| Join(" ");
|
||||||
}
|
}
|
||||||
} // namespace mijin
|
} // namespace mijin
|
||||||
|
#endif // MIJIN_TARGET_OS == MIJIN_OS_LINUX || MIJIN_TARGET_OS == MIJIN_OS_OSX
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#include "./stream.hpp"
|
#include "./stream.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
@ -143,6 +144,9 @@ StreamError FileStream::open(const char* path, FileOpenMode mode_)
|
|||||||
case FileOpenMode::READ_WRITE:
|
case FileOpenMode::READ_WRITE:
|
||||||
modeStr = "r+b";
|
modeStr = "r+b";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
MIJIN_FATAL("Invalid value for mode.");
|
||||||
|
return StreamError::UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
handle = std::fopen(path, modeStr); // NOLINT(cppcoreguidelines-owning-memory)
|
handle = std::fopen(path, modeStr); // NOLINT(cppcoreguidelines-owning-memory)
|
||||||
if (!handle && mode_ == FileOpenMode::READ_WRITE) {
|
if (!handle && mode_ == FileOpenMode::READ_WRITE) {
|
||||||
|
|||||||
@ -46,6 +46,9 @@ LibraryHandle openSharedLibrary(std::string_view libraryFile) noexcept
|
|||||||
const fs::path libraryPath = fs::absolute(libraryFile);
|
const fs::path libraryPath = fs::absolute(libraryFile);
|
||||||
return {.data = dlopen(libraryPath.c_str(), RTLD_NOW)};
|
return {.data = dlopen(libraryPath.c_str(), RTLD_NOW)};
|
||||||
#elif MIJIN_TARGET_OS == MIJIN_OS_WINDOWS
|
#elif MIJIN_TARGET_OS == MIJIN_OS_WINDOWS
|
||||||
|
// TODO
|
||||||
|
(void) libraryFile;
|
||||||
|
return {};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +57,9 @@ void* loadSymbolFromLibrary(const LibraryHandle library, const char* symbolName)
|
|||||||
#if MIJIN_TARGET_OS == MIJIN_OS_LINUX
|
#if MIJIN_TARGET_OS == MIJIN_OS_LINUX
|
||||||
return dlsym(library.data, symbolName);
|
return dlsym(library.data, symbolName);
|
||||||
#elif MIJIN_TARGET_OS == MIJIN_OS_WINDOWS
|
#elif MIJIN_TARGET_OS == MIJIN_OS_WINDOWS
|
||||||
|
(void) library;
|
||||||
|
(void) symbolName;
|
||||||
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,6 +68,7 @@ void setCurrentThreadName(const char* threadName) noexcept
|
|||||||
#if MIJIN_TARGET_OS == MIJIN_OS_LINUX
|
#if MIJIN_TARGET_OS == MIJIN_OS_LINUX
|
||||||
pthread_setname_np(pthread_self(), threadName);
|
pthread_setname_np(pthread_self(), threadName);
|
||||||
#elif MIJIN_TARGET_OS == MIJIN_OS_WINDOWS
|
#elif MIJIN_TARGET_OS == MIJIN_OS_WINDOWS
|
||||||
|
(void) threadName;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user