More uClibc++ build fixes

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5299 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-11-02 16:35:37 +00:00
parent 1850aff278
commit 708ebb52f0
10 changed files with 2339 additions and 1847 deletions

View File

@ -247,9 +247,13 @@ examples/cxxtest
is not included in the NuttX source tree by default, but must be installed
(see misc/uClibc++/README.txt for installation).
The only NuttX setting that is required is:
The NuttX setting that are required include:
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_UCLIBCXX=y
Additional uClibc++ settings may be required in your build environment.
The uClibc++ test includes simple test of:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -37,13 +37,16 @@
CXXSRCS += algorithm.cxx associative_base.cxx bitset.cxx char_traits.cxx
CXXSRCS += complex.cxx del_op.cxx del_opnt.cxx del_opv.cxx del_opvnt.cxx
CXXSRCS += deque.cxx exception.cxx fstream.cxx func_exception.cxx
CXXSRCS += iomanip.cxx ios.cxx iostream.cxx istream.cxx iterator.cxx
CXXSRCS += limits.cxx list.cxx locale.cxx map.cxx new_handler.cxx
CXXSRCS += new_op.cxx new_opnt.cxx new_opv.cxx new_opvnt.cxx numeric.cxx
CXXSRCS += ostream.cxx queue.cxx set.cxx sstream.cxx stack.cxx
CXXSRCS += stdexcept.cxx streambuf.cxx string.cxx typeinfo.cxx utility.cxx
CXXSRCS += valarray.cxx vector.cxx
CXXSRCS += deque.cxx fstream.cxx iomanip.cxx ios.cxx iostream.cxx
CXXSRCS += istream.cxx iterator.cxx limits.cxx list.cxx locale.cxx
CXXSRCS += map.cxx new_handler.cxx new_op.cxx new_opnt.cxx new_opv.cxx
CXXSRCS += new_opvnt.cxx numeric.cxx ostream.cxx queue.cxx set.cxx
CXXSRCS += sstream.cxx stack.cxx streambuf.cxx string.cxx typeinfo.cxx
CXXSRCS += utility.cxx valarray.cxx vector.cxx
ifeq ($(CONFIG_UCLIBCXX_EXCEPTION),y)
CXXSRCS += exception.cxx func_exception.cxx stdexcept.cxx
endif
ifneq ($(CONFIG_UCLIBCXX_HAVE_LIBSUPCXX),y)
CXXSRCS += eh_alloc.cxx eh_globals.cxx eh_terminate.cxx

View File

@ -20,8 +20,6 @@
#include <cstdlib>
#include <exception>
#ifdef CONFIG_UCLIBCXX_EXCEPTION
namespace std
{
_UCXXEXPORT static terminate_handler __terminate_handler = abort;
@ -71,5 +69,3 @@ namespace std
terminate();
}
}
#endif

View File

