diff --git a/include/blt/std/system.h b/include/blt/std/system.h index b1bd2bd..168b9eb 100755 --- a/include/blt/std/system.h +++ b/include/blt/std/system.h @@ -24,42 +24,7 @@ namespace blt::system { return __rdtsc(); } // 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 - void BLT_ATTRIB_NO_INLINE black_box_ref(const T& val){ - volatile void* hell; - hell = (void*)&val; - } - - template - void BLT_ATTRIB_NO_INLINE black_box(T val){ - volatile void* hell2; - hell2 = (void*)&val; - } - - template - const T& BLT_ATTRIB_NO_INLINE black_box_ref_ret(const T& val){ - volatile void* hell; - hell = (void*)&val; - return val; - } - - template - T BLT_ATTRIB_NO_INLINE black_box_ret(T val){ - volatile void* hell2; - hell2 = (void*)&val; - return val; - } } #endif //BLT_SYSTEM_H diff --git a/include/blt/std/utility.h b/include/blt/std/utility.h index cc994d6..bac114f 100644 --- a/include/blt/std/utility.h +++ b/include/blt/std/utility.h @@ -30,6 +30,46 @@ namespace blt private: }; + +#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 + void BLT_ATTRIB_NO_INLINE black_box_ref(const T& val) + { + volatile void* hell; + hell = (void*) &val; + } + + template + void BLT_ATTRIB_NO_INLINE black_box(T val) + { + volatile void* hell2; + hell2 = (void*) &val; + } + + template + const T& BLT_ATTRIB_NO_INLINE black_box_ref_ret(const T& val) + { + volatile void* hell; + hell = (void*) &val; + return val; + } + + template + T BLT_ATTRIB_NO_INLINE black_box_ret(T val) + { + volatile void* hell2; + hell2 = (void*) &val; + return val; + } } diff --git a/tests/src/main.cpp b/tests/src/main.cpp index 327b560..07929bd 100755 --- a/tests/src/main.cpp +++ b/tests/src/main.cpp @@ -14,6 +14,7 @@ #include #include #include +#include std::function test{ [](int i) -> int {