Skip to content

Commit

Permalink
Clean up compile options
Browse files Browse the repository at this point in the history
  • Loading branch information
Ledest committed Aug 20, 2024
1 parent 4726a24 commit 8ac37a8
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 35 deletions.
8 changes: 4 additions & 4 deletions src/otpbp_beam_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ strip_release(Root, AdditionalChunks) -> catch strip_rel(Root, AdditionalChunks)
-define(NEED_error_1, true).
-endif.

-compile({inline, [strip_rel/2]}).
-compile({inline, strip_rel/2}).
strip_rel(Root, AdditionalChunks) ->
filelib:is_dir(Root) orelse error({not_a_directory, Root}),
strip_fils(filelib:wildcard(filename:join([Root, "lib", "*", "ebin", "*.beam"])), AdditionalChunks).
Expand All @@ -79,7 +79,7 @@ strip_file(File, AdditionalChunks) ->
{ok, Stripped} = beam_lib:build_module(Chunks),
strip_file(File, Mod, zlib:gzip(Stripped)).

-compile({inline, [strip_file/3]}).
-compile({inline, strip_file/3}).
strip_file(File, Mod, Stripped) when is_binary(File) -> {ok, {Mod, Stripped}};
strip_file(File, Mod, Stripped) ->
FileName = filename:rootname(File, ".beam") ++ ".beam",
Expand All @@ -92,15 +92,15 @@ strip_file(File, Mod, Stripped) ->
Error -> file_error(FileName, Error)
end.

-compile({inline, [read_significant_chunks/2]}).
-compile({inline, read_significant_chunks/2}).
read_significant_chunks(File, ChunkList) ->
{ok, {Module, Chunks}} = beam_lib:chunks(File, ChunkList, [allow_missing_chunks]),
{Module, lists:filter(fun({_, Data}) when is_binary(Data) -> true;
({Id, missing_chunk}) ->
lists:member(Id, mandatory_chunks()) andalso error({missing_chunk, File, Id})
end, Chunks)}.

-compile({inline, [mandatory_chunks/0]}).
-compile({inline, mandatory_chunks/0}).
mandatory_chunks() -> ["Code", "ExpT", "ImpT", "StrT"].

file_error(FileName, {error, Reason}) -> error({file_error, FileName, Reason}).
Expand Down
2 changes: 1 addition & 1 deletion src/otpbp_code.erl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ where_is_file(T, File, D, Files) ->
_false -> where_is_file(T, File)
end.

-compile({inline, [module_changed_on_disk/2]}).
-compile({inline, module_changed_on_disk/2}).
module_changed_on_disk(Module, Path) ->
Arch = erlang:system_info(hipe_architecture),
case Arch =/= undefined andalso code:is_module_native(Module) of
Expand Down
2 changes: 1 addition & 1 deletion src/otpbp_gen_event.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ start_monitor(Name, Options) ->
Pid -> {error, {already_started, Pid}}
end.

-compile({inline, [where/1]}).
-compile({inline, where/1}).
where({global, Name}) -> global:whereis_name(Name);
where({via, Module, Name}) -> Module:whereis_name(Name);
where({local, Name}) -> whereis(Name).
Expand Down
2 changes: 1 addition & 1 deletion src/otpbp_gen_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ start_monitor(Name, Module, Args, Options) ->
Pid -> {error, {already_started, Pid}}
end.

