Botan 3.5.0
Crypto and TLS for C&
prefetch.h
Go to the documentation of this file.
1/*
2* (C) 2023 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_PREFETCH_UTILS_H_
8#define BOTAN_PREFETCH_UTILS_H_
9
10#include <botan/types.h>
11#include <type_traits>
12
13namespace Botan {
14
15/**
16* Prefetch an array
17*
18* This function returns a uint64_t which is accumulated from values
19* read from the array. This may help confuse the compiler sufficiently
20* to not elide otherwise "useless" reads. The return value will always
21* be zero.
22*/
23uint64_t prefetch_array_raw(size_t bytes, const void* array) noexcept;
24
25/**
26* Prefetch several arrays
27*
28* This function returns a uint64_t which is accumulated from values
29* read from the array. This may help confuse the compiler sufficiently
30* to not elide otherwise "useless" reads. The return value will always
31* be zero.
32*/
33template <typename T, size_t... Ns>
34T prefetch_arrays(T (&... arr)[Ns]) noexcept
35 requires std::is_integral<T>::value
36{
37 return (static_cast<T>(prefetch_array_raw(sizeof(T) * Ns, arr)) & ...);
38}
39
40} // namespace Botan
41
42#endif
FE_25519 T
Definition ge.cpp:34
uint64_t prefetch_array_raw(size_t bytes, const void *arrayv) noexcept
Definition prefetch.cpp:14
T prefetch_arrays(T(&... arr)[Ns]) noexcept
Definition prefetch.h:34