summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorMengxi-Xu <[email protected]>2023-05-20 13:27:55 +0800
committerGitHub <[email protected]>2023-05-20 01:27:55 -0400
commit1e5dc5509e0fbc325df926c8911fdc2780e7cf4c (patch)
tree78f59aff9ac768d96630896314d58c1c23fba7b9 /components
parenta36d2df236d943d14389578b5852b332d147b770 (diff)
[libc][cpp] 增加 cxx_crt_init.c 函数注释 (#7535)
Diffstat (limited to 'components')
-rw-r--r--components/libc/cplusplus/cxx_crt_init.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/components/libc/cplusplus/cxx_crt_init.c b/components/libc/cplusplus/cxx_crt_init.c
index 9e5262c101..c5d1e434b5 100644
--- a/components/libc/cplusplus/cxx_crt_init.c
+++ b/components/libc/cplusplus/cxx_crt_init.c
@@ -34,6 +34,18 @@ rt_weak void *__dso_handle = 0;
#endif
+/**
+ * @brief This function initializes the C++ runtime environment for ARM and GCC compilers.
+ *
+ * @note If there is no SHT$$INIT_ARRAY section, calling $Super$$__cpp_initialize__aeabi_() will cause an error
+ * in ARMCC compiler. Therefore, this function manually iterates through the base addresses of the
+ * SHT$$INIT_ARRAY section to call the constructor functions of each object. In GCC compiler, this function
+ * uses the __ctors_start__ and __ctors_end__ global variables to determine the range of constructor function
+ * pointers and calls each constructor function of every object in that range.
+ *
+ * @return Returns 0 if the initialization of the C++ runtime environment is successful. Otherwise, it returns
+ * an error code indicating the failure of the operation.
+ */
rt_weak int cplusplus_system_init(void)
{
#if defined(__ARMCC_VERSION)