Skip to content

Commit

Permalink
Move GC-related definitions to eval-gc.hh
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Sep 19, 2024
1 parent 5ad52a7 commit 6716b1d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 39 deletions.
5 changes: 0 additions & 5 deletions src/libcmd/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
#include "ref.hh"
#include "value.hh"

#if HAVE_BOEHMGC
#define GC_INCLUDE_NEW
#include <gc/gc_cpp.h>
#endif

#include "strings.hh"

namespace nix {
Expand Down
6 changes: 0 additions & 6 deletions src/libexpr-c/nix_api_external.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@

#include <nlohmann/json.hpp>

#if HAVE_BOEHMGC
# include "gc/gc.h"
# define GC_INCLUDE_NEW 1
# include "gc_cpp.h"
#endif

void nix_set_string_return(nix_string_return * str, const char * c)
{
str->str = c;
Expand Down
6 changes: 0 additions & 6 deletions src/libexpr-c/nix_api_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@
#include "nix_api_value.h"
#include "value/context.hh"

#if HAVE_BOEHMGC
# include "gc/gc.h"
# define GC_INCLUDE_NEW 1
# include "gc_cpp.h"
#endif

// Internal helper functions to check [in] and [out] `Value *` parameters
static const nix::Value & check_value_not_null(const nix_value * value)
{
Expand Down
18 changes: 18 additions & 0 deletions src/libexpr/eval-gc.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@

#include <cstddef>

#if HAVE_BOEHMGC

# define GC_INCLUDE_NEW

# include <gc/gc.h>
# include <gc/gc_cpp.h>
# include <gc/gc_allocator.h>

#else

template<typename T>
using traceable_allocator = std::allocator<T>;

template<typename T>
using gc_allocator = std::allocator<T>;

#endif

namespace nix {

/**
Expand Down
11 changes: 0 additions & 11 deletions src/libexpr/eval.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "eval.hh"
#include "eval-gc.hh"
#include "eval-settings.hh"
#include "primops.hh"
#include "print-options.hh"
Expand Down Expand Up @@ -39,16 +38,6 @@
# include <sys/resource.h>
#endif

#if HAVE_BOEHMGC

# define GC_INCLUDE_NEW

# include <gc/gc.h>
# include <gc/gc_cpp.h>
# include <gc/gc_allocator.h>

#endif

#include "strings-inline.hh"

using json = nlohmann::json;
Expand Down
11 changes: 1 addition & 10 deletions src/libexpr/value.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,13 @@
#include <cassert>
#include <span>

#include "eval-gc.hh"
#include "symbol-table.hh"
#include "value/context.hh"
#include "source-path.hh"
#include "print-options.hh"
#include "checked-arithmetic.hh"

#if HAVE_BOEHMGC
#include <gc/gc_allocator.h>
#else
template<typename T>
using traceable_allocator = std::allocator<T>;

template<typename T>
using gc_allocator = std::allocator<T>;
#endif

#include <nlohmann/json_fwd.hpp>

namespace nix {
Expand Down
1 change: 0 additions & 1 deletion src/nix/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "current-process.hh"
#include "command.hh"
#include "common-args.hh"
#include "eval-gc.hh"
#include "eval.hh"
#include "eval-settings.hh"
#include "globals.hh"
Expand Down

0 comments on commit 6716b1d

Please sign in to comment.