diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-05-26 09:14:26 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-05-26 12:39:34 -0400 |
commit | a82e949c00aceaedd9d9a76ddcc3c88c9cad3d80 (patch) | |
tree | 685af9ff540b0407cfb0f96664fc3dccbc160152 /src/sched.h | |
parent | ca9756413f2793279b5ba1c1ecf274ce734b2087 (diff) | |
download | kutter-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.h')
-rw-r--r-- | src/sched.h | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/sched.h b/src/sched.h index 9d6411d0..ad5c2c08 100644 --- a/src/sched.h +++ b/src/sched.h @@ -2,14 +2,14 @@ #define __SCHED_H #include <stdint.h> // uint32_t -#include "compiler.h" // __section +#include "ctr.h" // DECL_CTR // Declare an init function (called at firmware startup) -#define DECL_INIT(FUNC) _DECL_CALLBACK(initfuncs, FUNC) +#define DECL_INIT(FUNC) _DECL_CALLLIST(ctr_run_initfuncs, FUNC) // Declare a task function (called periodically during normal runtime) -#define DECL_TASK(FUNC) _DECL_CALLBACK(taskfuncs, FUNC) +#define DECL_TASK(FUNC) _DECL_CALLLIST(ctr_run_taskfuncs, FUNC) // Declare a shutdown function (called on an emergency stop) -#define DECL_SHUTDOWN(FUNC) _DECL_CALLBACK(shutdownfuncs, FUNC) +#define DECL_SHUTDOWN(FUNC) _DECL_CALLLIST(ctr_run_shutdownfuncs, FUNC) // Timer structure for scheduling timed events (see sched_add_timer() ) struct timer { @@ -33,15 +33,7 @@ void sched_report_shutdown(void); void sched_main(void); // Compiler glue for DECL_X macros above. -struct callback_handler { - void (*func)(void); -}; -#define _DECL_CALLBACK(NAME, FUNC) \ - const struct callback_handler _DECL_ ## NAME ## _ ## FUNC __visible \ - __section(".rodata." __stringify(NAME) ) = { .func = FUNC } - -#define foreachdecl(ITER, NAME) \ - extern typeof(*ITER) NAME ## _start[], NAME ## _end[]; \ - for (ITER = NAME ## _start ; ITER < NAME ## _end ; ITER ++) +#define _DECL_CALLLIST(NAME, FUNC) \ + DECL_CTR("_DECL_CALLLIST " __stringify(NAME) " " __stringify(FUNC)) #endif // sched.h |