From feaab27c1ba0fb9af8a0ad9d48f9f9ffa03a6510 Mon Sep 17 00:00:00 2001 From: Stephanos Ioannidis Date: Thu, 8 Dec 2022 20:54:28 +0900 Subject: [PATCH] lib: cpp: Relocate subsys/cpp to lib/cpp This commit moves the files under `subsys/cpp` directory to the `lib/cpp` directory because the C++ ABI runtime library and the standard C++ library components are not a "subsystem" (aka. API) in conventional sense and is better described as a "library." Classifying the C++ ABI runtime library and the standard C++ library as "libraries" instead of "subsystems" also better aligns with how the existing C standard library implementation (`lib/libc`) is handled. Signed-off-by: Stephanos Ioannidis --- MAINTAINERS.yml | 6 +++--- doc/develop/languages/cpp/index.rst | 14 +++++++------- lib/CMakeLists.txt | 1 + lib/Kconfig | 2 ++ {subsys => lib}/cpp/CMakeLists.txt | 0 {subsys => lib}/cpp/Kconfig | 0 {subsys => lib}/cpp/cpp_ctors.c | 0 {subsys => lib}/cpp/cpp_dtors.c | 0 {subsys => lib}/cpp/cpp_init.c | 0 {subsys => lib}/cpp/cpp_init_array.c | 0 {subsys => lib}/cpp/cpp_new.cpp | 0 {subsys => lib}/cpp/cpp_virtual.c | 0 {subsys => lib}/cpp/cpp_vtable.cpp | 0 {subsys => lib}/cpp/include/cstddef | 0 {subsys => lib}/cpp/include/cstdint | 0 {subsys => lib}/cpp/include/new | 0 subsys/CMakeLists.txt | 1 - subsys/Kconfig | 2 -- 18 files changed, 13 insertions(+), 13 deletions(-) rename {subsys => lib}/cpp/CMakeLists.txt (100%) rename {subsys => lib}/cpp/Kconfig (100%) rename {subsys => lib}/cpp/cpp_ctors.c (100%) rename {subsys => lib}/cpp/cpp_dtors.c (100%) rename {subsys => lib}/cpp/cpp_init.c (100%) rename {subsys => lib}/cpp/cpp_init_array.c (100%) rename {subsys => lib}/cpp/cpp_new.cpp (100%) rename {subsys => lib}/cpp/cpp_virtual.c (100%) rename {subsys => lib}/cpp/cpp_vtable.cpp (100%) rename {subsys => lib}/cpp/include/cstddef (100%) rename {subsys => lib}/cpp/include/cstdint (100%) rename {subsys => lib}/cpp/include/new (100%) diff --git a/MAINTAINERS.yml b/MAINTAINERS.yml index 8705c98b607..5e662fcfb05 100644 --- a/MAINTAINERS.yml +++ b/MAINTAINERS.yml @@ -286,9 +286,9 @@ Build system: - alexanderwachter - cfriedt files: - - subsys/cpp/ - - tests/subsys/cpp/ - - samples/subsys/cpp/ + - lib/cpp/ + - tests/lib/cpp/ + - samples/cpp/ labels: - "area: C++" diff --git a/doc/develop/languages/cpp/index.rst b/doc/develop/languages/cpp/index.rst index 1e556cf61c8..28364c41e73 100644 --- a/doc/develop/languages/cpp/index.rst +++ b/doc/develop/languages/cpp/index.rst @@ -63,19 +63,19 @@ In order to make use of the C++ exceptions, the :kconfig:option:`CONFIG_EXCEPTIONS` must be selected in the application configuration file. -Zephyr C++ Subsystem -******************** +Zephyr Minimal C++ Library +************************** -Zephyr C++ subsystem (:file:`subsys/cpp`) provides a minimal subset of the C++ -standard library and application binary interface (ABI) functions to enable -basic C++ language support. This includes: +Zephyr minimal C++ library (:file:`lib/cpp/minimal`) provides a minimal subset +of the C++ standard library and application binary interface (ABI) functions to +enable basic C++ language support. This includes: * ``new`` and ``delete`` operators * virtual function stub and vtables * static global initializers for global constructors -The scope of the C++ subsystem is strictly limited to providing the basic C++ -language support, and it does not implement any `Standard Template Library +The scope of the minimal C++ library is strictly limited to providing the basic +C++ language support, and it does not implement any `Standard Template Library (STL)`_ classes and functions. For this reason, it is only suitable for use in the applications that implement their own (non-standard) class library and do rely on the Standard Template Library (STL) components. diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index db2193a1ca8..c67789cec36 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -4,6 +4,7 @@ if(NOT CONFIG_EXTERNAL_LIBC) add_subdirectory(libc) add_subdirectory(posix) endif() +add_subdirectory_ifdef(CONFIG_CPLUSPLUS cpp) add_subdirectory(os) add_subdirectory(util) add_subdirectory_ifdef(CONFIG_SMF smf) diff --git a/lib/Kconfig b/lib/Kconfig index f3f30085b34..982d4f7a559 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -3,6 +3,8 @@ source "lib/libc/Kconfig" +source "lib/cpp/Kconfig" + menu "Additional libraries" source "lib/os/Kconfig" diff --git a/subsys/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt similarity index 100% rename from subsys/cpp/CMakeLists.txt rename to lib/cpp/CMakeLists.txt diff --git a/subsys/cpp/Kconfig b/lib/cpp/Kconfig similarity index 100% rename from subsys/cpp/Kconfig rename to lib/cpp/Kconfig diff --git a/subsys/cpp/cpp_ctors.c b/lib/cpp/cpp_ctors.c similarity index 100% rename from subsys/cpp/cpp_ctors.c rename to lib/cpp/cpp_ctors.c diff --git a/subsys/cpp/cpp_dtors.c b/lib/cpp/cpp_dtors.c similarity index 100% rename from subsys/cpp/cpp_dtors.c rename to lib/cpp/cpp_dtors.c diff --git a/subsys/cpp/cpp_init.c b/lib/cpp/cpp_init.c similarity index 100% rename from subsys/cpp/cpp_init.c rename to lib/cpp/cpp_init.c diff --git a/subsys/cpp/cpp_init_array.c b/lib/cpp/cpp_init_array.c similarity index 100% rename from subsys/cpp/cpp_init_array.c rename to lib/cpp/cpp_init_array.c diff --git a/subsys/cpp/cpp_new.cpp b/lib/cpp/cpp_new.cpp similarity index 100% rename from subsys/cpp/cpp_new.cpp rename to lib/cpp/cpp_new.cpp diff --git a/subsys/cpp/cpp_virtual.c b/lib/cpp/cpp_virtual.c similarity index 100% rename from subsys/cpp/cpp_virtual.c rename to lib/cpp/cpp_virtual.c diff --git a/subsys/cpp/cpp_vtable.cpp b/lib/cpp/cpp_vtable.cpp similarity index 100% rename from subsys/cpp/cpp_vtable.cpp rename to lib/cpp/cpp_vtable.cpp diff --git a/subsys/cpp/include/cstddef b/lib/cpp/include/cstddef similarity index 100% rename from subsys/cpp/include/cstddef rename to lib/cpp/include/cstddef diff --git a/subsys/cpp/include/cstdint b/lib/cpp/include/cstdint similarity index 100% rename from subsys/cpp/include/cstdint rename to lib/cpp/include/cstdint diff --git a/subsys/cpp/include/new b/lib/cpp/include/new similarity index 100% rename from subsys/cpp/include/new rename to lib/cpp/include/new diff --git a/subsys/CMakeLists.txt b/subsys/CMakeLists.txt index c59492e7725..1ec4d511880 100644 --- a/subsys/CMakeLists.txt +++ b/subsys/CMakeLists.txt @@ -6,7 +6,6 @@ add_subdirectory_ifdef(CONFIG_LORAWAN lorawan) add_subdirectory_ifdef(CONFIG_BT bluetooth) add_subdirectory_ifdef(CONFIG_CONSOLE_SUBSYS console) add_subdirectory_ifdef(CONFIG_SHELL shell) -add_subdirectory_ifdef(CONFIG_CPLUSPLUS cpp) add_subdirectory_ifdef(CONFIG_DISK_ACCESS disk) add_subdirectory_ifdef(CONFIG_EMUL emul) add_subdirectory(fs) diff --git a/subsys/Kconfig b/subsys/Kconfig index ba337e38d04..bf718b90155 100644 --- a/subsys/Kconfig +++ b/subsys/Kconfig @@ -12,8 +12,6 @@ source "subsys/canbus/Kconfig" source "subsys/console/Kconfig" -source "subsys/cpp/Kconfig" - source "subsys/debug/Kconfig" source "subsys/disk/Kconfig"