Add support for C++ static constructors (at least to a few platforms)

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4438 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2012-02-28 21:58:24 +00:00
parent ff6f30399f
commit d8085b89db
48 changed files with 595 additions and 21 deletions
Executable → Regular
+2 -2
View File
@@ -39,8 +39,8 @@ ASRCS =
AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS =
COBJS = $(CSRCS:.c=$(OBJEXT))
CXXSRCS = libxx_new.cxx libxx_newa.cxx libxx_delete.cxx \
libxx_deletea.cxx libxx_cxapurevirtual.cxx
CXXSRCS = libxx_cxapurevirtual.cxx libxx_delete.cxx libxx_deletea.cxx \
libxx_eabi_atexit.cxx libxx_new.cxx libxx_newa.cxx
CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
+83
View File
@@ -0,0 +1,83 @@
//***************************************************************************
// libxx/libxx_eabi_atexit.cxx
//
// Copyright (C) 2012 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 <cstdlib>
//***************************************************************************
// Definitions
//***************************************************************************
//***************************************************************************
// Private Data
//***************************************************************************
extern "C"
{
//*************************************************************************
// Public Data
//*************************************************************************
void *__dso_handle = NULL;
//*************************************************************************
// Public Functions
//*************************************************************************
//*************************************************************************
// Name: __aeabi_atexit
//
// Description:
// Registers static object destructors. Normally atexit(f) should call
// __aeabi_atexit (NULL, f, NULL). But in the usage model here, static
// constructors are initialized at power up and are never destroyed
// because they have global scope and must persist for as long as the
// embedded device is powered on.
//
// Reference:
// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf
//
//*************************************************************************
int __aeabi_atexit(void* object, void (*destroyer)(void*), void *dso_handle)
{
//return __cxa_atexit(destroyer, object, dso_handle); // 0 ? OK; non-0 ? failed }
return 0;
}
}
Executable → Regular
View File
Executable → Regular
View File