From a2a86dadc648dda68b5221a7c1d83b9238be1e25 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Fri, 12 Feb 2016 18:52:20 +0100 Subject: 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 --- erts/emulator/test/nif_SUITE.erl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'erts/emulator/test/nif_SUITE.erl') 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 -- cgit v1.2.3