apps: Remove all stuff related to CONFIG_xxx_CXXINITIALIZE

since it is moved to the central place in nuttx side instead

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I544d6110f1ca6460f7c82f970870aa9b1e7ab3dd
This commit is contained in:
Xiang Xiao 2020-06-30 20:57:45 +08:00 committed by patacongo
parent 989d1aef13
commit b217de70e5
22 changed files with 13 additions and 454 deletions

View File

@ -542,11 +542,6 @@ examples/helloxx
"built-in" that can be executed from the NSH command line. "built-in" that can be executed from the NSH command line.
CONFIG_EXAMPLES_HELLOXX_NOSTACKCONST - Set if the system does not CONFIG_EXAMPLES_HELLOXX_NOSTACKCONST - Set if the system does not
support construction of objects on the stack. support construction of objects on the stack.
CONFIG_EXAMPLES_HELLOXX_CXXINITIALIZE - By default, if CONFIG_HAVE_CXX
and CONFIG_HAVE_CXXINITIALIZE are defined, then this example
will call the NuttX function to initialize static C++ constructors.
This option may be disabled, however, if that static initialization
was performed elsewhere.
Also needed: Also needed:

View File

@ -120,16 +120,6 @@ config EXAMPLES_ELF_LIBC
program greatly increasing the total code size. This option is program greatly increasing the total code size. This option is
primarily intended only for testing. primarily intended only for testing.
config EXAMPLES_ELF_CXXINITIALIZE
bool "C++ Initialization"
default y
depends on HAVE_CXX && HAVE_CXXINITIALIZE
---help---
By default, if CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE are
defined, then this example will call the NuttX function to
initialize static C++ constructors. This option may be disabled,
however, if that static initialization was performed elsewhere.
config EXAMPLES_ELF_UCLIBCXX config EXAMPLES_ELF_UCLIBCXX
bool "uClibc++ is installed" bool "uClibc++ is installed"
default n default n

View File

@ -41,8 +41,6 @@
#include <nuttx/drivers/ramdisk.h> #include <nuttx/drivers/ramdisk.h>
#include <nuttx/binfmt/binfmt.h> #include <nuttx/binfmt/binfmt.h>
#include "platform/cxxinitialize.h"
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
@ -208,12 +206,6 @@ int main(int argc, FAR char *argv[])
int ret; int ret;
int i; int i;
#if defined(CONFIG_EXAMPLES_ELF_CXXINITIALIZE)
/* Call all C++ static constructors */
up_cxxinitialize();
#endif
/* Initialize the memory monitor */ /* Initialize the memory monitor */
mm_initmonitor(); mm_initmonitor();

View File

@ -63,7 +63,7 @@ BIN1 = hello++1
ALL_BIN = $(FSIMG_DIR)/$(BIN1) ALL_BIN = $(FSIMG_DIR)/$(BIN1)
BIN2 = hello++2 BIN2 = hello++2
ALL_BIN += $(FSIMG_DIR)/$(BIN2) ALL_BIN += $(FSIMG_DIR)/$(BIN2)
ifeq ($(CONFIG_BINFMT_CONSTRUCTORS),y) ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y)
BIN3 = hello++3 BIN3 = hello++3
ALL_BIN += $(FSIMG_DIR)/$(BIN3) ALL_BIN += $(FSIMG_DIR)/$(BIN3)
ifeq ($(CONFIG_EXAMPLES_ELF_UCLIBCXX),y) ifeq ($(CONFIG_EXAMPLES_ELF_UCLIBCXX),y)
@ -80,7 +80,7 @@ OBJS1 = $(SRCS1:.c=$(OBJEXT))
SRCS2 = $(BIN2).c SRCS2 = $(BIN2).c
OBJS2 = $(SRCS2:.c=$(OBJEXT)) OBJS2 = $(SRCS2:.c=$(OBJEXT))
ifeq ($(CONFIG_BINFMT_CONSTRUCTORS),y) ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y)
SRCS3 = $(BIN3).c SRCS3 = $(BIN3).c
OBJS3 = $(SRCS3:.c=$(OBJEXT)) OBJS3 = $(SRCS3:.c=$(OBJEXT))
ifeq ($(CONFIG_EXAMPLES_ELF_UCLIBCXX),y) ifeq ($(CONFIG_EXAMPLES_ELF_UCLIBCXX),y)
@ -125,7 +125,7 @@ $(BIN2): $(OBJS2)
# BIN3 is equivalent to BIN2 except that is uses static initializers # BIN3 is equivalent to BIN2 except that is uses static initializers
ifeq ($(CONFIG_BINFMT_CONSTRUCTORS),y) ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y)
$(BIN3): $(OBJS3) $(BIN3): $(OBJS3)
@echo "LD: $<" @echo "LD: $<"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS) $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS)
@ -158,7 +158,7 @@ ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(FSIMG_DIR)/$(BIN2) $(Q) $(STRIP) $(FSIMG_DIR)/$(BIN2)
endif endif
ifeq ($(CONFIG_BINFMT_CONSTRUCTORS),y) ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y)
$(FSIMG_DIR)/$(BIN3): $(BIN3) $(FSIMG_DIR)/$(BIN3): $(BIN3)
$(Q) mkdir -p $(FSIMG_DIR) $(Q) mkdir -p $(FSIMG_DIR)
$(Q) install $(BIN3) $(FSIMG_DIR)/$(BIN3) $(Q) install $(BIN3) $(FSIMG_DIR)/$(BIN3)

