[ox/std] Fix several issues found compiling on FreeBSD

This commit is contained in:
Gary Talent 2019-06-14 19:36:46 -05:00
parent 2b60c04f1a
commit 238bc58f66
6 changed files with 12 additions and 12 deletions

View File

@ -18,7 +18,7 @@
namespace ox {
template<>
void _assert<bool>([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]bool pass, [[maybe_unused]]const char *msg) {
void assertFunc<bool>([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]bool pass, [[maybe_unused]]const char *msg) {
#if defined(OX_USE_STDLIB)
if (!pass) {
std::cerr << "\033[31;1;1mASSERT FAILURE:\033[0m (" << file << ':' << line << "): " << msg << std::endl;
@ -29,7 +29,7 @@ void _assert<bool>([[maybe_unused]]const char *file, [[maybe_unused]]int line, [
}
template<>
void _assert<Error>([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]Error err, [[maybe_unused]]const char *msg) {
void assertFunc<Error>([[maybe_unused]]const char *file, [[maybe_unused]]int line, [[maybe_unused]]Error err, [[maybe_unused]]const char *msg) {
#if defined(OX_USE_STDLIB)
if (err) {
auto ei = ErrorInfo(err);

View File

@ -14,19 +14,19 @@
namespace ox {
template<typename T>
void _assert(const char*, int, T, const char*) {
void assertFunc(const char*, int, T, const char*) {
}
template<>
void _assert<bool>(const char *file, int line, bool pass, const char *msg);
void assertFunc<bool>(const char *file, int line, bool pass, const char *msg);
template<>
void _assert<Error>(const char *file, int line, Error err, const char*);
void assertFunc<Error>(const char *file, int line, Error err, const char*);
}
#ifndef NDEBUG
#define oxAssert(pass, msg) ox::_assert<decltype(pass)>(__FILE__, __LINE__, pass, msg)
#define oxAssert(pass, msg) ox::assertFunc<decltype(pass)>(__FILE__, __LINE__, pass, msg)
#else
#define oxAssert(pass, msg)
#endif

View File

@ -10,11 +10,11 @@
#include "types.hpp"
void *operator new(std::size_t, void *addr) {
void *operator new(std::size_t, void *addr) noexcept {
return addr;
}
void *operator new[](std::size_t, void *addr) {
void *operator new[](std::size_t, void *addr) noexcept {
return addr;
}

View File

@ -15,14 +15,14 @@
#include <malloc.h>
#define ox_alloca(size) _alloca(size)
#elif OX_USE_STDLIB
#include <alloca.h>
#include <stdlib.h>
#define ox_alloca(size) alloca(size)
#else
#define ox_alloca(size) __builtin_alloca(size)
#endif
void *operator new(std::size_t, void*);
void *operator new(std::size_t, void*) noexcept;
/**

View File

@ -20,7 +20,7 @@ namespace ox {
void printStackTrace([[maybe_unused]]int shave) {
#if defined(OX_USE_STDLIB)
std::array<void*, 100> frames;
auto size = backtrace(frames.data(), frames.size());
auto size = static_cast<int>(backtrace(frames.data(), frames.size()));
if (size > shave) {
std::cout << "\nStacktrace:\n";
backtrace_symbols_fd(frames.data() + shave, size - shave, STDERR_FILENO);

View File

@ -20,7 +20,7 @@ namespace ox::trace {
#if defined(OX_USE_STDLIB)
static const auto OxPrintTrace = std::getenv("OXTRACE");
#else
static const auto OxPrintTrace = false;
constexpr auto OxPrintTrace = false;
#endif
namespace gdblogger {