uClibc++ compiles... but it is a long way from linking

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5293 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-11-01 21:08:56 +00:00
parent eb26187767
commit f5776dec9f
28 changed files with 446 additions and 414 deletions

View File

@ -179,6 +179,7 @@ static void test_rtti(void)
// Name: test_exception
//***************************************************************************/
#ifdef CONFIG_UCLIBCXX_EXCEPTION
static void test_exception(void)
{
cout << "test exception==========================" << endl;
@ -192,6 +193,7 @@ static void test_exception(void)
cout << "Catch exception: " << e.what() << endl;
}
}
#endif
//***************************************************************************
// Public Functions
@ -213,7 +215,9 @@ int cxxtest_main(int argc, char *argv[])
test_iostream();
test_stl();
test_rtti();
#ifdef CONFIG_UCLIBCXX_EXCEPTION
test_exception();
#endif
return 0;
}

114
misc/uClibc++/compare.sh Executable file
View File

@ -0,0 +1,114 @@
#!/bin/bash
usage="USAGE: $0 <full path to the NuttX directory>"
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

View File

@ -18,6 +18,9 @@
#ifndef __BASIC_DEFINITIONS
#define __BASIC_DEFINITIONS 1
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <system_configuration.h>
#pragma GCC visibility push(default)
@ -30,7 +33,6 @@
#else
# define _UCXXEXPORT
# define _UCXXLOCAL
#endif
#ifdef __GCC__

View File

@ -69,13 +69,13 @@ namespace std{
_UCXXEXPORT basic_filebuf() : basic_streambuf<charT, traits>(), 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);
}

View File

@ -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();
}

View File

@ -72,7 +72,7 @@ namespace std{
basic_istream<charT,traits>& operator>>(void*& p);
basic_istream<charT,traits>& operator>>(basic_streambuf<char_type,traits>* sb);
#ifdef __UCLIBCXX_HAS_FLOATS__
#ifdef CONFIG_HAVE_FLOAT
basic_istream<charT,traits>& operator>>(float& f);
basic_istream<charT,traits>& operator>>(double& f);
basic_istream<charT,traits>& operator>>(long double& f);
@ -447,7 +447,7 @@ namespace std{
return *this;
}
#ifdef __UCLIBCXX_HAS_FLOATS__
#ifdef CONFIG_HAVE_FLOAT
template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
basic_istream<charT,traits>::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);

View File

@ -302,7 +302,7 @@ namespace std{
};
#ifdef __UCLIBCXX_HAS_FLOATS__
#ifdef CONFIG_HAVE_FLOAT
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, float>{
public:
@ -335,7 +335,7 @@ namespace std{
}
};
#endif // ifdef __UCLIBCXX_HAS_FLOATS__
#endif // ifdef CONFIG_HAVE_FLOAT
template <class traits> class _UCXXEXPORT __istream_readin<traits, char, void*>{
public:

View File

@ -25,7 +25,8 @@
#define HEADER_STD_EXCEPTIONS 1
// Don't include support if not needed
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
#ifdef CONFIG_UCLIBCXX_EXCEPTION
#pragma GCC visibility push(default)

View File

@ -17,6 +17,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <cstdbool>
#include <basic_definitions>
#include <char_traits>
#include <string.h>

View File

@ -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 <exception>
#include <cstdlib>
#include <typeinfo>
#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

View File

@ -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
#define __UCLIBCXX_HAS_TLS__ 1
#define __WARNINGS__ "-Wall"
#define __BUILD_EXTRA_LIBRARIES__ ""
#define __HAVE_DOT_CONFIG__ 1
/* Target Features and Options */
#define __UCLIBCXX_HAS_TLS__ 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

View File

@ -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));
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,22 +166,26 @@ 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'
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')
@ -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;
}

View File

@ -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"

View File

@ -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

View File