-compile({inline, [where/1]}).
-compile({inline, where/1}).
where({global, Name}) -> global:whereis_name(Name);
where({via, Module, Name}) -> Module:whereis_name(Name);
where({local, Name}) -> whereis(Name).
Expand Down
6 changes: 3 additions & 3 deletions src/otpbp_httpd.erl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ do_serve(#{help := true}) ->
halt(0);
do_serve(#{address := Address, port := Port, directory := Path}) -> do_serve(Address, Port, Path).

-compile({inline, [do_serve/3]}).
-compile({inline, do_serve/3}).
do_serve({_, _, _, _} = Address, Port, Path) -> do_serve(Address, Port, Path, inet);
do_serve(Address, Port, Path) -> do_serve(Address, Port, Path, inet6).

Expand All @@ -73,10 +73,10 @@ do_serve(Address, Port, Path, IpFamily) ->
From ! done
end.

-compile({inline, [default_mime_types/0]}).
-compile({inline, default_mime_types/0}).
default_mime_types() -> find_mime_types("/etc/mime.types").

-compile({inline, [find_mime_types/1]}).
-compile({inline, find_mime_types/1}).
find_mime_types(Path) ->
case filelib:is_file(Path) of
true -> Path;
Expand Down
2 changes: 1 addition & 1 deletion src/otpbp_proc_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ sync_start_monitor({Pid, Ref}, Timeout) ->
{{error, timeout}, Ref}
end.

-compile({inline, [kill_flush/1]}).
-compile({inline, kill_flush/1}).
kill_flush(Pid) ->
unlink(Pid),
exit(Pid, kill),
Expand Down
40 changes: 20 additions & 20 deletions src/otpbp_pt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ parse_transform(Forms, Options) ->
_ -> Forms
end.

-compile({inline, [get_funs/3]}).
-compile({inline, get_funs/3}).
get_funs(AF, Options, TL) ->
lists:foldl(fun({M, Fs}, IA) ->
lists:foldl(fun(FA, IAM) ->
Expand All @@ -308,7 +308,7 @@ get_funs(AF, Options, TL) ->
maps:without(get_no_auto_import(AF, Options), TL),
proplists:get_value(imports, AF, [])).

-compile({inline, [get_no_auto_import/2]}).
-compile({inline, get_no_auto_import/2}).
get_no_auto_import(AF, Options) ->
lists:usort(proplists:append_values(no_auto_import,
proplists:append_values(compile,
Expand All @@ -321,7 +321,7 @@ transform(Tree, P) ->
_ -> {Tree, P}
end.

-compile({inline, [transform_function/2]}).
-compile({inline, transform_function/2}).
transform_function(Tree, P) ->
case erl_syntax_lib:mapfold(fun(E, F) ->
case function_transform(E, P) of
Expand All @@ -333,7 +333,7 @@ transform_function(Tree, P) ->
_ -> Tree
end.

-compile({inline, [transform_attribute/2]}).
-compile({inline, transform_attribute/2}).
transform_attribute(Tree, P) ->
case erl_syntax_lib:analyze_attribute(Tree) of
{file, {F, _}} -> {Tree, P#param{file = F}};
Expand All @@ -353,7 +353,7 @@ transform_behaviour({_, _, _, B} = Tree, #param{behaviours = Bs}) ->
end;
transform_behaviour(Tree, _) -> Tree.

-compile({inline, [check_behaviour/1]}).
-compile({inline, check_behaviour/1}).
check_behaviour(B) ->
try B:module_info(exports) of
Exports -> lists:member({behaviour_info, 1}, Exports)
Expand Down Expand Up @@ -386,7 +386,7 @@ store_func(F, {_, _} = MF, D) -> D#{F => MF};
store_func({_, {F, _}} = MFA, M, D) -> store_func(MFA, {M, F}, D);
store_func({F, _} = FA, M, D) -> store_func(FA, {M, F}, D).

-compile({inline, [transform_list/0]}).
-compile({inline, transform_list/0}).
transform_list() -> lists:foldl(fun({F, D}, Acc) -> add_func(F, D, Acc) end, #{}, ?TRANSFORM_FUNCTIONS).

function_transform(Node, #param{} = P) ->
Expand All @@ -408,7 +408,7 @@ application_transform(Node, #param{funs = FL} = P) ->
end
end.

-compile({inline, [application_transform/2]}).
-compile({inline, application_transform/2}).
application_transform(Node, P, A, L) ->
case L of
#{A := {M, N}} ->
Expand All @@ -422,7 +422,7 @@ application_transform(Node, P, A, L) ->
#{} -> false
end.

-compile({inline, [apply_transform/3]}).
-compile({inline, apply_transform/3}).
apply_transform(Node, #param{apply = AL} = P, A) ->
lists:member(A, AL) andalso
case erl_syntax:application_arguments(Node) of
Expand All @@ -447,10 +447,10 @@ application(remote, O, As, M, N) -> application_(mqa(O), mqb(O), As, M, N).

application_(O1, O2, As, M, N) -> application_(atom(O1, M), atom(O2, N), As).

-compile({inline, [application_/3]}).
-compile({inline, application_/3}).
application_(M, N, As) -> erl_syntax:application(cp(M, erl_syntax:module_qualifier(M, N)), As).

-compile({inline, [implicit_fun_transform/2]}).
-compile({inline, implicit_fun_transform/2}).
implicit_fun_transform(Node, #param{funs = L} = P) ->
try erl_syntax_lib:analyze_implicit_fun(Node) of
F -> case L of
Expand All @@ -470,7 +470,7 @@ implicit_fun_transform(Node, #param{funs = L} = P) ->
throw:syntax_error -> false
end.

-compile({inline, [try_expr_transform/1]}).
-compile({inline, try_expr_transform/1}).
try_expr_transform(Node) ->
case lists:mapfoldr(fun(H, A) ->
case try_expr_handler_transform(H) of
Expand All @@ -485,15 +485,15 @@ try_expr_transform(Node) ->
Hs, erl_syntax:try_expr_after(Node)))
end.

-compile({inline, [try_expr_handler_transform/1]}).
-compile({inline, try_expr_handler_transform/1}).
try_expr_handler_transform(Node) ->
case type(Node) =:= clause andalso try_expr_clause_patterns_transform(erl_syntax:clause_patterns(Node)) of
{P, {true, B}} ->
cp(Node, erl_syntax:clause(P, erl_syntax:clause_guard(Node), B ++ erl_syntax:clause_body(Node)));
_ -> false
end.

-compile({inline, [try_expr_clause_patterns_transform/1]}).
-compile({inline, try_expr_clause_patterns_transform/1}).
try_expr_clause_patterns_transform(Ps) ->
lists:mapfoldr(fun(P, {_, L} = A) ->
case type(P) of
Expand Down Expand Up @@ -562,29 +562,29 @@ match_expr_list(M, L) -> [cp(M, erl_syntax:match_expr(M, cp(M, application(local

atom(P, A) when is_tuple(P), is_atom(A) -> cp(P, erl_syntax:atom(A)).

-compile({inline, [otp_release/0]}).
-compile({inline, otp_release/0}).
otp_release() -> list_to_integer(erlang:system_info(otp_release)).

-compile({inline, [erts_version/0]}).
-compile({inline, erts_version/0}).
erts_version() -> lists:map(fun list_to_integer/1, string:tokens(erlang:system_info(version), ".")).

replace_message(_Node, #param{verbose = false}, _F, _NM, _NN) -> ok;
replace_message(Node, #param{file = File}, F, NM, NN) -> replace_message_(erl_syntax:get_pos(Node), File, F, NM, NN).

-compile({inline, [replace_message_/5]}).
-compile({inline, replace_message_/5}).
replace_message_(P, F, {M, {N, A}}, NM, NN) -> replace_message_(P, F, lists:concat([M, ":", N]), NM, NN, A);
replace_message_(P, F, {N, A}, NM, NN) -> replace_message_(P, F, N, NM, NN, A).

replace_message_(P, F, N, NM, NN, A) -> io:fwrite("~ts:~p: replace ~ts/~B to ~s:~ts/~B~n", [F, P, N, A, NM, NN, A]).

-compile({inline, [cp/2]}).
-compile({inline, cp/2}).
cp(S, T) -> erl_syntax:copy_pos(S, T).

-compile({inline, [type/1]}).
-compile({inline, type/1}).
type(N) -> erl_syntax:type(N).

-compile({inline, [mqa/1]}).
-compile({inline, mqa/1}).
mqa(N) -> erl_syntax:module_qualifier_argument(N).

-compile({inline, [mqb/1]}).
-compile({inline, mqb/1}).
mqb(N) -> erl_syntax:module_qualifier_body(N).
4 changes: 2 additions & 2 deletions src/otpbp_pubkey_os_cacerts.erl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ get() ->
CaCerts -> CaCerts
end.

-compile({inline, [get1/0]}).
-compile({inline, get1/0}).
-ifdef(HAVE_persistent_term__get_1).
get1() -> persistent_term:get(pubkey_os_cacerts).
-else.
Expand All @@ -87,7 +87,7 @@ get1() ->
Value.
-endif.

-compile({inline, [get2/0]}).
-compile({inline, get2/0}).
-ifdef(HAVE_persistent_term__get_2).
get2() -> persistent_term:get(pubkey_os_cacerts, undefined).
-else.
Expand Down
4 changes: 2 additions & 2 deletions src/otpbp_rand.erl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ bytes_s(N, {#{max := Mask, next := Next} = AlgHandler, R}) when is_integer(N), 0
%% giving 56 bits i.e precisely 7 bytes per generated number
bytes_r(N, AlgHandler, Next, R, 58, 2).

-compile({inline, [bytes_r/6]}).
-compile({inline, bytes_r/6}).
bytes_r(N, AlgHandler, Next, R, Bits, WeakLowBits) ->
%% We use whole bytes from each generator word,
%% GoodBytes: that number of bytes
Expand Down Expand Up @@ -140,7 +140,7 @@ uniform_real_s({#{next := Next} = Alg, R0}) ->
{V1, R1} = Next(R0),
uniform_real_s(Alg, V1, R1, Next).

-compile({inline, [uniform_real_s/5]}).
-compile({inline, uniform_real_s/5}).
uniform_real_s(#{bits := Bits} = Alg, V1, R1, Next) ->
case V1 bsr (Bits - 56) of
M1 when ?BIT(55) =< M1 -> %% We have 56 bits - waste 3
Expand Down

0 comments on commit 8ac37a8

Please sign in to comment.