Skip to content

Commit

Permalink
libc: add option for c11 threads
Browse files Browse the repository at this point in the history
Add a config option for C11 threads.

Signed-off-by: Christopher Friedt <[email protected]>
  • Loading branch information
cfriedt-friedtco authored and stephanosio committed Mar 27, 2024
1 parent 822807a commit 5dfdb4b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
10 changes: 10 additions & 0 deletions config/libc.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ config LIBC_SUPPORT_THREADS_POSIX
bool
select LIBC_SUPPORT_THREADS_ANY

config LIBC_SUPPORT_THREADS_C11
bool
select LIBC_SUPPORT_THREADS_ANY

config LIBC_SUPPORT_THREADS_NONE
bool

Expand All @@ -40,6 +44,7 @@ choice
default THREADS_NATIVE if LIBC_SUPPORT_THREADS_NATIVE
default THREADS_LT if LIBC_SUPPORT_THREADS_LT
default THREADS_POSIX if LIBC_SUPPORT_THREADS_POSIX
default THREADS_C11 if LIBC_SUPPORT_THREADS_C11
default THREADS_NONE

config THREADS_NATIVE
Expand All @@ -63,6 +68,11 @@ config THREADS_POSIX
prompt "posix"
depends on LIBC_SUPPORT_THREADS_POSIX

config THREADS_C11
bool
prompt "c11"
depends on LIBC_SUPPORT_THREADS_C11

config THREADS_NONE
bool
prompt "none"
Expand Down
4 changes: 4 additions & 0 deletions config/libc/newlib.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## depends on BARE_METAL
## select LIBC_PROVIDES_CXA_ATEXIT
## select LIBC_SUPPORT_THREADS_C11
## select LIBC_SUPPORT_THREADS_NONE
## select CC_CORE_NEEDED

Expand All @@ -12,6 +13,9 @@
## help array of processors, and will usually work on any architecture with
## help the addition of a few low-level routines.

config THREADS
default "c11" if THREADS_C11

config LIBC_NEWLIB_TARGET_CFLAGS
string
prompt "Target CFLAGS for newlib"
Expand Down
23 changes: 14 additions & 9 deletions scripts/build/cc/gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1073,16 +1073,21 @@ do_gcc_backend() {
extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}")
fi

if [ "${CT_THREADS}" = "none" ]; then
case "${CT_THREADS}" in
none)
extra_config+=("--disable-threads")
else
if [ "${CT_THREADS}" = "win32" ]; then
extra_config+=("--enable-threads=win32")
extra_config+=("--disable-win32-registry")
else
extra_config+=("--enable-threads=posix")
fi
fi
;;
win32)
extra_config+=("--enable-threads=win32")
extra_config+=("--disable-win32-registry")
;;
c11)
extra_config+=("--enable-threads=c11")
;;
*)
extra_config+=("--enable-threads=posix")
;;
esac

if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ] || \
[ "${enable_optspace}" = "yes" ]; then
Expand Down

0 comments on commit 5dfdb4b

Please sign in to comment.