diff options
author | Damien George <damien@micropython.org> | 2023-12-01 13:24:19 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-12-01 14:14:08 +1100 |
commit | bfdf500ea5756a4f0f2f8b384389b6f70af69526 (patch) | |
tree | f8bdacef1eccb814e54c602e3cb2783ae3a53c93 /py | |
parent | 7d784e53853db7935112d5952aee13c19b539255 (diff) | |
download | micropython-bfdf500ea5756a4f0f2f8b384389b6f70af69526.tar.gz micropython-bfdf500ea5756a4f0f2f8b384389b6f70af69526.zip |
py/mphal: Move configuration of ATOMIC_SECTION macros to mphal.h.
MICROPY_BEGIN_ATOMIC_SECTION/MICROPY_END_ATOMIC_SECTION belong more to the
MicroPython HAL rather than build configuration settings, so move their
default configuration to py/mphal.h, and require all users of these macros
to include py/mphal.h (here, py/objexcept.c and py/scheduler.c).
This helps ports separate configuration from their HAL implementations, and
can improve build times (because mpconfig.h is included everywhere, whereas
mphal.h is not).
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py')
-rw-r--r-- | py/mpconfig.h | 8 | ||||
-rw-r--r-- | py/mphal.h | 8 | ||||
-rw-r--r-- | py/objexcept.c | 2 | ||||
-rw-r--r-- | py/scheduler.c | 1 |
4 files changed, 11 insertions, 8 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h index 6995600abe..d14b1aa044 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1850,14 +1850,6 @@ typedef double mp_float_t; #endif #endif -// On embedded platforms, these will typically enable/disable irqs. -#ifndef MICROPY_BEGIN_ATOMIC_SECTION -#define MICROPY_BEGIN_ATOMIC_SECTION() (0) -#endif -#ifndef MICROPY_END_ATOMIC_SECTION -#define MICROPY_END_ATOMIC_SECTION(state) (void)(state) -#endif - // Allow to override static modifier for global objects, e.g. to use with // object code analysis tools which don't support static symbols. #ifndef STATIC diff --git a/py/mphal.h b/py/mphal.h index 0d4b1224e5..19fceef718 100644 --- a/py/mphal.h +++ b/py/mphal.h @@ -35,6 +35,14 @@ #include <mphalport.h> #endif +// On embedded platforms, these will typically enable/disable irqs. +#ifndef MICROPY_BEGIN_ATOMIC_SECTION +#define MICROPY_BEGIN_ATOMIC_SECTION() (0) +#endif +#ifndef MICROPY_END_ATOMIC_SECTION +#define MICROPY_END_ATOMIC_SECTION(state) (void)(state) +#endif + #ifndef mp_hal_stdio_poll uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags); #endif diff --git a/py/objexcept.c b/py/objexcept.c index a54b81370d..fe74458cae 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -81,6 +81,8 @@ void mp_init_emergency_exception_buf(void) { #else #define mp_emergency_exception_buf_size MP_STATE_VM(mp_emergency_exception_buf_size) +#include "py/mphal.h" // for MICROPY_BEGIN_ATOMIC_SECTION/MICROPY_END_ATOMIC_SECTION + void mp_init_emergency_exception_buf(void) { mp_emergency_exception_buf_size = 0; MP_STATE_VM(mp_emergency_exception_buf) = NULL; diff --git a/py/scheduler.c b/py/scheduler.c index 165b26dc86..b9a43bfbdb 100644 --- a/py/scheduler.c +++ b/py/scheduler.c @@ -26,6 +26,7 @@ #include <stdio.h> +#include "py/mphal.h" #include "py/runtime.h" // Schedules an exception on the main thread (for exceptions "thrown" by async |