Nix
2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Toggle main menu visibility
Loading...
Searching...
No Matches
eval-gc.hh
Go to the documentation of this file.
1
#pragma once
3
4
#include <cstddef>
5
#include <cstring>
6
7
// For `NIX_USE_BOEHMGC`
8
#include "nix/expr/config.hh"
9
10
#if NIX_USE_BOEHMGC
11
12
# define GC_INCLUDE_NEW
13
# define GC_THREADS 1
14
15
# include <gc/gc.h>
16
# include <gc/gc_cpp.h>
17
# include <gc/gc_allocator.h>
18
28
template
<
typename
T>
29
struct
gc_root_allocator : traceable_allocator<T>
30
{
31
using
traceable_allocator<T>::traceable_allocator;
32
33
template
<
typename
U>
34
struct
rebind
35
{
36
using
other = gc_root_allocator<U>;
37
};
38
39
template
<
typename
U>
40
void
destroy(U * p)
41
{
42
p->~U();
43
std::memset(
static_cast<
void
*
>
(p), 0,
sizeof
(U));
44
}
45
};
46
47
#else
48
49
# include <memory>
50
51
/* Some dummy aliases for Boehm GC definitions to reduce the number of
52
#ifdefs. */
53
54
template
<
typename
T>
55
using
traceable_allocator = std::allocator<T>;
56
57
template
<
typename
T>
58
using
gc_allocator = std::allocator<T>;
59
60
template
<
typename
T>
61
using
gc_root_allocator = std::allocator<T>;
62
63
# define GC_MALLOC_ATOMIC std::malloc
64
65
struct
gc
66
{};
67
68
struct
gc_cleanup
69
{};
70
71
#endif
72
73
namespace
nix {
74
78
void
initGC();
79
83
void
assertGCInitialized();
84
85
#if NIX_USE_BOEHMGC
89
size_t
getGCCycles();
90
#endif
91
92
}
// namespace nix
gc_cleanup
Definition
eval-gc.hh:69
gc
Definition
eval-gc.hh:66
libexpr
include
nix
expr
eval-gc.hh
Generated by
1.18.0