This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 577f301a2c4193c10c8d96e628fa7592ee8593c2
Author: Xiang Xiao <xiaoxi...@xiaomi.com>
AuthorDate: Tue May 3 16:02:30 2022 +0800

    libc: Move cxx_initialize.c from libc/sched/ to libc/misc
    
    Signed-off-by: Xiang Xiao <xiaoxi...@xiaomi.com>
---
 libs/libc/libc.h                                    |  4 ++++
 libs/libc/misc/Make.defs                            |  1 +
 .../cxx_initialize.c => misc/lib_cxx_initialize.c}  | 14 +++++++++-----
 libs/libc/sched/Make.defs                           |  1 -
 libs/libc/sched/cxx_initialize.h                    | 21 ---------------------
 libs/libc/sched/task_startup.c                      |  4 ++--
 6 files changed, 16 insertions(+), 29 deletions(-)

diff --git a/libs/libc/libc.h b/libs/libc/libc.h
index 7e2c2a6332..a295e89a1a 100644
--- a/libs/libc/libc.h
+++ b/libs/libc/libc.h
@@ -158,6 +158,10 @@ ssize_t lib_parse_hostfile(FAR FILE *stream, FAR struct 
hostent *host,
 int lib_restoredir(void);
 #endif
 
+/* Defined in lib_cxx_initialize.c */
+
+void lib_cxx_initialize(void);
+
 #undef EXTERN
 #if defined(__cplusplus)
 }
diff --git a/libs/libc/misc/Make.defs b/libs/libc/misc/Make.defs
index a4c8bc8ce9..3e25e4038a 100644
--- a/libs/libc/misc/Make.defs
+++ b/libs/libc/misc/Make.defs
@@ -22,6 +22,7 @@
 
 CSRCS += lib_mknod.c lib_umask.c lib_utsname.c lib_getrandom.c
 CSRCS += lib_xorshift128.c lib_tea_encrypt.c lib_tea_decrypt.c
+CSRCS += lib_cxx_initialize.c
 
 # Support for platforms that do not have long long types
 
diff --git a/libs/libc/sched/cxx_initialize.c 
b/libs/libc/misc/lib_cxx_initialize.c
similarity index 94%
rename from libs/libc/sched/cxx_initialize.c
rename to libs/libc/misc/lib_cxx_initialize.c
index b8e21b5a7e..898a4efc52 100644
--- a/libs/libc/sched/cxx_initialize.c
+++ b/libs/libc/misc/lib_cxx_initialize.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * libs/libc/sched/cxx_initialize.c
+ * libs/libc/misc/lib_cxx_initialize.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -29,6 +29,8 @@
 #include <sched.h>
 #include <stdlib.h>
 
+#include "libc.h"
+
 /****************************************************************************
  * Private Types
  ****************************************************************************/
@@ -55,12 +57,16 @@ extern initializer_t _einit;
 extern uintptr_t _stext;
 extern uintptr_t _etext;
 
+#if defined(CONFIG_ARCH_SIM) && defined(CONFIG_HOST_MACOS)
+extern void macho_call_saved_init_funcs(void);
+#endif
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
 
 /****************************************************************************
- * Name: cxx_initialize
+ * Name: lib_cxx_initialize
  *
  * Description:
  *   If C++ and C++ static constructors are supported, then this function
@@ -75,7 +81,7 @@ extern uintptr_t _etext;
  *
  ****************************************************************************/
 
-void cxx_initialize(void)
+void lib_cxx_initialize(void)
 {
 #ifdef CONFIG_HAVE_CXXINITIALIZE
   static int inited = 0;
@@ -83,8 +89,6 @@ void cxx_initialize(void)
   if (inited == 0)
     {
 #if defined(CONFIG_ARCH_SIM) && defined(CONFIG_HOST_MACOS)
-      extern void macho_call_saved_init_funcs(void);
-
       macho_call_saved_init_funcs();
 #else
       initializer_t *initp;
diff --git a/libs/libc/sched/Make.defs b/libs/libc/sched/Make.defs
index 71c063731d..70b95c614f 100644
--- a/libs/libc/sched/Make.defs
+++ b/libs/libc/sched/Make.defs
@@ -23,7 +23,6 @@
 CSRCS += sched_getprioritymax.c sched_getprioritymin.c
 CSRCS += clock_ticks2time.c clock_time2ticks.c
 CSRCS += clock_timespec_add.c clock_timespec_subtract.c
-CSRCS += cxx_initialize.c
 
 ifneq ($(CONFIG_CANCELLATION_POINTS),y)
 CSRCS += task_setcanceltype.c task_testcancel.c
diff --git a/libs/libc/sched/cxx_initialize.h b/libs/libc/sched/cxx_initialize.h
deleted file mode 100644
index e8fd6549d9..0000000000
--- a/libs/libc/sched/cxx_initialize.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/****************************************************************************
- * libs/libc/sched/cxx_initialize.h
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.  The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-void cxx_initialize(void);
diff --git a/libs/libc/sched/task_startup.c b/libs/libc/sched/task_startup.c
index 76a03f5291..a723be05f9 100644
--- a/libs/libc/sched/task_startup.c
+++ b/libs/libc/sched/task_startup.c
@@ -29,7 +29,7 @@
 #include <assert.h>
 #include <debug.h>
 
-#include "cxx_initialize.h"
+#include "libc.h"
 
 #ifndef CONFIG_BUILD_KERNEL
 
@@ -61,7 +61,7 @@ void nxtask_startup(main_t entrypt, int argc, FAR char 
*argv[])
    * that first
    */
 
-  cxx_initialize();
+  lib_cxx_initialize();
 
   /* Call the 'main' entry point passing argc and argv, calling exit()
    * if/when the task returns.

Reply via email to