View File

@ -9,17 +9,3 @@ config EXAMPLES_HELLOXX
depends on HAVE_CXX depends on HAVE_CXX
---help--- ---help---
Enable the \"Hello, World!\" C++ example Enable the \"Hello, World!\" C++ example
if EXAMPLES_HELLOXX
config EXAMPLES_HELLOXX_CXXINITIALIZE
bool "C++ Initialization"
default y
depends on HAVE_CXX && HAVE_CXXINITIALIZE
---help---
By default, if CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE are
defined, then this example will call the NuttX function to
initialize static C++ constructors. This option may be disabled,
however, if that static initialization was performed elsewhere.
endif

View File

@ -42,19 +42,10 @@
#include <cstdio> #include <cstdio>
#include <debug.h> #include <debug.h>
#include <nuttx/init.h>
#include "platform/cxxinitialize.h"
//*************************************************************************** //***************************************************************************
// Definitions // Definitions
//*************************************************************************** //***************************************************************************
// Configuration ************************************************************ // Configuration ************************************************************
// C++ initialization requires CXX initializer support
#if !defined(CONFIG_HAVE_CXX) || !defined(CONFIG_HAVE_CXXINITIALIZE)
# undef CONFIG_EXAMPLES_HELLOXX_CXXINITIALIZE
#endif
// Debug ******************************************************************** // Debug ********************************************************************
// Non-standard debug that may be enabled just for testing the constructors // Non-standard debug that may be enabled just for testing the constructors
@ -129,13 +120,6 @@ extern "C"
{ {
int main(int argc, FAR char *argv[]) int main(int argc, FAR char *argv[])
{ {
// If C++ initialization for static constructors is supported, then do
// that first
#ifdef CONFIG_EXAMPLES_HELLOXX_CXXINITIALIZE
up_cxxinitialize();
#endif
// Exercise an explicitly instantiated C++ object // Exercise an explicitly instantiated C++ object
CHelloWorld *pHelloWorld = new CHelloWorld; CHelloWorld *pHelloWorld = new CHelloWorld;

View File

@ -63,7 +63,6 @@
#include <nuttx/nx/nxfonts.h> #include <nuttx/nx/nxfonts.h>
#include <nuttx/nx/nxterm.h> #include <nuttx/nx/nxterm.h>
#include "platform/cxxinitialize.h"
#include "nshlib/nshlib.h" #include "nshlib/nshlib.h"
#include "nxterm_internal.h" #include "nxterm_internal.h"
@ -117,7 +116,8 @@ static int nxterm_initialize(void)
ret = boardctl(BOARDIOC_NX_START, 0); ret = boardctl(BOARDIOC_NX_START, 0);
if (ret < 0) if (ret < 0)
{ {
printf("nxterm_initialize: Failed to start the NX server: %d\n", errno); printf("nxterm_initialize: Failed to start the NX server: %d\n",
errno);
return ERROR; return ERROR;
} }
@ -145,9 +145,9 @@ static int nxterm_initialize(void)
} }
#endif #endif
/* Start a separate thread to listen for server events. This is probably /* Start a separate thread to listen for server events. This is
* the least efficient way to do this, but it makes this example flow more * probably the least efficient way to do this, but it makes this
* smoothly. * example flow more smoothly.
*/ */
pthread_attr_init(&attr); pthread_attr_init(&attr);
@ -230,12 +230,6 @@ int main(int argc, FAR char *argv[])
printf("nxterm_main: Started\n"); printf("nxterm_main: Started\n");
memset(&g_nxterm_vars, 0, sizeof(struct nxterm_state_s)); memset(&g_nxterm_vars, 0, sizeof(struct nxterm_state_s));
/* Call all C++ static constructors */
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
up_cxxinitialize();
#endif
/* NSH Initialization *****************************************************/ /* NSH Initialization *****************************************************/
/* Initialize the NSH library */ /* Initialize the NSH library */
@ -312,8 +306,10 @@ int main(int argc, FAR char *argv[])
/* Determine the size and position of the window */ /* Determine the size and position of the window */
g_nxterm_vars.wndo.wsize.w = g_nxterm_vars.xres / 2 + g_nxterm_vars.xres / 4; g_nxterm_vars.wndo.wsize.w = g_nxterm_vars.xres / 2 +
g_nxterm_vars.wndo.wsize.h = g_nxterm_vars.yres / 2 + g_nxterm_vars.yres / 4; g_nxterm_vars.xres / 4;
g_nxterm_vars.wndo.wsize.h = g_nxterm_vars.yres / 2 +
g_nxterm_vars.yres / 4;
g_nxterm_vars.wpos.x = g_nxterm_vars.xres / 8; g_nxterm_vars.wpos.x = g_nxterm_vars.xres / 8;
g_nxterm_vars.wpos.y = g_nxterm_vars.yres / 8; g_nxterm_vars.wpos.y = g_nxterm_vars.yres / 8;

View File

@ -49,10 +49,6 @@
# include "platform/configdata.h" # include "platform/configdata.h"
#endif #endif
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
# include "platform/cxxinitialize.h"
#endif
#include "graphics/nxwm/ctaskbar.hxx" #include "graphics/nxwm/ctaskbar.hxx"
#include "graphics/nxwm/cstartwindow.hxx" #include "graphics/nxwm/cstartwindow.hxx"
@ -502,12 +498,6 @@ static bool createMediaPlayer(void)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
// Call all C++ static constructors
up_cxxinitialize();
#endif
#if defined(CONFIG_LIB_BOARDCTL) && !defined(CONFIG_BOARD_LATE_INITIALIZE) #if defined(CONFIG_LIB_BOARDCTL) && !defined(CONFIG_BOARD_LATE_INITIALIZE)
// Should we perform board-specific initialization? There are two ways // Should we perform board-specific initialization? There are two ways
// that board initialization can occur: 1) automatically via // that board initialization can occur: 1) automatically via

View File

@ -46,7 +46,6 @@
#include <sys/boardctl.h> #include <sys/boardctl.h>
#include "platform/cxxinitialize.h"
#include "netutils/netinit.h" #include "netutils/netinit.h"
#include "graphics/twm4nx/twm4nx_config.hxx" #include "graphics/twm4nx/twm4nx_config.hxx"
@ -143,12 +142,6 @@ int main(int argc, FAR char *argv[])
UNUSED(ret); UNUSED(ret);
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
// Call all C++ static constructors
up_cxxinitialize();
#endif
/* Create an instance of CTwm4Nx and initialize it */ /* Create an instance of CTwm4Nx and initialize it */
FAR CTwm4Nx *twm4nx = new CTwm4Nx(display); FAR CTwm4Nx *twm4nx = new CTwm4Nx(display);

View File

@ -1,84 +0,0 @@
/****************************************************************************
* apps/include/platform/cxxinitialize.h
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __APPS_INCLUDE_PLATFORM_CXXINITIALIZE_H
#define __APPS_INCLUDE_PLATFORM_CXXINITIALIZE_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Public Functions
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: up_cxxinitialize
*
* 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
* 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
*
****************************************************************************/
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
void up_cxxinitialize(void);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __APPS_INCLUDE_PLATFORM_CXXINITIALIZE_H */

View File

@ -16,7 +16,6 @@ config PLATFORM_CONFIGDATA
volatile storage can be used: A file, EEPROM, hardcoded values in volatile storage can be used: A file, EEPROM, hardcoded values in
FLASH, etc. FLASH, etc.
source "$APPSDIR/platform/gnu/Kconfig"
source "$APPSDIR/platform/board/Kconfig" source "$APPSDIR/platform/board/Kconfig"
endmenu # Platform-specific Support endmenu # Platform-specific Support

View File

@ -39,7 +39,6 @@ CONFIG_ARCH_BOARD ?= dummy
# Directories # Directories
GNUDIR = gnu
PLATFORMDIR = board PLATFORMDIR = board
DUMMYDIR = $(APPDIR)/platform/dummy DUMMYDIR = $(APPDIR)/platform/dummy
@ -54,11 +53,9 @@ VPATH += board
ROOTDEPPATH += --obj-path bin ROOTDEPPATH += --obj-path bin
ROOTDEPPATH += --obj-suffix $(OBJEXT) ROOTDEPPATH += --obj-suffix $(OBJEXT)
ROOTDEPPATH += --dep-path $(PLATFORMDIR) ROOTDEPPATH += --dep-path $(PLATFORMDIR)
ROOTDEPPATH += --dep-path $(GNUDIR)
# Binaries # Binaries
-include $(GNUDIR)$(DELIM)Make.defs
-include $(PLATFORMDIR)$(DELIM)Make.defs -include $(PLATFORMDIR)$(DELIM)Make.defs
# Build context setup # Build context setup

View File

@ -1,13 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config HAVE_CXXINITIALIZE
bool "Have C++ initialization"
default n
depends on HAVE_CXX
---help---
The platform-specific logic includes support for initialization
of static C++ instances for this architecture and for the selected
toolchain (via up_cxxinitialize()).

View File

@ -1,51 +0,0 @@
############################################################################
# apps/platform/gnu/Make.defs
#
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
# Check for a GNU toolchain
ifeq ($(CONFIG_ARCH_TOOLCHAIN_GNU),y)
# Add GNU specific sources to ASRCS and CSRCS
ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y)
CSRCS += gnu_cxxinitialize.c
endif
# Add the gnu/ sub-directory to the build
VPATH += :gnu
DEPPATH += --dep-path gnu
endif # CONFIG_ARCH_TOOLCHAIN_GNU

View File

@ -1,134 +0,0 @@
/****************************************************************************
* apps/platform/gnu/gnu_cxxinitialize.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include "platform/cxxinitialize.h"
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Debug ********************************************************************/
/* Non-standard debug that may be enabled just for testing the static
* constructors.
*/
#ifdef CONFIG_DEBUG_CXX
# define cxxinfo _info
#else
# define cxxinfo(x...)
#endif
/****************************************************************************
* Private Types
****************************************************************************/
/* This type defines one entry in initialization array */
typedef void (*initializer_t)(void);
/****************************************************************************
* External References
****************************************************************************/
/* _sinit and _einit are symbols exported by the linker script that mark the
* beginning and the end of the C++ initialization section.
*/
extern initializer_t _sinit;
extern initializer_t _einit;
/* _stext and _etext are symbols exported by the linker script that mark the
* beginning and the end of text.
*/
extern uint32_t _stext;
extern uint32_t _etext;
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_cxxinitialize
*
* 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 up_cxxinitialize(void)
{
initializer_t *initp;
cxxinfo("_sinit: %p _einit: %p _stext: %p _etext: %p\n",
&_sinit, &_einit, &_stext, &_etext);
/* Visit each entry in the initialization table */
for (initp = &_sinit; initp != &_einit; initp++)
{
initializer_t initializer = *initp;
cxxinfo("initp: %p initializer: %p\n", initp, initializer);
/* Make sure that the address is non-NULL and lies in the text region
* defined by the linker script. Some toolchains may put NULL values
* or counts in the initialization table.
*/
if ((void *)initializer > (void *)&_stext &&
(void *)initializer < (void *)&_etext)
{
cxxinfo("Calling %p\n", initializer);
initializer();
}
}
}
#endif /* CONFIG_HAVE_CXX && CONFIG_HAVE_CXXINITIALIZE */

View File

@ -76,15 +76,4 @@ config SYSTEM_NSH_PROGNAME
This is the name of the program that will be used when the NSH ELF This is the name of the program that will be used when the NSH ELF
program is installed. program is installed.
config SYSTEM_NSH_CXXINITIALIZE
bool "C++ Initialization"
default n
depends on HAVE_CXX && HAVE_CXXINITIALIZE
---help---
If HAVE_CXX and HAVE_CXXINITIALIZE are selected, then this NSH
example can be configured to initialize C++ constructors when it
is started. NSH does not use C++ and, by default, assumes that
constructors are initialized elsewhere. However, you can force
NSH to initialize constructors by setting this option.
endif endif

View File

@ -43,13 +43,3 @@ README
CONFIG_STDIO_BUFFER_SIZE - Some value >= 64 CONFIG_STDIO_BUFFER_SIZE - Some value >= 64
CONFIG_STDIO_LINEBUFFER=y CONFIG_STDIO_LINEBUFFER=y
C++ Support
-----------
If CONFIG_HAVE_CXX=y and CONFIG_HAVE_CXXINITIALIZE=y, then this NSH
example can be configured to initialize C++ constructors when it
is started. NSH does not use C++ and, by default, assumes that
constructors are initialized elsewhere. However, you can force
NSH to initialize constructors by setting:
CONFIG_SYSTEM_NSH_CXXINITIALIZE=y

View File

@ -50,8 +50,6 @@
# include <nuttx/symtab.h> # include <nuttx/symtab.h>
#endif #endif
#include "platform/cxxinitialize.h"
#include "nshlib/nshlib.h" #include "nshlib/nshlib.h"
/**************************************************************************** /****************************************************************************
@ -80,12 +78,6 @@
# undef CONFIG_SYSTEM_NSH_SYMTAB # undef CONFIG_SYSTEM_NSH_SYMTAB
#endif #endif
/* C++ initialization requires CXX initializer support */
#if !defined(CONFIG_HAVE_CXX) || !defined(CONFIG_HAVE_CXXINITIALIZE)
# undef CONFIG_SYSTEM_NSH_CXXINITIALIZE
#endif
/* The NSH telnet console requires networking support (and TCP/IP) */ /* The NSH telnet console requires networking support (and TCP/IP) */
#ifndef CONFIG_NET #ifndef CONFIG_NET
@ -137,12 +129,6 @@ int main(int argc, FAR char *argv[])
sched_setparam(0, &param); sched_setparam(0, &param);
} }
#if defined(CONFIG_SYSTEM_NSH_CXXINITIALIZE)
/* Call all C++ static constructors */
up_cxxinitialize();
#endif
#if defined(CONFIG_SYSTEM_NSH_SYMTAB) #if defined(CONFIG_SYSTEM_NSH_SYMTAB)
/* Make sure that we are using our symbol table */ /* Make sure that we are using our symbol table */

