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 <stephanos.ioannidis@nordicsemi.no>
This commit is contained in:
parent
9d2fe69b4e
commit
feaab27c1b
18 changed files with 13 additions and 13 deletions
|
@ -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)
|
||||
|
|
|
@ -12,8 +12,6 @@ source "subsys/canbus/Kconfig"
|
|||
|
||||
source "subsys/console/Kconfig"
|
||||
|
||||
source "subsys/cpp/Kconfig"
|
||||
|
||||
source "subsys/debug/Kconfig"
|
||||
|
||||
source "subsys/disk/Kconfig"
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_sources(cpp_init.c)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_CPP_STATIC_INIT_GNU
|
||||
cpp_init_array.c
|
||||
cpp_ctors.c
|
||||
cpp_dtors.c
|
||||
)
|
||||
|
||||
if (NOT CONFIG_LIB_CPLUSPLUS)
|
||||
zephyr_system_include_directories(
|
||||
include
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT CONFIG_LIB_CPLUSPLUS AND
|
||||
(NOT CONFIG_MINIMAL_LIBC OR
|
||||
(CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE GREATER 0)))
|
||||
zephyr_sources(
|
||||
cpp_virtual.c
|
||||
cpp_vtable.cpp
|
||||
cpp_new.cpp
|
||||
)
|
||||
endif()
|
|
@ -1,97 +0,0 @@
|
|||
# C++ configuration options
|
||||
|
||||
# Copyright (c) 2018 B. Leforestier
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
menuconfig CPLUSPLUS
|
||||
bool "C++ support for the application"
|
||||
help
|
||||
This option enables the use of applications built with C++.
|
||||
|
||||
if CPLUSPLUS
|
||||
|
||||
choice
|
||||
prompt "C++ Standard"
|
||||
default STD_CPP11
|
||||
help
|
||||
C++ Standards.
|
||||
|
||||
config STD_CPP98
|
||||
bool "C++ 98"
|
||||
help
|
||||
1998 C++ standard as modified by the 2003 technical corrigendum
|
||||
and some later defect reports.
|
||||
|
||||
config STD_CPP11
|
||||
bool "C++ 11"
|
||||
help
|
||||
2011 C++ standard, previously known as C++0x.
|
||||
|
||||
config STD_CPP14
|
||||
bool "C++ 14"
|
||||
help
|
||||
2014 C++ standard.
|
||||
|
||||
config STD_CPP17
|
||||
bool "C++ 17"
|
||||
help
|
||||
2017 C++ standard, previously known as C++0x.
|
||||
|
||||
config STD_CPP2A
|
||||
bool "C++ 2a"
|
||||
help
|
||||
Next revision of the C++ standard, which is expected to be published in 2020.
|
||||
|
||||
config STD_CPP20
|
||||
bool "C++ 20"
|
||||
help
|
||||
2020 C++ standard, previously known as C++2A.
|
||||
|
||||
config STD_CPP2B
|
||||
bool "C++ 2b"
|
||||
help
|
||||
Next revision of the C++ standard, which is expected to be published in 2023.
|
||||
|
||||
endchoice
|
||||
|
||||
config CPP_MAIN
|
||||
bool "C++ main() function definition"
|
||||
help
|
||||
This option instructs the Zephyr kernel to call the 'int main(void)'
|
||||
instead of the 'void main(void)', which is the default main() type
|
||||
for Zephyr.
|
||||
|
||||
C++ does not allow the main() to be defined with 'void' return type,
|
||||
and any applications defining its main() in a C++ source file must
|
||||
enable this option.
|
||||
|
||||
config LIB_CPLUSPLUS
|
||||
bool "Link with STD C++ library"
|
||||
select REQUIRES_FULL_LIBC
|
||||
help
|
||||
Link with STD C++ Library.
|
||||
|
||||
if LIB_CPLUSPLUS
|
||||
|
||||
config EXCEPTIONS
|
||||
bool "C++ exceptions support"
|
||||
depends on !NEWLIB_LIBC_NANO
|
||||
help
|
||||
This option enables support of C++ exceptions.
|
||||
|
||||
config RTTI
|
||||
bool "C++ RTTI support"
|
||||
help
|
||||
This option enables support of C++ RTTI.
|
||||
|
||||
endif # LIB_CPLUSPLUS
|
||||
|
||||
config CPP_STATIC_INIT_GNU
|
||||
# As of today only ARC MWDT toolchain doesn't support GNU-compatible
|
||||
# initialization of CPP static objects, new toolchains can be added
|
||||
# here if required.
|
||||
def_bool "$(ZEPHYR_TOOLCHAIN_VARIANT)" != "arcmwdt"
|
||||
help
|
||||
GNU-compatible initialization of CPP static objects
|
||||
|
||||
endif # CPLUSPLUS
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2014 Wind River Systems, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file - Constructor module
|
||||
* @brief
|
||||
* The ctors section contains a list of function pointers that execute the
|
||||
* C++ constructors of static global objects. These must be executed before
|
||||
* the application's main() routine.
|
||||
*
|
||||
* NOTE: Not all compilers put those function pointers into the ctors section;
|
||||
* some put them into the init_array section instead.
|
||||
*/
|
||||
|
||||
/* What a constructor function pointer looks like */
|
||||
|
||||
typedef void (*CtorFuncPtr)(void);
|
||||
|
||||
/* Constructor function pointer list is generated by the linker script. */
|
||||
|
||||
extern CtorFuncPtr __ZEPHYR_CTOR_LIST__[];
|
||||
extern CtorFuncPtr __ZEPHYR_CTOR_END__[];
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Invoke all C++ style global object constructors
|
||||
*
|
||||
* This routine is invoked by the kernel prior to the execution of the
|
||||
* application's main().
|
||||
*/
|
||||
void __do_global_ctors_aux(void)
|
||||
{
|
||||
unsigned int nCtors;
|
||||
|
||||
nCtors = (unsigned long)__ZEPHYR_CTOR_LIST__[0];
|
||||
|
||||
while (nCtors >= 1U) {
|
||||
__ZEPHYR_CTOR_LIST__[nCtors--]();
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Wind River Systems, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* @file
|
||||
* @brief Basic C++ destructor module for globals
|
||||
*
|
||||
*/
|
||||
|
||||
#include <zephyr/toolchain.h>
|
||||
|
||||
__weak void *__dso_handle;
|
||||
|
||||
/**
|
||||
* @brief Register destructor for a global object
|
||||
*
|
||||
* @param destructor the global object destructor function
|
||||
* @param objptr global object pointer
|
||||
* @param dso Dynamic Shared Object handle for shared libraries
|
||||
*
|
||||
* Function does nothing at the moment, assuming the global objects
|
||||
* do not need to be deleted
|
||||
*
|
||||
* @retval 0 on success.
|
||||
*/
|
||||
int __cxa_atexit(void (*destructor)(void *), void *objptr, void *dso)
|
||||
{
|
||||
ARG_UNUSED(destructor);
|
||||
ARG_UNUSED(objptr);
|
||||
ARG_UNUSED(dso);
|
||||
return 0;
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Synopsys, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Author: Evgeniy Paltsev
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_CPP_STATIC_INIT_GNU
|
||||
|
||||
void __do_global_ctors_aux(void);
|
||||
void __do_init_array_aux(void);
|
||||
|
||||
void z_cpp_init_static(void)
|
||||
{
|
||||
__do_global_ctors_aux();
|
||||
__do_init_array_aux();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#ifdef __CCAC__
|
||||
void __do_global_ctors_aux(void);
|
||||
|
||||
void z_cpp_init_static(void)
|
||||
{
|
||||
__do_global_ctors_aux();
|
||||
}
|
||||
#endif /* __CCAC__ */
|
||||
|
||||
#endif /* CONFIG_CPP_STATIC_INIT_GNU */
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Wind River Systems, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* @file
|
||||
* @brief Execute initialization routines referenced in .init_array section
|
||||
*/
|
||||
|
||||
typedef void (*func_ptr)(void);
|
||||
|
||||
extern func_ptr __zephyr_init_array_start[];
|
||||
extern func_ptr __zephyr_init_array_end[];
|
||||
|
||||
/**
|
||||
* @brief Execute initialization routines referenced in .init_array section
|
||||
*/
|
||||
void __do_init_array_aux(void)
|
||||
{
|
||||
for (func_ptr *func = __zephyr_init_array_start;
|
||||
func < __zephyr_init_array_end;
|
||||
func++) {
|
||||
(*func)();
|
||||
}
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <new>
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
#define NOEXCEPT
|
||||
#else /* >= C++11 */
|
||||
#define NOEXCEPT noexcept
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if __cplusplus < 202002L
|
||||
#define NODISCARD
|
||||
#else
|
||||
#define NODISCARD [[nodiscard]]
|
||||
#endif /* __cplusplus */
|
||||
|
||||
NODISCARD void* operator new(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
NODISCARD void* operator new[](size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
NODISCARD void* operator new(std::size_t size, const std::nothrow_t& tag) NOEXCEPT
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
NODISCARD void* operator new[](std::size_t size, const std::nothrow_t& tag) NOEXCEPT
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
NODISCARD void* operator new(size_t size, std::align_val_t al)
|
||||
{
|
||||
return aligned_alloc(static_cast<size_t>(al), size);
|
||||
}
|
||||
|
||||
NODISCARD void* operator new[](std::size_t size, std::align_val_t al)
|
||||
{
|
||||
return aligned_alloc(static_cast<size_t>(al), size);
|
||||
}
|
||||
|
||||
NODISCARD void* operator new(std::size_t size, std::align_val_t al,
|
||||
const std::nothrow_t&) NOEXCEPT
|
||||
{
|
||||
return aligned_alloc(static_cast<size_t>(al), size);
|
||||
}
|
||||
|
||||
NODISCARD void* operator new[](std::size_t size, std::align_val_t al,
|
||||
const std::nothrow_t&) NOEXCEPT
|
||||
{
|
||||
return aligned_alloc(static_cast<size_t>(al), size);
|
||||
}
|
||||
#endif /* __cplusplus >= 201703L */
|
||||
|
||||
void operator delete(void* ptr) NOEXCEPT
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void operator delete[](void* ptr) NOEXCEPT
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
#if (__cplusplus > 201103L)
|
||||
void operator delete(void* ptr, size_t) NOEXCEPT
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void operator delete[](void* ptr, size_t) NOEXCEPT
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
#endif // __cplusplus > 201103L
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Wind River Systems, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* @file
|
||||
* @brief Stub for C++ pure virtual functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Stub for pure virtual functions
|
||||
*
|
||||
* This routine is needed for linking C++ code that uses pure virtual
|
||||
* functions.
|
||||
*/
|
||||
void __cxa_pure_virtual(void)
|
||||
{
|
||||
while (1) {
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Wind River Systems, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* @file
|
||||
* @brief Stub for C++ virtual tables
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief basic virtual tables required for classes to build
|
||||
*
|
||||
*/
|
||||
namespace __cxxabiv1 {
|
||||
class __class_type_info {
|
||||
virtual void dummy();
|
||||
};
|
||||
class __si_class_type_info {
|
||||
virtual void dummy();
|
||||
};
|
||||
void __class_type_info::dummy() { } // causes the vtable to get created here
|
||||
void __si_class_type_info::dummy() { } // causes the vtable to get created here
|
||||
};
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief Stub header allowing compilation of `#include <cstddef>`
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_SUBSYS_CPP_INCLUDE_CSTDDEF_
|
||||
#define ZEPHYR_SUBSYS_CPP_INCLUDE_CSTDDEF_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace std {
|
||||
using ::ptrdiff_t;
|
||||
using ::size_t;
|
||||
using ::max_align_t;
|
||||
using nullptr_t = decltype(nullptr);
|
||||
}
|
||||
|
||||
#endif /* ZEPHYR_SUBSYS_CPP_INCLUDE_CSTDDEF_ */
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief Stub header allowing compilation of `#include <cstdint>`
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_SUBSYS_CPP_INCLUDE_CSTDINT_
|
||||
#define ZEPHYR_SUBSYS_CPP_INCLUDE_CSTDINT_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace std {
|
||||
using ::int8_t;
|
||||
using ::int16_t;
|
||||
using ::int32_t;
|
||||
using ::int64_t;
|
||||
using ::intmax_t;
|
||||
|
||||
using ::int_fast8_t;
|
||||
using ::int_fast16_t;
|
||||
using ::int_fast32_t;
|
||||
using ::int_fast64_t;
|
||||
|
||||
using ::int_least8_t;
|
||||
using ::int_least16_t;
|
||||
using ::int_least32_t;
|
||||
using ::int_least64_t;
|
||||
|
||||
using ::uint8_t;
|
||||
using ::uint16_t;
|
||||
using ::uint32_t;
|
||||
using ::uint64_t;
|
||||
using ::uintmax_t;
|
||||
|
||||
using ::uint_fast8_t;
|
||||
using ::uint_fast16_t;
|
||||
using ::uint_fast32_t;
|
||||
using ::uint_fast64_t;
|
||||
|
||||
using ::uint_least8_t;
|
||||
using ::uint_least16_t;
|
||||
using ::uint_least32_t;
|
||||
using ::uint_least64_t;
|
||||
|
||||
using ::intptr_t;
|
||||
using ::uintptr_t;
|
||||
}
|
||||
|
||||
#endif /* ZEPHYR_SUBSYS_CPP_INCLUDE_CSTDINT_ */
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright 2022 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief Stub header allowing compilation of `#include <new>`
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_SUBSYS_CPP_INCLUDE_NEW_
|
||||
#define ZEPHYR_SUBSYS_CPP_INCLUDE_NEW_
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace std {
|
||||
#if __cplusplus < 201103L
|
||||
struct nothrow_t {};
|
||||
#else
|
||||
struct nothrow_t {
|
||||
explicit nothrow_t() = default;
|
||||
};
|
||||
#endif /* __cplusplus */
|
||||
extern const std::nothrow_t nothrow;
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
enum class align_val_t : std::size_t {};
|
||||
#endif /* CONFIG_STD_CPP17 */
|
||||
|
||||
}
|
||||
#endif /* ZEPHYR_SUBSYS_CPP_INCLUDE_NEW_ */
|
Loading…
Add table
Add a link
Reference in a new issue