emscript on system.h

v1
Brett 2023-12-16 02:37:24 -05:00
parent bda044de1e
commit 4de984bdb8
1 changed files with 11 additions and 3 deletions

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)