View File

@ -28,11 +28,6 @@ testing/cxxtest
Example Configuration Options Example Configuration Options
----------------------------- -----------------------------
CONFIG_TESTING_CXXTEST=y - Eanbles the example CONFIG_TESTING_CXXTEST=y - Eanbles the example
CONFIG_TESTING_CXXTEST_CXXINITIALIZE=y - By default, if CONFIG_HAVE_CXX
and CONFIG_HAVE_CXXINITIALIZE are defined, then this example
will call the NuttX function to initialize static C++ constructors.
This option may be disabled, however, if that static initialization
was performed elsewhere.
Other Required Configuration Settings Other Required Configuration Settings
------------------------------------- -------------------------------------

View File

@ -9,17 +9,3 @@ config TESTING_CXXTEST
depends on HAVE_CXX depends on HAVE_CXX
---help--- ---help---
Enable the C++ test program Enable the C++ test program
if TESTING_CXXTEST
config TESTING_CXXTEST_CXXINITIALIZE
bool "C++ Initialization"
default y
depends on HAVE_CXX && HAVE_CXXINITIALIZE
---help---
By default, if CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE are
defined, then this example will call the NuttX function to
initialize static C++ constructors. This option may be disabled,
however, if that static initialization was performed elsewhere.
endif

View File

