errno

Porting Method

  • Set Picolibc configuration newlib-global-errno to true, not using the TLS mechanism to implement errno;
  • Set Picolibc configuration errno-function to '__errno';
  • XWOS defines an __errno variable in each thread object structure and re-implements the int * __errno(void) function, returning the address of the current thread object’s __errno:
int * __errno(void)
{
        xwos_thd_d thdd = xwos_cthd_self();
        return &thdd.thd->osthd.libc.error_number;
}
  • When using the errno macro from <errno.h>, the thread’s own __errno can be obtained, no longer depending on libgloss.