summaryrefslogtreecommitdiff
path: root/py/scheduler.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2020-05-02 17:49:15 +1000
committerDamien George <damien.p.george@gmail.com>2020-05-08 23:20:45 +1000
commitf792e6c283e90067919e083c5ce6db156c0cd0e2 (patch)
treed02b70b2fa800e621ec62c9fa818b28d0564c7bd /py/scheduler.c
parent0f83ef395cccaa771543450ff8a4200da108e3d6 (diff)
py/scheduler: Convert mp_sched_full and mp_sched_num_pending to macros.
So they are guaranteed to be inlined within functions like mp_sched_schedule which may be located in a special memory region.
Diffstat (limited to 'py/scheduler.c')
-rw-r--r--py/scheduler.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/py/scheduler.c b/py/scheduler.c
index 06d7b36c2..6b138a631 100644
--- a/py/scheduler.c
+++ b/py/scheduler.c
@@ -45,14 +45,14 @@ void MICROPY_WRAP_MP_KEYBOARD_INTERRUPT(mp_keyboard_interrupt)(void) {
#define IDX_MASK(i) ((i) & (MICROPY_SCHEDULER_DEPTH - 1))
-static inline bool mp_sched_full(void) {
+// This is a macro so it is guaranteed to be inlined in functions like
+// mp_sched_schedule that may be located in a special memory region.
+#define mp_sched_full() (mp_sched_num_pending() == MICROPY_SCHEDULER_DEPTH)
+
+static inline bool mp_sched_empty(void) {
MP_STATIC_ASSERT(MICROPY_SCHEDULER_DEPTH <= 255); // MICROPY_SCHEDULER_DEPTH must fit in 8 bits
MP_STATIC_ASSERT((IDX_MASK(MICROPY_SCHEDULER_DEPTH) == 0)); // MICROPY_SCHEDULER_DEPTH must be a power of 2
- return mp_sched_num_pending() == MICROPY_SCHEDULER_DEPTH;
-}
-
-static inline bool mp_sched_empty(void) {
return mp_sched_num_pending() == 0;
}