diff --git a/py/mpconfig.h b/py/mpconfig.h
index 618b8fde5f7324755d0cfda1e126c737d9b4df35..4efe21d4b5ee6dc66b2fe8641f55c91804b63e2e 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -431,10 +431,10 @@ typedef double mp_float_t;
 
 // On embedded platforms, these will typically enable/disable irqs.
 #ifndef MICROPY_BEGIN_ATOMIC_SECTION
-#define MICROPY_BEGIN_ATOMIC_SECTION()
+#define MICROPY_BEGIN_ATOMIC_SECTION() (0)
 #endif
 #ifndef MICROPY_END_ATOMIC_SECTION
-#define 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
diff --git a/py/objexcept.c b/py/objexcept.c
index 9b22acd995cf90d068f22a3ec6f0e0490a0c37a7..a9c0436e2868c7e3fbcc5225ee50ce3275046546 100644
--- a/py/objexcept.c
+++ b/py/objexcept.c
@@ -88,10 +88,10 @@ mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in) {
 
     // Update the 2 variables atomically so that an interrupt can't occur
     // between the assignments.
-    mp_uint_t irq_state = MICROPY_BEGIN_ATOMIC_SECTION();
+    mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION();
     mp_emergency_exception_buf_size = size;
     mp_emergency_exception_buf = buf;
-    MICROPY_END_ATOMIC_SECTION(irq_state);
+    MICROPY_END_ATOMIC_SECTION(atomic_state);
 
     if (old_buf != NULL) {
         m_free(old_buf, old_size);