File tree Expand file tree Collapse file tree 4 files changed +22
-6
lines changed Expand file tree Collapse file tree 4 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -169,7 +169,7 @@ struct _mem_domain_info {
169169
170170#ifdef CONFIG_THREAD_USERSPACE_LOCAL_DATA
171171struct _thread_userspace_local_data {
172- #if defined(CONFIG_ERRNO ) && !defined(CONFIG_ERRNO_IN_TLS )
172+ #if defined(CONFIG_ERRNO ) && !defined(CONFIG_ERRNO_IN_TLS ) && !defined( CONFIG_LIBC_ERRNO )
173173 int errno_var ;
174174#endif
175175};
@@ -274,7 +274,7 @@ struct k_thread {
274274 struct _thread_userspace_local_data * userspace_local_data ;
275275#endif
276276
277- #if defined(CONFIG_ERRNO ) && !defined(CONFIG_ERRNO_IN_TLS )
277+ #if defined(CONFIG_ERRNO ) && !defined(CONFIG_ERRNO_IN_TLS ) && !defined( CONFIG_LIBC_ERRNO )
278278#ifndef CONFIG_USERSPACE
279279 /** per-thread errno variable */
280280 int errno_var ;
Original file line number Diff line number Diff line change @@ -17,7 +17,15 @@ extern "C" {
1717 * and kernel.h
1818 */
1919
20- #ifdef CONFIG_ERRNO_IN_TLS
20+ #ifdef CONFIG_LIBC_ERRNO
21+ #include <errno.h>
22+
23+ static inline int * z_errno (void )
24+ {
25+ return & errno ;
26+ }
27+
28+ #elif defined(CONFIG_ERRNO_IN_TLS )
2129extern __thread int z_errno_var ;
2230
2331static inline int * z_errno (void )
@@ -41,7 +49,7 @@ __syscall int *z_errno(void);
4149}
4250#endif
4351
44- #ifndef CONFIG_ERRNO_IN_TLS
52+ #if !defined( CONFIG_ERRNO_IN_TLS ) && !defined( CONFIG_LIBC_ERRNO )
4553#include <syscalls/errno_private.h>
4654#endif /* CONFIG_ERRNO_IN_TLS */
4755
Original file line number Diff line number Diff line change @@ -204,6 +204,12 @@ config THREAD_USERSPACE_LOCAL_DATA
204204 depends on USERSPACE
205205 default y if ERRNO && !ERRNO_IN_TLS
206206
207+ config LIBC_ERRNO
208+ bool
209+ help
210+ Use external libc errno, not the internal one. This eliminates any
211+ locally allocated errno storage and usage.
212+
207213config ERRNO
208214 bool "Errno support"
209215 default y
@@ -215,7 +221,7 @@ config ERRNO
215221
216222config ERRNO_IN_TLS
217223 bool "Store errno in thread local storage (TLS)"
218- depends on ERRNO && THREAD_LOCAL_STORAGE
224+ depends on ERRNO && THREAD_LOCAL_STORAGE && !LIBC_ERRNO
219225 default y
220226 help
221227 Use thread local storage to store errno instead of storing it in
Original file line number Diff line number Diff line change @@ -24,7 +24,9 @@ const int _k_neg_eagain = -EAGAIN;
2424
2525#ifdef CONFIG_ERRNO
2626
27- #ifdef CONFIG_ERRNO_IN_TLS
27+ #if defined(CONFIG_LIBC_ERRNO )
28+ /* nothing needed here */
29+ #elif defined(CONFIG_ERRNO_IN_TLS )
2830__thread int z_errno_var ;
2931#else
3032
You can’t perform that action at this time.
0 commit comments