uClibc++ updates

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5302 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-11-03 13:02:31 +00:00
parent df77815b8b
commit 1336ed8637
5 changed files with 165 additions and 79 deletions

View File

@ -6,9 +6,20 @@ originates from http://cxx.uclibc.org/ and has been adapted for NuttX by the
RGMP team (http://rgmp.sourceforge.net/wiki/index.php/Main_Page).
uClibc++ resides in the misc/ directory rather than in the main NuttX source
tree due to licensing issues: NuttX is licensed under the permissiv
modified BSD License; uClibc, on the other hand, islicensed under the
stricter GNU LGPL Version 3 license.
tree due to licensing issues: NuttX is licensed under the permissive
modified BSD License; uClibc, on the other hand, is licensed under the
stricter GNU LGPL Version 3 license.
Contents:
^^^^^^^^^
o Installation of uClibc++
o Dependencies
o NuttX Configuration File Changes
o Make.defs File Changes
o Building NuttX with uClibc++
o Callbacks
o RGMP
Installation of uClibc++
^^^^^^^^^^^^^^^^^^^^^^^^
@ -50,7 +61,6 @@ enabled. The following must be defined in your NuttX configuration file.
There are many ways to provide math library support (see nuttx/README.txt).
If you choose to use the NuttX math library, that is enabled as follows:
CONFIG_LIBM=y
The math libraries depend on the float.h header file that is normally
@ -59,6 +69,10 @@ can be installed by setting:
CONFIG_ARCH_FLOAT_H=y
Exception support can be enabled with:
CONFIG_UCLIBCXX_EXCEPTION=y
Make.defs File Changes
^^^^^^^^^^^^^^^^^^^^^^
@ -74,9 +88,25 @@ And, of course, you no long need to suppress exceptions or run-time typing:
-ARCHCPUFLAGSXX = -fno-builtin -fno-exceptions -fno-rtti
+ARCHCPUFLAGSXX = -fno-builtin
If exceptions are disabled via CONFIG_UCLIBCXX_EXCEPTION=n, then -fno-exceptions
is still required. This logic would handle both cases:
I create the nuttx/configs/rgmp/x86/cxxtest/Make.def, add the two libs to EXTRA_LIBS to be linked
to NUTTX. The code.
ifeq ($(CONFIG_UCLIBCXX_EXCEPTION),y)
ARCHCPUFLAGSXX = -fno-builtin
else
ARCHCPUFLAGSXX = -fno-builtin -fno-exceptions
endif
To get the required libraries into to the NuttX build, it is necessary to add
them to EXTRA_LIBS and to EXTRA_LIBPATHS.
LIBSUPXX = ${shell $(CC) --print-file-name=libsupc++.a}
EXTRA_LIBPATHS = -L "${shell dirname "$(LIBSUPXX)"}"
EXTRA_LIBS = -lsupc++
NOTE: This assumes that support for these options has been incorporated into
arch/<architecture>/src/Makefile. As of this writing that is true only for
the ARM and simulation platforms.
Building NuttX with uClibc++
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -101,6 +131,34 @@ build, add the uClibc++ subdirectory to the dependency list, and add the
uClibc++ subdirectory to the VPATH. That should, in principle, be all it
takes.
Callbacks
^^^^^^^^^
The runtime will call this function if exception handling must be abandoned
for any reason.
void std::terminate(void) throw();
NOTE: If exception handling is disabled via CONFIG_UCLIBCXX_EXCEPTION, then
this function is always called when an exception would have been thrown.
By default, std::terminate() just calls abort(), but that can be changed
with std:terminate(). std::set_terminated takes a new handler function
as an argument and returns the old handler:
typedef CODE void (*terminate_handler)(void);
terminate_handler std::set_terminate(std::terminate_handler func) throw();
The runtime will call this function if an exception is thrown which violates
the function's %exception specification:
void std::unexpected(void) throw()
This handler defaults to std::terminate but can be re-directed with:
typedef CODE void (*unexpected_handler)(void);
unexpected_handler set_unexpected(unexpected_handler) throw();
RGMP
^^^^

View File

@ -1,26 +1,31 @@
/* 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
*/
#ifndef __BASIC_DEFINITIONS
#define __BASIC_DEFINITIONS 1
// NuttX Configuration
#include <nuttx/config.h>
#include <nuttx/compiler.h>
// Deprecated
#include <system_configuration.h>
#pragma GCC visibility push(default)

View File

@ -1,38 +1,37 @@
/* 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 <basic_definitions>
#include <exception>
#ifndef HEADER_IMPLEMENTATION_FUNC_EXCEPTION
#define HEADER_IMPLEMENTATION_FUNC_EXCEPTION
#pragma GCC visibility push(default)
namespace std{
_UCXXEXPORT void __throw_bad_alloc();
_UCXXEXPORT void __throw_out_of_range(const char * message = 0);
_UCXXEXPORT void __throw_overflow_error(const char * message = 0);
_UCXXEXPORT void __throw_length_error(const char * message = 0);
_UCXXEXPORT void __throw_invalid_argument(const char * message = 0);
namespace std
{
_UCXXEXPORT void __throw_bad_alloc();
_UCXXEXPORT void __throw_out_of_range(const char *message = 0);
_UCXXEXPORT void __throw_overflow_error(const char *message = 0);
_UCXXEXPORT void __throw_length_error(const char *message = 0);
_UCXXEXPORT void __throw_invalid_argument(const char *message = 0);
}
#pragma GCC visibility pop

View File

@ -1,35 +1,54 @@
/* 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 <new>
#include <cstdlib>
#include <func_exception>
_UCXXEXPORT void* operator new[](std::size_t numBytes) throw(std::bad_alloc){
//C++ stardard 5.3.4.8 requires that a valid pointer be returned for
//a call to new(0). Thus:
if(numBytes == 0){
numBytes = 1;
}
void * p = malloc(numBytes);
if(p == 0){
std::__throw_bad_alloc();
}
return p;
#include <basic_definitions>
#ifdef CONFIG_UCLIBCXX_EXCEPTION
# include <func_exception>
#else
# include <exception>
#endif
_UCXXEXPORT void *operator new[](std::size_t numBytes) throw(std::bad_alloc)
{
// C++ stardard 5.3.4.8 requires that a valid pointer be returned for
// a call to new(0). Thus:
if (numBytes == 0)
{
numBytes = 1;
}
// Allocate the memory
void *p = malloc(numBytes);
if (p == 0)
{
#ifdef CONFIG_UCLIBCXX_EXCEPTION
std::__throw_bad_alloc();
#else
std::terminate();
#endif
}
return p;
}

View File

@ -40,9 +40,14 @@
ASRCS =
CSRCS =
CXXSRCS = libxx_cxapurevirtual.cxx libxx_delete.cxx libxx_deletea.cxx
CXXSRCS += libxx_eabi_atexit.cxx libxx_cxa_atexit.cxx libxx_new.cxx
CXXSRCS += libxx_newa.cxx
CXXSRCS = libxx_cxapurevirtual.cxx libxx_eabi_atexit.cxx libxx_cxa_atexit.cxx
# Some of the libxx/ files are not need if uClibc++ is installed because
# uClibx++ replaces them
ifneq ($(CONFIG_UCLIBCXX),y)
CXXSRCS += libxx_delete.cxx libxx_deletea.cxx libxx_new.cxx libxx_newa.cxx
endif
# Paths