File 4743-kernel-Add-callback-attributes-to-application.patch of Package erlang
From b407b4d887a7b242e3c49e2b5cd9ef87e6670306 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Wed, 27 Sep 2023 16:34:18 +0200
Subject: [PATCH 03/10] kernel: Add callback attributes to application
---
lib/kernel/src/application.erl | 20 +++++++++++++++++++-
lib/stdlib/test/erl_internal_SUITE.erl | 4 ++--
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/lib/kernel/src/application.erl b/lib/kernel/src/application.erl
index b3e6eea64f..97cf6e6c06 100644
--- a/lib/kernel/src/application.erl
+++ b/lib/kernel/src/application.erl
@@ -18,7 +18,6 @@
%% %CopyrightEnd%
%%
-module(application).
-
-export([ensure_all_started/1, ensure_all_started/2, ensure_all_started/3,
start/1, start/2,
start_boot/1, start_boot/2, stop/1,
@@ -68,6 +67,25 @@
-callback stop(State :: term()) ->
term().
+-callback config_change(Changed, New, Removed) -> ok when
+ Changed :: [{Par, Val}],
+ New :: [{Par, Val}],
+ Removed :: [Par],
+ Par :: atom(),
+ Val :: term().
+
+-callback prep_stop(State) -> NewState when
+ State :: term(), NewState :: term().
+
+-callback start_phase(Phase, StartType, PhaseArgs) ->
+ ok | {error, Reason} when
+ Phase :: atom(),
+ StartType :: start_type(),
+ PhaseArgs :: term(),
+ Reason :: term().
+
+-optional_callbacks([config_change/3, prep_stop/1, start_phase/3]).
+
%%%-----------------------------------------------------------------
%%% This module is API towards application_controller and
%%% application_master.
diff --git a/lib/stdlib/test/erl_internal_SUITE.erl b/lib/stdlib/test/erl_internal_SUITE.erl
index 5c2d6b0091..e626d85884 100644
--- a/lib/stdlib/test/erl_internal_SUITE.erl
+++ b/lib/stdlib/test/erl_internal_SUITE.erl
@@ -76,7 +76,7 @@ check_behav_list([L | L1], L2) ->
check_behav_list(L1, L3).
callbacks(application) ->
- [{start,2}, {stop,1}];
+ [{start,2}, {stop,1}, {config_change, 3}, {prep_stop, 1}, {start_phase, 3}];
callbacks(gen_server) ->
[{init,1}, {handle_call,3}, {handle_cast,2},
{handle_info,2}, {terminate,2}, {code_change,3},
@@ -99,7 +99,7 @@ callbacks(supervisor) ->
[{init,1}].
optional_callbacks(application) ->
- [];
+ [{config_change, 3}, {prep_stop, 1}, {start_phase, 3}];
optional_callbacks(gen_server) ->
[{handle_info, 2}, {handle_continue, 2}, {terminate, 2}, {code_change, 3}, {format_status, 1}, {format_status, 2}];
optional_callbacks(gen_fsm) ->
--
2.35.3