aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/big.c
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2010-02-04 12:15:29 +0100
committerBjörn Gustavsson <[email protected]>2010-03-10 14:25:00 +0100
commit0cbb78132f50be8ba38051963314b9722c1aba05 (patch)
tree31d9eab7b879280e87ad800f3303092f80bea5a0 /erts/emulator/beam/big.c
parentfb94cd974dc03baf149264ca4f4d50c6d1f80f21 (diff)
downloadotp-0cbb78132f50be8ba38051963314b9722c1aba05.tar.gz
otp-0cbb78132f50be8ba38051963314b9722c1aba05.tar.bz2
otp-0cbb78132f50be8ba38051963314b9722c1aba05.zip
Fix the BEAM dissambler for the half-word emulator
Diffstat (limited to 'erts/emulator/beam/big.c')
-rw-r--r--erts/emulator/beam/big.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/erts/emulator/beam/big.c b/erts/emulator/beam/big.c
index b8464ded28..c70044ed43 100644
--- a/erts/emulator/beam/big.c
+++ b/erts/emulator/beam/big.c
@@ -1878,6 +1878,42 @@ term_to_Uint(Eterm term, Uint *up)
}
}
+int
+term_to_UWord(Eterm term, UWord *up)
+{
+ if (is_small(term)) {
+ Sint i = signed_val(term);
+ if (i < 0) {
+ *up = BADARG;
+ return 0;
+ }
+ *up = (UWord) i;
+ return 1;
+ } else if (is_big(term)) {
+ ErtsDigit* xr = big_v(term);
+ dsize_t xl = big_size(term);
+ UWord uval = 0;
+ int n = 0;
+
+ if (big_sign(term)) {
+ *up = BADARG;
+ return 0;
+ } else if (xl*D_EXP > sizeof(UWord)*8) {
+ *up = SYSTEM_LIMIT;
+ return 0;
+ }
+ while (xl-- > 0) {
+ uval |= ((Uint)(*xr++)) << n;
+ n += D_EXP;
+ }
+ *up = uval;
+ return 1;
+ } else {
+ *up = BADARG;
+ return 0;
+ }
+}
+
int term_to_Sint(Eterm term, Sint *sp)
{
if (is_small(term)) {