Skip to content

Commit 1b6890b

Browse files
committed
cleanup(core,samples,tests): dropped m_mod_ctx API.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
1 parent 85427bb commit 1b6890b

File tree

13 files changed

+25
-30
lines changed

13 files changed

+25
-30
lines changed

Lib/core/ctx.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77

88
#define M_CTX_DEFAULT_EVENTS 64
99

10+
// #define M_CTX() m_ctx_t *c = m_ctx();
11+
//
12+
// #define M_CTX_ASSERT(c) \
13+
// M_CTX(); \
14+
// M_RET_ASSERT(c, -EPIPE); \
15+
// M_RET_ASSERT(c->state != M_CTX_ZOMBIE, -EACCES)
16+
1017
#define M_CTX_ASSERT(c) \
1118
M_PARAM_ASSERT(c); \
1219
M_RET_ASSERT(c->state != M_CTX_ZOMBIE, -EACCES)

Lib/core/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ _public_ _weak_ int main(int argc, char *argv[]) {
3232
const int ret = m_ctx_loop(c);
3333
m_ctx_post_loop(c, argc, argv);
3434
m_ctx_deregister(&c); // default_ctx may be NULL here, if eg: all modules where deregistered. We don't care
35-
m_mem_unrefp((void **)&c);
3635
return ret;
3736
}
3837

Lib/core/mod.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -635,14 +635,6 @@ _public_ int m_mod_stats(const m_mod_t *mod, m_mod_stats_t *stats) {
635635
return 0;
636636
}
637637

638-
_public_ m_ctx_t *m_mod_ctx(const m_mod_t *mod) {
639-
M_RET_ASSERT(mod, NULL);
640-
M_RET_ASSERT(!m_mod_is(mod, M_MOD_ZOMBIE), NULL);
641-
M_RET_ASSERT(!(mod->flags & M_MOD_DENY_CTX), NULL);
642-
643-
return mod->ctx;
644-
}
645-
646638
/** Module state setters **/
647639

648640
#define M_MOD_BOUND(fn) \

Lib/core/public/module/mod.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,6 @@ int m_mod_register(const char *name, m_ctx_t *c, OUT m_mod_t **mod_ref, const m_
205205
m_mod_flags flags, const void *userdata);
206206
int m_mod_deregister(OUT m_mod_t **mod);
207207

208-
/* Retrieve module context */
209-
m_ctx_t *m_mod_ctx(const m_mod_t *mod);
210-
211208
/* Retrieve module name */
212209
const char *m_mod_name(const m_mod_t *mod);
213210

Lib/core/public/module/mod_easy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* dtors order:
1515
* 0) each m_mod_dtor() (only mod_easy API)
1616
*/
17-
#define _m_ctor0_ __attribute__((constructor (113)))
18-
#define _m_ctor1_ __attribute__((constructor (114)))
17+
#define _m_ctor0_ __attribute__((constructor (111)))
18+
#define _m_ctor1_ __attribute__((constructor (112)))
1919
#define _m_dtor0_ __attribute__((destructor (111)))
2020

2121
/* Simple macro to automatically manage module lifecycle and callbacks */

