diff options
| author | Alessandro Gatti <a.gatti@frob.it> | 2024-10-02 23:46:14 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-12-23 10:02:42 +1100 |
| commit | 1857e62fdcb9a9fb0df987b2502ed98346457a6f (patch) | |
| tree | 294ce6e23ba7155b9c8963b3d7482d284c492826 /examples | |
| parent | 6760e00817ff6cb449134418411850fc577d0f9c (diff) | |
examples/natmod/re: Fix build on RV32 with alloca.
This fixes compilation of the `re` natmod example when built with Picolibc
in the CI environment. Ubuntu 22.04's combination of its bare metal RISC-V
toolchain and its version of Picolibc makes the `alloca` symbol more
elusive than it should be.
This commit makes the `re` natmod try harder to get an `alloca`
implementation.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/natmod/re/re.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/examples/natmod/re/re.c b/examples/natmod/re/re.c index eb6d13778..c0279ee7e 100644 --- a/examples/natmod/re/re.c +++ b/examples/natmod/re/re.c @@ -4,7 +4,20 @@ #define MICROPY_PY_RE_MATCH_SPAN_START_END (1) #define MICROPY_PY_RE_SUB (0) // requires vstr interface +#if defined __has_builtin +#if __has_builtin(__builtin_alloca) +#define alloca __builtin_alloca +#endif +#endif + +#if !defined(alloca) +#if defined(_PICOLIBC__) && !defined(HAVE_BUILTIN_ALLOCA) +#define alloca(n) m_malloc(n) +#else #include <alloca.h> +#endif +#endif + #include "py/dynruntime.h" #define STACK_LIMIT (2048) |
