aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/botan/src/lib/utils/prefetch.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/3rdparty/botan/src/lib/utils/prefetch.h')
-rw-r--r--src/libs/3rdparty/botan/src/lib/utils/prefetch.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/libs/3rdparty/botan/src/lib/utils/prefetch.h b/src/libs/3rdparty/botan/src/lib/utils/prefetch.h
new file mode 100644
index 0000000000..92c41e5738
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/utils/prefetch.h
@@ -0,0 +1,39 @@
+/*
+* Prefetching Operations
+* (C) 2009 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_PREFETCH_H_
+#define BOTAN_PREFETCH_H_
+
+#include <botan/cpuid.h>
+
+namespace Botan {
+
+template<typename T>
+inline void prefetch_readonly(const T* addr, size_t length)
+ {
+#if defined(__GNUG__)
+ const size_t Ts_per_cache_line = CPUID::cache_line_size() / sizeof(T);
+
+ for(size_t i = 0; i <= length; i += Ts_per_cache_line)
+ __builtin_prefetch(addr + i, 0);
+#endif
+ }
+
+template<typename T>
+inline void prefetch_readwrite(const T* addr, size_t length)
+ {
+#if defined(__GNUG__)
+ const size_t Ts_per_cache_line = CPUID::cache_line_size() / sizeof(T);
+
+ for(size_t i = 0; i <= length; i += Ts_per_cache_line)
+ __builtin_prefetch(addr + i, 1);
+#endif
+ }
+
+}
+
+#endif