Samples/Easy/doggo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static void m_mod_on_evt(m_mod_t *mod, const m_queue_t *const evts) {
6464
* Test runtime module loading; loaded module won't have direct access to CTX.
6565
* We own a ref on it!
6666
*/
67-
m_mod_register("./libtestmod.so", m_mod_ctx(mod), &plugin, NULL, M_MOD_DENY_CTX, NULL);
67+
m_mod_register("./libtestmod.so", m_ctx(), &plugin, NULL, M_MOD_DENY_CTX, NULL);
6868
} else if (!strcmp((char *)msg->ps_evt->data, "ByeBye")) {
6969
m_mod_log(mod, "Sob...\n");
7070
} else if (!strcmp((char *)msg->ps_evt->data, "WakeUp")) {
@@ -87,7 +87,7 @@ static void m_mod_on_evt_sleeping(m_mod_t *mod, const m_queue_t *const evts) {
8787
if (!strcmp((char *)msg->ps_evt->data, "WakeUp")) {
8888
m_mod_unbecome(mod);
8989
m_mod_log(mod, "Yawn...\n");
90-
m_ctx_dump(m_mod_ctx(mod));
90+
m_ctx_dump(m_ctx());
9191
m_mod_deregister(&plugin);
9292
m_mod_src_deregister(mod, M_PS_MOD_STARTED);
9393
} else {

Samples/Easy/pippo.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static bool m_mod_on_start(m_mod_t *mod) {
4242
doggo = m_mod_lookup(mod, "Doggo");
4343

4444
// let context tick every 5s and subscribe to it
45-
m_ctx_set_tick(m_mod_ctx(mod), (uint64_t)5 * 1000 * 1000 * 1000);
45+
m_ctx_set_tick(m_ctx(), (uint64_t)5 * 1000 * 1000 * 1000);
4646
m_mod_src_register(mod, M_PS_CTX_TICK, 0, NULL);
4747
return true;
4848
}
@@ -86,7 +86,7 @@ static void m_mod_on_evt(m_mod_t *mod, const m_queue_t *const evts) {
8686
case 'q':
8787
m_mod_log(mod, "I have to go now!\n");
8888
m_mod_ps_publish(mod, "leaving", "ByeBye", 0);
89-
m_ctx_quit(m_mod_ctx(mod), 0);
89+
m_ctx_quit(m_ctx(), 0);
9090
break;
9191
default:
9292
/* Avoid newline */
@@ -96,7 +96,7 @@ static void m_mod_on_evt(m_mod_t *mod, const m_queue_t *const evts) {
9696
break;
9797
}
9898
} else if (strcmp((char *)msg->ps_evt->data, "BauBau") == 0) {
99-
m_ctx_dump(m_mod_ctx(mod));
99+
m_ctx_dump(m_ctx());
100100
m_mod_become(mod, m_mod_on_evt_ready);
101101
m_mod_log(mod, "Press 'p' to play with Doggo! Or 'f' to feed your Doggo. 's' to have a nap. 'w' to wake him up. 'q' to leave him for now.\n");
102102
}
@@ -146,7 +146,7 @@ static void m_mod_on_evt_ready(m_mod_t *mod, const m_queue_t *const evts) {
146146
m_mod_dump(mod);
147147
m_mod_log(mod, "I have to go now!\n");
148148
m_mod_ps_publish(mod, "leaving", "ByeBye", 0);
149-
m_ctx_quit(m_mod_ctx(mod), 0);
149+
m_ctx_quit(m_ctx(), 0);
150150
break;
151151
default:
152152
/* Avoid newline */
@@ -159,7 +159,7 @@ static void m_mod_on_evt_ready(m_mod_t *mod, const m_queue_t *const evts) {
159159
m_mod_log(mod, "Received ctx tick.\n");
160160
if (++tick_ctr == 5) {
161161
m_mod_log(mod, "Stop playing and get back to do stuff!\n");
162-
m_ctx_quit(m_mod_ctx(mod), -EPIPE);
162+
m_ctx_quit(m_ctx(), -EPIPE);
163163
}
164164
}
165165
});

Samples/Poll/pippo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static void m_mod_on_evt(m_mod_t *mod, const m_queue_t *const evts) {
5959
case 'q':
6060
m_mod_log(mod,"I have to go now!\n");
6161
m_mod_ps_publish(mod, "leaving", "ByeBye", 0);
62-
m_ctx_quit(m_mod_ctx(mod), 0);
62+
m_ctx_quit(m_ctx(), 0);
6363
break;
6464
default:
6565
/* Avoid newline */
@@ -99,7 +99,7 @@ static void m_mod_on_evt_ready(m_mod_t *mod, const m_queue_t *const evts) {
9999
case 'p':
100100
m_mod_log(mod,"Doggo, let's play a bit!\n");
101101
m_mod_ps_tell(mod, doggo, "LetsPlay", 0);
102-
m_ctx_dump(m_mod_ctx(mod));
102+
m_ctx_dump(m_ctx());
103103
break;
104104
case 's':
105105
m_mod_log(mod,"Doggo, you should sleep a bit!\n");
@@ -116,7 +116,7 @@ static void m_mod_on_evt_ready(m_mod_t *mod, const m_queue_t *const evts) {
116116
case 'q':
117117
m_mod_log(mod, "I have to go now!\n");
118118
m_mod_ps_publish(mod, "leaving", "ByeBye", 0);
119-
m_ctx_quit(m_mod_ctx(mod), 0);
119+
m_ctx_quit(m_ctx(), 0);
120120
break;
121121
default:
122122
/* Avoid newline */

Samples/SharedSrc/mod.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static void A_recv(m_mod_t *mod, const m_queue_t *const evts) {
6161
case 'q':
6262
m_mod_log(mod, "I have to go now!\n");
6363
m_mod_ps_publish(mod, "leaving", (unsigned char *)"ByeBye", 0);
64-
m_ctx_quit(m_mod_ctx(mod), 0);
64+
m_ctx_quit(m_ctx(), 0);
6565
break;
6666
default:
6767
/* Avoid newline */
@@ -106,7 +106,7 @@ static void A_recv_ready(m_mod_t *mod, const m_queue_t *const evts) {
106106
case 'q':
107107
m_mod_log(mod, "I have to go now!\n");
108108
m_mod_ps_publish(mod, "leaving", (unsigned char *)"ByeBye", 0);
109-
m_ctx_quit(m_mod_ctx(mod), 0);
109+
m_ctx_quit(m_ctx(), 0);
110110
break;
111111
default:
112112
/* Avoid newline */

Samples/Task/pippo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static void m_mod_on_evt(m_mod_t *mod, const m_queue_t *const evts) {
5050
int *data = (int *)msg->userdata;
5151
if (*data == 5) {
5252
m_mod_log(mod, "Timed out.\n");
53-
m_ctx_quit(m_mod_ctx(mod), 0);
53+
m_ctx_quit(m_ctx(), 0);
5454
m_mod_log(mod,"Final data val: %d\n", thData);
5555
} else {
5656
(*data)++;

0 commit comments

Comments
 (0)