kernel: support using thread local storage for errno

This enables storing errno in the thread local storage area.
With this enabled, a syscall to access errno can be avoided
when userspace is also enabled.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2020-10-05 14:54:45 -07:00 committed by Andrew Boie
commit 62cf1960ad
5 changed files with 35 additions and 3 deletions

View file

@ -23,6 +23,11 @@
const int _k_neg_eagain = -EAGAIN;
#ifdef CONFIG_ERRNO
#ifdef CONFIG_ERRNO_IN_TLS
__thread int z_errno_var;
#else
#ifdef CONFIG_USERSPACE
int *z_impl_z_errno(void)
{
@ -44,4 +49,7 @@ int *z_impl_z_errno(void)
return &_current->errno_var;
}
#endif /* CONFIG_USERSPACE */
#endif /* CONFIG_ERRNO_IN_TLS */
#endif /* CONFIG_ERRNO */