move blackbox to utility

v1
Brett 2023-11-26 17:35:06 -05:00
parent 82d960f833
commit f5886416bf
3 changed files with 41 additions and 35 deletions

View File

@ -25,41 +25,6 @@ namespace blt::system {
} }
// 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

View File

@ -31,6 +31,46 @@ namespace blt
}; };
#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_UTILITY_H #endif //BLT_UTILITY_H

View File

@ -14,6 +14,7 @@
#include <memory_test.h> #include <memory_test.h>
#include <blt/parse/argparse.h> #include <blt/parse/argparse.h>
#include <utility_test.h> #include <utility_test.h>
#include <blt/std/system.h>
std::function<int(int i)> test{ std::function<int(int i)> test{
[](int i) -> int { [](int i) -> int {