@ -16,11 +16,6 @@ README
Example Configuration Options Example Configuration Options
----------------------------- -----------------------------
CONFIG_TESTING_CXXTEST=y - Eanbles the example CONFIG_TESTING_CXXTEST=y - Eanbles the example
CONFIG_TESTING_CXXTEST_CXXINITIALIZE=y - By default, if CONFIG_HAVE_CXX
and CONFIG_HAVE_CXXINITIALIZE are defined, then this example
will call the NuttX function to initialize static C++ constructors.
This option may be disabled, however, if that static initialization
was performed elsewhere.
Other Required Configuration Settings Other Required Configuration Settings
------------------------------------- -------------------------------------

View File

@ -47,23 +47,8 @@
#include <stdexcept> #include <stdexcept>
#include <cassert> #include <cassert>
#include <nuttx/init.h>
#include "platform/cxxinitialize.h"
using namespace std; using namespace std;
//***************************************************************************
// Definitions
//***************************************************************************
// Configuration ************************************************************
// C++ initialization requires CXX initializer support
#if !defined(CONFIG_HAVE_CXX) || !defined(CONFIG_HAVE_CXXINITIALIZE)
# warning Support for static initializers is NOT enabled
# undef CONFIG_TESTING_CXXTEST_CXXINITIALIZE
#endif
//*************************************************************************** //***************************************************************************
// Private Classes // Private Classes
//*************************************************************************** //***************************************************************************
@ -247,13 +232,6 @@ extern "C"
{ {
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// If C++ initialization for static constructors is supported, then do
// that first
#ifdef CONFIG_TESTING_CXXTEST_CXXINITIALIZE
up_cxxinitialize();
#endif
test_ofstream(); test_ofstream();
test_iostream(); test_iostream();
test_stl(); test_stl();