Merge remote-tracking branch 'refs/remotes/tpgc/main'

v1
Brett 2023-12-16 15:53:18 -05:00
commit 57be387904
4 changed files with 24 additions and 14 deletions

View File

@ -18,9 +18,6 @@
namespace blt::logging namespace blt::logging
{ {
template<typename K, typename V>
using hashmap = std::unordered_map<K, V>;
enum class log_level enum class log_level
{ {
// default // default
@ -206,6 +203,7 @@ namespace blt::logging
#include <thread> #include <thread>
#include <cstdarg> #include <cstdarg>
#include <iostream> #include <iostream>
#include <vector>
#if defined(CXX17_FILESYSTEM) || defined (CXX17_FILESYSTEM_LIBFS) #if defined(CXX17_FILESYSTEM) || defined (CXX17_FILESYSTEM_LIBFS)
#include <filesystem> #include <filesystem>
#elif defined(CXX11_EXP_FILESYSTEM) || defined (CXX11_EXP_FILESYSTEM_LIBFS) #elif defined(CXX11_EXP_FILESYSTEM) || defined (CXX11_EXP_FILESYSTEM_LIBFS)
@ -216,6 +214,9 @@ namespace blt::logging
#include <ios> #include <ios>
#include <fstream> #include <fstream>
template<typename K, typename V>
using hashmap = std::unordered_map<K, V>;
namespace blt::logging { namespace blt::logging {
/** /**

View File

@ -7,11 +7,15 @@
#ifndef BLT_SYSTEM_H #ifndef BLT_SYSTEM_H
#define BLT_SYSTEM_H #define BLT_SYSTEM_H
#ifndef __EMSCRIPTEN__
#ifdef _WIN32 #ifdef _WIN32
#include <intrin.h> #include <intrin.h>
#else #else
#include <x86intrin.h> #include <x86intrin.h>
#endif #endif
#else
#include <chrono>
#endif
#include <cstdint> #include <cstdint>
namespace blt::system { namespace blt::system {
@ -21,7 +25,11 @@ namespace blt::system {
// #define GNU_INLINE // #define GNU_INLINE
//#endif //#endif
inline std::uint64_t rdtsc(){ inline std::uint64_t rdtsc(){
#ifdef __EMSCRIPTEN__
return std::chrono::high_resolution_clock::now().time_since_epoch().count();
#else
return __rdtsc(); return __rdtsc();
#endif
} }
// TODO: system memory and current CPU usage. (Linux Only currently) // TODO: system memory and current CPU usage. (Linux Only currently)

View File

@ -6,6 +6,7 @@
#include <blt/parse/argparse.h> #include <blt/parse/argparse.h>
#include <iostream> #include <iostream>
#include <blt/std/string.h> #include <blt/std/string.h>
#include <algorithm>
namespace blt namespace blt
{ {
@ -526,7 +527,7 @@ namespace blt
{ {
const auto& name = arg->a_flags.name; const auto& name = arg->a_flags.name;
std::cout << name; std::cout << name;
auto size = std::max(static_cast<int64_t>(max_length) - static_cast<int64_t>(name.size()), 0l); auto size = std::max(static_cast<int64_t>(max_length) - static_cast<int64_t>(name.size()), static_cast<int64_t>(0));
size += tab_size; size += tab_size;
for (int64_t i = 0; i < size; i++) for (int64_t i = 0; i < size; i++)
std::cout << " "; std::cout << " ";
@ -540,7 +541,7 @@ namespace blt
{ {
const auto& name = getFlagHelp(arg); const auto& name = getFlagHelp(arg);
std::cout << name; std::cout << name;
auto size = std::max(static_cast<int64_t>(max_length) - static_cast<int64_t>(name.size()), 0l); auto size = std::max(static_cast<int64_t>(max_length) - static_cast<int64_t>(name.size()), static_cast<int64_t>(0));
size += tab_size; size += tab_size;
for (int64_t i = 0; i < size; i++) for (int64_t i = 0; i < size; i++)
std::cout << " "; std::cout << " ";

View File

@ -11,13 +11,13 @@
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
#ifdef __GNUC__ #if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
#include <execinfo.h> #include <execinfo.h>
#include <cstdlib> #include <cstdlib>
#endif #endif
#ifdef __GNUC__ #if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
#define BLT_STACK_TRACE(number) void* ptrs[number]; \ #define BLT_STACK_TRACE(number) void* ptrs[number]; \
int size = backtrace(ptrs, number); \ int size = backtrace(ptrs, number); \
char** messages = backtrace_symbols(ptrs, size); char** messages = backtrace_symbols(ptrs, size);
@ -41,7 +41,7 @@ namespace blt {
void b_throw(const char* what, const char* path, int line) void b_throw(const char* what, const char* path, int line)
{ {
#ifdef __GNUC__ #if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
BLT_STACK_TRACE(50); BLT_STACK_TRACE(50);
BLT_ERROR("An exception '%s' has occurred in file '%s:%d'", what, path, line); BLT_ERROR("An exception '%s' has occurred in file '%s:%d'", what, path, line);
@ -54,7 +54,7 @@ namespace blt {
void b_assert_failed(const char* expression, const char* path, int line) void b_assert_failed(const char* expression, const char* path, int line)
{ {
#ifdef __GNUC__ #if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
BLT_STACK_TRACE(50); BLT_STACK_TRACE(50);
BLT_ERROR("The assertion '%s' has failed in file '%s:%d'", expression, path, line); BLT_ERROR("The assertion '%s' has failed in file '%s:%d'", expression, path, line);
@ -70,7 +70,7 @@ namespace blt {
{ {
if (messages == nullptr) if (messages == nullptr)
return; return;
#ifdef __GNUC__ #if defined(__GNUC__) && !defined(__EMSCRIPTEN__)
for (int i = 1; i < size; i++){ for (int i = 1; i < size; i++){
int tabs = i - 1; int tabs = i - 1;
std::string buffer; std::string buffer;