1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 21:41:48 +02:00
nix/src/libexpr/eval-gc.hh
2024-09-30 22:15:04 +02:00

51 lines
741 B
C++

#pragma once
///@file
#include <cstddef>
#if HAVE_BOEHMGC
# define GC_INCLUDE_NEW
# include <gc/gc.h>
# include <gc/gc_cpp.h>
# include <gc/gc_allocator.h>
#else
/* Some dummy aliases for Boehm GC definitions to reduce the number of
#ifdefs. */
template<typename T>
using traceable_allocator = std::allocator<T>;
template<typename T>
using gc_allocator = std::allocator<T>;
# define GC_MALLOC_ATOMIC std::malloc
struct gc
{};
#endif
namespace nix {
/**
* Initialise the Boehm GC, if applicable.
*/
void initGC();
/**
* Make sure `initGC` has already been called.
*/
void assertGCInitialized();
#ifdef HAVE_BOEHMGC
/**
* The number of GC cycles since initGC().
*/
size_t getGCCycles();
#endif
} // namespace nix