@ -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
*
* 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 <cstdlib>
#include <cstring>
#include <func_exception>
//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 <unwind-cxx.h>
namespace __cxxabiv1{
extern "C" void * __cxa_allocate_exception(std::size_t thrown_size) throw(){
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
// 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));
if (0 == retval){
// Check to see that we actuall allocated memory
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(){
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(){
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
// 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)));
if (0 == retval){
// 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(){
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 *))
{
}
}

View File

@ -23,30 +23,31 @@
// 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{
namespace std
{
_UCXXEXPORT static char * __std_exception_what_value = "exception";
//We are providing our own versions to be sneaky
_UCXXEXPORT exception::~exception() throw(){
_UCXXEXPORT exception::~exception() throw()
{
//Empty function
}
_UCXXEXPORT const char* exception::what() const throw(){
_UCXXEXPORT const char* exception::what() const throw()
{
return __std_exception_what_value;
}
_UCXXEXPORT bad_exception::~bad_exception() throw(){
_UCXXEXPORT bad_exception::~bad_exception() throw()
{
}
}
#endif

View File

@ -24,59 +24,77 @@
namespace std{
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
#ifdef CONFIG_UCLIBCXX_EXCEPTION
_UCXXEXPORT void __throw_bad_alloc(){
_UCXXEXPORT void __throw_bad_alloc()
{
throw bad_alloc();
}
_UCXXEXPORT void __throw_out_of_range( const char * message){
if(message == 0){
_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){
_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){
_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){
_UCXXEXPORT void __throw_invalid_argument(const char * message)
{
if(message == 0)
{
throw invalid_argument();
}
throw invalid_argument(message);
}
#else
_UCXXEXPORT void __throw_bad_alloc(){
_UCXXEXPORT void __throw_bad_alloc()
{
abort();
}
_UCXXEXPORT void __throw_out_of_range( const char * ){
_UCXXEXPORT void __throw_out_of_range(const char *)
{
abort();
}
_UCXXEXPORT void __throw_overflow_error( const char * ){
_UCXXEXPORT void __throw_overflow_error(const char *)
{
abort();
}
_UCXXEXPORT void __throw_length_error(const char * ){
_UCXXEXPORT void __throw_length_error(const char *)
{
abort();
}
_UCXXEXPORT void __throw_invalid_argument(const char *){
_UCXXEXPORT void __throw_invalid_argument(const char *)
{
abort();
}

View File

@ -22,7 +22,6 @@
#include <istream>
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);

View File

@ -20,7 +20,7 @@
#include <exception>
#include <stdexcept>
#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__
#ifdef CONFIG_UCLIBCXX_EXCEPTION
namespace std{

View File

@ -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 <support>
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 *) ){
}

View File

@ -279,6 +279,9 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512
CONFIG_HAVE_CXX=y
# CONFIG_HAVE_CXXINITIALIZE is not set
# CONFIG_CXX_NEWLONG is not set
CONFIG_UCLIBCXX=y
CONFIG_UCLIBCXX_EXCEPTION=y
CONFIG_UCLIBCXX_IOSTREAM_BUFSIZE=32
#
# Application Configuration

View File

@ -46,4 +46,13 @@
// Namespace
//***************************************************************************
//***************************************************************************
// Namespace
//***************************************************************************
namespace std
{
using ::_Bool8;
}
#endif // __INCLUDE_CXX_CSTDBOOL

View File

@ -52,6 +52,8 @@ namespace std
using ::FILE;
using ::fpos_t;
using ::size_t;
using ::clearerr;
using ::fclose;
using ::fflush;
using ::feof;
@ -69,16 +71,24 @@ namespace std
using ::ftell;
using ::fwrite;
using ::gets;
using ::ungetc;
using ::printf;
using ::puts;
using ::rename;
using ::sprintf;
using ::asprintf;
using ::snprintf;
using ::ungetc;
using ::sscanf;
using ::perror;
using ::vprintf;
using ::vfprintf;
using ::vsprintf;
using ::avsprintf;
using ::vsnprintf;
using ::vsscanf;
using ::fdopen;
using ::statfs;
}

View File

@ -197,6 +197,7 @@
/* GCC supports both types double and long long */
# define CONFIG_HAVE_LONG_LONG 1
# define CONFIG_HAVE_FLOAT 1
# define CONFIG_HAVE_DOUBLE 1
# define CONFIG_HAVE_LONG_DOUBLE 1
@ -301,6 +302,7 @@
/* SDCC does not support type long long or type double */
# undef CONFIG_HAVE_LONG_LONG
# define CONFIG_HAVE_FLOAT 1
# undef CONFIG_HAVE_DOUBLE
# undef CONFIG_HAVE_LONG_DOUBLE
@ -406,6 +408,7 @@
*/
# undef CONFIG_HAVE_LONG_LONG
# define CONFIG_HAVE_FLOAT 1
# undef CONFIG_HAVE_DOUBLE
# undef CONFIG_HAVE_LONG_DOUBLE
@ -441,8 +444,9 @@
# undef CONFIG_LONG_IS_NOT_INT
# undef CONFIG_PTR_IS_NOT_INT
# undef CONFIG_HAVE_INLINE
# define inline
# define inline 1
# undef CONFIG_HAVE_LONG_LONG
# define CONFIG_HAVE_FLOAT 1
# undef CONFIG_HAVE_DOUBLE
# undef CONFIG_HAVE_LONG_DOUBLE
# undef CONFIG_CAN_PASS_STRUCTS

View File

@ -10,6 +10,10 @@ config HAVE_CXX
Toolchain supports C++ and CXX, CXXFLAGS, and COMPILEXX have been
defined in the configurations Make.defs file.
if HAVE_CXX
comment "Basic CXX Support"
config HAVE_CXXINITIALIZE
bool "Have C++ initialization"
default n
@ -25,3 +29,26 @@ config CXX_NEWLONG
size_t may be type long or type int. This matters for some
C++ library routines because the NuttX size_t might not have
the same underlying type as your toolchain's size_t.
comment "uClibc++ Standard C++ Library"
config UCLIBCXX
bool "Build uClibc++ (must be installed)"
default n
---help---
If you have installed uClibc++ into the NuttX source try, then it can
be built by selecting this option. See misc/uClibc++/README.txt for
information on installing uClibc++.
if UCLIBCXX
config UCLIBCXX_EXCEPTION
bool "Enable Exception Suppport"
default y
config UCLIBCXX_IOSTREAM_BUFSIZE
int "IO Stream Buffer Size"
default 32
endif
endif

View File

@ -49,12 +49,19 @@ CXXSRCS += libxx_newa.cxx
DEPPATH = --dep-path .
VPATH = .
# Include the uClibc++ Make.defs file (if it is present). If is present,
# Include the uClibc++ Make.defs file if selected. If it is included,
# the uClibc++/Make.defs file will add its files to the source file list,
# add its DEPPATH info, and will add the appropriate paths to the VPATH
# variable
#
# Note that an error will occur if you select CONFIG_LIBXX_UCLIBCXX
# without installing the uClibc++ package. This is intentional to let
# you know about the configuration problem. Refer to misc/uClibc++/README.txt
# for more information
-include uClibc++/Make.defs
ifeq ($(CONFIG_UCLIBCXX),y)
include uClibc++/Make.defs
endif
# Object Files

View File

@ -12,6 +12,10 @@ are recommended:
- uClibc++ http://cxx.uclibc.org/
- uSTL http://ustl.sourceforge.net/
There is a version of uClibc++ that is customized for NuttX that can
be found here: misc/uClibc++. See misc/uClibc++ for installation
instructions.
At present, only the following are supported here:
- void *operator new(std::size_t nbytes);
@ -19,6 +23,7 @@ At present, only the following are supported here:
- void operator delete[](void *ptr);
- void __cxa_pure_virtual(void);
- int __aeabi_atexit(void* object, void (*destroyer)(void*), void *dso_handle);
- int __cxa_atexit(__cxa_exitfunc_t func, FAR void *arg, FAR void *dso_handle);
operator new
------------

View File

@ -130,6 +130,9 @@ extern "C"
{
// Register the function to be called when the task/thread exists.
alloc->func = func;
alloc->arg = arg;
return on_exit(__cxa_callback, alloc);
}
else