Skip to content

Merge uClibc++ upstream, preserved AVR & Arduino specific fixes #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions src/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,6 @@ namespace std{
return result;
}

template< class InputIterator, class Size, class OutputIterator >
OutputIterator copy_n( InputIterator first, Size count, OutputIterator result ) {
if (count > 0) {
*result++ = *first;
for (Size i = 1; i < count; ++i) {
*result++ = *++first;
}
}
return result;
}

template<class BidirectionalIterator1, class BidirectionalIterator2> _UCXXEXPORT
BidirectionalIterator2
copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
Expand All @@ -394,16 +383,6 @@ namespace std{
b = temp;
}

template<class ForwardIterator1, class ForwardIterator2> _UCXXEXPORT
void
iter_swap(ForwardIterator1 a, ForwardIterator2 b)
{
typename iterator_traits<ForwardIterator1>::value_type temp(*a);
*a = *b;
*b = temp;
}


template<class ForwardIterator1, class ForwardIterator2> _UCXXEXPORT
ForwardIterator2
swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2)
Expand All @@ -417,6 +396,16 @@ namespace std{
}


template<class ForwardIterator1, class ForwardIterator2> _UCXXEXPORT
void
iter_swap(ForwardIterator1 a, ForwardIterator2 b)
{
typename iterator_traits<ForwardIterator1>::value_type temp(*a);
*a = *b;
*b = temp;
}


template<class InputIterator, class OutputIterator, class UnaryOperation> _UCXXEXPORT
OutputIterator
transform(InputIterator first, InputIterator last,
Expand Down
3 changes: 1 addition & 2 deletions src/associative_base
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ public:
}
void erase(iterator first, iterator last){
while(first != last){
backing.erase(first.base_iterator());
++first;
first = backing.erase(first.base_iterator());
}
}

Expand Down
22 changes: 22 additions & 0 deletions src/basic_definitions
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@
#define __UCLIBCXX_NORETURN
#endif

#ifdef __GCC__
# ifndef _UCXX_NOTHROW
# ifndef __cplusplus
# define _UCXX_NOTHROW __attribute__((__nothrow__))
# endif
# endif
#endif
#ifdef __cplusplus
# if __cplusplus >= 201103L
# define _UCXX_NOEXCEPT noexcept
# define _UCXX_USE_NOEXCEPT noexcept
# define _UCXX_THROW(_EXCEPTION)
# else
# define _UCXX_NOEXCEPT
# define _UCXX_USE_NOEXCEPT throw()
# define _UCXX_THROW(_EXCEPTION) throw(_EXCEPTION)
# endif
# ifndef _UCXX_NOTHROW
# define _UCXX_NOTHROW _UCXX_USE_NOEXCEPT
# endif
#endif

