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 <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
c1082f04d3
commit
b9eff677fe
@ -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"
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
@ -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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user