diff options
author | Sverker Eriksson <[email protected]> | 2016-03-01 14:30:34 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2016-03-01 14:30:34 +0100 |
commit | e1489c448b7486cdcfec6a89fea238d88e6ce2f3 (patch) | |
tree | e51068d8358245f5bc1726aec7130b9ff801b093 /erts/emulator/beam/big.c | |
parent | 75bc5bebc070a59535b8f6b7b9085c210b4723b5 (diff) | |
parent | 1b094d72ffc56069c72f17c7edd673dbbfe47e39 (diff) | |
download | otp-e1489c448b7486cdcfec6a89fea238d88e6ce2f3.tar.gz otp-e1489c448b7486cdcfec6a89fea238d88e6ce2f3.tar.bz2 otp-e1489c448b7486cdcfec6a89fea238d88e6ce2f3.zip |
Merge branch 'sverk/halt-INT_MIN' into maint
OTP-13251
* sverk/halt-INT_MIN:
erts: Make erlang:halt() accept bignums as Status
erts: Change erl_exit into erts_exit
kernel: Remove calls to erl_exit
Diffstat (limited to 'erts/emulator/beam/big.c')
-rw-r--r-- | erts/emulator/beam/big.c | 26 |
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) { |