aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/big.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2016-02-23 21:05:03 +0100
committerSverker Eriksson <[email protected]>2016-02-24 17:04:01 +0100
commit1b094d72ffc56069c72f17c7edd673dbbfe47e39 (patch)
tree45675d9bc82b8496765bee32831de2501471ebae /erts/emulator/beam/big.c
parent56090db3ea417157a749bdd810fc61d117493f1f (diff)
downloadotp-1b094d72ffc56069c72f17c7edd673dbbfe47e39.tar.gz
otp-1b094d72ffc56069c72f17c7edd673dbbfe47e39.tar.bz2
otp-1b094d72ffc56069c72f17c7edd673dbbfe47e39.zip
erts: Make erlang:halt() accept bignums as Status
Just mask away the high bits to get a more tolerant erlang:halt that behaves the same on 32 and 64 bit architectures.
Diffstat (limited to 'erts/emulator/beam/big.c')
-rw-r--r--erts/emulator/beam/big.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/erts/emulator/beam/big.c b/erts/emulator/beam/big.c
index 15bcd44fb9..87d3be2b0f 100644
--- a/erts/emulator/beam/big.c
+++ b/erts/emulator/beam/big.c
@@ -2028,6 +2028,32 @@ term_to_Uint(Eterm term, Uint *up)
}
}
+/* same as term_to_Uint()
+ but also accept larger bignums by masking
+ */
+int
+term_to_Uint_mask(Eterm term, Uint *up)
+{
+ if (is_small(term)) {
+ Sint i = signed_val(term);
+ if (i < 0) {
+ *up = BADARG;
+ return 0;
+ }
+ *up = (Uint) i;
+ return 1;
+ } else if (is_big(term) && !big_sign(term)) {
+ ErtsDigit* xr = big_v(term);
+
+ ERTS_CT_ASSERT(sizeof(ErtsDigit) == sizeof(Uint));
+ *up = (Uint)*xr; /* just pick first word */
+ return 1;
+ } else {
+ *up = BADARG;
+ return 0;
+ }
+}
+
int
term_to_UWord(Eterm term, UWord *up)
{