Skip to content

Commit 37b8b62

Browse files
committed
[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);
1 parent 6064079 commit 37b8b62

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

components/libc/compilers/picolibc/syscall.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,31 @@
99
*/
1010

1111
#include <rtthread.h>
12+
#include <sys/types.h>
1213

13-
int pico_get_errno(void)
14+
/* global errno */
15+
static volatile int __pico_errno;
16+
17+
int *pico_get_errno(void)
1418
{
15-
return rt_get_errno();
19+
rt_thread_t tid = RT_NULL;
20+
21+
if (rt_interrupt_get_nest() != 0)
22+
{
23+
/* it's in interrupt context */
24+
return &__pico_errno;
25+
}
26+
27+
tid = rt_thread_self();
28+
if (tid == RT_NULL)
29+
{
30+
return &__pico_errno;
31+
}
32+
33+
return &tid->error;
1634
}
1735

18-
#ifdef RT_USING_HEAP /* Memory routine */
36+
#ifdef RT_USING_HEAP
1937
void *malloc(size_t n)
2038
{
2139
return rt_malloc(n);
@@ -39,4 +57,4 @@ void free(void *rmem)
3957
rt_free(rmem);
4058
}
4159
RTM_EXPORT(free);
42-
#endif
60+
#endif /* RT_USING_HEAP */

0 commit comments

Comments
 (0)