diff options
Diffstat (limited to 'erts/preloaded')
-rw-r--r-- | erts/preloaded/ebin/erl_prim_loader.beam | bin | 50392 -> 50528 bytes | |||
-rw-r--r-- | erts/preloaded/ebin/erlang.beam | bin | 24148 -> 27148 bytes | |||
-rw-r--r-- | erts/preloaded/ebin/init.beam | bin | 44880 -> 45296 bytes | |||
-rw-r--r-- | erts/preloaded/ebin/zlib.beam | bin | 10620 -> 12148 bytes | |||
-rw-r--r-- | erts/preloaded/src/erl_prim_loader.erl | 49 | ||||
-rw-r--r-- | erts/preloaded/src/erlang.erl | 142 | ||||
-rw-r--r-- | erts/preloaded/src/init.erl | 31 | ||||
-rw-r--r-- | erts/preloaded/src/zlib.erl | 144 |
8 files changed, 280 insertions, 86 deletions
diff --git a/erts/preloaded/ebin/erl_prim_loader.beam b/erts/preloaded/ebin/erl_prim_loader.beam Binary files differindex dccb92a5af..20c82c52bb 100644 --- a/erts/preloaded/ebin/erl_prim_loader.beam +++ b/erts/preloaded/ebin/erl_prim_loader.beam diff --git a/erts/preloaded/ebin/erlang.beam b/erts/preloaded/ebin/erlang.beam Binary files differindex b537546071..9202b5be4f 100644 --- a/erts/preloaded/ebin/erlang.beam +++ b/erts/preloaded/ebin/erlang.beam diff --git a/erts/preloaded/ebin/init.beam b/erts/preloaded/ebin/init.beam Binary files differindex 901def5eba..faa2cf573c 100644 --- a/erts/preloaded/ebin/init.beam +++ b/erts/preloaded/ebin/init.beam diff --git a/erts/preloaded/ebin/zlib.beam b/erts/preloaded/ebin/zlib.beam Binary files differindex 542e266f88..d400269ed0 100644 --- a/erts/preloaded/ebin/zlib.beam +++ b/erts/preloaded/ebin/zlib.beam diff --git a/erts/preloaded/src/erl_prim_loader.erl b/erts/preloaded/src/erl_prim_loader.erl index 024b20eadb..ccfa7978c8 100644 --- a/erts/preloaded/src/erl_prim_loader.erl +++ b/erts/preloaded/src/erl_prim_loader.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% Copyright Ericsson AB 1996-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -102,8 +102,14 @@ debug(#prim_state{debug = Deb}, Term) -> %%% Interface Functions. %%% -------------------------------------------------------- --spec start(term(), atom() | string(), host() | [host()]) -> - {'ok', pid()} | {'error', term()}. +-spec start(Id, Loader, Hosts) -> + {'ok', Pid} | {'error', What} when + Id :: term(), + Loader :: atom() | string(), + Hosts :: Host | [Host], + Host :: host(), + Pid :: pid(), + What :: term(). start(Id, Pgm, Hosts) when is_atom(Hosts) -> start(Id, Pgm, [Hosts]); start(Id, Pgm0, Hosts) -> @@ -123,18 +129,6 @@ start(Id, Pgm0, Hosts) -> {error,Reason} end. -start_it("ose_inet"=Cmd, Id, Pid, Hosts) -> - %% Setup reserved port for ose_inet driver (only OSE) - case catch erlang:open_port({spawn,Cmd}, [binary]) of - {'EXIT',Why} -> - ?dbg(ose_inet_port_open_fail, Why), - Why; - OseInetPort -> - ?dbg(ose_inet_port, OseInetPort), - OseInetPort - end, - start_it("inet", Id, Pid, Hosts); - %% Hosts must be a list on form ['1.2.3.4' ...] start_it("inet", Id, Pid, Hosts) -> process_flag(trap_exit, true), @@ -174,15 +168,20 @@ init_ack(Pid) -> Pid ! {self(),ok}, ok. --spec set_path([string()]) -> 'ok'. +-spec set_path(Path) -> 'ok' when + Path :: [Dir :: string()]. set_path(Paths) when is_list(Paths) -> request({set_path,Paths}). --spec get_path() -> {'ok', [string()]}. +-spec get_path() -> {'ok', Path} when + Path :: [Dir :: string()]. get_path() -> request({get_path,[]}). --spec get_file(atom() | string()) -> {'ok', binary(), string()} | 'error'. +-spec get_file(Filename) -> {'ok', Bin, FullName} | 'error' when + Filename :: atom() | string(), + Bin :: binary(), + FullName :: string(). get_file(File) when is_atom(File) -> get_file(atom_to_list(File)); get_file(File) -> @@ -202,13 +201,15 @@ get_files(ModFiles, Fun) -> ok end. --spec list_dir(string()) -> {'ok', [string()]} | 'error'. +-spec list_dir(Dir) -> {'ok', Filenames} | 'error' when + Dir :: string(), + Filenames :: [Filename :: string()]. list_dir(Dir) -> check_file_result(list_dir, Dir, request({list_dir,Dir})). -%% -> {ok,Info} | error --spec read_file_info(string()) -> {'ok', tuple()} | 'error'. - +-spec read_file_info(Filename) -> {'ok', FileInfo} | 'error' when + Filename :: string(), + FileInfo :: file:file_info(). read_file_info(File) -> check_file_result(read_file_info, File, request({read_file_info,File})). @@ -1360,9 +1361,7 @@ pathtype(Name) when is_list(Name) -> absolute; _ -> relative - end; - {ose,_} -> - unix_pathtype(Name) + end end. unix_pathtype(Name) -> diff --git a/erts/preloaded/src/erlang.erl b/erts/preloaded/src/erlang.erl index 4679a916c7..5deb69edab 100644 --- a/erts/preloaded/src/erlang.erl +++ b/erts/preloaded/src/erlang.erl @@ -53,22 +53,31 @@ -compile({no_auto_import,[spawn_opt/4]}). -compile({no_auto_import,[spawn_opt/5]}). -%%-------------------------------------------------------------------------- +-export_type([timestamp/0]). --type date() :: {pos_integer(), pos_integer(), pos_integer()}. --type time() :: {non_neg_integer(), non_neg_integer(), non_neg_integer()}. --type date_time() :: {date(), time()}. +-type timestamp() :: {MegaSecs :: non_neg_integer(), + Secs :: non_neg_integer(), + MicroSecs :: non_neg_integer()}. %%-------------------------------------------------------------------------- +-spec apply(Fun, Args) -> term() when + Fun :: function(), + Args :: [term()]. apply(Fun, Args) -> erlang:apply(Fun, Args). +-spec apply(Module, Function, Args) -> term() when + Module :: module(), + Function :: atom(), + Args :: [term()]. apply(Mod, Name, Args) -> erlang:apply(Mod, Name, Args). %% Spawns with a fun +-spec spawn(Fun) -> pid() when + Fun :: function(). spawn(F) when is_function(F) -> spawn(erlang, apply, [F, []]); spawn({M,F}=MF) when is_atom(M), is_atom(F) -> @@ -76,6 +85,9 @@ spawn({M,F}=MF) when is_atom(M), is_atom(F) -> spawn(F) -> erlang:error(badarg, [F]). +-spec spawn(Node, Fun) -> pid() when + Node :: node(), + Fun :: function(). spawn(N, F) when N =:= node() -> spawn(F); spawn(N, F) when is_function(F) -> @@ -85,6 +97,8 @@ spawn(N, {M,F}=MF) when is_atom(M), is_atom(F) -> spawn(N, F) -> erlang:error(badarg, [N, F]). +-spec spawn_link(Fun) -> pid() when + Fun :: function(). spawn_link(F) when is_function(F) -> spawn_link(erlang, apply, [F, []]); spawn_link({M,F}=MF) when is_atom(M), is_atom(F) -> @@ -92,6 +106,9 @@ spawn_link({M,F}=MF) when is_atom(M), is_atom(F) -> spawn_link(F) -> erlang:error(badarg, [F]). +-spec spawn_link(Node, Fun) -> pid() when + Node :: node(), + Fun :: function(). spawn_link(N, F) when N =:= node() -> spawn_link(F); spawn_link(N, F) when is_function(F) -> @@ -103,16 +120,30 @@ spawn_link(N, F) -> %% Spawn and atomically set up a monitor. +-spec spawn_monitor(Fun) -> {pid(), reference()} when + Fun :: function(). spawn_monitor(F) when is_function(F, 0) -> erlang:spawn_opt({erlang,apply,[F,[]],[monitor]}); spawn_monitor(F) -> erlang:error(badarg, [F]). +-spec spawn_monitor(Module, Function, Args) -> {pid(), reference()} when + Module :: module(), + Function :: atom(), + Args :: [term()]. spawn_monitor(M, F, A) when is_atom(M), is_atom(F), is_list(A) -> erlang:spawn_opt({M,F,A,[monitor]}); spawn_monitor(M, F, A) -> erlang:error(badarg, [M,F,A]). +-spec spawn_opt(Fun, Options) -> pid() | {pid(), reference()} when + Fun :: function(), + Options :: [Option], + Option :: link | monitor | {priority, Level} + | {fullsweep_after, Number :: non_neg_integer()} + | {min_heap_size, Size :: non_neg_integer()} + | {min_bin_vheap_size, VSize :: non_neg_integer()}, + Level :: low | normal | high. spawn_opt(F, O) when is_function(F) -> spawn_opt(erlang, apply, [F, []], O); spawn_opt({M,F}=MF, O) when is_atom(M), is_atom(F) -> @@ -122,6 +153,15 @@ spawn_opt({M,F,A}, O) -> % For (undocumented) backward compatibility spawn_opt(F, O) -> erlang:error(badarg, [F, O]). +-spec spawn_opt(Node, Fun, Options) -> pid() | {pid(), reference()} when + Node :: node(), + Fun :: function(), + Options :: [Option], + Option :: link | monitor | {priority, Level} + | {fullsweep_after, Number :: non_neg_integer()} + | {min_heap_size, Size :: non_neg_integer()} + | {min_bin_vheap_size, VSize :: non_neg_integer()}, + Level :: low | normal | high. spawn_opt(N, F, O) when N =:= node() -> spawn_opt(F, O); spawn_opt(N, F, O) when is_function(F) -> @@ -133,6 +173,11 @@ spawn_opt(N, F, O) -> %% Spawns with MFA +-spec spawn(Node, Module, Function, Args) -> pid() when + Node :: node(), + Module :: module(), + Function :: atom(), + Args :: [term()]. spawn(N,M,F,A) when N =:= node(), is_atom(M), is_atom(F), is_list(A) -> spawn(M,F,A); spawn(N,M,F,A) when is_atom(N), is_atom(M), is_atom(F) -> @@ -158,6 +203,11 @@ spawn(N,M,F,A) when is_atom(N), is_atom(M), is_atom(F) -> spawn(N,M,F,A) -> erlang:error(badarg, [N, M, F, A]). +-spec spawn_link(Node, Module, Function, Args) -> pid() when + Node :: node(), + Module :: module(), + Function :: atom(), + Args :: [term()]. spawn_link(N,M,F,A) when N =:= node(), is_atom(M), is_atom(F), is_list(A) -> spawn_link(M,F,A); spawn_link(N,M,F,A) when is_atom(N), is_atom(M), is_atom(F) -> @@ -183,6 +233,17 @@ spawn_link(N,M,F,A) when is_atom(N), is_atom(M), is_atom(F) -> spawn_link(N,M,F,A) -> erlang:error(badarg, [N, M, F, A]). +-spec spawn_opt(Module, Function, Args, Options) -> + pid() | {pid(), reference()} when + Module :: module(), + Function :: atom(), + Args :: [term()], + Options :: [Option], + Option :: link | monitor | {priority, Level} + | {fullsweep_after, Number :: non_neg_integer()} + | {min_heap_size, Size :: non_neg_integer()} + | {min_bin_vheap_size, VSize :: non_neg_integer()}, + Level :: low | normal | high. spawn_opt(M, F, A, Opts) -> case catch erlang:spawn_opt({M,F,A,Opts}) of {'EXIT',{Reason,_}} -> @@ -191,6 +252,18 @@ spawn_opt(M, F, A, Opts) -> Res end. +-spec spawn_opt(Node, Module, Function, Args, Options) -> + pid() | {pid(), reference()} when + Node :: node(), + Module :: module(), + Function :: atom(), + Args :: [term()], + Options :: [Option], + Option :: link | monitor | {priority, Level} + | {fullsweep_after, Number :: non_neg_integer()} + | {min_heap_size, Size :: non_neg_integer()} + | {min_bin_vheap_size, VSize :: non_neg_integer()}, + Level :: low | normal | high. spawn_opt(N, M, F, A, O) when N =:= node(), is_atom(M), is_atom(F), is_list(A), is_list(O) -> @@ -260,18 +333,25 @@ crasher(Node,Mod,Fun,Args,Opts,Reason) -> [Mod,Fun,Args,Opts,Node]), exit(Reason). --spec yield() -> 'true'. +-spec erlang:yield() -> 'true'. yield() -> erlang:yield(). --spec nodes() -> [node()]. +-spec nodes() -> Nodes when + Nodes :: [node()]. nodes() -> erlang:nodes(visible). --spec disconnect_node(node()) -> boolean(). +-spec disconnect_node(Node) -> boolean() | ignored when + Node :: node(). disconnect_node(Node) -> net_kernel:disconnect(Node). +-spec erlang:fun_info(Fun) -> [{Item, Info}] when + Fun :: function(), + Item :: arity | env | index | name + | module | new_index | new_uniq | pid | type | uniq, + Info :: term(). fun_info(Fun) when is_function(Fun) -> Keys = [type,env,arity,name,uniq,index,new_uniq,new_index,module,pid], fun_info_1(Keys, Fun, []). @@ -283,24 +363,37 @@ fun_info_1([K|Ks], Fun, A) -> end; fun_info_1([], _, A) -> A. --type dst() :: pid() | port() | atom() | {atom(), node()}. +-type dst() :: pid() + | port() + | (RegName :: atom()) + | {RegName :: atom(), Node :: node()}. --spec send_nosuspend(dst(), term()) -> boolean(). +-spec erlang:send_nosuspend(Dest, Msg) -> boolean() when + Dest :: dst(), + Msg :: term(). send_nosuspend(Pid, Msg) -> send_nosuspend(Pid, Msg, []). --spec send_nosuspend(dst(), term(), ['noconnect' | 'nosuspend']) -> boolean(). +-spec erlang:send_nosuspend(Dest, Msg, Options) -> boolean() when + Dest :: dst(), + Msg :: term(), + Options :: [noconnect]. send_nosuspend(Pid, Msg, Opts) -> case erlang:send(Pid, Msg, [nosuspend|Opts]) of ok -> true; _ -> false end. --spec localtime_to_universaltime(date_time()) -> date_time(). +-spec erlang:localtime_to_universaltime({Date1, Time1}) -> {Date2, Time2} when + Date1 :: calendar:date(), + Date2 :: calendar:date(), + Time1 :: calendar:time(), + Time2 :: calendar:time(). localtime_to_universaltime(Localtime) -> erlang:localtime_to_universaltime(Localtime, undefined). --spec suspend_process(pid()) -> 'true'. +-spec erlang:suspend_process(Suspendee) -> 'true' when + Suspendee :: pid(). suspend_process(P) -> case catch erlang:suspend_process(P, []) of {'EXIT', {Reason, _}} -> erlang:error(Reason, [P]); @@ -426,6 +519,9 @@ delay_trap(Result, Timeout) -> receive after Timeout -> Result end. %% Messages to us use our cookie. IF we change our cookie, other nodes %% have to reflect that, which we cannot forsee. %% +-spec erlang:set_cookie(Node, Cookie) -> true when + Node :: node(), + Cookie :: atom(). set_cookie(Node, C) when Node =/= nonode@nohost, is_atom(Node) -> case is_atom(C) of true -> @@ -434,14 +530,19 @@ set_cookie(Node, C) when Node =/= nonode@nohost, is_atom(Node) -> error(badarg) end. --spec get_cookie() -> atom(). +-spec erlang:get_cookie() -> Cookie | nocookie when + Cookie :: atom(). get_cookie() -> auth:get_cookie(). +-spec concat_binary(ListOfBinaries) -> binary() when + ListOfBinaries :: iolist(). concat_binary(List) -> list_to_binary(List). --spec integer_to_list(integer(), 1..255) -> string(). +-spec integer_to_list(Integer, Base) -> string() when + Integer :: integer(), + Base :: 2..36. integer_to_list(I, 10) -> erlang:integer_to_list(I); integer_to_list(I, Base) @@ -469,6 +570,9 @@ integer_to_list(I0, Base, R0) -> end. +-spec list_to_integer(String, Base) -> integer() when + String :: string(), + Base :: 2..36. list_to_integer(L, 10) -> erlang:list_to_integer(L); list_to_integer(L, Base) @@ -689,10 +793,16 @@ await_proc_exit(Proc, Op, Data) -> end end. --spec min(term(), term()) -> term(). +-spec min(Term1, Term2) -> Minimum when + Term1 :: term(), + Term2 :: term(), + Minimum :: term(). min(A, B) when A > B -> B; min(A, _) -> A. --spec max(term(), term()) -> term(). +-spec max(Term1, Term2) -> Maximum when + Term1 :: term(), + Term2 :: term(), + Maximum :: term(). max(A, B) when A < B -> B; max(A, _) -> A. diff --git a/erts/preloaded/src/init.erl b/erts/preloaded/src/init.erl index 24430a3d40..e52c813029 100644 --- a/erts/preloaded/src/init.erl +++ b/erts/preloaded/src/init.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% Copyright Ericsson AB 1996-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -28,10 +28,10 @@ %% : $Var in the boot script is expanded to %% Value. %% -loader LoaderMethod -%% : efile, inet, ose_inet +%% : efile, inet %% (Optional - default efile) %% -hosts [Node] : List of hosts from which we can boot. -%% (Mandatory if -loader inet or ose_inet) +%% (Mandatory if -loader inet) %% -mode embedded : Load all modules at startup, no automatic loading %% -mode interactive : Auto load modules (default system behaviour). %% -path : Override path in bootfile. @@ -79,19 +79,24 @@ debug(false, _) -> ok; debug(_, T) -> erlang:display(T). --spec get_arguments() -> [{atom(), [string()]}]. +-spec get_arguments() -> Flags when + Flags :: [{Flag :: atom(), Values :: [string()]}]. get_arguments() -> request(get_arguments). --spec get_plain_arguments() -> [string()]. +-spec get_plain_arguments() -> [Arg] when + Arg :: string(). get_plain_arguments() -> bs2ss(request(get_plain_arguments)). --spec get_argument(atom()) -> 'error' | {'ok', [[string()]]}. +-spec get_argument(Flag) -> {'ok', Arg} | 'error' when + Flag :: atom(), + Arg :: [Values :: [string()]]. get_argument(Arg) -> request({get_argument, Arg}). --spec script_id() -> term(). +-spec script_id() -> Id when + Id :: term(). script_id() -> request(script_id). @@ -105,7 +110,9 @@ bs2ss(L0) when is_list(L0) -> bs2ss(L) -> L. --spec get_status() -> {internal_status(), term()}. +-spec get_status() -> {InternalStatus, ProvidedStatus} when + InternalStatus :: internal_status(), + ProvidedStatus :: term(). get_status() -> request(get_status). @@ -150,10 +157,12 @@ reboot() -> init ! {stop,reboot}, ok. -spec stop() -> 'ok'. stop() -> init ! {stop,stop}, ok. --spec stop(non_neg_integer() | string()) -> 'ok'. +-spec stop(Status) -> 'ok' when + Status :: non_neg_integer() | string(). stop(Status) -> init ! {stop,{stop,Status}}, ok. --spec boot([binary()]) -> no_return(). +-spec boot(BootArgs) -> no_return() when + BootArgs :: [binary()]. boot(BootArgs) -> register(init, self()), process_flag(trap_exit, true), @@ -1024,7 +1033,7 @@ start_it({eval,Bin}) -> TsR -> reverse([{dot,1} | TsR]) end, {ok,Expr} = erl_parse:parse_exprs(Ts1), - erl_eval:exprs(Expr, []), + erl_eval:exprs(Expr, erl_eval:new_bindings()), ok; start_it([_|_]=MFA) -> Ref = make_ref(), diff --git a/erts/preloaded/src/zlib.erl b/erts/preloaded/src/zlib.erl index 51d6cd0a0b..6cc7b27114 100644 --- a/erts/preloaded/src/zlib.erl +++ b/erts/preloaded/src/zlib.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2003-2010. All Rights Reserved. +%% Copyright Ericsson AB 2003-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -124,7 +124,6 @@ -type zwindowbits() :: -15..-9 | 9..47. -type zmemlevel() :: 1..9. -type zstrategy() :: 'default' | 'filtered' | 'huffman_only'. --type zflush() :: 'none' | 'sync' | 'full' | 'finish'. %%------------------------------------------------------------------------ @@ -134,7 +133,8 @@ open() -> open_port({spawn, "zlib_drv"}, [binary]). %% close and release z_stream --spec close(zstream()) -> 'ok'. +-spec close(Z) -> 'ok' when + Z :: zstream(). close(Z) -> try true = port_close(Z), @@ -145,16 +145,25 @@ close(Z) -> catch _:_ -> erlang:error(badarg) end. --spec deflateInit(zstream()) -> 'ok'. +-spec deflateInit(Z) -> 'ok' when + Z :: zstream(). deflateInit(Z) -> call(Z, ?DEFLATE_INIT, <<?Z_DEFAULT_COMPRESSION:32>>). --spec deflateInit(zstream(), zlevel()) -> 'ok'. +-spec deflateInit(Z, Level) -> 'ok' when + Z :: zstream(), + Level :: zlevel(). deflateInit(Z, Level) -> call(Z, ?DEFLATE_INIT, <<(arg_level(Level)):32>>). --spec deflateInit(zstream(), zlevel(), zmethod(), - zwindowbits(), zmemlevel(), zstrategy()) -> 'ok'. +-spec deflateInit(Z, Level, Method, + WindowBits, MemLevel, Strategy) -> 'ok' when + Z :: zstream(), + Level :: zlevel(), + Method :: zmethod(), + WindowBits :: zwindowbits(), + MemLevel :: zmemlevel(), + Strategy :: zstrategy(). deflateInit(Z, Level, Method, WindowBits, MemLevel, Strategy) -> call(Z, ?DEFLATE_INIT2, <<(arg_level(Level)):32, (arg_method(Method)):32, @@ -162,24 +171,38 @@ deflateInit(Z, Level, Method, WindowBits, MemLevel, Strategy) -> (arg_mem(MemLevel)):32, (arg_strategy(Strategy)):32>>). --spec deflateSetDictionary(zstream(), binary()) -> integer(). +-spec deflateSetDictionary(Z, Dictionary) -> Adler32 when + Z :: zstream(), + Dictionary :: binary(), + Adler32 :: integer(). deflateSetDictionary(Z, Dictionary) -> call(Z, ?DEFLATE_SETDICT, Dictionary). --spec deflateReset(zstream()) -> 'ok'. +-spec deflateReset(Z) -> 'ok' when + Z :: zstream(). deflateReset(Z) -> call(Z, ?DEFLATE_RESET, []). --spec deflateParams(zstream(), zlevel(), zstrategy()) -> 'ok'. +-spec deflateParams(Z, Level, Strategy) -> ok when + Z :: zstream(), + Level :: zlevel(), + Strategy :: zstrategy(). deflateParams(Z, Level, Strategy) -> call(Z, ?DEFLATE_PARAMS, <<(arg_level(Level)):32, (arg_strategy(Strategy)):32>>). --spec deflate(zstream(), iodata()) -> iolist(). +-spec deflate(Z, Data) -> Compressed when + Z :: zstream(), + Data :: iodata(), + Compressed :: iolist(). deflate(Z, Data) -> deflate(Z, Data, none). --spec deflate(zstream(), iodata(), zflush()) -> iolist(). +-spec deflate(Z, Data, Flush) -> Compressed when + Z :: zstream(), + Data :: iodata(), + Flush :: none | sync | full | finish, + Compressed :: iolist(). deflate(Z, Data, Flush) -> try port_command(Z, Data) of true -> @@ -191,19 +214,25 @@ deflate(Z, Data, Flush) -> erlang:error(badarg) end. --spec deflateEnd(zstream()) -> 'ok'. +-spec deflateEnd(Z) -> 'ok' when + Z :: zstream(). deflateEnd(Z) -> call(Z, ?DEFLATE_END, []). --spec inflateInit(zstream()) -> 'ok'. +-spec inflateInit(Z) -> 'ok' when + Z :: zstream(). inflateInit(Z) -> call(Z, ?INFLATE_INIT, []). --spec inflateInit(zstream(), zwindowbits()) -> 'ok'. +-spec inflateInit(Z, WindowBits) -> 'ok' when + Z :: zstream(), + WindowBits :: zwindowbits(). inflateInit(Z, WindowBits) -> call(Z, ?INFLATE_INIT2, <<(arg_bitsz(WindowBits)):32>>). --spec inflateSetDictionary(zstream(), binary()) -> 'ok'. +-spec inflateSetDictionary(Z, Dictionary) -> 'ok' when + Z :: zstream(), + Dictionary :: binary(). inflateSetDictionary(Z, Dictionary) -> call(Z, ?INFLATE_SETDICT, Dictionary). @@ -211,11 +240,15 @@ inflateSetDictionary(Z, Dictionary) -> inflateSync(Z) -> call(Z, ?INFLATE_SYNC, []). --spec inflateReset(zstream()) -> 'ok'. +-spec inflateReset(Z) -> 'ok' when + Z :: zstream(). inflateReset(Z) -> call(Z, ?INFLATE_RESET, []). --spec inflate(zstream(), iodata()) -> iolist(). +-spec inflate(Z, Data) -> Decompressed when + Z :: zstream(), + Data :: iodata(), + Decompressed :: iolist(). inflate(Z, Data) -> try port_command(Z, Data) of true -> @@ -227,50 +260,81 @@ inflate(Z, Data) -> erlang:error(badarg) end. --spec inflateEnd(zstream()) -> 'ok'. +-spec inflateEnd(Z) -> 'ok' when + Z :: zstream(). inflateEnd(Z) -> call(Z, ?INFLATE_END, []). --spec setBufSize(zstream(), non_neg_integer()) -> 'ok'. +-spec setBufSize(Z, Size) -> 'ok' when + Z :: zstream(), + Size :: non_neg_integer(). setBufSize(Z, Size) -> call(Z, ?SET_BUFSZ, <<Size:32>>). --spec getBufSize(zstream()) -> non_neg_integer(). +-spec getBufSize(Z) -> Size when + Z :: zstream(), + Size :: non_neg_integer(). getBufSize(Z) -> call(Z, ?GET_BUFSZ, []). --spec crc32(zstream()) -> integer(). +-spec crc32(Z) -> CRC when + Z :: zstream(), + CRC :: integer(). crc32(Z) -> call(Z, ?CRC32_0, []). --spec crc32(zstream(), binary()) -> integer(). +-spec crc32(Z, Binary) -> CRC when + Z :: zstream(), + Binary :: binary(), + CRC :: integer(). crc32(Z, Binary) -> call(Z, ?CRC32_1, Binary). --spec crc32(zstream(), integer(), binary()) -> integer(). +-spec crc32(Z, PrevCRC, Binary) -> CRC when + Z :: zstream(), + PrevCRC :: integer(), + Binary :: binary(), + CRC :: integer(). crc32(Z, CRC, Binary) when is_binary(Binary), is_integer(CRC) -> call(Z, ?CRC32_2, <<CRC:32, Binary/binary>>); crc32(_Z, _CRC, _Binary) -> erlang:error(badarg). --spec adler32(zstream(), binary()) -> integer(). +-spec adler32(Z, Binary) -> CheckSum when + Z :: zstream(), + Binary :: binary(), + CheckSum :: integer(). adler32(Z, Binary) -> call(Z, ?ADLER32_1, Binary). --spec adler32(zstream(), integer(), binary()) -> integer(). +-spec adler32(Z, PrevAdler, Binary) -> CheckSum when + Z :: zstream(), + PrevAdler :: integer(), + Binary :: binary(), + CheckSum :: integer(). adler32(Z, Adler, Binary) when is_binary(Binary), is_integer(Adler) -> call(Z, ?ADLER32_2, <<Adler:32, Binary/binary>>); adler32(_Z, _Adler, _Binary) -> erlang:error(badarg). --spec crc32_combine(zstream(), integer(), integer(), integer()) -> integer(). +-spec crc32_combine(Z, CRC1, CRC2, Size2) -> CRC when + Z :: zstream(), + CRC :: integer(), + CRC1 :: integer(), + CRC2 :: integer(), + Size2 :: integer(). crc32_combine(Z, CRC1, CRC2, Len2) when is_integer(CRC1), is_integer(CRC2), is_integer(Len2) -> call(Z, ?CRC32_COMBINE, <<CRC1:32, CRC2:32, Len2:32>>); crc32_combine(_Z, _CRC1, _CRC2, _Len2) -> erlang:error(badarg). --spec adler32_combine(zstream(), integer(), integer(), integer()) -> integer(). +-spec adler32_combine(Z, Adler1, Adler2, Size2) -> Adler when + Z :: zstream(), + Adler :: integer(), + Adler1 :: integer(), + Adler2 :: integer(), + Size2 :: integer(). adler32_combine(Z, Adler1, Adler2, Len2) when is_integer(Adler1), is_integer(Adler2), is_integer(Len2) -> call(Z, ?ADLER32_COMBINE, <<Adler1:32, Adler2:32, Len2:32>>); @@ -282,7 +346,9 @@ getQSize(Z) -> call(Z, ?GET_QSIZE, []). %% compress/uncompress zlib with header --spec compress(binary()) -> binary(). +-spec compress(Binary) -> Compressed when + Binary :: binary(), + Compressed :: binary(). compress(Binary) -> Z = open(), deflateInit(Z, default), @@ -291,7 +357,9 @@ compress(Binary) -> close(Z), list_to_binary(Bs). --spec uncompress(binary()) -> binary(). +-spec uncompress(Binary) -> Decompressed when + Binary :: binary(), + Decompressed :: binary(). uncompress(Binary) when byte_size(Binary) >= 8 -> Z = open(), inflateInit(Z), @@ -303,7 +371,9 @@ uncompress(Binary) when is_binary(Binary) -> erlang:error(data_error); uncompress(_) -> erlang:error(badarg). %% unzip/zip zlib without header (zip members) --spec zip(binary()) -> binary(). +-spec zip(Binary) -> Compressed when + Binary :: binary(), + Compressed :: binary(). zip(Binary) -> Z = open(), deflateInit(Z, default, deflated, -?MAX_WBITS, 8, default), @@ -312,7 +382,9 @@ zip(Binary) -> close(Z), list_to_binary(Bs). --spec unzip(binary()) -> binary(). +-spec unzip(Binary) -> Decompressed when + Binary :: binary(), + Decompressed :: binary(). unzip(Binary) -> Z = open(), inflateInit(Z, -?MAX_WBITS), @@ -321,7 +393,9 @@ unzip(Binary) -> close(Z), list_to_binary(Bs). --spec gzip(iodata()) -> binary(). +-spec gzip(Data) -> Compressed when + Data :: iodata(), + Compressed :: binary(). gzip(Data) when is_binary(Data); is_list(Data) -> Z = open(), deflateInit(Z, default, deflated, 16+?MAX_WBITS, 8, default), @@ -331,7 +405,9 @@ gzip(Data) when is_binary(Data); is_list(Data) -> iolist_to_binary(Bs); gzip(_) -> erlang:error(badarg). --spec gunzip(iodata()) -> binary(). +-spec gunzip(Binary) -> Decompressed when + Binary :: binary(), + Decompressed :: binary(). gunzip(Data) when is_binary(Data); is_list(Data) -> Z = open(), inflateInit(Z, 16+?MAX_WBITS), |