@ -22,8 +22,8 @@
#include <stdexcept>
#include <cstdlib>
namespace std{
namespace std
{
#ifdef CONFIG_UCLIBCXX_EXCEPTION
_UCXXEXPORT void __throw_bad_alloc()
@ -33,7 +33,7 @@ _UCXXEXPORT void __throw_bad_alloc()
_UCXXEXPORT void __throw_out_of_range(const char * message)
{
if(message == 0)
if (message == 0)
{
throw out_of_range();
}
@ -43,7 +43,7 @@ _UCXXEXPORT void __throw_out_of_range(const char * message)
_UCXXEXPORT void __throw_overflow_error(const char * message)
{
if(message == 0)
if (message == 0)
{
throw overflow_error();
}
@ -53,7 +53,7 @@ _UCXXEXPORT void __throw_overflow_error(const char * message)
_UCXXEXPORT void __throw_length_error(const char * message)
{
if(message == 0)
if (message == 0)
{
throw length_error();
}
@ -63,7 +63,7 @@ _UCXXEXPORT void __throw_length_error(const char * message)
_UCXXEXPORT void __throw_invalid_argument(const char * message)
{
if(message == 0)
if (message == 0)
{
throw invalid_argument();
}
@ -100,6 +100,4 @@ _UCXXEXPORT void __throw_invalid_argument(const char *)
#endif
}
} // namespace

View File

@ -1,63 +1,64 @@
/* 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
*/
/* 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 <stdexcept>
#ifdef CONFIG_UCLIBCXX_EXCEPTION
namespace std{
namespace std
{
_UCXXEXPORT logic_error::logic_error() throw() : mstring()
{
}
_UCXXEXPORT logic_error::logic_error() throw() : mstring(){
_UCXXEXPORT logic_error::logic_error(const string& what_arg) : mstring(what_arg)
{
}
}
_UCXXEXPORT const char * logic_error::what() const throw()
{
return mstring.c_str();
}
_UCXXEXPORT logic_error::logic_error(const string& what_arg) : mstring(what_arg){
_UCXXEXPORT out_of_range::out_of_range() : logic_error()
{
}
}
_UCXXEXPORT out_of_range::out_of_range(const string & what_arg) : logic_error(what_arg)
{
}
_UCXXEXPORT const char * logic_error::what() const throw(){
return mstring.c_str();
}
_UCXXEXPORT runtime_error::runtime_error() : mstring()
{
}
_UCXXEXPORT runtime_error::runtime_error(const string& what_arg) : mstring(what_arg)
{
}
_UCXXEXPORT out_of_range::out_of_range() : logic_error(){
_UCXXEXPORT const char * runtime_error::what() const throw()
{
return mstring.c_str();
}
}
_UCXXEXPORT out_of_range::out_of_range(const string & what_arg) : logic_error(what_arg) {
}
_UCXXEXPORT runtime_error::runtime_error() : mstring(){
}
_UCXXEXPORT runtime_error::runtime_error(const string& what_arg) : mstring(what_arg){
}
_UCXXEXPORT const char * runtime_error::what() const throw(){
return mstring.c_str();
}
}
} // namespace
#endif

View File

@ -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
*/
#define __UCLIBCXX_COMPILE_STRING__ 1
@ -26,87 +26,81 @@
#include <string.h>
#include <ostream>
namespace std{
namespace std
{
#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template _UCXXEXPORT string::basic_string(const allocator<char> &);
template _UCXXEXPORT string::basic_string(size_type n, char c, const allocator<char> & );
template _UCXXEXPORT string::basic_string(const char* s, const allocator<char>& al);
template _UCXXEXPORT string::basic_string(const basic_string& str, size_type pos, size_type n, const allocator<char>& al);
template _UCXXEXPORT string::~basic_string();
template _UCXXEXPORT string::basic_string(const allocator<char> &);
template _UCXXEXPORT string::basic_string(size_type n, char c, const allocator<char> & );
template _UCXXEXPORT string::basic_string(const char* s, const allocator<char>& al);
template _UCXXEXPORT string::basic_string(const basic_string& str, size_type pos, size_type n, const allocator<char>& al);
template _UCXXEXPORT string::~basic_string();
#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
template _UCXXEXPORT string & string::append(const char * s, size_type n);
template _UCXXEXPORT string & string::append(const char * s, size_type n);
template _UCXXEXPORT string::size_type string::find(const string & str, size_type pos) const;
template _UCXXEXPORT string::size_type string::find(const char* s, size_type pos) const;
template _UCXXEXPORT string::size_type string::find (char c, size_type pos) const;
template _UCXXEXPORT string::size_type string::rfind(const string & str, size_type pos) const;
template _UCXXEXPORT string::size_type string::rfind(char c, size_type pos) const;
template _UCXXEXPORT string::size_type string::rfind(const char* s, size_type pos) const;
template _UCXXEXPORT string::size_type string::find(const string & str, size_type pos) const;
template _UCXXEXPORT string::size_type string::find(const char* s, size_type pos) const;
template _UCXXEXPORT string::size_type string::find (char c, size_type pos) const;
template _UCXXEXPORT string::size_type string::rfind(const string & str, size_type pos) const;
template _UCXXEXPORT string::size_type string::rfind(char c, size_type pos) const;
template _UCXXEXPORT string::size_type string::rfind(const char* s, size_type pos) const;
template _UCXXEXPORT string::size_type string::find_first_of(const string &, size_type) const;
template _UCXXEXPORT string::size_type string::find_first_of(const char *, size_type pos, size_type n) const;
template _UCXXEXPORT string::size_type string::find_first_of(const char*, size_type pos) const;
template _UCXXEXPORT string::size_type string::find_first_of(char c, size_type pos) const;
template _UCXXEXPORT string::size_type string::find_first_of(const string &, size_type) const;
template _UCXXEXPORT string::size_type string::find_first_of(const char *, size_type pos, size_type n) const;
template _UCXXEXPORT string::size_type string::find_first_of(const char*, size_type pos) const;
template _UCXXEXPORT string::size_type string::find_first_of(char c, size_type pos) const;
template _UCXXEXPORT string::size_type string::find_last_of (const string & , size_type pos) const;
template _UCXXEXPORT string::size_type string::find_last_of (const char* s, size_type pos, size_type n) const;
template _UCXXEXPORT string::size_type string::find_last_of (const char* s, size_type pos) const;
template _UCXXEXPORT string::size_type string::find_last_of (char c, size_type pos) const;
template _UCXXEXPORT string::size_type string::find_last_of (const string & , size_type pos) const;
template _UCXXEXPORT string::size_type string::find_last_of (const char* s, size_type pos, size_type n) const;
template _UCXXEXPORT string::size_type string::find_last_of (const char* s, size_type pos) const;
template _UCXXEXPORT string::size_type string::find_last_of (char c, size_type pos) const;
template _UCXXEXPORT string::size_type string::find_first_not_of(const string &, size_type) const;
template _UCXXEXPORT string::size_type string::find_first_not_of(const char*, size_type, size_type) const;
template _UCXXEXPORT string::size_type string::find_first_not_of(const char*, size_type) const;
template _UCXXEXPORT string::size_type string::find_first_not_of(char c, size_type) const;
template _UCXXEXPORT string::size_type string::find_first_not_of(const string &, size_type) const;
template _UCXXEXPORT string::size_type string::find_first_not_of(const char*, size_type, size_type) const;
template _UCXXEXPORT string::size_type string::find_first_not_of(const char*, size_type) const;
template _UCXXEXPORT string::size_type string::find_first_not_of(char c, size_type) const;
template _UCXXEXPORT int string::compare(const string & str) const;
// template _UCXXEXPORT int string::compare(size_type pos1, size_type n1, const string & str) const;
template _UCXXEXPORT int string::compare(
size_type pos1, size_type n1, const string & str, size_type pos2, size_type n2) const;
template _UCXXEXPORT int string::compare(const string & str) const;
//template _UCXXEXPORT int string::compare(size_type pos1, size_type n1, const string & str) const;
template _UCXXEXPORT int string::compare(
size_type pos1, size_type n1, const string & str, size_type pos2, size_type n2) const;
template _UCXXEXPORT string string::substr(size_type pos, size_type n) const;
template _UCXXEXPORT string string::substr(size_type pos, size_type n) const;
template _UCXXEXPORT string & string::operator=(const string & str);
template _UCXXEXPORT string & string::operator=(const char * s);
template _UCXXEXPORT string & string::operator=(const string & str);
template _UCXXEXPORT string & string::operator=(const char * s);
template _UCXXEXPORT bool operator==(const string & lhs, const string & rhs);
template _UCXXEXPORT bool operator==(const char * lhs, const string & rhs);
template _UCXXEXPORT bool operator==(const string & lhs, const char * rhs);
template _UCXXEXPORT bool operator==(const string & lhs, const string & rhs);
template _UCXXEXPORT bool operator==(const char * lhs, const string & rhs);
template _UCXXEXPORT bool operator==(const string & lhs, const char * rhs);
template _UCXXEXPORT bool operator!=(const string & lhs, const string & rhs);
template _UCXXEXPORT bool operator!=(const char * lhs, const string & rhs);
template _UCXXEXPORT bool operator!=(const string & lhs, const char * rhs);
template _UCXXEXPORT bool operator!=(const string & lhs, const string & rhs);
template _UCXXEXPORT bool operator!=(const char * lhs, const string & rhs);
template _UCXXEXPORT bool operator!=(const string & lhs, const char * rhs);
template _UCXXEXPORT string operator+(const string & lhs, const char* rhs);
template _UCXXEXPORT string operator+(const char* lhs, const string & rhs);
template _UCXXEXPORT string operator+(const string & lhs, const string & rhs);
template _UCXXEXPORT string operator+(const string & lhs, const char* rhs);
template _UCXXEXPORT string operator+(const char* lhs, const string & rhs);
template _UCXXEXPORT string operator+(const string & lhs, const string & rhs);
template _UCXXEXPORT bool operator> (const string & lhs, const string & rhs);
template _UCXXEXPORT bool operator< (const string & lhs, const string & rhs);
template _UCXXEXPORT bool operator> (const string & lhs, const string & rhs);
template _UCXXEXPORT bool operator< (const string & lhs, const string & rhs);
// Functions dependent upon OSTREAM
//Functions dependent upon OSTREAM
#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__
template _UCXXEXPORT ostream & operator<<(ostream & os, const string & str);
#endif
//Functions dependent upon ISTREAM
// Functions dependent upon ISTREAM
#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__
template _UCXXEXPORT istream & operator>>(istream & is, string & str);
#endif
#endif
#endif
}
} // namespace

View File

@ -215,6 +215,19 @@ cxxtest
b. Execute 'make menuconfig' in nuttx/ in order to start the
reconfiguration process.
3. At presenet (2012/11/02), this example builds only with exceptions
disabled (CONFIG_UCLIBCXX_EXCEPTIONS=n). And even then, it will
not run.
The reason that the example will will not run on the simulator has
to do with when static constructors are enabled: In the simulator
it will attempt to execute the static constructros before main()
starts. BUT... NuttX is not initialized and this results in a crash.
To really use this example, I will have to think of some way to
postpone running C++ static initializers until NuttX has been
initialied.
mount
Description

View File

@ -45,7 +45,11 @@ else
endif
ARCHCPUFLAGS = -fno-builtin
ARCHCPUFLAGSXX = -fno-builtin
ifeq ($(CONFIG_UCLIBCXX_EXCEPTION),y)
ARCHCPUFLAGSXX = -fno-builtin
else
ARCHCPUFLAGSXX = -fno-builtin -fno-exceptions
endif
ARCHPICFLAGS = -fpic
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
ARCHWARNINGSXX = -Wall -Wshadow