Skip to content

Commit 0984aed

Browse files
keith-packardcarlescufi
authored andcommitted
libc/picolibc: When !TLS, use zephyr errno
For targets without thread local storage, we need to use the builtin per-thread errno support provided by Zephyr as the multi-thread errno support provided in picolibc relies on TLS. Signed-off-by: Keith Packard <[email protected]>
1 parent d81b3d7 commit 0984aed

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

lib/libc/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ config MINIMAL_LIBC
3838

3939
config PICOLIBC
4040
bool "Picolibc library"
41-
select LIBC_ERRNO
4241
select THREAD_LOCAL_STORAGE if ARCH_HAS_THREAD_LOCAL_STORAGE
42+
select LIBC_ERRNO if THREAD_LOCAL_STORAGE
4343
depends on !NATIVE_APPLICATION
4444
help
4545
Build with picolibc library. The picolibc library is built as

lib/libc/picolibc/libc-hooks.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,3 +448,17 @@ void abort(void)
448448
k_panic();
449449
CODE_UNREACHABLE;
450450
}
451+
452+
#ifndef CONFIG_LIBC_ERRNO
453+
454+
/*
455+
* Picolibc needs to be able to declare this itself so that the library
456+
* doesn't end up needing zephyr header files. That means using a regular
457+
* function instead of an inline.
458+
*/
459+
int *z_errno_wrap(void)
460+
{
461+
return z_errno();
462+
}
463+
464+
#endif

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ manifest:
198198
path: modules/lib/openthread
199199
- name: picolibc
200200
path: modules/lib/picolibc
201-
revision: 4f8076520240192be284843a114c92853e29bbbc
201+
revision: e87b2fc37345a62361478f0a6efd140e14180ba5
202202
- name: segger
203203
revision: 3a52ab222133193802d3c3b4d21730b9b1f1d2f6
204204
path: modules/debug/segger

0 commit comments

Comments
 (0)