Iros
Loading...
Searching...
No Matches
black_box.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
di/meta/operations.h
"
4
#include "
di/util/addressof.h
"
5
6
namespace
di::util
{
7
template
<concepts::CopyConstructible T>
8
[[gnu::noinline]]
auto
black_box
(T
const
& value) -> T {
9
// We want to produce an identical value from this function, without the compiler realizing it.
10
// This is done by passing a pointer through inline assembly, since the compiler won't realize
11
// the pointer points to the original object.
12
T
const
* result;
13
asm
volatile
(
"mov %1, %0\n"
:
"=r"
(result) :
"r"
(util::addressof(value)) :
"memory"
);
14
return
*result;
15
}
16
}
17
18
namespace
di
{
19
using
util::black_box
;
20
}
addressof.h
operations.h
di::util
Definition
vocab.h:96
di::util::black_box
auto black_box(T const &value) -> T
Definition
black_box.h:8
di
Definition
zstring_parser.h:9
libs
di
include
di
util
black_box.h
Generated by
1.13.0