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>
This commit is contained in:
Alessandro Gatti 2024-10-02 23:46:14 +02:00 committed by Damien George
parent 6760e00817
commit 1857e62fdc

View file

@ -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)