move blackboxes to system

v1
Brett 2023-11-22 21:21:17 -05:00
parent 6514736262
commit 02c62a2d63
2 changed files with 36 additions and 36 deletions

View File

@ -14,42 +14,6 @@ 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);
void b_throw(const char* what, const char* path, int line); void b_throw(const char* what, const char* path, int line);
#if defined(__GNUC__) || defined(__llvm__)
#define BLT_ATTRIB_NO_INLINE __attribute__ ((noinline))
#else
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
#define BLT_ATTRIB_NO_INLINE __declspec(noinline)
#else
#define BLT_ATTRIB_NO_INLINE
#endif
#endif
template<typename T>
void BLT_ATTRIB_NO_INLINE black_box_ref(const T& val){
volatile void* hell;
hell = (void*)&val;
}
template<typename T>
void BLT_ATTRIB_NO_INLINE black_box(T val){
volatile void* hell2;
hell2 = (void*)&val;
}
template<typename T>
const T& BLT_ATTRIB_NO_INLINE black_box_ref_ret(const T& val){
volatile void* hell;
hell = (void*)&val;
return val;
}
template<typename T>
T BLT_ATTRIB_NO_INLINE black_box_ret(T val){
volatile void* hell2;
hell2 = (void*)&val;
return val;
}
} }
// prints error with stack trace if assertion fails. Does not stop execution. // prints error with stack trace if assertion fails. Does not stop execution.

View File

@ -24,6 +24,42 @@ namespace blt::system {
return __rdtsc(); return __rdtsc();
} }
// TODO: system memory and current CPU usage. (Linux Only currently) // TODO: system memory and current CPU usage. (Linux Only currently)
#if defined(__GNUC__) || defined(__llvm__)
#define BLT_ATTRIB_NO_INLINE __attribute__ ((noinline))
#else
#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
#define BLT_ATTRIB_NO_INLINE __declspec(noinline)
#else
#define BLT_ATTRIB_NO_INLINE
#endif
#endif
template<typename T>
void BLT_ATTRIB_NO_INLINE black_box_ref(const T& val){
volatile void* hell;
hell = (void*)&val;
}
template<typename T>
void BLT_ATTRIB_NO_INLINE black_box(T val){
volatile void* hell2;
hell2 = (void*)&val;
}
template<typename T>
const T& BLT_ATTRIB_NO_INLINE black_box_ref_ret(const T& val){
volatile void* hell;
hell = (void*)&val;
return val;
}
template<typename T>
T BLT_ATTRIB_NO_INLINE black_box_ret(T val){
volatile void* hell2;
hell2 = (void*)&val;
return val;
}
} }
#endif //BLT_SYSTEM_H #endif //BLT_SYSTEM_H