about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-04-16T14·28+0200
committertazjin <mail@tazj.in>2020-07-17T20·04+0000
commit80eaa1eaf9dde0caa4e983374fb1356aed67c8e1 (patch)
treeca4a33da8de115e888234252ecdd6629b3e8b9d3 /third_party/nix/src/libexpr/eval.cc
parent014436eb4ad0c403647939a2461e1fe4a7967c89 (diff)
feat(3p/nix): Add function to allocate a Value in traceable memory r/1354
Backported from:
https://github.com/NixOS/nix/commit/b3e5eea4a91400fb2a12aba4b07a94d03ba54605
https://github.com/NixOS/nix/commit/fcd048a526bd239fa615457e77d61d69d679bf03

Intentionally skipped because we have not backported the JSON changes:
https://github.com/NixOS/nix/commit/9f46f54de4e55267df492456fc0393f74616366b

Did not apply changes ni primops.cc, because those look suspect and
are also based on something that we don't have in our tree.

Change-Id: I837787ce9f2c90267bc39fce15177980d209d4e9
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1253
Tested-by: BuildkiteCI
Reviewed-by: isomer <isomer@tvl.fyi>
Diffstat (limited to 'third_party/nix/src/libexpr/eval.cc')
-rw-r--r--third_party/nix/src/libexpr/eval.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc
index 2b825bfd27..0f3b7fabe0 100644
--- a/third_party/nix/src/libexpr/eval.cc
+++ b/third_party/nix/src/libexpr/eval.cc
@@ -5,10 +5,13 @@
 #include <cstring>
 #include <fstream>
 #include <iostream>
+#include <memory>
 #include <new>
 #include <optional>
 #include <variant>
 
+#define GC_INCLUDE_NEW
+
 #include <absl/strings/match.h>
 #include <gc/gc.h>
 #include <gc/gc_cpp.h>
@@ -40,6 +43,10 @@ static char* dupString(const char* s) {
   return t;
 }
 
+std::shared_ptr<Value*> allocRootValue(Value* v) {
+  return std::allocate_shared<Value*>(traceable_allocator<Value*>(), v);
+}
+
 static void printValue(std::ostream& str, std::set<const Value*>& active,
                        const Value& v) {
   checkInterrupt();