#ifdef __UCLIBCXX_HAS_TLS__
#define __UCLIBCXX_TLS __thread
#else
Expand Down
6 changes: 3 additions & 3 deletions src/char_traits
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace std{
static char_type to_char_type(const int_type & i);

inline static int_type to_int_type(const char_type & c){
return (short int)(unsigned char)c;
return static_cast<short int>(static_cast<unsigned char>(c));
}

inline static bool eq_int_type(const int_type & a, const int_type & b){
Expand All @@ -71,7 +71,7 @@ namespace std{
}

inline static char_type* move(char_type* s1, const char_type* s2, size_t n){
return (char*) memmove(s1, s2, n);
return static_cast<char*>(memmove(s1, s2, n));
}

inline static char_type* copy(char_type* s1, const char_type* s2, size_t n){
Expand All @@ -82,7 +82,7 @@ namespace std{
}

inline static char_type* assign(char_type* s, size_t n, char_type a){
return (char *)memset(s, a, n);
return static_cast<char *>(memset(s, a, n));
}

inline static int compare(const char_type* s1, const char_type* s2, size_t n){
Expand Down
12 changes: 12 additions & 0 deletions src/cstdio
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
#ifndef __HEADER_CSTDIO
#define __HEADER_CSTDIO 1

#undef clearerr
#undef feof
#undef ferror
#undef fgetc
#undef fputc
#undef getc
#undef getchar
#undef putc
#undef putchar

namespace std{
using ::FILE;
Expand Down Expand Up @@ -48,6 +57,7 @@ namespace std{
using ::getc;
using ::getchar;
#if __cplusplus <= 201103L
// LWG 2249
using ::gets;
#endif
using ::perror;
Expand All @@ -64,7 +74,9 @@ namespace std{
using ::sprintf;
using ::sscanf;
using ::tmpfile;
#ifdef _GLIBCXX_USE_TMPNAM
using ::tmpnam;
#endif
using ::ungetc;
using ::vfprintf;
using ::vprintf;
Expand Down
2 changes: 1 addition & 1 deletion src/del_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <cstdlib>
#include <func_exception>

_UCXXEXPORT void operator delete(void* ptr) throw(){
_UCXXEXPORT void operator delete(void* ptr) _UCXX_USE_NOEXCEPT{
free(ptr);
}

Expand Down
2 changes: 1 addition & 1 deletion src/del_opnt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <func_exception>

#ifndef NO_NOTHROW
_UCXXEXPORT void operator delete(void* ptr, const std::nothrow_t& ) throw() {
_UCXXEXPORT void operator delete(void* ptr, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT {
free(ptr);
}
#endif
2 changes: 1 addition & 1 deletion src/del_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
#include <cstdlib>
#include <func_exception>

_UCXXEXPORT void operator delete(void* ptr, std::size_t) throw(){
_UCXXEXPORT void operator delete(void* ptr, std::size_t) _UCXX_USE_NOEXCEPT{
::operator delete (ptr);
}
2 changes: 1 addition & 1 deletion src/del_opv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <cstdlib>
#include <func_exception>

_UCXXEXPORT void operator delete[](void * ptr) throw(){
_UCXXEXPORT void operator delete[](void * ptr) _UCXX_USE_NOEXCEPT{
free(ptr);
}

Expand Down
2 changes: 1 addition & 1 deletion src/del_opvnt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <func_exception>

#ifndef NO_NOTHROW
_UCXXEXPORT void operator delete[](void* ptr, const std::nothrow_t& ) throw(){
_UCXXEXPORT void operator delete[](void* ptr, const std::nothrow_t& ) _UCXX_USE_NOEXCEPT{
free(ptr);
}
#endif
2 changes: 1 addition & 1 deletion src/del_opvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
#include <cstdlib>
#include <func_exception>

_UCXXEXPORT void operator delete[](void * ptr, std::size_t) throw(){
_UCXXEXPORT void operator delete[](void * ptr, std::size_t) _UCXX_USE_NOEXCEPT{
::operator delete[] (ptr);
}
8 changes: 4 additions & 4 deletions src/eh_alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
namespace __cxxabiv1
{

extern "C" void * __cxa_allocate_exception(std::size_t thrown_size) throw(){
extern "C" void * __cxa_allocate_exception(std::size_t thrown_size) _UCXX_USE_NOEXCEPT{
void *e;
// The sizeof crap is required by Itanium ABI because we need to
// provide space for accounting information which is implementation
Expand All @@ -40,12 +40,12 @@ extern "C" void * __cxa_allocate_exception(std::size_t thrown_size) throw(){
return (void *)((unsigned char *)e + sizeof(__cxa_refcounted_exception));
}

extern "C" void __cxa_free_exception(void *vptr) throw(){
extern "C" void __cxa_free_exception(void *vptr) _UCXX_USE_NOEXCEPT{
free( (char *)(vptr) - sizeof(__cxa_refcounted_exception) );
}


extern "C" __cxa_dependent_exception * __cxa_allocate_dependent_exception() throw(){
extern "C" __cxa_dependent_exception * __cxa_allocate_dependent_exception() _UCXX_USE_NOEXCEPT{
__cxa_dependent_exception *retval;
// The sizeof crap is required by Itanium ABI because we need to
// provide space for accounting information which is implementation
Expand All @@ -58,7 +58,7 @@ extern "C" __cxa_dependent_exception * __cxa_allocate_dependent_exception() thro
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) _UCXX_USE_NOEXCEPT{
free( (char *)(vptr) );
}

Expand Down
4 changes: 2 additions & 2 deletions src/eh_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ namespace __cxxabiv1{

static __UCLIBCXX_TLS __cxa_eh_globals eh_globals;

extern "C" __cxa_eh_globals* __cxa_get_globals() throw(){
extern "C" __cxa_eh_globals* __cxa_get_globals() _UCXX_USE_NOEXCEPT{
return &eh_globals;
}

extern "C" __cxa_eh_globals* __cxa_get_globals_fast() throw(){
extern "C" __cxa_eh_globals* __cxa_get_globals_fast() _UCXX_USE_NOEXCEPT{
return &eh_globals;
}

Expand Down
16 changes: 8 additions & 8 deletions src/exception
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ namespace std
class exception
{
public:
exception() throw() { }
virtual ~exception() throw();
exception() _UCXX_NOTHROW { }
virtual ~exception() _UCXX_NOTHROW;
/** Returns a C-style character string describing the general cause
* of the current error. */
virtual const char* what() const throw();
virtual const char* what() const _UCXX_NOTHROW;
};

/** If an %exception is thrown which is not listed in a function's
* %exception specification, one of these may be thrown. */
class bad_exception : public exception
{
public:
bad_exception() throw() { }
bad_exception() _UCXX_USE_NOEXCEPT { }
// This declaration is not useless:
// http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
virtual ~bad_exception() throw();
virtual ~bad_exception() _UCXX_USE_NOEXCEPT;
};

/// If you write a replacement %terminate handler, it must be of this type.
Expand All @@ -78,13 +78,13 @@ namespace std
typedef void (*unexpected_handler) ();

/// Takes a new handler function as an argument, returns the old function.
terminate_handler set_terminate(terminate_handler) throw();
terminate_handler set_terminate(terminate_handler) _UCXX_USE_NOEXCEPT;
/** The runtime will call this function if %exception handling must be
* abandoned for any reason. */
void terminate() __UCLIBCXX_NORETURN;

/// Takes a new handler function as an argument, returns the old function.
unexpected_handler set_unexpected(unexpected_handler) throw();
unexpected_handler set_unexpected(unexpected_handler) _UCXX_USE_NOEXCEPT;
/** The runtime will call this function if an %exception is thrown which
* violates the function's %exception specification. */
void unexpected() __UCLIBCXX_NORETURN;
Expand All @@ -99,7 +99,7 @@ namespace std
* 2: "When @c uncaught_exception() is true, throwing an %exception can
* result in a call of @c terminate() (15.5.1)."
*/
bool uncaught_exception() throw();
bool uncaught_exception() _UCXX_USE_NOEXCEPT;
} // namespace std

namespace __gnu_cxx
Expand Down
6 changes: 3 additions & 3 deletions src/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ namespace std{
//We are providing our own versions to be sneaky


_UCXXEXPORT exception::~exception() throw(){
_UCXXEXPORT exception::~exception() _UCXX_USE_NOEXCEPT{
//Empty function
}

_UCXXEXPORT const char* exception::what() const throw(){
_UCXXEXPORT const char* exception::what() const _UCXX_USE_NOEXCEPT{
return __std_exception_what_value;
}

_UCXXEXPORT bad_exception::~bad_exception() throw(){
_UCXXEXPORT bad_exception::~bad_exception() _UCXX_USE_NOEXCEPT{

}

Expand Down
8 changes: 4 additions & 4 deletions src/functional
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,25 @@ namespace std{
};

template <class T> struct _UCXXEXPORT greater : binary_function<T,T,bool>{
bool operator()(const T& x, const T& y) const{
bool operator()(const T& x, const T& y) const _UCXX_NOTHROW {
return (x > y);
}
};

template <class T> struct _UCXXEXPORT less : binary_function<T,T,bool>{
bool operator()(const T& x, const T& y) const{
bool operator()(const T& x, const T& y) const _UCXX_NOTHROW {
return (x < y);
}
};

template <class T> struct _UCXXEXPORT greater_equal : binary_function<T,T,bool>{
bool operator()(const T& x, const T& y) const{
bool operator()(const T& x, const T& y) const _UCXX_NOTHROW {
return (x >= y);
}
};

template <class T> struct _UCXXEXPORT less_equal : binary_function<T,T,bool>{
bool operator()(const T& x, const T& y) const{
bool operator()(const T& x, const T& y) const _UCXX_NOTHROW {
return (x <= y);
}
};
Expand Down
Loading