Move prototype from nuttx/include/nuttx/arch.h to apps/include/platform/cxxinitialize.h

This commit is contained in:
Gregory Nutt 2017-05-13 16:53:33 -06:00
parent 041d0d2c68
commit b08ea68a33
9 changed files with 114 additions and 13 deletions

View File

@ -1,7 +1,7 @@
//***************************************************************************
// examples/cxxtest/main.cxx
//
// Copyright (C) 2012 Gregory Nutt. All rights reserved.
// Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved.
// Author: Qiang Yu, http://rgmp.sourceforge.net/wiki/index.php/Main_Page
//
// Redistribution and use in source and binary forms, with or without
@ -38,8 +38,6 @@
//***************************************************************************
#include <nuttx/config.h>
#include <nuttx/init.h>
#include <nuttx/arch.h>
#include <cstdio>
#include <fstream>
@ -49,6 +47,10 @@
#include <stdexcept>
#include <cassert>
#include <nuttx/init.h>
#include "platform/cxxinitialize.h"
using namespace std;
//***************************************************************************

View File

@ -1,7 +1,7 @@
/****************************************************************************
* examples/elf/elf_main.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -55,6 +55,8 @@
#include <nuttx/binfmt/elf.h>
#include <nuttx/binfmt/symtab.h>
#include "platform/cxxinitialize.h"
#include "tests/romfs.h"
#include "tests/dirlist.h"

View File

@ -1,7 +1,7 @@
//***************************************************************************
// examples/helloxx/helloxx_main.cxx
//
// Copyright (C) 2009, 2011-2013 Gregory Nutt. All rights reserved.
// Copyright (C) 2009, 2011-2013, 2017 Gregory Nutt. All rights reserved.
// Author: Gregory Nutt <gnutt@nuttx.org>
//
// Redistribution and use in source and binary forms, with or without
@ -43,7 +43,8 @@
#include <debug.h>
#include <nuttx/init.h>
#include <nuttx/arch.h>
#include "platform/cxxinitialize.h"
//***************************************************************************
// Definitions

View File

@ -1,7 +1,7 @@
/****************************************************************************
* examples/nsh/nsh_main.c
*
* Copyright (C) 2007-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2013, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -45,8 +45,6 @@
#include <sched.h>
#include <errno.h>
#include <nuttx/arch.h>
#if defined(CONFIG_FS_BINFS) && (CONFIG_BUILTIN)
# include <nuttx/binfmt/builtin.h>
#endif
@ -55,6 +53,8 @@
# include <nuttx/binfmt/symtab.h>
#endif
#include "platform/cxxinitialize.h"
#include "nshlib/nshlib.h"
/****************************************************************************

View File

@ -1,7 +1,7 @@
/****************************************************************************
* examples/nxterm/nxterm_main.c
*
* Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -61,12 +61,12 @@
# endif
#endif
#include <nuttx/arch.h>
#include <nuttx/nx/nx.h>
#include <nuttx/nx/nxglib.h>
#include <nuttx/nx/nxfonts.h>
#include <nuttx/nx/nxterm.h>
#include "platform/cxxinitialize.h"
#include "nshlib/nshlib.h"
#include "nxterm_internal.h"

View File

@ -42,7 +42,7 @@
#include <cstdio>
#include <cstdlib>
#include <nuttx/arch.h>
#include "platform/cxxinitialize.h"
#include <uavcan/uavcan.hpp>

View File

@ -0,0 +1,87 @@
/****************************************************************************
* 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>
#ifdef CONFIG_PLATFORM_CONFIGDATA
/****************************************************************************
* 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 /* CONFIG_PLATFORM_CONFIGDATA */
#endif /* __APPS_INCLUDE_PLATFORM_CXXINITIALIZE_H */

View File

@ -3,3 +3,12 @@
# 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

@ -41,7 +41,7 @@
#include <debug.h>
#include <nuttx/arch.h>
#include "platform/cxxinitialize.h"
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)