diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-10-22T13·39+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-10-22T13·39+0000 |
commit | 64c3325b0bef8c0234bf797033e129323b36ad1e (patch) | |
tree | 75e6e8d30b204101289a808d7132af9ccb848f82 /src | |
parent | 76feaf016a7e9a9b019148df5ff84a63e48dbda7 (diff) |
* Make building against the Boehm GC a configure option.
Diffstat (limited to 'src')
-rw-r--r-- | src/libexpr/Makefile.am | 3 | ||||
-rw-r--r-- | src/libexpr/eval.cc | 23 | ||||
-rw-r--r-- | src/libexpr/eval.hh | 6 | ||||
-rw-r--r-- | src/nix-env/Makefile.am | 5 | ||||
-rw-r--r-- | src/nix-instantiate/Makefile.am | 6 |
5 files changed, 29 insertions, 14 deletions
diff --git a/src/libexpr/Makefile.am b/src/libexpr/Makefile.am index 24aa2968b195..e7228e183581 100644 --- a/src/libexpr/Makefile.am +++ b/src/libexpr/Makefile.am @@ -20,8 +20,7 @@ EXTRA_DIST = lexer.l parser.y 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. diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 46978f6d0b81..c8a031ac6d0a 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -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 @@ void EvalState::addPrimOp(const string & name, 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 @@ LocalNoInline(void addErrorPrefix(Error & e, const char * s, const string & s2, 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 @@ void mkString(Value & v, const string & s, const PathSet & context) 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 mkString(Value & v, const string & s, const PathSet & context) 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::mkList(Value & v, unsigned int length) void EvalState::mkAttrs(Value & v) { v.type = tAttrs; +#if HAVE_BOEHMGC v.attrs = new (UseGC) Bindings; +#else + v.attrs = new Bindings; +#endif nrAttrsets++; } diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 9144d99a4b38..738ca9439f6d 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -7,7 +7,9 @@ #include <map> +#if HAVE_BOEHMGC #include <gc/gc_allocator.h> +#endif namespace nix { @@ -18,7 +20,11 @@ struct Env; 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 { diff --git a/src/nix-env/Makefile.am b/src/nix-env/Makefile.am index 169c85fcb679..a876b3eb386d 100644 --- a/src/nix-env/Makefile.am +++ b/src/nix-env/Makefile.am @@ -5,7 +5,7 @@ nix_env_SOURCES = nix-env.cc profiles.cc profiles.hh user-env.cc user-env.hh hel 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 @@ nix-env.o: help.txt.hh 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 diff --git a/src/nix-instantiate/Makefile.am b/src/nix-instantiate/Makefile.am index c6455b116d43..bc9792818c3c 100644 --- a/src/nix-instantiate/Makefile.am +++ b/src/nix-instantiate/Makefile.am @@ -4,7 +4,7 @@ nix_instantiate_SOURCES = nix-instantiate.cc help.txt 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 @@ nix-instantiate.o: help.txt.hh 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 |