diff options
| author | Meco Man <[email protected]> | 2023-09-19 01:50:22 -0400 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2023-09-19 23:02:43 -0400 |
| commit | 7732f8618b197e2d6ddc66c06a0978ed7834151b (patch) | |
| tree | 473d1adc57c8fb42a1058a39995ba2c07c87e8fc /components/libc/compilers | |
| parent | 8e6f9cf1be2b08704ff02992dc57d3022bfb073a (diff) | |
[picolibc] fix the errno declaration conflict
/home/runner/work/rt-thread/rt-thread/components/libc/compilers/picolibc/syscall.c:13:5: error: conflicting types for 'pico_get_errno'
int pico_get_errno(void)
^
/opt/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64/bin/../lib/clang-runtimes/arm-none-eabi/armv7em_hard_fpv4_sp_d16/include/sys/errno.h:59:6: note: previous declaration is here
int *__PICOLIBC_ERRNO_FUNCTION(void);
Diffstat (limited to 'components/libc/compilers')
| -rw-r--r-- | components/libc/compilers/picolibc/syscall.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/components/libc/compilers/picolibc/syscall.c b/components/libc/compilers/picolibc/syscall.c index ba496c6864..c2e45624f9 100644 --- a/components/libc/compilers/picolibc/syscall.c +++ b/components/libc/compilers/picolibc/syscall.c @@ -9,13 +9,31 @@ */ #include <rtthread.h> +#include <sys/types.h> -int pico_get_errno(void) +/* global errno */ +static volatile int __pico_errno; + +int *pico_get_errno(void) { - return rt_get_errno(); + rt_thread_t tid = RT_NULL; + + if (rt_interrupt_get_nest() != 0) + { + /* it's in interrupt context */ + return &__pico_errno; + } + + tid = rt_thread_self(); + if (tid == RT_NULL) + { + return &__pico_errno; + } + + return &tid->error; } -#ifdef RT_USING_HEAP /* Memory routine */ +#ifdef RT_USING_HEAP void *malloc(size_t n) { return rt_malloc(n); @@ -39,4 +57,4 @@ void free(void *rmem) rt_free(rmem); } RTM_EXPORT(free); -#endif +#endif /* RT_USING_HEAP */ |
