aboutsummaryrefslogtreecommitdiffstats
path: root/src/sched.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-05-26 09:14:26 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-05-26 12:39:34 -0400
commita82e949c00aceaedd9d9a76ddcc3c88c9cad3d80 (patch)
tree685af9ff540b0407cfb0f96664fc3dccbc160152 /src/sched.c
parentca9756413f2793279b5ba1c1ecf274ce734b2087 (diff)
downloadkutter-a82e949c00aceaedd9d9a76ddcc3c88c9cad3d80.tar.gz
kutter-a82e949c00aceaedd9d9a76ddcc3c88c9cad3d80.tar.xz
kutter-a82e949c00aceaedd9d9a76ddcc3c88c9cad3d80.zip
build: Use compile_time_request system for init, tasks, and shutdown
Avoid using linker magic to define the init, task, and shutdown functions. Instead, use the compile_time_request system. This simplifies the build and produces more efficient code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/sched.c')
-rw-r--r--src/sched.c40
1 files changed, 9 insertions, 31 deletions
diff --git a/src/sched.c b/src/sched.c
index f82b0060..542e3747 100644
--- a/src/sched.c
+++ b/src/sched.c
@@ -1,6 +1,6 @@
// Basic scheduling functions and startup/shutdown code.
//
-// Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net>
+// Copyright (C) 2016,2017 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU GPLv3 license.
@@ -167,7 +167,7 @@ sched_timer_dispatch(void)
}
// Shutdown all user timers on an emergency stop.
-static void
+void
sched_timer_shutdown(void)
{
timer_list = &deleted_timer;
@@ -209,11 +209,8 @@ run_shutdown(void)
{
uint32_t cur = timer_read_time();
shutdown_status = 2;
- struct callback_handler *p;
- foreachdecl(p, shutdownfuncs) {
- void (*func)(void) = READP(p->func);
- func();
- }
+ extern void ctr_run_shutdownfuncs(void);
+ ctr_run_shutdownfuncs();
shutdown_status = 1;
irq_enable();
@@ -252,39 +249,20 @@ sched_shutdown(uint_fast8_t reason)
* Startup and background task processing
****************************************************************/
-// Invoke all init functions (as declared by DECL_INIT)
-static void
-run_init(void)
-{
- struct callback_handler *p;
- foreachdecl(p, initfuncs) {
- void (*func)(void) = READP(p->func);
- func();
- }
-}
-
-// Invoke all background task functions (as declared by DECL_TASK)
-static void
-run_task(void)
-{
- struct callback_handler *p;
- foreachdecl(p, taskfuncs) {
- irq_poll();
- void (*func)(void) = READP(p->func);
- func();
- }
-}
+// Auto-generated code in out/compile_time_requests.c
+extern void ctr_run_initfuncs(void);
+extern void ctr_run_taskfuncs(void);
// Main loop of program
void
sched_main(void)
{
- run_init();
+ ctr_run_initfuncs();
int ret = setjmp(shutdown_jmp);
if (ret)
run_shutdown();
for (;;)
- run_task();
+ ctr_run_taskfuncs();
}