diff options
Diffstat (limited to 'libartbase/base/utils.h')
| -rw-r--r-- | libartbase/base/utils.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libartbase/base/utils.h b/libartbase/base/utils.h index 0e8231a92c..f311f09975 100644 --- a/libartbase/base/utils.h +++ b/libartbase/base/utils.h @@ -31,6 +31,10 @@ #include "globals.h" #include "macros.h" +#if defined(__linux__) +#include <sys/utsname.h> +#endif + namespace art { static inline uint32_t PointerToLowMemUInt32(const void* p) { @@ -125,6 +129,10 @@ NO_RETURN void SleepForever(); // Flush CPU caches. Returns true on success, false if flush failed. WARN_UNUSED bool FlushCpuCaches(void* begin, void* end); +#if defined(__linux__) +bool IsKernelVersionAtLeast(int reqd_major, int reqd_minor); +#endif + // On some old kernels, a cache operation may segfault. WARN_UNUSED bool CacheOperationsMaySegFault(); @@ -158,6 +166,13 @@ static inline void CheckedCall(const Func& function, const char* what, Args... a } } +// Forces the compiler to emit a load instruction, but discards the value. +// Useful when dealing with memory paging. +template <typename T> +inline void ForceRead(const T* pointer) { + static_cast<void>(*const_cast<volatile T*>(pointer)); +} + // Lookup value for a given key in /proc/self/status. Keys and values are separated by a ':' in // the status file. Returns value found on success and "<unknown>" if the key is not found or // there is an I/O error. |