From 7b2d6f83b69892f68b4e9fe3102b686169c86e2c Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 28 Feb 2012 21:58:24 +0000 Subject: Add support for C++ static constructors (at least to a few platforms) git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4438 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/libxx/Makefile | 4 +- nuttx/libxx/README.txt | 0 nuttx/libxx/libxx_cxapurevirtual.cxx | 0 nuttx/libxx/libxx_delete.cxx | 0 nuttx/libxx/libxx_deletea.cxx | 0 nuttx/libxx/libxx_eabi_atexit.cxx | 83 ++++++++++++++++++++++++++++++++++++ nuttx/libxx/libxx_new.cxx | 0 nuttx/libxx/libxx_newa.cxx | 0 8 files changed, 85 insertions(+), 2 deletions(-) mode change 100755 => 100644 nuttx/libxx/Makefile mode change 100755 => 100644 nuttx/libxx/README.txt mode change 100755 => 100644 nuttx/libxx/libxx_cxapurevirtual.cxx mode change 100755 => 100644 nuttx/libxx/libxx_delete.cxx mode change 100755 => 100644 nuttx/libxx/libxx_deletea.cxx create mode 100644 nuttx/libxx/libxx_eabi_atexit.cxx mode change 100755 => 100644 nuttx/libxx/libxx_new.cxx mode change 100755 => 100644 nuttx/libxx/libxx_newa.cxx (limited to 'nuttx/libxx') diff --git a/nuttx/libxx/Makefile b/nuttx/libxx/Makefile old mode 100755 new mode 100644 index 0326e64e45..f34a526000 --- a/nuttx/libxx/Makefile +++ b/nuttx/libxx/Makefile @@ -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) diff --git a/nuttx/libxx/README.txt b/nuttx/libxx/README.txt old mode 100755 new mode 100644 diff --git a/nuttx/libxx/libxx_cxapurevirtual.cxx b/nuttx/libxx/libxx_cxapurevirtual.cxx old mode 100755 new mode 100644 diff --git a/nuttx/libxx/libxx_delete.cxx b/nuttx/libxx/libxx_delete.cxx old mode 100755 new mode 100644 diff --git a/nuttx/libxx/libxx_deletea.cxx b/nuttx/libxx/libxx_deletea.cxx old mode 100755 new mode 100644 diff --git a/nuttx/libxx/libxx_eabi_atexit.cxx b/nuttx/libxx/libxx_eabi_atexit.cxx new file mode 100644 index 0000000000..aa0ff6956c --- /dev/null +++ b/nuttx/libxx/libxx_eabi_atexit.cxx @@ -0,0 +1,83 @@ +//*************************************************************************** +// libxx/libxx_eabi_atexit.cxx +// +// Copyright (C) 2012 Gregory Nutt. All rights reserved. +// Author: Gregory Nutt +// +// 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 +#include + +//*************************************************************************** +// 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; + } +} diff --git a/nuttx/libxx/libxx_new.cxx b/nuttx/libxx/libxx_new.cxx old mode 100755 new mode 100644 diff --git a/nuttx/libxx/libxx_newa.cxx b/nuttx/libxx/libxx_newa.cxx old mode 100755 new mode 100644 -- cgit v1.2.3