summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/mpconfig.h9
-rw-r--r--py/nlrthumb.c6
2 files changed, 10 insertions, 5 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index a21a6c7075..e8f60bd77f 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -1527,6 +1527,15 @@ typedef double mp_float_t;
#define MP_UNLIKELY(x) __builtin_expect((x), 0)
#endif
+// To annotate that code is unreachable
+#ifndef MP_UNREACHABLE
+#if defined(__GNUC__)
+#define MP_UNREACHABLE __builtin_unreachable();
+#else
+#define MP_UNREACHABLE for (;;);
+#endif
+#endif
+
#ifndef MP_HTOBE16
#if MP_ENDIANNESS_LITTLE
# define MP_HTOBE16(x) ((uint16_t)( (((x) & 0xff) << 8) | (((x) >> 8) & 0xff) ))
diff --git a/py/nlrthumb.c b/py/nlrthumb.c
index eef05229d6..bc30388278 100644
--- a/py/nlrthumb.c
+++ b/py/nlrthumb.c
@@ -135,11 +135,7 @@ NORETURN void nlr_jump(void *val) {
: // clobbered registers
);
- #if defined(__GNUC__)
- __builtin_unreachable();
- #else
- for (;;); // needed to silence compiler warning
- #endif
+ MP_UNREACHABLE
}
#endif // MICROPY_NLR_THUMB