diff options
author | Patrik Nyblom <[email protected]> | 2010-04-30 11:52:38 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2010-05-17 15:51:50 +0200 |
commit | 8f21d4026e8f338245812d6edfd113c05282e321 (patch) | |
tree | 90c8151cdcba7ad8b9fda5a1d63ac64cd958aa2c /erts/emulator/beam | |
parent | 1dad48ee9f2e1aba6a0ec69d9cf688705d6f187c (diff) | |
download | otp-8f21d4026e8f338245812d6edfd113c05282e321.tar.gz otp-8f21d4026e8f338245812d6edfd113c05282e321.tar.bz2 otp-8f21d4026e8f338245812d6edfd113c05282e321.zip |
Add referenced_byte_size/1
Add testcases for referenced_byte_size/1.
Add failure tests for referenced_byte_size.
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r-- | erts/emulator/beam/bif.tab | 2 | ||||
-rw-r--r-- | erts/emulator/beam/erl_bif_binary.c | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/erts/emulator/beam/bif.tab b/erts/emulator/beam/bif.tab index bd908566ee..7978044fe5 100644 --- a/erts/emulator/beam/bif.tab +++ b/erts/emulator/beam/bif.tab @@ -778,7 +778,7 @@ bif binary:bin_to_list/3 bif binary:list_to_bin/1 bif binary:copy/1 bif binary:copy/2 -# bif binary:referenced_byte_size/1 +bif binary:referenced_byte_size/1 # bif binary:decode_unsigned/1 # bif binary:decode_unsigned/2 diff --git a/erts/emulator/beam/erl_bif_binary.c b/erts/emulator/beam/erl_bif_binary.c index e2d3d00db2..b3ebc95cea 100644 --- a/erts/emulator/beam/erl_bif_binary.c +++ b/erts/emulator/beam/erl_bif_binary.c @@ -2418,6 +2418,29 @@ BIF_RETTYPE binary_copy_2(BIF_ALIST_2) return do_binary_copy(BIF_P,BIF_ARG_1,BIF_ARG_2); } +BIF_RETTYPE binary_referenced_byte_size_1(BIF_ALIST_1) +{ + ErlSubBin *sb; + ProcBin *pb; + Eterm res; + Eterm bin = BIF_ARG_1; + + if (is_not_binary(BIF_ARG_1)) { + BIF_ERROR(BIF_P,BADARG); + } + sb = (ErlSubBin *) binary_val(bin); + if (sb->thing_word == HEADER_SUB_BIN) { + bin = sb->orig; + } + pb = (ProcBin *) binary_val(bin); + if (pb->thing_word == HEADER_PROC_BIN) { + res = erts_make_integer((Uint) pb->val->orig_size, BIF_P); /* XXX:PaN Halfword? orig_size is a long */ + } else { /* heap binary */ + res = erts_make_integer((Uint) ((ErlHeapBin *) pb)->size, BIF_P); + } + BIF_RET(res); +} + /* * Hard debug functions (dump) for the search structures */ |