From 6bd29cb2e3c9dfedee2cbd73a324eaef76c292ae Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 1 Nov 2012 21:08:56 +0000 Subject: uClibc++ compiles... but it is a long way from linking git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5293 42af7a65-404d-4744-a932-0658087f49c3 --- misc/uClibc++/compare.sh | 114 ++++++++++++++ misc/uClibc++/include/uClibc++/basic_definitions | 22 +-- misc/uClibc++/include/uClibc++/fstream | 10 +- misc/uClibc++/include/uClibc++/ios | 4 +- misc/uClibc++/include/uClibc++/istream | 6 +- misc/uClibc++/include/uClibc++/istream_helpers | 4 +- misc/uClibc++/include/uClibc++/stdexcept | 5 +- misc/uClibc++/include/uClibc++/string | 1 + misc/uClibc++/include/uClibc++/support | 165 --------------------- .../include/uClibc++/system_configuration.h | 33 ++--- misc/uClibc++/include/uClibc++/unwind-cxx.h | 42 ++++-- misc/uClibc++/install.sh | 9 ++ misc/uClibc++/libxx/uClibc++/Make.defs | 3 +- misc/uClibc++/libxx/uClibc++/eh_alloc.cxx | 130 ++++++++++------ misc/uClibc++/libxx/uClibc++/exception.cxx | 63 ++++---- misc/uClibc++/libxx/uClibc++/func_exception.cxx | 110 ++++++++------ misc/uClibc++/libxx/uClibc++/istream.cxx | 4 +- misc/uClibc++/libxx/uClibc++/stdexcept.cxx | 2 +- misc/uClibc++/libxx/uClibc++/support.cxx | 53 ------- 19 files changed, 370 insertions(+), 410 deletions(-) create mode 100755 misc/uClibc++/compare.sh delete mode 100644 misc/uClibc++/include/uClibc++/support delete mode 100644 misc/uClibc++/libxx/uClibc++/support.cxx (limited to 'misc') diff --git a/misc/uClibc++/compare.sh b/misc/uClibc++/compare.sh new file mode 100755 index 000000000..ead5e5d69 --- /dev/null +++ b/misc/uClibc++/compare.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +usage="USAGE: $0 " +special="include/features.h" + +# Get the single, required command line argument + +nuttx_path=$1 +if [ -z "${nuttx_path}" ]; then + echo "ERROR: Missing path to the NuttX directory" + echo $usage + exit 1 +fi + +# Lots of sanity checking so that we do not do anything too stupid + +if [ ! -d libxx ]; then + echo "ERROR: Directory libxx does not exist in this directory" + echo " Please CD into the misc/uClibc++ directory and try again" + echo $usage + exit 1 +fi + +if [ ! -d include ]; then + echo "ERROR: Directory include does not exist in this directory" + echo " Please CD into the misc/uClibc++ directory and try again" + echo $usage + exit 1 +fi + +if [ ! -d "${nuttx_path}" ]; then + echo "ERROR: Directory ${nuttx_path} does not exist" + echo $usage + exit 1 +fi + +if [ ! -f "${nuttx_path}/Makefile" ]; then + echo "ERROR: No Makefile in directory ${nuttx_path}" + echo $usage + exit 1 +fi + +libxx_srcdir=${nuttx_path}/libxx + +if [ ! -d "${libxx_srcdir}" ]; then + echo "ERROR: Directory ${libxx_srcdir} does not exist" + echo $usage + exit 1 +fi + +if [ ! -f "${libxx_srcdir}/Makefile" ]; then + echo "ERROR: No Makefile in directory ${libxx_srcdir}" + echo $usage + exit 1 +fi + +uclibc_srcdir=${libxx_srcdir}/uClibc++ + +if [ ! -d "${uclibc_srcdir}" ]; then + echo "ERROR: Directory ${uclibc_srcdir} does not exiss" + echo " uClibc++ has not been installed" + echo $usage + exit 1 +fi + +nuttx_incdir=${nuttx_path}/include + +if [ ! -d "${nuttx_incdir}" ]; then + echo "ERROR: Directory ${nuttx_incdir} does not exist" + echo $usage + exit 1 +fi + +nuttxcxx_incdir=${nuttx_incdir}/cxx + +if [ ! -d "${nuttxcxx_incdir}" ]; then + echo "ERROR: Directory ${nuttxcxx_incdir} does not exist" + echo $usage + exit 1 +fi + +uclibc_incdir=${nuttx_incdir}/uClibc++ + +if [ ! -d "${uclibc_incdir}" ]; then + echo "ERROR: Directory ${uclibc_incdir} does not exist" + echo " uClibc++ has not been installed" + echo $usage + exit 1 +fi + +echo "##### Comparing libxx" + +filelist=`find libxx -type f | fgrep -v '.svn'` + +for file in $filelist; do + diff -u $file ${nuttx_path}/${file} +done + +echo "" +echo "##### Comparing include" + +filelist=`find include -type f | fgrep -v '.svn'` + +for file in $filelist; do + diff -u $file ${nuttx_path}/${file} +done + +echo "" +echo "##### Comparing other files" + +for file in $speical; do + diff -u $file ${nuttx_path}/${file} +done + diff --git a/misc/uClibc++/include/uClibc++/basic_definitions b/misc/uClibc++/include/uClibc++/basic_definitions index e0392b8ea..4f833ee94 100644 --- a/misc/uClibc++/include/uClibc++/basic_definitions +++ b/misc/uClibc++/include/uClibc++/basic_definitions @@ -18,31 +18,33 @@ #ifndef __BASIC_DEFINITIONS #define __BASIC_DEFINITIONS 1 +#include +#include + #include #pragma GCC visibility push(default) -//The following is used to support GCC symbol visibility patch +// The following is used to support GCC symbol visibility patch #ifdef GCC_HASCLASSVISIBILITY - #define _UCXXEXPORT __attribute__ ((visibility("default"))) - #define _UCXXLOCAL __attribute__ ((visibility("hidden"))) +# define _UCXXEXPORT __attribute__ ((visibility("default"))) +# define _UCXXLOCAL __attribute__ ((visibility("hidden"))) #else - #define _UCXXEXPORT - #define _UCXXLOCAL - +# define _UCXXEXPORT +# define _UCXXLOCAL #endif #ifdef __GCC__ -#define __UCLIBCXX_NORETURN __attribute__ ((__noreturn__)) +# define __UCLIBCXX_NORETURN __attribute__ ((__noreturn__)) #else -#define __UCLIBCXX_NORETURN +# define __UCLIBCXX_NORETURN #endif #ifdef __UCLIBCXX_HAS_TLS__ - #define __UCLIBCXX_TLS __thread +# define __UCLIBCXX_TLS __thread #else - #define __UCLIBCXX_TLS +# define __UCLIBCXX_TLS #endif diff --git a/misc/uClibc++/include/uClibc++/fstream b/misc/uClibc++/include/uClibc++/fstream index b8dd602c2..d5c1d083b 100644 --- a/misc/uClibc++/include/uClibc++/fstream +++ b/misc/uClibc++/include/uClibc++/fstream @@ -69,13 +69,13 @@ namespace std{ _UCXXEXPORT basic_filebuf() : basic_streambuf(), fp(0), pbuffer(0), gbuffer(0) { append=false; - pbuffer = new char_type[__UCLIBCXX_IOSTREAM_BUFSIZE__]; - gbuffer = new char_type[__UCLIBCXX_IOSTREAM_BUFSIZE__]; + pbuffer = new char_type[CONFIG_UCLIBCXX_IOSTREAM_BUFSIZE]; + gbuffer = new char_type[CONFIG_UCLIBCXX_IOSTREAM_BUFSIZE]; - this->setp(pbuffer, pbuffer + __UCLIBCXX_IOSTREAM_BUFSIZE__); + this->setp(pbuffer, pbuffer + CONFIG_UCLIBCXX_IOSTREAM_BUFSIZE); //Position get buffer so that there is no data available - this->setg(gbuffer, gbuffer + __UCLIBCXX_IOSTREAM_BUFSIZE__, - gbuffer + __UCLIBCXX_IOSTREAM_BUFSIZE__); + this->setg(gbuffer, gbuffer + CONFIG_UCLIBCXX_IOSTREAM_BUFSIZE, + gbuffer + CONFIG_UCLIBCXX_IOSTREAM_BUFSIZE); } diff --git a/misc/uClibc++/include/uClibc++/ios b/misc/uClibc++/include/uClibc++/ios index 63dc4edbc..2af1a14cb 100644 --- a/misc/uClibc++/include/uClibc++/ios +++ b/misc/uClibc++/include/uClibc++/ios @@ -35,7 +35,7 @@ namespace std{ class _UCXXEXPORT ios_base { public: class failure; -#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ +#ifdef CONFIG_UCLIBCXX_EXCEPTION class failure : public exception { public: explicit failure(const std::string&) { } @@ -303,7 +303,7 @@ namespace std{ } _UCXXEXPORT void setstate(iostate state) { clear(rdstate() | state); -#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ +#ifdef CONFIG_UCLIBCXX_EXCEPTION if(rdstate() & throw_mask){ throw failure(); } diff --git a/misc/uClibc++/include/uClibc++/istream b/misc/uClibc++/include/uClibc++/istream index d67f48f57..37ffa127b 100644 --- a/misc/uClibc++/include/uClibc++/istream +++ b/misc/uClibc++/include/uClibc++/istream @@ -72,7 +72,7 @@ namespace std{ basic_istream& operator>>(void*& p); basic_istream& operator>>(basic_streambuf* sb); -#ifdef __UCLIBCXX_HAS_FLOATS__ +#ifdef CONFIG_HAVE_FLOAT basic_istream& operator>>(float& f); basic_istream& operator>>(double& f); basic_istream& operator>>(long double& f); @@ -447,7 +447,7 @@ namespace std{ return *this; } -#ifdef __UCLIBCXX_HAS_FLOATS__ +#ifdef CONFIG_HAVE_FLOAT template _UCXXEXPORT basic_istream& basic_istream::operator>>(float& n) { @@ -578,7 +578,7 @@ namespace std{ template <> _UCXXEXPORT istream & istream::operator>>(long int &n); template <> _UCXXEXPORT istream & istream::operator>>(void *& p); -#ifdef __UCLIBCXX_HAS_FLOATS__ +#ifdef CONFIG_HAVE_FLOAT template <> _UCXXEXPORT istream & istream::operator>>(float &f); template <> _UCXXEXPORT istream & istream::operator>>(double &f); template <> _UCXXEXPORT istream & istream::operator>>(long double &f); diff --git a/misc/uClibc++/include/uClibc++/istream_helpers b/misc/uClibc++/include/uClibc++/istream_helpers index 0bdca7d21..36765dd70 100644 --- a/misc/uClibc++/include/uClibc++/istream_helpers +++ b/misc/uClibc++/include/uClibc++/istream_helpers @@ -302,7 +302,7 @@ namespace std{ }; -#ifdef __UCLIBCXX_HAS_FLOATS__ +#ifdef CONFIG_HAVE_FLOAT template class _UCXXEXPORT __istream_readin{ public: @@ -335,7 +335,7 @@ namespace std{ } }; -#endif // ifdef __UCLIBCXX_HAS_FLOATS__ +#endif // ifdef CONFIG_HAVE_FLOAT template class _UCXXEXPORT __istream_readin{ public: diff --git a/misc/uClibc++/include/uClibc++/stdexcept b/misc/uClibc++/include/uClibc++/stdexcept index 7557f24c4..60305bcd9 100644 --- a/misc/uClibc++/include/uClibc++/stdexcept +++ b/misc/uClibc++/include/uClibc++/stdexcept @@ -24,8 +24,9 @@ #ifndef HEADER_STD_EXCEPTIONS #define HEADER_STD_EXCEPTIONS 1 -//Don't include support if not needed -#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ +// Don't include support if not needed + +#ifdef CONFIG_UCLIBCXX_EXCEPTION #pragma GCC visibility push(default) diff --git a/misc/uClibc++/include/uClibc++/string b/misc/uClibc++/include/uClibc++/string index 7826ce77c..d04579414 100644 --- a/misc/uClibc++/include/uClibc++/string +++ b/misc/uClibc++/include/uClibc++/string @@ -17,6 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include #include #include diff --git a/misc/uClibc++/include/uClibc++/support b/misc/uClibc++/include/uClibc++/support deleted file mode 100644 index 9279987ad..000000000 --- a/misc/uClibc++/include/uClibc++/support +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz - - This file is part of the uClibc++ Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include - -#ifndef HEADER_ULC_SUPPORT -#define HEADER_ULC_SUPPORT 1 - -using namespace std; - -//From C++ ABI spec -typedef enum { - _URC_NO_REASON = 0, - _URC_FOREIGN_EXCEPTION_CAUGHT = 1, - _URC_FATAL_PHASE2_ERROR = 2, - _URC_FATAL_PHASE1_ERROR = 3, - _URC_NORMAL_STOP = 4, - _URC_END_OF_STACK = 5, - _URC_HANDLER_FOUND = 6, - _URC_INSTALL_CONTEXT = 7, - _URC_CONTINUE_UNWIND = 8 -} _Unwind_Reason_Code; - - -typedef void (*_Unwind_Exception_Cleanup_Fn) - (_Unwind_Reason_Code reason, struct _Unwind_Exception *exc); - -//The following definitions were grabbed from the gcc implementation -typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__))); -typedef unsigned _Unwind_Word __attribute__((__mode__(__word__))); -typedef signed _Unwind_Sword __attribute__((__mode__(__word__))); -typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__))); -typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code, struct _Unwind_Exception *); - -typedef int _Unwind_Action; -static const _Unwind_Action _UA_SEARCH_PHASE = 1; -static const _Unwind_Action _UA_CLEANUP_PHASE = 2; -static const _Unwind_Action _UA_HANDLER_FRAME = 4; -static const _Unwind_Action _UA_FORCE_UNWIND = 8; - -const _Unwind_Exception_Class __uclibcxx_exception_class = (((((((( - _Unwind_Exception_Class) 'u' << 8 | (_Unwind_Exception_Class) 'l') << 8 - | (_Unwind_Exception_Class) 'i') << 8 | (_Unwind_Exception_Class) 'b') << 8 - | (_Unwind_Exception_Class) 'C')<< 8 | (_Unwind_Exception_Class) '+') << 8 - | (_Unwind_Exception_Class) '+') << 8 | (_Unwind_Exception_Class) '\0'); - - -#define _UA_SEARCH_PHASE 1 -#define _UA_CLEANUP_PHASE 2 -#define _UA_HANDLER_FRAME 4 -#define _UA_FORCE_UNWIND 8 -#define _UA_END_OF_STACK 16 - -struct _Unwind_Exception{ - _Unwind_Exception_Class exception_class; //Type of exception, eg ulibC++\0 - _Unwind_Exception_Cleanup_Fn exception_cleanup; //Destructor if from diff runtime - _Unwind_Word private_1; //Don't touch at all! - _Unwind_Word private_2; //Don't touch at all! -} __attribute__((__aligned__)); - - -//The following structure is system-dependent and defined by the compiler -//Thus it's definition was copied from the gcc 3.4.0 header files -struct _Unwind_Context; -//{ -// void *reg[DWARF_FRAME_REGISTERS+1]; -// void *cfa; -// void *ra; -// void *lsda; -// struct dwarf_eh_bases bases; -// _Unwind_Word args_size; -//}; - - - -_Unwind_Reason_Code _Unwind_RaiseException ( struct _Unwind_Exception *exception_object ); - -//_Unwind_ForcedUnwind - -typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) - (int version, _Unwind_Action actions, _Unwind_Exception_Class exceptionClass, - struct _Unwind_Exception *exceptionObject, - struct _Unwind_Context *context, void *stop_parameter ); - -_Unwind_Reason_Code _Unwind_ForcedUnwind ( - struct _Unwind_Exception *exception_object, _Unwind_Stop_Fn stop, - void *stop_parameter ); - -void _Unwind_Resume (struct _Unwind_Exception *exception_object); -void _Unwind_DeleteException (struct _Unwind_Exception *exception_object); - -_Unwind_Word _Unwind_GetGR (struct _Unwind_Context *context, int index); -void _Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word); - -_Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *context); -void _Unwind_SetIP (struct _Unwind_Context *context, _Unwind_Ptr new_value); - -_Unwind_Ptr _Unwind_GetLanguageSpecificData (struct _Unwind_Context *context); -_Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *context); - -_Unwind_Reason_Code (*__personality_routine) - (int version, //Should be 1 - _Unwind_Action actions, //Actions the routine will perform (bitmask) - _Unwind_Exception_Class exceptionClass, //Type of exception - vendor is high 4 bytes - struct _Unwind_Exception *exceptionObject, //Points to exception header - struct _Unwind_Context *context); //Unwinder state information - - -/*The following part is the Level II ABI which is required for compatability*/ -//This might be the only stuff that *I* need to implement - -struct __cxa_exception { - std::type_info *exceptionType; //Type of thrown exception - void (*exceptionDestructor) (void *); //Pointer to the destructor - unexpected_handler unexpectedHandler; //Unexpected handler to use - terminate_handler terminateHandler; //Terminate handle to use - __cxa_exception *nextException; //per thread linked list - - int handlerCount; //How many handlers have caught this - int handlerSwitchValue; - const char *actionRecord; - const char *languageSpecificData; - void *catchTemp; - void *adjustedPtr; - - _Unwind_Exception unwindHeader; -}; - -struct __cxa_eh_globals { - __cxa_exception *caughtExceptions; - unsigned int uncaughtExceptions; -}; - -extern "C" __cxa_eh_globals *__cxa_get_globals(void); //Return ptr to the eh_globals object for current thread -extern "C" __cxa_eh_globals *__cxa_get_globals_fast(void); //Same as above, assumes that above called at least once - -extern "C" void *__cxa_allocate_exception(size_t thrown_size); //Allocate space for exception plus header -extern "C" void __cxa_free_exception(void *thrown_exception); //Free space allocated from the above - -extern "C" void __cxa_throw (void *thrown_exception, //This is the actual throw call -// std::type_info *tinfo, //Type of object - void * tinfo, //Type of object - void (*dest) (void *) ); //Pointer to destructor destroy object - - -#endif - diff --git a/misc/uClibc++/include/uClibc++/system_configuration.h b/misc/uClibc++/include/uClibc++/system_configuration.h index 4db8e8bd8..e813f2076 100644 --- a/misc/uClibc++/include/uClibc++/system_configuration.h +++ b/misc/uClibc++/include/uClibc++/system_configuration.h @@ -1,28 +1,20 @@ -/* - * Automatically generated C config: don't edit - */ -/* - * Version Number +/* This file is being deprecated. Eventually all configuration options will + * need to be moved into the NuttX configuration system. */ + +/* Version Number */ + #define __UCLIBCXX_MAJOR__ 0 #define __UCLIBCXX_MINOR__ 2 #define __UCLIBCXX_SUBLEVEL__ 4 -/* - * Target Features and Options - */ -#define __UCLIBCXX_HAS_FLOATS__ 1 -#define __UCLIBCXX_HAS_LONG_DOUBLE__ 1 +/* Target Features and Options */ + #define __UCLIBCXX_HAS_TLS__ 1 -#define __WARNINGS__ "-Wall" -#define __BUILD_EXTRA_LIBRARIES__ "" -#define __HAVE_DOT_CONFIG__ 1 -/* - * String and I/O Stream Support - */ +/* String and I/O Stream Support */ + #undef __UCLIBCXX_HAS_WCHAR__ -#define __UCLIBCXX_IOSTREAM_BUFSIZE__ 32 #define __UCLIBCXX_HAS_LFS__ 1 #define __UCLIBCXX_SUPPORT_CDIR__ 1 #define __UCLIBCXX_SUPPORT_CIN__ 1 @@ -30,9 +22,8 @@ #define __UCLIBCXX_SUPPORT_CERR__ 1 #undef __UCLIBCXX_SUPPORT_CLOG__ -/* - * STL and Code Expansion - */ +/* STL and Code Expansion */ + #define __UCLIBCXX_STL_BUFFER_SIZE__ 32 #define __UCLIBCXX_CODE_EXPANSION__ 1 #define __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 1 @@ -44,5 +35,3 @@ #define __UCLIBCXX_EXPAND_OSTREAM_CHAR__ 1 #define __UCLIBCXX_EXPAND_FSTREAM_CHAR__ 1 #define __UCLIBCXX_EXPAND_SSTREAM_CHAR__ 1 - - diff --git a/misc/uClibc++/include/uClibc++/unwind-cxx.h b/misc/uClibc++/include/uClibc++/unwind-cxx.h index 4a8961a97..b0d5b416b 100644 --- a/misc/uClibc++/include/uClibc++/unwind-cxx.h +++ b/misc/uClibc++/include/uClibc++/unwind-cxx.h @@ -79,10 +79,10 @@ struct __cxa_exception _Unwind_Exception unwindHeader; }; - // A dependent C++ exception object consists of a header, which is a wrapper // around an unwind object header with additional C++ specific information, // followed by the exception object itself. + struct __cxa_dependent_exception { // The primary exception @@ -112,44 +112,52 @@ struct __cxa_dependent_exception _Unwind_Exception unwindHeader; }; - // Each thread in a C++ program has access to a __cxa_eh_globals object. + struct __cxa_eh_globals { __cxa_exception *caughtExceptions; unsigned int uncaughtExceptions; }; - // The __cxa_eh_globals for the current thread can be obtained by using // either of the following functions. The "fast" version assumes at least // one prior call of __cxa_get_globals has been made from the current // thread, so no initialization is necessary. + extern "C" __cxa_eh_globals *__cxa_get_globals () throw(); extern "C" __cxa_eh_globals *__cxa_get_globals_fast () throw(); // Allocate memory for the primary exception plus the thrown object. + extern "C" void *__cxa_allocate_exception(std::size_t thrown_size) throw(); + // Allocate memory for dependent exception. + extern "C" __cxa_dependent_exception *__cxa_allocate_dependent_exception() throw(); // Free the space allocated for the primary exception. + extern "C" void __cxa_free_exception(void *thrown_exception) throw(); + // Free the space allocated for the dependent exception. + extern "C" void __cxa_free_dependent_exception(__cxa_dependent_exception *dependent_exception) throw(); // Throw the exception. + extern "C" void __cxa_throw (void *thrown_exception, - std::type_info *tinfo, - void (*dest) (void *)) - __attribute__((noreturn)); + std::type_info *tinfo, + void (*dest) (void *)) __attribute__((noreturn)); // Used to implement exception handlers. + extern "C" void *__cxa_begin_catch (void *) throw(); extern "C" void __cxa_end_catch (); extern "C" void __cxa_rethrow () __attribute__((noreturn)); // These facilitate code generation for recurring situations. + extern "C" void __cxa_bad_cast (); extern "C" void __cxa_bad_typeid (); @@ -158,24 +166,28 @@ extern "C" void __cxa_bad_typeid (); // Handles re-checking the exception specification if unexpectedHandler // throws, and if bad_exception needs to be thrown. Called from the // compiler. + extern "C" void __cxa_call_unexpected (void *) __attribute__((noreturn)); // Invokes given handler, dying appropriately if the user handler was // so inconsiderate as to return. + extern void __terminate(std::terminate_handler) __attribute__((noreturn)); extern void __unexpected(std::unexpected_handler) __attribute__((noreturn)); // The current installed user handlers. + extern std::terminate_handler __terminate_handler; extern std::unexpected_handler __unexpected_handler; // These are explicitly GNU C++ specific. // This is the exception class we report -- "GNUCC++\0". -const _Unwind_Exception_Class __gxx_exception_class -= ((((((((_Unwind_Exception_Class) 'G' - << 8 | (_Unwind_Exception_Class) 'N') - << 8 | (_Unwind_Exception_Class) 'U') + +const _Unwind_Exception_Class __gxx_exception_class = + ((((((((_Unwind_Exception_Class) 'G' + << 8 | (_Unwind_Exception_Class) 'N') + << 8 | (_Unwind_Exception_Class) 'U') << 8 | (_Unwind_Exception_Class) 'C') << 8 | (_Unwind_Exception_Class) 'C') << 8 | (_Unwind_Exception_Class) '+') @@ -183,25 +195,27 @@ const _Unwind_Exception_Class __gxx_exception_class << 8 | (_Unwind_Exception_Class) '\0'); // GNU C++ personality routine, Version 0. + extern "C" _Unwind_Reason_Code __gxx_personality_v0 (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *, struct _Unwind_Context *); // GNU C++ sjlj personality routine, Version 0. + extern "C" _Unwind_Reason_Code __gxx_personality_sj0 (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *, struct _Unwind_Context *); // Acquire the C++ exception header from the C++ object. -static inline __cxa_exception * -__get_exception_header_from_obj (void *ptr) + +static inline __cxa_exception *__get_exception_header_from_obj (void *ptr) { return reinterpret_cast<__cxa_exception *>(ptr) - 1; } // Acquire the C++ exception header from the generic exception header. -static inline __cxa_exception * -__get_exception_header_from_ue (_Unwind_Exception *exc) + +static inline __cxa_exception *__get_exception_header_from_ue (_Unwind_Exception *exc) { return reinterpret_cast<__cxa_exception *>(exc + 1) - 1; } diff --git a/misc/uClibc++/install.sh b/misc/uClibc++/install.sh index 065738e1a..d0bf8e211 100755 --- a/misc/uClibc++/install.sh +++ b/misc/uClibc++/install.sh @@ -261,6 +261,15 @@ if [ ! -d "${nuttxcxx_incdir}" ]; then exit 1 fi +uclibc_incdir=${nuttx_incdir}/uClibc++ + +if [ -d "${uclibc_incdir}" ]; then + echo "ERROR: Directory ${uclibc_incdir} already exists" + echo " Please remove the ${uclibc_incdir} directory and try again" + echo $usage + exit 1 +fi + # Licensing echo "You are about to install the uClibc++ library into the NuttX source" diff --git a/misc/uClibc++/libxx/uClibc++/Make.defs b/misc/uClibc++/libxx/uClibc++/Make.defs index 9f1b2f51f..a4e7a02f7 100644 --- a/misc/uClibc++/libxx/uClibc++/Make.defs +++ b/misc/uClibc++/libxx/uClibc++/Make.defs @@ -43,8 +43,7 @@ CXXSRCS += iostream.cxx istream.cxx iterator.cxx limits.cxx list.cxx CXXSRCS += locale.cxx map.cxx new_handler.cxx new_op.cxx new_opnt.cxx CXXSRCS += new_opv.cxx new_opvnt.cxx numeric.cxx ostream.cxx queue.cxx CXXSRCS += set.cxx sstream.cxx stack.cxx stdexcept.cxx streambuf.cxx -CXXSRCS += string.cxx support.cxx typeinfo.cxx utility.cxx valarray.cxx -CXXSRCS += vector.cxx +CXXSRCS += string.cxx typeinfo.cxx utility.cxx valarray.cxx vector.cxx # Add the path to the uClibc++ subdirectory diff --git a/misc/uClibc++/libxx/uClibc++/eh_alloc.cxx b/misc/uClibc++/libxx/uClibc++/eh_alloc.cxx index 5098196d8..ea3308a30 100644 --- a/misc/uClibc++/libxx/uClibc++/eh_alloc.cxx +++ b/misc/uClibc++/libxx/uClibc++/eh_alloc.cxx @@ -1,61 +1,93 @@ -/* Copyright (C) 2006 Garrett A. Kajmowicz - - This file is part of the uClibc++ Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation, version 2.1 - of the License. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +/* Copyright (C) 2006 Garrett A. Kajmowicz + * + * This file is part of the uClibc++ Library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include #include #include -//This is a system-specific header which does all of the error-handling management +// This is a system-specific header which does all of the error-handling +// management + #include -namespace __cxxabiv1{ - -extern "C" void * __cxa_allocate_exception(std::size_t thrown_size) throw(){ - void *retval; - //The sizeof crap is required by Itanium ABI because we need to provide space for - //accounting information which is implementaion (gcc) specified - retval = malloc (thrown_size + sizeof(__cxa_exception)); - if (0 == retval){ - std::terminate(); - } - memset (retval, 0, sizeof(__cxa_exception)); - return (void *)((unsigned char *)retval + sizeof(__cxa_exception)); -} +namespace __cxxabiv1 +{ + extern "C" void *__cxa_allocate_exception(std::size_t thrown_size) throw() + { + void *retval; -extern "C" void __cxa_free_exception(void *vptr) throw(){ - free( (char *)(vptr) - sizeof(__cxa_exception) ); -} + // The amount of data needed is the size of the object *PLUS* + // the size of the header. The header is of struct __cxa_exception + // The address needs to be adjusted because the pointer we return + // should not point to the start of the memory, but to the point + // where the object being thrown actually starts + retval = malloc (thrown_size + sizeof(__cxa_exception)); -extern "C" __cxa_dependent_exception * __cxa_allocate_dependent_exception() throw(){ - __cxa_dependent_exception *retval; - //The sizeof crap is required by Itanium ABI because we need to provide space for - //accounting information which is implementaion (gcc) specified - retval = static_cast<__cxa_dependent_exception*>(malloc (sizeof(__cxa_dependent_exception))); - if (0 == retval){ - std::terminate(); - } - memset (retval, 0, sizeof(__cxa_dependent_exception)); - return retval; -} + // Check to see that we actuall allocated memory -extern "C" void __cxa_free_dependent_exception(__cxa_dependent_exception *vptr) throw(){ - free( (char *)(vptr) ); -} + if (0 == retval) + { + std::terminate(); + } + + // Need to do a typecast to char* otherwize we are doing math with + // a void* which makes the compiler cranky (Like me) + + memset (retval, 0, sizeof(__cxa_exception)); + return (void *)((unsigned char *)retval + sizeof(__cxa_exception)); + } + + extern "C" void __cxa_free_exception(void *vptr) throw() + { + free( (char *)(vptr) - sizeof(__cxa_exception) ); + } + + extern "C" __cxa_dependent_exception *__cxa_allocate_dependent_exception() throw() + { + __cxa_dependent_exception *retval; + + // The amount of data needed is the size of the object *PLUS* + // the size of the header. The header is of struct __cxa_exception + // The address needs to be adjusted because the pointer we return + // should not point to the start of the memory, but to the point + // where the object being thrown actually starts + + retval = static_cast<__cxa_dependent_exception*>(malloc (sizeof(__cxa_dependent_exception))); + + // Check to see that we actuall allocated memory + + if (0 == retval) + { + std::terminate(); + } + + memset (retval, 0, sizeof(__cxa_dependent_exception)); + return retval; + } + + extern "C" void __cxa_free_dependent_exception(__cxa_dependent_exception *vptr) throw() + { + free( (char *)(vptr) ); + } + + extern "C" void __cxa_throw(void *thrown_exception, std::type_info *tinfo, void (*dest) (void *)) + { + } } diff --git a/misc/uClibc++/libxx/uClibc++/exception.cxx b/misc/uClibc++/libxx/uClibc++/exception.cxx index 82021ddb6..6d487a116 100644 --- a/misc/uClibc++/libxx/uClibc++/exception.cxx +++ b/misc/uClibc++/libxx/uClibc++/exception.cxx @@ -1,52 +1,53 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz +/* Copyright (C) 2004 Garrett A. Kajmowicz - This file is part of the uClibc++ Library. + This file is part of the uClibc++ Library. - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include -//We can't do this yet because gcc is too stupid to be able to handle -//different implementations of exception class. +// We can't do this yet because gcc is too stupid to be able to handle +// different implementations of exception class. -#undef __UCLIBCXX_EXCEPTION_SUPPORT__ +#undef CONFIG_UCLIBCXX_EXCEPTION -#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ +#ifdef CONFIG_UCLIBCXX_EXCEPTION -namespace std{ - _UCXXEXPORT static char * __std_exception_what_value = "exception"; +namespace std +{ + _UCXXEXPORT static char * __std_exception_what_value = "exception"; - //We are providing our own versions to be sneaky + //We are providing our own versions to be sneaky - _UCXXEXPORT exception::~exception() throw(){ - //Empty function - } + _UCXXEXPORT exception::~exception() throw() + { + //Empty function + } - _UCXXEXPORT const char* exception::what() const throw(){ - return __std_exception_what_value; - } - - _UCXXEXPORT bad_exception::~bad_exception() throw(){ - - } + _UCXXEXPORT const char* exception::what() const throw() + { + return __std_exception_what_value; + } + _UCXXEXPORT bad_exception::~bad_exception() throw() + { + } } - #endif diff --git a/misc/uClibc++/libxx/uClibc++/func_exception.cxx b/misc/uClibc++/libxx/uClibc++/func_exception.cxx index fab095f3d..9971871ef 100644 --- a/misc/uClibc++/libxx/uClibc++/func_exception.cxx +++ b/misc/uClibc++/libxx/uClibc++/func_exception.cxx @@ -1,20 +1,20 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz +/* Copyright (C) 2004 Garrett A. Kajmowicz - This file is part of the uClibc++ Library. + This file is part of the uClibc++ Library. - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include @@ -24,60 +24,78 @@ namespace std{ -#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ +#ifdef CONFIG_UCLIBCXX_EXCEPTION -_UCXXEXPORT void __throw_bad_alloc(){ - throw bad_alloc(); +_UCXXEXPORT void __throw_bad_alloc() +{ + throw bad_alloc(); } -_UCXXEXPORT void __throw_out_of_range( const char * message){ - if(message == 0){ - throw out_of_range(); - } - throw out_of_range(message); +_UCXXEXPORT void __throw_out_of_range(const char * message) +{ + if(message == 0) + { + throw out_of_range(); + } + + throw out_of_range(message); } -_UCXXEXPORT void __throw_overflow_error( const char * message){ - if(message == 0){ - throw overflow_error(); - } - throw overflow_error(message); +_UCXXEXPORT void __throw_overflow_error(const char * message) +{ + if(message == 0) + { + throw overflow_error(); + } + + throw overflow_error(message); } -_UCXXEXPORT void __throw_length_error(const char * message){ - if(message == 0){ - throw length_error(); - } - throw length_error(message); +_UCXXEXPORT void __throw_length_error(const char * message) +{ + if(message == 0) + { + throw length_error(); + } + + throw length_error(message); } -_UCXXEXPORT void __throw_invalid_argument(const char * message){ - if(message == 0){ - throw invalid_argument(); - } - throw invalid_argument(message); +_UCXXEXPORT void __throw_invalid_argument(const char * message) +{ + if(message == 0) + { + throw invalid_argument(); + } + + throw invalid_argument(message); } #else -_UCXXEXPORT void __throw_bad_alloc(){ - abort(); +_UCXXEXPORT void __throw_bad_alloc() +{ + abort(); } -_UCXXEXPORT void __throw_out_of_range( const char * ){ - abort(); +_UCXXEXPORT void __throw_out_of_range(const char *) +{ + abort(); } -_UCXXEXPORT void __throw_overflow_error( const char * ){ - abort(); +_UCXXEXPORT void __throw_overflow_error(const char *) +{ + abort(); } -_UCXXEXPORT void __throw_length_error(const char * ){ - abort(); +_UCXXEXPORT void __throw_length_error(const char *) +{ + abort(); } -_UCXXEXPORT void __throw_invalid_argument(const char *){ - abort(); +_UCXXEXPORT void __throw_invalid_argument(const char *) +{ + abort(); } #endif diff --git a/misc/uClibc++/libxx/uClibc++/istream.cxx b/misc/uClibc++/libxx/uClibc++/istream.cxx index 9e9613973..bcb81c0f9 100644 --- a/misc/uClibc++/libxx/uClibc++/istream.cxx +++ b/misc/uClibc++/libxx/uClibc++/istream.cxx @@ -22,7 +22,6 @@ #include - namespace std{ #ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ @@ -59,8 +58,7 @@ namespace std{ template _UCXXEXPORT istream & istream::operator>>(void *& p); template _UCXXEXPORT istream & operator>>(istream & is, char & c); - -#ifdef __UCLIBCXX_HAS_FLOATS__ +#ifdef CONFIG_HAVE_FLOAT template _UCXXEXPORT istream & istream::operator>>(float &f); template _UCXXEXPORT istream & istream::operator>>(double &f); template _UCXXEXPORT istream & istream::operator>>(long double &f); diff --git a/misc/uClibc++/libxx/uClibc++/stdexcept.cxx b/misc/uClibc++/libxx/uClibc++/stdexcept.cxx index 90dccc7a4..d372c0b77 100644 --- a/misc/uClibc++/libxx/uClibc++/stdexcept.cxx +++ b/misc/uClibc++/libxx/uClibc++/stdexcept.cxx @@ -20,7 +20,7 @@ #include #include -#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ +#ifdef CONFIG_UCLIBCXX_EXCEPTION namespace std{ diff --git a/misc/uClibc++/libxx/uClibc++/support.cxx b/misc/uClibc++/libxx/uClibc++/support.cxx deleted file mode 100644 index 875459442..000000000 --- a/misc/uClibc++/libxx/uClibc++/support.cxx +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz - - This file is part of the uClibc++ Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include - -extern "C" void *__cxa_allocate_exception(size_t thrown_size){ - void * retval; - -// The amount of data needed is the size of the object *PLUS* -// the size of the header. The header is of struct __cxa_exception -// The address needs to be adjusted because the pointer we return -// should not point to the start of the memory, but to the point -// where the object being thrown actually starts -// - retval = malloc(thrown_size + sizeof(__cxa_exception)); - -// Check to see that we actuall allocated memory - if(retval == 0){ - std::terminate(); - } - - //Need to do a typecast to char* otherwize we are doing math with - //a void* which makes the compiler cranky (Like me) - return ((char *)retval + sizeof(__cxa_exception)); -} - -extern "C" void __cxa_free_exception(void *thrown_exception){ - - - -} - -extern "C" void __cxa_throw (void *thrown_exception, void *info,void (*dest) (void *) ){ - - -} - -- cgit v1.2.3