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
@@ -18,31 +18,33 @@
#ifndef __BASIC_DEFINITIONS
#define __BASIC_DEFINITIONS 1
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <system_configuration.h>
#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
+5 -5
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);
}
+2 -2
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();
}
+3 -3
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);
@@ -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:
+3 -2
View File
@@ -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)
+1
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>
-165
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
@@ -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
+28 -14
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));
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;
}