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 b9eff677fe1c31b07a01913387dcd7dd3d4a1736
Author: Xiang Xiao <xiaoxi...@xiaomi.com>
AuthorDate: Tue May 3 15:54:18 2022 +0800

    libc: Simplify the c++ initialization
    
    1.Remove CXX_INITIALIZE_MACHO and CXX_INITIALIZE_SINIT
    2.Merge cxx_initialize_sinit.c and cxx_initialize_macho.c into 
cxx_initialize.c
    
    Signed-off-by: Xiang Xiao <xiaoxi...@xiaomi.com>
---
 libs/libc/Kconfig                                  |  1 -
 libs/libc/sched/Kconfig                            | 17 ------
 libs/libc/sched/Make.defs                          |  9 +---
 .../{cxx_initialize_sinit.c => cxx_initialize.c}   |  8 ++-
 libs/libc/sched/cxx_initialize_macho.c             | 61 ----------------------
 5 files changed, 8 insertions(+), 88 deletions(-)

diff --git a/libs/libc/Kconfig b/libs/libc/Kconfig
index 1a36dca660..cf512d886a 100644
--- a/libs/libc/Kconfig
+++ b/libs/libc/Kconfig
@@ -9,7 +9,6 @@ source "libs/libc/stdio/Kconfig"
 source "libs/libc/audio/Kconfig"
 source "libs/libc/math/Kconfig"
 source "libs/libc/machine/Kconfig"
-source "libs/libc/sched/Kconfig"
 source "libs/libc/stdlib/Kconfig"
 source "libs/libc/unistd/Kconfig"
 source "libs/libc/string/Kconfig"
diff --git a/libs/libc/sched/Kconfig b/libs/libc/sched/Kconfig
deleted file mode 100644
index c13df9eed8..0000000000
--- a/libs/libc/sched/Kconfig
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# For a description of the syntax of this configuration file,
-# see the file kconfig-language.txt in the NuttX tools repository.
-#
-
-choice
-       prompt "CXX initialization style"
-       default CXX_INITIALIZE_MACHO if ARCH_SIM && HOST_MACOS
-       default CXX_INITIALIZE_SINIT
-
-config CXX_INITIALIZE_SINIT
-       bool "_sinit/_einit style intialization"
-
-config CXX_INITIALIZE_MACHO
-       bool "Mach-O style intialization (sim/macOS)"
-
-endchoice
diff --git a/libs/libc/sched/Make.defs b/libs/libc/sched/Make.defs
index f3881bc1e0..71c063731d 100644
--- a/libs/libc/sched/Make.defs
+++ b/libs/libc/sched/Make.defs
@@ -23,6 +23,7 @@
 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
@@ -35,14 +36,6 @@ endif
 ifneq ($(CONFIG_BUILD_KERNEL),y)
 CSRCS += task_startup.c
 
-ifeq ($(CONFIG_CXX_INITIALIZE_SINIT),y)
-CSRCS += cxx_initialize_sinit.c
-endif
-
-ifeq ($(CONFIG_CXX_INITIALIZE_MACHO),y)
-CSRCS += cxx_initialize_macho.c
-endif
-
 ifeq ($(CONFIG_SCHED_BACKTRACE),y)
 CSRCS += sched_dumpstack.c sched_backtrace.c
 endif
diff --git a/libs/libc/sched/cxx_initialize_sinit.c 
b/libs/libc/sched/cxx_initialize.c
similarity index 95%
rename from libs/libc/sched/cxx_initialize_sinit.c
rename to libs/libc/sched/cxx_initialize.c
index 1fcc0dcd63..b8e21b5a7e 100644
--- a/libs/libc/sched/cxx_initialize_sinit.c
+++ b/libs/libc/sched/cxx_initialize.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * libs/libc/sched/cxx_initialize_sinit.c
+ * libs/libc/sched/cxx_initialize.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -82,6 +82,11 @@ 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;
 
       sinfo("_sinit: %p _einit: %p _stext: %p _etext: %p\n",
@@ -106,6 +111,7 @@ void cxx_initialize(void)
               initializer();
             }
         }
+#endif
 
       inited = 1;
     }
diff --git a/libs/libc/sched/cxx_initialize_macho.c 
b/libs/libc/sched/cxx_initialize_macho.c
deleted file mode 100644
index ca9cf7fd40..0000000000
--- a/libs/libc/sched/cxx_initialize_macho.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
- * libs/libc/sched/cxx_initialize_macho.c
- *
- * 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.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: cxx_initialize
- *
- * Description:
- *   If C++ and C++ static constructors are supported, then this function
- *   must be provided by board-specific logic in order to perform
- *   initialization of the static C++ class instances.
- *
- *   This function should then be called in the application-specific
- *   user_start logic in order to perform the C++ initialization.  NOTE
- *   that no component of the core NuttX RTOS logic is involved; this
- *   function definition only provides the 'contract' between application
- *   specific C++ code and platform-specific toolchain support.
- *
- ****************************************************************************/
-
-void cxx_initialize(void)
-{
-#ifdef CONFIG_HAVE_CXXINITIALIZE
-  static int inited = 0;
-
-  if (inited == 0)
-    {
-      extern void macho_call_saved_init_funcs(void);
-
-      macho_call_saved_init_funcs();
-
-      inited = 1;
-    }
-#endif
-}

Reply via email to