3535
3636#include "common/alignment.h"
3737#include "common/macros.h"
38+ #include "common/types.h"
3839#include "event/event.h"
3940#include "timer/timer.h"
4041#include "ao/ao.h"
@@ -108,12 +109,18 @@ static int rand_012(void) {
108109 return (int )((unsigned )(next / 65536 ) % 3 );
109110}
110111
111- static int smoker_top (struct smoker * me , const struct am_event * event );
112- static int smoker_idle (struct smoker * me , const struct am_event * event );
113- static int smoker_smoking (struct smoker * me , const struct am_event * event );
114- static int smoker_stopping (struct smoker * me , const struct am_event * event );
115-
116- static int smoker_stopping (struct smoker * me , const struct am_event * event ) {
112+ static enum am_rc smoker_top (struct smoker * me , const struct am_event * event );
113+ static enum am_rc smoker_idle (struct smoker * me , const struct am_event * event );
114+ static enum am_rc smoker_smoking (
115+ struct smoker * me , const struct am_event * event
116+ );
117+ static enum am_rc smoker_stopping (
118+ struct smoker * me , const struct am_event * event
119+ );
120+
121+ static enum am_rc smoker_stopping (
122+ struct smoker * me , const struct am_event * event
123+ ) {
117124 switch (event -> id ) {
118125 case EVT_STOP : {
119126 am_ao_publish (& m_evt_stopped );
@@ -126,7 +133,7 @@ static int smoker_stopping(struct smoker *me, const struct am_event *event) {
126133 return AM_HSM_SUPER (am_hsm_top );
127134}
128135
129- static int smoker_top (struct smoker * me , const struct am_event * event ) {
136+ static enum am_rc smoker_top (struct smoker * me , const struct am_event * event ) {
130137 switch (event -> id ) {
131138 case EVT_STOP : {
132139 return AM_HSM_TRAN_REDISPATCH (smoker_stopping );
@@ -137,7 +144,7 @@ static int smoker_top(struct smoker *me, const struct am_event *event) {
137144 return AM_HSM_SUPER (am_hsm_top );
138145}
139146
140- static int smoker_idle (struct smoker * me , const struct am_event * event ) {
147+ static enum am_rc smoker_idle (struct smoker * me , const struct am_event * event ) {
141148 switch (event -> id ) {
142149 case EVT_RESOURCE : {
143150 const struct resource * e = (const struct resource * )event ;
@@ -157,7 +164,9 @@ static int smoker_idle(struct smoker *me, const struct am_event *event) {
157164 return AM_HSM_SUPER (smoker_top );
158165}
159166
160- static int smoker_smoking (struct smoker * me , const struct am_event * event ) {
167+ static enum am_rc smoker_smoking (
168+ struct smoker * me , const struct am_event * event
169+ ) {
161170 switch (event -> id ) {
162171 case AM_EVT_ENTRY :
163172 am_timer_arm_ms (& me -> timer_done_smoking , /*ms=*/ 20 , /*interval=*/ 0 );
@@ -185,7 +194,7 @@ static int smoker_smoking(struct smoker *me, const struct am_event *event) {
185194 return AM_HSM_SUPER (smoker_top );
186195}
187196
188- static int smoker_init (struct smoker * me , const struct am_event * event ) {
197+ static enum am_rc smoker_init (struct smoker * me , const struct am_event * event ) {
189198 (void )event ;
190199 am_ao_subscribe (& me -> ao , EVT_RESOURCE );
191200 am_ao_subscribe (& me -> ao , EVT_STOP );
@@ -225,7 +234,9 @@ static void agent_check_stats(const struct agent *me) {
225234 }
226235}
227236
228- static int agent_stopping (struct agent * me , const struct am_event * event ) {
237+ static enum am_rc agent_stopping (
238+ struct agent * me , const struct am_event * event
239+ ) {
229240 switch (event -> id ) {
230241 case AM_EVT_ENTRY :
231242 am_ao_publish_exclude (& m_evt_stop , & me -> ao );
@@ -278,7 +289,7 @@ static void publish_resources(struct agent *me) {
278289 me -> resource_id ++ ;
279290}
280291
281- static int agent_proc (struct agent * me , const struct am_event * event ) {
292+ static enum am_rc agent_proc (struct agent * me , const struct am_event * event ) {
282293 switch (event -> id ) {
283294 case AM_EVT_ENTRY : {
284295 am_timer_arm_ms (& me -> timeout , AM_TIMEOUT_MS , /*interval=*/ 0 );
@@ -306,7 +317,7 @@ static int agent_proc(struct agent *me, const struct am_event *event) {
306317 return AM_HSM_SUPER (am_hsm_top );
307318}
308319
309- static int agent_init (struct agent * me , const struct am_event * event ) {
320+ static enum am_rc agent_init (struct agent * me , const struct am_event * event ) {
310321 (void )event ;
311322 am_ao_subscribe (& me -> ao , EVT_DONE_SMOKING );
312323 am_ao_subscribe (& me -> ao , EVT_STOPPED );
0 commit comments