Author: eelco
Date: Fri Oct 22 13:39:15 2010
New Revision: 24418
URL: https://svn.nixos.org/websvn/nix/?rev=24418&sc=1
Log:
* Make building against the Boehm GC a configure option.
Modified:
nix/branches/gc/configure.ac
nix/branches/gc/src/libexpr/Makefile.am
nix/branches/gc/src/libexpr/eval.cc
nix/branches/gc/src/libexpr/eval.hh
nix/branches/gc/src/nix-env/Makefile.am
nix/branches/gc/src/nix-instantiate/Makefile.am
Modified: nix/branches/gc/configure.ac
==============================================================================
--- nix/branches/gc/configure.ac Fri Oct 22 13:18:26 2010 (r24417)
+++ nix/branches/gc/configure.ac Fri Oct 22 13:39:15 2010 (r24418)
@@ -250,6 +250,19 @@
AC_SUBST(bzip2_bin_test)
+# Whether to use the Boehm garbage collector.
+AC_ARG_WITH(boehm-gc, AC_HELP_STRING([--with-boehm-gc=PATH],
+ [prefix of the Boehm GC package to enable garbage collection in the Nix
expression evaluator]),
+ boehmgc=$withval, boehmgc=)
+if test -n "$boehmgc"; then
+ boehmgc_lib="-L$boehmgc/lib -lgc"
+ CXXFLAGS="-I$boehmgc/include $CXXFLAGS"
+ AC_DEFINE(HAVE_BOEHMGC, 1, [Whether to use the Boehm garbage collector.])
+fi
+AC_SUBST(boehmgc_lib)
+AC_SUBST(boehmgc_include)
+
+
AC_ARG_ENABLE(init-state, AC_HELP_STRING([--disable-init-state],
[do not initialise DB etc. in `make install']),
init_state=$enableval, init_state=yes)
Modified: nix/branches/gc/src/libexpr/Makefile.am
==============================================================================
--- nix/branches/gc/src/libexpr/Makefile.am Fri Oct 22 13:18:26 2010
(r24417)
+++ nix/branches/gc/src/libexpr/Makefile.am Fri Oct 22 13:39:15 2010
(r24418)
@@ -20,8 +20,7 @@
AM_CXXFLAGS = \
-I$(srcdir)/.. \
- -I$(srcdir)/../libutil -I$(srcdir)/../libstore \
- -I/home/eelco/Dev/nix/boehmgc/include
+ -I$(srcdir)/../libutil -I$(srcdir)/../libstore
# Parser generation.
Modified: nix/branches/gc/src/libexpr/eval.cc
==============================================================================
--- nix/branches/gc/src/libexpr/eval.cc Fri Oct 22 13:18:26 2010 (r24417)
+++ nix/branches/gc/src/libexpr/eval.cc Fri Oct 22 13:39:15 2010 (r24418)
@@ -8,9 +8,18 @@
#include <cstring>
+#if HAVE_BOEHMGC
+
#include <gc/gc.h>
#include <gc/gc_cpp.h>
+#else
+
+#define GC_STRDUP strdup
+#define GC_MALLOC malloc
+
+#endif
+
#define LocalNoInline(f) static f __attribute__((noinline)); f
#define LocalNoInlineNoReturn(f) static f __attribute__((noinline, noreturn));
f
@@ -151,7 +160,7 @@
v.type = tPrimOp;
v.primOp.arity = arity;
v.primOp.fun = primOp;
- v.primOp.name = GC_strdup(name2.c_str());
+ v.primOp.name = GC_STRDUP(name2.c_str());
staticBaseEnv.vars[symbols.create(name)] = baseEnvDispl;
baseEnv.values[baseEnvDispl++] = v;
(*baseEnv.values[0].attrs)[symbols.create(name2)].value = v;
@@ -222,7 +231,7 @@
void mkString(Value & v, const char * s)
{
v.type = tString;
- v.string.s = GC_strdup(s);
+ v.string.s = GC_STRDUP(s);
v.string.context = 0;
}
@@ -233,9 +242,9 @@
if (!context.empty()) {
unsigned int n = 0;
v.string.context = (const char * *)
- GC_malloc((context.size() + 1) * sizeof(char *));
+ GC_MALLOC((context.size() + 1) * sizeof(char *));
foreach (PathSet::const_iterator, i, context)
- v.string.context[n++] = GC_strdup(i->c_str());
+ v.string.context[n++] = GC_STRDUP(i->c_str());
v.string.context[n] = 0;
}
}
@@ -244,7 +253,7 @@
void mkPath(Value & v, const char * s)
{
v.type = tPath;
- v.path = GC_strdup(s);
+ v.path = GC_STRDUP(s);
}
@@ -294,7 +303,11 @@
void EvalState::mkAttrs(Value & v)
{
v.type = tAttrs;
+#if HAVE_BOEHMGC
v.attrs = new (UseGC) Bindings;
+#else
+ v.attrs = new Bindings;
+#endif
nrAttrsets++;
}
Modified: nix/branches/gc/src/libexpr/eval.hh
==============================================================================
--- nix/branches/gc/src/libexpr/eval.hh Fri Oct 22 13:18:26 2010 (r24417)
+++ nix/branches/gc/src/libexpr/eval.hh Fri Oct 22 13:39:15 2010 (r24418)
@@ -7,7 +7,9 @@
#include <map>
+#if HAVE_BOEHMGC
#include <gc/gc_allocator.h>
+#endif
namespace nix {
@@ -18,7 +20,11 @@
struct Value;
struct Attr;
+#if HAVE_BOEHMGC
typedef std::map<Symbol, Attr, std::less<Symbol>, gc_allocator<std::pair<const
Symbol, Attr> > > Bindings;
+#else
+typedef std::map<Symbol, Attr> Bindings;
+#endif
typedef enum {
Modified: nix/branches/gc/src/nix-env/Makefile.am
==============================================================================
--- nix/branches/gc/src/nix-env/Makefile.am Fri Oct 22 13:18:26 2010
(r24417)
+++ nix/branches/gc/src/nix-env/Makefile.am Fri Oct 22 13:39:15 2010
(r24418)
@@ -5,7 +5,7 @@
nix_env_LDADD = ../libmain/libmain.la ../libexpr/libexpr.la \
../libstore/libstore.la ../libutil/libutil.la \
../boost/format/libformat.la @ADDITIONAL_NETWORK_LIBS@ \
- -L/home/eelco/Dev/nix/boehmgc/lib -lgc
+ @boehmgc_lib@
nix-env.o: help.txt.hh
@@ -15,5 +15,4 @@
AM_CXXFLAGS = \
-I$(srcdir)/.. \
-I$(srcdir)/../libutil -I$(srcdir)/../libstore \
- -I$(srcdir)/../libexpr -I$(srcdir)/../libmain -I../libexpr \
- -I/home/eelco/Dev/nix/boehmgc/include
+ -I$(srcdir)/../libexpr -I$(srcdir)/../libmain -I../libexpr
Modified: nix/branches/gc/src/nix-instantiate/Makefile.am
==============================================================================
--- nix/branches/gc/src/nix-instantiate/Makefile.am Fri Oct 22 13:18:26
2010 (r24417)
+++ nix/branches/gc/src/nix-instantiate/Makefile.am Fri Oct 22 13:39:15
2010 (r24418)
@@ -4,7 +4,7 @@
nix_instantiate_LDADD = ../libmain/libmain.la ../libexpr/libexpr.la \
../libstore/libstore.la ../libutil/libutil.la \
../boost/format/libformat.la @ADDITIONAL_NETWORK_LIBS@ \
- -L/home/eelco/Dev/nix/boehmgc/lib -lgc
+ @boehmgc_lib@
nix-instantiate.o: help.txt.hh
@@ -13,6 +13,4 @@
AM_CXXFLAGS = \
-I$(srcdir)/.. -I$(srcdir)/../libutil -I$(srcdir)/../libstore \
- -I$(srcdir)/../libexpr -I$(srcdir)/../libmain -I../libexpr \
- -I/home/eelco/Dev/nix/boehmgc/include
-
+ -I$(srcdir)/../libexpr -I$(srcdir)/../libmain -I../libexpr
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits