lix/src/libexpr
aszlig 0ad643ed5c
libexpr: Use int64_t for NixInt
Using a 64bit integer on 32bit systems will come with a bit of a
performance overhead, but given that Nix doesn't use a lot of integers
compared to other types, I think the overhead is negligible also
considering that 32bit systems are in decline.

The biggest advantage however is that when we use a consistent integer
size across all platforms it's less likely that we miss things that we
break due to that. One example would be:

https://github.com/NixOS/nixpkgs/pull/44233

On Hydra it will evaluate, because the evaluator runs on a 64bit
machine, but when evaluating the same on a 32bit machine it will fail,
so using 64bit integers should make that consistent.

While the change of the type in value.hh is rather easy to do, we have a
few more options available for doing the conversion in the lexer:

  * Via an #ifdef on the architecture and using strtol() or strtoll()
    accordingly depending on which architecture we are. For the #ifdef
    we would need another AX_COMPILE_CHECK_SIZEOF in configure.ac.
  * Using istringstream, which would involve copying the value.
  * As we're already using boost, lexical_cast might be a good idea.

Spoiler: I went for the latter, first of all because lexical_cast does
have an overload for const char* and second of all, because it doesn't
involve copying around the input string. Also, because istringstream
seems to come with a bigger overhead than boost::lexical_cast:

https://www.boost.org/doc/libs/release/doc/html/boost_lexical_cast/performance.html

The first method (still using strtol/strtoll) also wasn't something I
pursued further, because it is also locale-aware which I doubt is what
we want, given that the regex for int is [0-9]+.

Signed-off-by: aszlig <aszlig@nix.build>
Fixes: #2339
2018-08-29 01:05:52 +02:00
..
primops Fix build on 32-bit systems and macOS 2018-07-11 21:12:18 +02:00
attr-path.cc Replace Unicode quotes in user-facing strings by ASCII 2017-07-30 12:32:45 +01:00
attr-path.hh Work on Values instead of Exprs 2013-09-03 13:17:51 +00:00
attr-set.cc Remove duplicate definition of allocBytes() 2018-06-12 17:49:51 +02:00
attr-set.hh libexpr: Don't create lots of temporary strings in Bindings::lexicographicOrder 2018-02-19 22:47:25 +02:00
common-eval-args.cc nix: Respect -I, --arg, --argstr 2017-10-24 12:58:34 +02:00
common-eval-args.hh Fix build 2017-11-01 21:32:30 +01:00
eval-inline.hh GC_malloc -> GC_MALLOC 2018-06-12 17:49:55 +02:00
eval.cc Merge pull request #2326 from aszlig/fix-symlink-leak 2018-08-03 17:01:34 +02:00
eval.hh Remove unused function printStats2() 2018-07-11 20:29:18 +02:00
get-drvs.cc nix-shell/nix-build: Support .drv files again 2017-11-24 18:08:35 +01:00
get-drvs.hh nix-shell/nix-build: Support .drv files again 2017-11-24 18:08:35 +01:00
json-to-value.cc json-to-value: Use strtol instead of strtoi 2018-05-26 18:43:46 -04:00
json-to-value.hh Add builtin function ‘fromJSON’ 2014-07-04 13:34:15 +02:00
lexer.l libexpr: Use int64_t for NixInt 2018-08-29 01:05:52 +02:00
local.mk Revert "Fix parser/lexer generation with parallel make" 2018-08-23 00:23:35 +02:00
names.cc Add splitVersion primop. 2018-02-14 09:55:43 -05:00
names.hh Add splitVersion primop. 2018-02-14 09:55:43 -05:00
nix-expr.pc.in Export required C++ version in pkgconfig. 2018-04-09 11:32:43 -04:00
nixexpr.cc Fix compatibility with latest boost::format 2018-03-14 19:25:09 +01:00
nixexpr.hh Revert "Throw a specific error for incomplete parse errors." 2018-05-11 11:40:50 +02:00
parser.y parser.y: right-associativity of -> 2018-07-23 07:28:48 +00:00
primops.cc FIx floating point evaluation 2018-08-19 11:59:49 +02:00
primops.hh Make prim_exec and prim_importNative available to plugins 2018-04-09 10:26:50 -04:00
symbol-table.hh Fix some random -Wconversion warnings 2018-05-02 13:56:34 +02:00
value-to-json.cc nix path-info: Add --json flag 2016-08-29 17:29:24 +02:00
value-to-json.hh nix path-info: Add --json flag 2016-08-29 17:29:24 +02:00
value-to-xml.cc First hit at providing support for floats in the language. 2016-01-05 00:40:40 +01:00
value-to-xml.hh Use "#pragma once" to prevent repeated header file inclusion 2012-07-18 14:59:03 -04:00
value.hh libexpr: Use int64_t for NixInt 2018-08-29 01:05:52 +02:00