aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/nif_SUITE.erl
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2016-02-12 18:52:20 +0100
committerLukas Larsson <[email protected]>2016-03-29 14:57:11 +0200
commita2a86dadc648dda68b5221a7c1d83b9238be1e25 (patch)
tree6229f416cc8a8e8a4b413a3a91246e37a693ff3a /erts/emulator/test/nif_SUITE.erl
parent209c5cf22b5cdc70eb48e6afdcddfa7132471aab (diff)
downloadotp-a2a86dadc648dda68b5221a7c1d83b9238be1e25.tar.gz
otp-a2a86dadc648dda68b5221a7c1d83b9238be1e25.tar.bz2
otp-a2a86dadc648dda68b5221a7c1d83b9238be1e25.zip
erts: Improve enif_binary_to_term
* Accept a raw data buffer instead of ErlNifBinary * Accept option ERL_NIF_BIN2TERM_SAFE * Return number of read bytes
Diffstat (limited to 'erts/emulator/test/nif_SUITE.erl')
-rw-r--r--erts/emulator/test/nif_SUITE.erl17
1 files changed, 13 insertions, 4 deletions
diff --git a/erts/emulator/test/nif_SUITE.erl b/erts/emulator/test/nif_SUITE.erl
index bbd523b4ef..4dcfbf35ca 100644
--- a/erts/emulator/test/nif_SUITE.erl
+++ b/erts/emulator/test/nif_SUITE.erl
@@ -1971,13 +1971,22 @@ nif_term_to_binary(Config) ->
true = term_to_binary_nif(T, self()),
receive Bin -> ok end.
+-define(ERL_NIF_BIN2TERM_SAFE, 16#20000000).
+
nif_binary_to_term(Config) ->
ensure_lib_loaded(Config),
T = {#{ok => nok}, <<0:8096>>, lists:seq(1,100)},
Bin = term_to_binary(T),
- T = binary_to_term_nif(Bin, undefined),
- true = binary_to_term_nif(Bin, self()),
- receive T -> ok end.
+ Len = byte_size(Bin),
+ {Len,T} = binary_to_term_nif(Bin, undefined, 0),
+ Len = binary_to_term_nif(Bin, self(), 0),
+ T = receive M -> M after 1000 -> timeout end,
+
+ {Len, T} = binary_to_term_nif(Bin, undefined, ?ERL_NIF_BIN2TERM_SAFE),
+ false = binary_to_term_nif(<<131,100,0,14,"undefined_atom">>,
+ undefined, ?ERL_NIF_BIN2TERM_SAFE),
+ false = binary_to_term_nif(Bin, undefined, 1),
+ ok.
nif_port_command(Config) ->
ensure_lib_loaded(Config),
@@ -2069,7 +2078,7 @@ unique_integer_nif(_) -> ?nif_stub.
is_process_alive_nif(_) -> ?nif_stub.
is_port_alive_nif(_) -> ?nif_stub.
term_to_binary_nif(_, _) -> ?nif_stub.
-binary_to_term_nif(_, _) -> ?nif_stub.
+binary_to_term_nif(_, _, _) -> ?nif_stub.
port_command_nif(_, _) -> ?nif_stub.
%% maps