Botan
3.6.1
Crypto and TLS for C&
src
lib
utils
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
13
namespace
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
*/
23
uint64_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
*/
33
template
<
typename
T
,
size_t
... Ns>
34
T
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
T
FE_25519 T
Definition
ge.cpp:34
Botan
Definition
alg_id.cpp:13
Botan::prefetch_array_raw
uint64_t prefetch_array_raw(size_t bytes, const void *arrayv) noexcept
Definition
prefetch.cpp:14
Botan::prefetch_arrays
T prefetch_arrays(T(&... arr)[Ns]) noexcept
Definition
prefetch.h:34
Generated by
1.12.0