diff --git a/include/blt/std/logging.h b/include/blt/std/logging.h index 6b19ab8..f8d0210 100755 --- a/include/blt/std/logging.h +++ b/include/blt/std/logging.h @@ -18,9 +18,6 @@ namespace blt::logging { - template - using hashmap = std::unordered_map; - enum class log_level { // default @@ -206,6 +203,7 @@ namespace blt::logging #include #include #include + #include #if defined(CXX17_FILESYSTEM) || defined (CXX17_FILESYSTEM_LIBFS) #include #elif defined(CXX11_EXP_FILESYSTEM) || defined (CXX11_EXP_FILESYSTEM_LIBFS) @@ -215,6 +213,9 @@ namespace blt::logging #endif #include #include + + template + using hashmap = std::unordered_map; namespace blt::logging { diff --git a/include/blt/std/system.h b/include/blt/std/system.h index 168b9eb..960521e 100755 --- a/include/blt/std/system.h +++ b/include/blt/std/system.h @@ -7,10 +7,14 @@ #ifndef BLT_SYSTEM_H #define BLT_SYSTEM_H -#ifdef _WIN32 -#include +#ifndef __EMSCRIPTEN__ + #ifdef _WIN32 + #include + #else + #include + #endif #else -#include + #include #endif #include @@ -21,7 +25,11 @@ namespace blt::system { // #define GNU_INLINE //#endif inline std::uint64_t rdtsc(){ +#ifdef __EMSCRIPTEN__ + return std::chrono::high_resolution_clock::now().time_since_epoch().count(); +#else return __rdtsc(); +#endif } // TODO: system memory and current CPU usage. (Linux Only currently) diff --git a/src/blt/parse/argparse.cpp b/src/blt/parse/argparse.cpp index 6cbb4c2..247468d 100755 --- a/src/blt/parse/argparse.cpp +++ b/src/blt/parse/argparse.cpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace blt { @@ -526,7 +527,7 @@ namespace blt { const auto& name = arg->a_flags.name; std::cout << name; - auto size = std::max(static_cast(max_length) - static_cast(name.size()), 0l); + auto size = std::max(static_cast(max_length) - static_cast(name.size()), static_cast(0)); size += tab_size; for (int64_t i = 0; i < size; i++) std::cout << " "; @@ -540,7 +541,7 @@ namespace blt { const auto& name = getFlagHelp(arg); std::cout << name; - auto size = std::max(static_cast(max_length) - static_cast(name.size()), 0l); + auto size = std::max(static_cast(max_length) - static_cast(name.size()), static_cast(0)); size += tab_size; for (int64_t i = 0; i < size; i++) std::cout << " "; diff --git a/src/blt/std/assert.cpp b/src/blt/std/assert.cpp index 30a53c9..d41cf29 100644 --- a/src/blt/std/assert.cpp +++ b/src/blt/std/assert.cpp @@ -11,13 +11,13 @@ #include #include -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__EMSCRIPTEN__) #include #include #endif -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__EMSCRIPTEN__) #define BLT_STACK_TRACE(number) void* ptrs[number]; \ int size = backtrace(ptrs, number); \ char** messages = backtrace_symbols(ptrs, size); @@ -25,7 +25,7 @@ #define BLT_FREE_STACK_TRACE() free(messages); #else -#define BLT_STACK_TRACE(number) void(); + #define BLT_STACK_TRACE(number) void(); #define BLT_FREE_STACK_TRACE() void(); #endif @@ -41,7 +41,7 @@ namespace blt { void b_throw(const char* what, const char* path, int line) { -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__EMSCRIPTEN__) BLT_STACK_TRACE(50); 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) { -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__EMSCRIPTEN__) BLT_STACK_TRACE(50); BLT_ERROR("The assertion '%s' has failed in file '%s:%d'", expression, path, line); @@ -70,7 +70,7 @@ namespace blt { { if (messages == nullptr) return; -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__EMSCRIPTEN__) for (int i = 1; i < size; i++){ int tabs = i - 1; std::string buffer;