Skip to content

Commit

Permalink
[picolibc] fix the errno declaration conflict
Browse files Browse the repository at this point in the history
  /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);
  • Loading branch information
mysterywolf committed Sep 19, 2023
1 parent 6064079 commit 37b8b62
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions components/libc/compilers/picolibc/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -39,4 +57,4 @@ void free(void *rmem)
rt_free(rmem);
}
RTM_EXPORT(free);
#endif
#endif /* RT_USING_HEAP */

0 comments on commit 37b8b62

Please sign in to comment.