sdk: build libsupc++ from libstdc++ source

git-svn-id: svn://kolibrios.org@5134 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge)
2014-09-21 10:51:57 +00:00
parent c993fd46f8
commit 9d5ad505ec
863 changed files with 369722 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
// chrono -*- C++ -*-
// Copyright (C) 2008-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <bits/c++config.h>
#include <chrono>
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
// Conditional inclusion of sys/time.h for gettimeofday
#if !defined(_GLIBCXX_USE_CLOCK_MONOTONIC) && \
!defined(_GLIBCXX_USE_CLOCK_REALTIME) && \
defined(_GLIBCXX_USE_GETTIMEOFDAY)
#include <sys/time.h>
#endif
#ifdef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL
#include <unistd.h>
#include <sys/syscall.h>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace chrono
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// XXX GLIBCXX_ABI Deprecated
inline namespace _V2 {
constexpr bool system_clock::is_steady;
system_clock::time_point
system_clock::now() noexcept
{
#ifdef _GLIBCXX_USE_CLOCK_REALTIME
timespec tp;
// -EINVAL, -EFAULT
#ifdef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL
syscall(SYS_clock_gettime, CLOCK_REALTIME, &tp);
#else
clock_gettime(CLOCK_REALTIME, &tp);
#endif
return time_point(duration(chrono::seconds(tp.tv_sec)
+ chrono::nanoseconds(tp.tv_nsec)));
#elif defined(_GLIBCXX_USE_GETTIMEOFDAY)
timeval tv;
// EINVAL, EFAULT
gettimeofday(&tv, 0);
return time_point(duration(chrono::seconds(tv.tv_sec)
+ chrono::microseconds(tv.tv_usec)));
#else
std::time_t __sec = std::time(0);
return system_clock::from_time_t(__sec);
#endif
}
constexpr bool steady_clock::is_steady;
steady_clock::time_point
steady_clock::now() noexcept
{
#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
timespec tp;
// -EINVAL, -EFAULT
#ifdef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL
syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &tp);
#else
clock_gettime(CLOCK_MONOTONIC, &tp);
#endif
return time_point(duration(chrono::seconds(tp.tv_sec)
+ chrono::nanoseconds(tp.tv_nsec)));
#else
return time_point(system_clock::now().time_since_epoch());
#endif
}
} // end inline namespace _V2
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace chrono
} // namespace std
#endif // _GLIBCXX_USE_C99_STDINT_TR1

View File

@@ -0,0 +1,160 @@
// <atomic> compatibility -*- C++ -*-
// Copyright (C) 2008-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include "gstdint.h"
#include <atomic>
#include <mutex>
// XXX GLIBCXX_ABI Deprecated
// gcc-4.7.0
#ifdef _GLIBCXX_SHARED
#define LOGSIZE 4
namespace
{
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
std::mutex&
get_atomic_mutex()
{
static std::mutex atomic_mutex;
return atomic_mutex;
}
#endif
std::__atomic_flag_base flag_table[ 1 << LOGSIZE ] =
{
ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT,
ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT,
ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT,
ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT,
};
} // anonymous namespace
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace __atomic0
{
struct atomic_flag : public __atomic_flag_base
{
bool
test_and_set(memory_order) noexcept;
void
clear(memory_order) noexcept;
};
bool
atomic_flag::test_and_set(memory_order) noexcept
{
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
lock_guard<mutex> __lock(get_atomic_mutex());
#endif
bool result = _M_i;
_M_i = true;
return result;
}
void
atomic_flag::clear(memory_order) noexcept
{
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
lock_guard<mutex> __lock(get_atomic_mutex());
#endif
_M_i = false;
}
} // namespace __atomic0
_GLIBCXX_BEGIN_EXTERN_C
bool
atomic_flag_test_and_set_explicit(__atomic_flag_base* __a,
memory_order __m) _GLIBCXX_NOTHROW
{
atomic_flag* d = static_cast<atomic_flag*>(__a);
return d->test_and_set(__m);
}
void
atomic_flag_clear_explicit(__atomic_flag_base* __a,
memory_order __m) _GLIBCXX_NOTHROW
{
atomic_flag* d = static_cast<atomic_flag*>(__a);
return d->clear(__m);
}
void
__atomic_flag_wait_explicit(__atomic_flag_base* __a,
memory_order __x) _GLIBCXX_NOTHROW
{
while (atomic_flag_test_and_set_explicit(__a, __x))
{ };
}
_GLIBCXX_CONST __atomic_flag_base*
__atomic_flag_for_address(const volatile void* __z) _GLIBCXX_NOTHROW
{
uintptr_t __u = reinterpret_cast<uintptr_t>(__z);
__u += (__u >> 2) + (__u << 4);
__u += (__u >> 7) + (__u << 5);
__u += (__u >> 17) + (__u << 13);
if (sizeof(uintptr_t) > 4)
__u += (__u >> 31);
__u &= ~((~uintptr_t(0)) << LOGSIZE);
return flag_table + __u;
}
_GLIBCXX_END_EXTERN_C
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
// XXX GLIBCXX_ABI Deprecated
// gcc-4.5.0
// <atomic> signature changes
// The rename syntax for default exported names is
// asm (".symver name1,exportedname@GLIBCXX_3.4")
// asm (".symver name2,exportedname@@GLIBCXX_3.4.5")
// In the future, GLIBCXX_ABI > 6 should remove all uses of
// _GLIBCXX_*_SYMVER macros in this file.
#if defined(_GLIBCXX_SYMVER_GNU) && defined(_GLIBCXX_SHARED) \
&& defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE) \
&& defined(_GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT)
#define _GLIBCXX_ASM_SYMVER(cur, old, version) \
asm (".symver " #cur "," #old "@@" #version);
_GLIBCXX_ASM_SYMVER(_ZNSt9__atomic011atomic_flag5clearESt12memory_order, _ZNVSt9__atomic011atomic_flag5clearESt12memory_order, GLIBCXX_3.4.11)
_GLIBCXX_ASM_SYMVER(_ZNSt9__atomic011atomic_flag12test_and_setESt12memory_order, _ZNVSt9__atomic011atomic_flag12test_and_setESt12memory_order, GLIBCXX_3.4.11)
#endif

View File

@@ -0,0 +1,124 @@
// Compatibility symbols for previous versions, C++0x bits -*- C++ -*-
// Copyright (C) 2009-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#define _GLIBCXX_COMPATIBILITY_CXX0X
#include <string>
#include <system_error>
#if __cplusplus < 201103L
# error "compatibility-c++0x.cc must be compiled with -std=gnu++0x"
#endif
#ifdef _GLIBCXX_SHARED
namespace std _GLIBCXX_VISIBILITY(default)
{
// gcc-4.4.0
// <mutex> exported std::lock_error
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
class lock_error : public exception
{
public:
virtual const char*
_GLIBCXX_CONST what() const throw();
};
const char*
lock_error::what() const throw()
{ return "std::lock_error"; }
#endif
// We need these due to the symbols exported since GLIBCXX_3.4.10.
// See libstdc++/41662 for details.
#ifndef _GLIBCXX_LONG_DOUBLE_COMPAT_IMPL
template<>
struct hash<string>
{
size_t operator()(string) const;
};
size_t
hash<string>::operator()(string __s) const
{ return _Hash_impl::hash(__s.data(), __s.length()); }
template<>
struct hash<const string&>
{
size_t operator()(const string&) const;
};
size_t
hash<const string&>::operator()(const string& __s) const
{ return _Hash_impl::hash(__s.data(), __s.length()); }
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
struct hash<wstring>
{
size_t operator()(wstring) const;
};
size_t
hash<wstring>::operator()(wstring __s) const
{ return _Hash_impl::hash(__s.data(), __s.length() * sizeof(wchar_t)); }
template<>
struct hash<const wstring&>
{
size_t operator()(const wstring&) const;
};
size_t
hash<const wstring&>::operator()(const wstring& __s) const
{ return _Hash_impl::hash(__s.data(), __s.length() * sizeof(wchar_t)); }
#endif
#endif
template<>
struct hash<error_code>
{
size_t operator()(error_code) const;
};
size_t
hash<error_code>::operator()(error_code __e) const
{
const size_t __tmp = std::_Hash_impl::hash(__e._M_value);
return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp);
}
// gcc-4.7.0
// <chrono> changes is_monotonic to is_steady.
namespace chrono
{
struct system_clock
{
static constexpr bool is_monotonic = false;
};
constexpr bool system_clock::is_monotonic;
} // namespace chrono
}
#endif

View File

@@ -0,0 +1,92 @@
// Compatibility symbols for previous versions, C++0x bits -*- C++ -*-
// Copyright (C) 2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <bits/c++config.h>
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
#ifdef _GLIBCXX_USE_GETTIMEOFDAY
#include <sys/time.h>
#endif
#define system_clock system_clockXX
#define steady_clock steady_clockXX
#include <chrono>
#undef system_clock
#undef steady_clock
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace chrono
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// NB: Default configuration was no realtime.
struct system_clock
{
#ifdef _GLIBCXX_USE_GETTIMEOFDAY
typedef chrono::microseconds duration;
#else
typedef chrono::seconds duration;
#endif
typedef duration::rep rep;
typedef duration::period period;
typedef chrono::time_point<system_clock, duration> time_point;
static_assert(system_clock::duration::min()
< system_clock::duration::zero(),
"a clock's minimum duration cannot be less than its epoch");
static constexpr bool is_steady = false;
static time_point
now() noexcept;
};
constexpr bool system_clock::is_steady;
system_clock::time_point
system_clock::now() noexcept
{
#ifdef _GLIBCXX_USE_GETTIMEOFDAY
timeval tv;
// EINVAL, EFAULT
gettimeofday(&tv, 0);
return time_point(duration(chrono::seconds(tv.tv_sec)
+ chrono::microseconds(tv.tv_usec)));
#else
std::time_t __sec = std::time(0);
// This is the conversion done by system_clock::from_time_t(__sec)
typedef chrono::time_point<system_clock, seconds> __from;
return time_point_cast<system_clock::duration>
(__from(chrono::seconds(__sec)));
#endif
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace chrono
} // namespace std
#endif // _GLIBCXX_USE_C99_STDINT_TR1

View File

@@ -0,0 +1,97 @@
// Compatibility symbols for previous versions, C++0x bits -*- C++ -*-
// Copyright (C) 2009-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <bits/c++config.h>
#if defined(_GLIBCXX_HAVE_TLS) && defined(_GLIBCXX_SHARED)
#define _GLIBCXX_ASYNC_ABI_COMPAT
#endif
#include <future>
#include <mutex>
#if __cplusplus < 201103L
# error "compatibility-thread-c++0x.cc must be compiled with -std=gnu++0x"
#endif
#define _GLIBCXX_ASM_SYMVER(cur, old, version) \
asm (".symver " #cur "," #old "@@@" #version);
// XXX GLIBCXX_ABI Deprecated
// gcc-4.6.0
// <future> export changes
#if defined(_GLIBCXX_SYMVER_GNU) && defined(_GLIBCXX_SHARED) \
&& defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE) \
&& defined(_GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT)
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
const std::error_category* future_category = &std::future_category();
}
_GLIBCXX_ASM_SYMVER(_ZN9__gnu_cxx15future_categoryE, _ZSt15future_category, GLIBCXX_3.4.14)
#endif
// XXX GLIBCXX_ABI Deprecated
// gcc-4.6.0
// <mutex> export changes
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
#if defined(_GLIBCXX_SYMVER_GNU) && defined(_GLIBCXX_SHARED) \
&& defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE) \
&& defined(_GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT)
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
std::defer_lock_t defer_lock;
std::try_to_lock_t try_to_lock;
std::adopt_lock_t adopt_lock;
}
_GLIBCXX_ASM_SYMVER(_ZN9__gnu_cxx10adopt_lockE, _ZSt10adopt_lock, GLIBCXX_3.4.11)
_GLIBCXX_ASM_SYMVER(_ZN9__gnu_cxx10defer_lockE, _ZSt10defer_lock, GLIBCXX_3.4.11)
_GLIBCXX_ASM_SYMVER(_ZN9__gnu_cxx11try_to_lockE, _ZSt11try_to_lock, GLIBCXX_3.4.11)
#endif
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
// XXX GLIBCXX_ABI Deprecated
// gcc-4.7.0
// <future> export changes
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \
&& (ATOMIC_INT_LOCK_FREE > 1)
#if defined(_GLIBCXX_HAVE_TLS) && defined(_GLIBCXX_SHARED)
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
__future_base::_Async_state_common::~_Async_state_common() { _M_join(); }
// Explicit instantiation due to -fno-implicit-instantiation.
template void call_once(once_flag&, void (thread::*&&)(), reference_wrapper<thread>&&);
template _Bind_simple_helper<void (thread::*)(), reference_wrapper<thread>>::__type __bind_simple(void (thread::*&&)(), reference_wrapper<thread>&&);
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1

View File

@@ -0,0 +1,87 @@
// condition_variable -*- C++ -*-
// Copyright (C) 2008-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <condition_variable>
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#ifdef __GTHREAD_COND_INIT
condition_variable::condition_variable() noexcept = default;
#else
condition_variable::condition_variable() noexcept
{
__GTHREAD_COND_INIT_FUNCTION(&_M_cond);
}
#endif
condition_variable::~condition_variable() noexcept
{
// XXX no thread blocked
/* int __e = */ __gthread_cond_destroy(&_M_cond);
// if __e == EBUSY then blocked
}
void
condition_variable::wait(unique_lock<mutex>& __lock)
{
int __e = __gthread_cond_wait(&_M_cond, __lock.mutex()->native_handle());
if (__e)
__throw_system_error(__e);
}
void
condition_variable::notify_one() noexcept
{
int __e = __gthread_cond_signal(&_M_cond);
// XXX not in spec
// EINVAL
if (__e)
__throw_system_error(__e);
}
void
condition_variable::notify_all() noexcept
{
int __e = __gthread_cond_broadcast(&_M_cond);
// XXX not in spec
// EINVAL
if (__e)
__throw_system_error(__e);
}
condition_variable_any::condition_variable_any() noexcept = default;
condition_variable_any::~condition_variable_any() noexcept = default;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1

View File

@@ -0,0 +1,962 @@
// Debugging mode support code -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <debug/debug.h>
#include <debug/safe_sequence.h>
#include <debug/safe_unordered_container.h>
#include <debug/safe_iterator.h>
#include <debug/safe_local_iterator.h>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <functional>
using namespace std;
namespace
{
/** Returns different instances of __mutex depending on the passed address
* in order to limit contention without breaking current library binary
* compatibility. */
__gnu_cxx::__mutex&
get_safe_base_mutex(void* __address)
{
const size_t mask = 0xf;
static __gnu_cxx::__mutex safe_base_mutex[mask + 1];
const size_t index = _Hash_impl::hash(__address) & mask;
return safe_base_mutex[index];
}
void
swap_its(__gnu_debug::_Safe_sequence_base& __lhs,
__gnu_debug::_Safe_iterator_base*& __lhs_its,
__gnu_debug::_Safe_sequence_base& __rhs,
__gnu_debug::_Safe_iterator_base*& __rhs_its)
{
swap(__lhs_its, __rhs_its);
__gnu_debug::_Safe_iterator_base* __iter;
for (__iter = __rhs_its; __iter; __iter = __iter->_M_next)
__iter->_M_sequence = &__rhs;
for (__iter = __lhs_its; __iter; __iter = __iter->_M_next)
__iter->_M_sequence = &__lhs;
}
void
swap_seq(__gnu_debug::_Safe_sequence_base& __lhs,
__gnu_debug::_Safe_sequence_base& __rhs)
{
swap(__lhs._M_version, __rhs._M_version);
swap_its(__lhs, __lhs._M_iterators,
__rhs, __rhs._M_iterators);
swap_its(__lhs, __lhs._M_const_iterators,
__rhs, __rhs._M_const_iterators);
}
void
swap_ucont(__gnu_debug::_Safe_unordered_container_base& __lhs,
__gnu_debug::_Safe_unordered_container_base& __rhs)
{
swap_seq(__lhs, __rhs);
swap_its(__lhs, __lhs._M_local_iterators,
__rhs, __rhs._M_local_iterators);
swap_its(__lhs, __lhs._M_const_local_iterators,
__rhs, __rhs._M_const_local_iterators);
}
void
detach_all(__gnu_debug::_Safe_iterator_base* __iter)
{
for (; __iter;)
{
__gnu_debug::_Safe_iterator_base* __old = __iter;
__iter = __iter->_M_next;
__old->_M_reset();
}
}
} // anonymous namespace
namespace __gnu_debug
{
const char* _S_debug_messages[] =
{
// General Checks
"function requires a valid iterator range [%1.name;, %2.name;)",
"attempt to insert into container with a singular iterator",
"attempt to insert into container with an iterator"
" from a different container",
"attempt to erase from container with a %2.state; iterator",
"attempt to erase from container with an iterator"
" from a different container",
"attempt to subscript container with out-of-bounds index %2;,"
" but container only holds %3; elements",
"attempt to access an element in an empty container",
"elements in iterator range [%1.name;, %2.name;)"
" are not partitioned by the value %3;",
"elements in iterator range [%1.name;, %2.name;)"
" are not partitioned by the predicate %3; and value %4;",
"elements in iterator range [%1.name;, %2.name;) are not sorted",
"elements in iterator range [%1.name;, %2.name;)"
" are not sorted according to the predicate %3;",
"elements in iterator range [%1.name;, %2.name;) do not form a heap",
"elements in iterator range [%1.name;, %2.name;)"
" do not form a heap with respect to the predicate %3;",
// std::bitset checks
"attempt to write through a singular bitset reference",
"attempt to read from a singular bitset reference",
"attempt to flip a singular bitset reference",
// std::list checks
"attempt to splice a list into itself",
"attempt to splice lists with unequal allocators",
"attempt to splice elements referenced by a %1.state; iterator",
"attempt to splice an iterator from a different container",
"splice destination %1.name;"
" occurs within source range [%2.name;, %3.name;)",
// iterator checks
"attempt to initialize an iterator that will immediately become singular",
"attempt to copy-construct an iterator from a singular iterator",
"attempt to construct a constant iterator"
" from a singular mutable iterator",
"attempt to copy from a singular iterator",
"attempt to dereference a %1.state; iterator",
"attempt to increment a %1.state; iterator",
"attempt to decrement a %1.state; iterator",
"attempt to subscript a %1.state; iterator %2; step from"
" its current position, which falls outside its dereferenceable range",
"attempt to advance a %1.state; iterator %2; steps,"
" which falls outside its valid range",
"attempt to retreat a %1.state; iterator %2; steps,"
" which falls outside its valid range",
"attempt to compare a %1.state; iterator to a %2.state; iterator",
"attempt to compare iterators from different sequences",
"attempt to order a %1.state; iterator to a %2.state; iterator",
"attempt to order iterators from different sequences",
"attempt to compute the difference between a %1.state;"
" iterator to a %2.state; iterator",
"attempt to compute the different between two iterators"
" from different sequences",
// istream_iterator
"attempt to dereference an end-of-stream istream_iterator",
"attempt to increment an end-of-stream istream_iterator",
// ostream_iterator
"attempt to output via an ostream_iterator with no associated stream",
// istreambuf_iterator
"attempt to dereference an end-of-stream istreambuf_iterator"
" (this is a GNU extension)",
"attempt to increment an end-of-stream istreambuf_iterator",
// std::forward_list
"attempt to insert into container after an end iterator",
"attempt to erase from container after a %2.state; iterator not followed"
" by a dereferenceable one",
"function requires a valid iterator range (%2.name;, %3.name;)"
", \"%2.name;\" shall be before and not equal to \"%3.name;\"",
// std::unordered_container::local_iterator
"attempt to compare local iterators from different unordered container"
" buckets",
"function requires a non-empty iterator range [%1.name;, %2.name;)",
"attempt to self move assign",
"attempt to access container with out-of-bounds bucket index %2;,"
" container only holds %3; buckets",
"load factor shall be positive",
"allocators must be equal"
};
void
_Safe_sequence_base::
_M_detach_all()
{
__gnu_cxx::__scoped_lock sentry(_M_get_mutex());
detach_all(_M_iterators);
_M_iterators = 0;
detach_all(_M_const_iterators);
_M_const_iterators = 0;
}
void
_Safe_sequence_base::
_M_detach_singular()
{
__gnu_cxx::__scoped_lock sentry(_M_get_mutex());
for (_Safe_iterator_base* __iter = _M_iterators; __iter;)
{
_Safe_iterator_base* __old = __iter;
__iter = __iter->_M_next;
if (__old->_M_singular())
__old->_M_detach_single();
}
for (_Safe_iterator_base* __iter2 = _M_const_iterators; __iter2;)
{
_Safe_iterator_base* __old = __iter2;
__iter2 = __iter2->_M_next;
if (__old->_M_singular())
__old->_M_detach_single();
}
}
void
_Safe_sequence_base::
_M_revalidate_singular()
{
__gnu_cxx::__scoped_lock sentry(_M_get_mutex());
for (_Safe_iterator_base* __iter = _M_iterators; __iter;
__iter = __iter->_M_next)
__iter->_M_version = _M_version;
for (_Safe_iterator_base* __iter2 = _M_const_iterators; __iter2;
__iter2 = __iter2->_M_next)
__iter2->_M_version = _M_version;
}
void
_Safe_sequence_base::
_M_swap(_Safe_sequence_base& __x)
{
// We need to lock both sequences to swap
using namespace __gnu_cxx;
__mutex *__this_mutex = &_M_get_mutex();
__mutex *__x_mutex = &__x._M_get_mutex();
if (__this_mutex == __x_mutex)
{
__scoped_lock __lock(*__this_mutex);
swap_seq(*this, __x);
}
else
{
__scoped_lock __l1(__this_mutex < __x_mutex
? *__this_mutex : *__x_mutex);
__scoped_lock __l2(__this_mutex < __x_mutex
? *__x_mutex : *__this_mutex);
swap_seq(*this, __x);
}
}
__gnu_cxx::__mutex&
_Safe_sequence_base::
_M_get_mutex() throw ()
{ return get_safe_base_mutex(this); }
void
_Safe_sequence_base::
_M_attach(_Safe_iterator_base* __it, bool __constant)
{
__gnu_cxx::__scoped_lock sentry(_M_get_mutex());
_M_attach_single(__it, __constant);
}
void
_Safe_sequence_base::
_M_attach_single(_Safe_iterator_base* __it, bool __constant) throw ()
{
_Safe_iterator_base*& __its =
__constant ? _M_const_iterators : _M_iterators;
__it->_M_next = __its;
if (__it->_M_next)
__it->_M_next->_M_prior = __it;
__its = __it;
}
void
_Safe_sequence_base::
_M_detach(_Safe_iterator_base* __it)
{
// Remove __it from this sequence's list
__gnu_cxx::__scoped_lock sentry(_M_get_mutex());
_M_detach_single(__it);
}
void
_Safe_sequence_base::
_M_detach_single(_Safe_iterator_base* __it) throw ()
{
// Remove __it from this sequence's list
__it->_M_unlink();
if (_M_const_iterators == __it)
_M_const_iterators = __it->_M_next;
if (_M_iterators == __it)
_M_iterators = __it->_M_next;
}
void
_Safe_iterator_base::
_M_attach(_Safe_sequence_base* __seq, bool __constant)
{
_M_detach();
// Attach to the new sequence (if there is one)
if (__seq)
{
_M_sequence = __seq;
_M_version = _M_sequence->_M_version;
_M_sequence->_M_attach(this, __constant);
}
}
void
_Safe_iterator_base::
_M_attach_single(_Safe_sequence_base* __seq, bool __constant) throw ()
{
_M_detach_single();
// Attach to the new sequence (if there is one)
if (__seq)
{
_M_sequence = __seq;
_M_version = _M_sequence->_M_version;
_M_sequence->_M_attach_single(this, __constant);
}
}
void
_Safe_iterator_base::
_M_detach()
{
if (_M_sequence)
_M_sequence->_M_detach(this);
_M_reset();
}
void
_Safe_iterator_base::
_M_detach_single() throw ()
{
if (_M_sequence)
_M_sequence->_M_detach_single(this);
_M_reset();
}
void
_Safe_iterator_base::
_M_reset() throw ()
{
_M_sequence = 0;
_M_version = 0;
_M_prior = 0;
_M_next = 0;
}
bool
_Safe_iterator_base::
_M_singular() const throw ()
{ return !_M_sequence || _M_version != _M_sequence->_M_version; }
bool
_Safe_iterator_base::
_M_can_compare(const _Safe_iterator_base& __x) const throw ()
{
return (!_M_singular()
&& !__x._M_singular() && _M_sequence == __x._M_sequence);
}
__gnu_cxx::__mutex&
_Safe_iterator_base::
_M_get_mutex() throw ()
{ return get_safe_base_mutex(_M_sequence); }
_Safe_unordered_container_base*
_Safe_local_iterator_base::
_M_get_container() const _GLIBCXX_NOEXCEPT
{ return static_cast<_Safe_unordered_container_base*>(_M_sequence); }
void
_Safe_local_iterator_base::
_M_attach(_Safe_sequence_base* __cont, bool __constant)
{
_M_detach();
// Attach to the new container (if there is one)
if (__cont)
{
_M_sequence = __cont;
_M_version = _M_sequence->_M_version;
_M_get_container()->_M_attach_local(this, __constant);
}
}
void
_Safe_local_iterator_base::
_M_attach_single(_Safe_sequence_base* __cont, bool __constant) throw ()
{
_M_detach_single();
// Attach to the new container (if there is one)
if (__cont)
{
_M_sequence = __cont;
_M_version = _M_sequence->_M_version;
_M_get_container()->_M_attach_local_single(this, __constant);
}
}
void
_Safe_local_iterator_base::
_M_detach()
{
if (_M_sequence)
_M_get_container()->_M_detach_local(this);
_M_reset();
}
void
_Safe_local_iterator_base::
_M_detach_single() throw ()
{
if (_M_sequence)
_M_get_container()->_M_detach_local_single(this);
_M_reset();
}
void
_Safe_unordered_container_base::
_M_detach_all()
{
__gnu_cxx::__scoped_lock sentry(_M_get_mutex());
detach_all(_M_iterators);
_M_iterators = 0;
detach_all(_M_const_iterators);
_M_const_iterators = 0;
detach_all(_M_local_iterators);
_M_local_iterators = 0;
detach_all(_M_const_local_iterators);
_M_const_local_iterators = 0;
}
void
_Safe_unordered_container_base::
_M_swap(_Safe_unordered_container_base& __x)
{
// We need to lock both containers to swap
using namespace __gnu_cxx;
__mutex *__this_mutex = &_M_get_mutex();
__mutex *__x_mutex = &__x._M_get_mutex();
if (__this_mutex == __x_mutex)
{
__scoped_lock __lock(*__this_mutex);
swap_ucont(*this, __x);
}
else
{
__scoped_lock __l1(__this_mutex < __x_mutex
? *__this_mutex : *__x_mutex);
__scoped_lock __l2(__this_mutex < __x_mutex
? *__x_mutex : *__this_mutex);
swap_ucont(*this, __x);
}
}
void
_Safe_unordered_container_base::
_M_attach_local(_Safe_iterator_base* __it, bool __constant)
{
__gnu_cxx::__scoped_lock sentry(_M_get_mutex());
_M_attach_local_single(__it, __constant);
}
void
_Safe_unordered_container_base::
_M_attach_local_single(_Safe_iterator_base* __it, bool __constant) throw ()
{
_Safe_iterator_base*& __its =
__constant ? _M_const_local_iterators : _M_local_iterators;
__it->_M_next = __its;
if (__it->_M_next)
__it->_M_next->_M_prior = __it;
__its = __it;
}
void
_Safe_unordered_container_base::
_M_detach_local(_Safe_iterator_base* __it)
{
// Remove __it from this container's list
__gnu_cxx::__scoped_lock sentry(_M_get_mutex());
_M_detach_local_single(__it);
}
void
_Safe_unordered_container_base::
_M_detach_local_single(_Safe_iterator_base* __it) throw ()
{
// Remove __it from this container's list
__it->_M_unlink();
if (_M_const_local_iterators == __it)
_M_const_local_iterators = __it->_M_next;
if (_M_local_iterators == __it)
_M_local_iterators = __it->_M_next;
}
void
_Error_formatter::_Parameter::
_M_print_field(const _Error_formatter* __formatter, const char* __name) const
{
assert(this->_M_kind != _Parameter::__unused_param);
const int __bufsize = 64;
char __buf[__bufsize];
if (_M_kind == __iterator)
{
if (strcmp(__name, "name") == 0)
{
assert(_M_variant._M_iterator._M_name);
__formatter->_M_print_word(_M_variant._M_iterator._M_name);
}
else if (strcmp(__name, "address") == 0)
{
__formatter->_M_format_word(__buf, __bufsize, "%p",
_M_variant._M_iterator._M_address);
__formatter->_M_print_word(__buf);
}
else if (strcmp(__name, "type") == 0)
{
if (!_M_variant._M_iterator._M_type)
__formatter->_M_print_word("<unknown type>");
else
// TBD: demangle!
__formatter->_M_print_word(_M_variant._M_iterator.
_M_type->name());
}
else if (strcmp(__name, "constness") == 0)
{
static const char* __constness_names[__last_constness] =
{
"<unknown>",
"constant",
"mutable"
};
__formatter->_M_print_word(__constness_names[_M_variant.
_M_iterator.
_M_constness]);
}
else if (strcmp(__name, "state") == 0)
{
static const char* __state_names[__last_state] =
{
"<unknown>",
"singular",
"dereferenceable (start-of-sequence)",
"dereferenceable",
"past-the-end",
"before-begin"
};
__formatter->_M_print_word(__state_names[_M_variant.
_M_iterator._M_state]);
}
else if (strcmp(__name, "sequence") == 0)
{
assert(_M_variant._M_iterator._M_sequence);
__formatter->_M_format_word(__buf, __bufsize, "%p",
_M_variant._M_iterator._M_sequence);
__formatter->_M_print_word(__buf);
}
else if (strcmp(__name, "seq_type") == 0)
{
if (!_M_variant._M_iterator._M_seq_type)
__formatter->_M_print_word("<unknown seq_type>");
else
// TBD: demangle!
__formatter->_M_print_word(_M_variant._M_iterator.
_M_seq_type->name());
}
else
assert(false);
}
else if (_M_kind == __sequence)
{
if (strcmp(__name, "name") == 0)
{
assert(_M_variant._M_sequence._M_name);
__formatter->_M_print_word(_M_variant._M_sequence._M_name);
}
else if (strcmp(__name, "address") == 0)
{
assert(_M_variant._M_sequence._M_address);
__formatter->_M_format_word(__buf, __bufsize, "%p",
_M_variant._M_sequence._M_address);
__formatter->_M_print_word(__buf);
}
else if (strcmp(__name, "type") == 0)
{
if (!_M_variant._M_sequence._M_type)
__formatter->_M_print_word("<unknown type>");
else
// TBD: demangle!
__formatter->_M_print_word(_M_variant._M_sequence.
_M_type->name());
}
else
assert(false);
}
else if (_M_kind == __integer)
{
if (strcmp(__name, "name") == 0)
{
assert(_M_variant._M_integer._M_name);
__formatter->_M_print_word(_M_variant._M_integer._M_name);
}
else
assert(false);
}
else if (_M_kind == __string)
{
if (strcmp(__name, "name") == 0)
{
assert(_M_variant._M_string._M_name);
__formatter->_M_print_word(_M_variant._M_string._M_name);
}
else
assert(false);
}
else
{
assert(false);
}
}
void
_Error_formatter::_Parameter::
_M_print_description(const _Error_formatter* __formatter) const
{
const int __bufsize = 128;
char __buf[__bufsize];
if (_M_kind == __iterator)
{
__formatter->_M_print_word("iterator ");
if (_M_variant._M_iterator._M_name)
{
__formatter->_M_format_word(__buf, __bufsize, "\"%s\" ",
_M_variant._M_iterator._M_name);
__formatter->_M_print_word(__buf);
}
__formatter->_M_format_word(__buf, __bufsize, "@ 0x%p {\n",
_M_variant._M_iterator._M_address);
__formatter->_M_print_word(__buf);
if (_M_variant._M_iterator._M_type)
{
__formatter->_M_print_word("type = ");
_M_print_field(__formatter, "type");
if (_M_variant._M_iterator._M_constness != __unknown_constness)
{
__formatter->_M_print_word(" (");
_M_print_field(__formatter, "constness");
__formatter->_M_print_word(" iterator)");
}
__formatter->_M_print_word(";\n");
}
if (_M_variant._M_iterator._M_state != __unknown_state)
{
__formatter->_M_print_word(" state = ");
_M_print_field(__formatter, "state");
__formatter->_M_print_word(";\n");
}
if (_M_variant._M_iterator._M_sequence)
{
__formatter->_M_print_word(" references sequence ");
if (_M_variant._M_iterator._M_seq_type)
{
__formatter->_M_print_word("with type `");
_M_print_field(__formatter, "seq_type");
__formatter->_M_print_word("' ");
}
__formatter->_M_format_word(__buf, __bufsize, "@ 0x%p\n",
_M_variant._M_sequence._M_address);
__formatter->_M_print_word(__buf);
}
__formatter->_M_print_word("}\n");
}
else if (_M_kind == __sequence)
{
__formatter->_M_print_word("sequence ");
if (_M_variant._M_sequence._M_name)
{
__formatter->_M_format_word(__buf, __bufsize, "\"%s\" ",
_M_variant._M_sequence._M_name);
__formatter->_M_print_word(__buf);
}
__formatter->_M_format_word(__buf, __bufsize, "@ 0x%p {\n",
_M_variant._M_sequence._M_address);
__formatter->_M_print_word(__buf);
if (_M_variant._M_sequence._M_type)
{
__formatter->_M_print_word(" type = ");
_M_print_field(__formatter, "type");
__formatter->_M_print_word(";\n");
}
__formatter->_M_print_word("}\n");
}
}
const _Error_formatter&
_Error_formatter::_M_message(_Debug_msg_id __id) const throw ()
{ return this->_M_message(_S_debug_messages[__id]); }
void
_Error_formatter::_M_error() const
{
const int __bufsize = 128;
char __buf[__bufsize];
// Emit file & line number information
_M_column = 1;
_M_wordwrap = false;
if (_M_file)
{
_M_format_word(__buf, __bufsize, "%s:", _M_file);
_M_print_word(__buf);
_M_column += strlen(__buf);
}
if (_M_line > 0)
{
_M_format_word(__buf, __bufsize, "%u:", _M_line);
_M_print_word(__buf);
_M_column += strlen(__buf);
}
if (_M_max_length)
_M_wordwrap = true;
_M_print_word("error: ");
// Print the error message
assert(_M_text);
_M_print_string(_M_text);
_M_print_word(".\n");
// Emit descriptions of the objects involved in the operation
_M_wordwrap = false;
bool __has_noninteger_parameters = false;
for (unsigned int __i = 0; __i < _M_num_parameters; ++__i)
{
if (_M_parameters[__i]._M_kind == _Parameter::__iterator
|| _M_parameters[__i]._M_kind == _Parameter::__sequence)
{
if (!__has_noninteger_parameters)
{
_M_first_line = true;
_M_print_word("\nObjects involved in the operation:\n");
__has_noninteger_parameters = true;
}
_M_parameters[__i]._M_print_description(this);
}
}
abort();
}
template<typename _Tp>
void
_Error_formatter::_M_format_word(char* __buf,
int __n __attribute__ ((__unused__)),
const char* __fmt, _Tp __s) const throw ()
{
#ifdef _GLIBCXX_USE_C99
std::snprintf(__buf, __n, __fmt, __s);
#else
std::sprintf(__buf, __fmt, __s);
#endif
}
void
_Error_formatter::_M_print_word(const char* __word) const
{
if (!_M_wordwrap)
{
fprintf(stderr, "%s", __word);
return;
}
size_t __length = strlen(__word);
if (__length == 0)
return;
if ((_M_column + __length < _M_max_length)
|| (__length >= _M_max_length && _M_column == 1))
{
// If this isn't the first line, indent
if (_M_column == 1 && !_M_first_line)
{
char __spacing[_M_indent + 1];
for (int i = 0; i < _M_indent; ++i)
__spacing[i] = ' ';
__spacing[_M_indent] = '\0';
fprintf(stderr, "%s", __spacing);
_M_column += _M_indent;
}
fprintf(stderr, "%s", __word);
_M_column += __length;
if (__word[__length - 1] == '\n')
{
_M_first_line = false;
_M_column = 1;
}
}
else
{
_M_column = 1;
_M_print_word("\n");
_M_print_word(__word);
}
}
void
_Error_formatter::
_M_print_string(const char* __string) const
{
const char* __start = __string;
const char* __finish = __start;
const int __bufsize = 128;
char __buf[__bufsize];
while (*__start)
{
if (*__start != '%')
{
// [__start, __finish) denotes the next word
__finish = __start;
while (isalnum(*__finish))
++__finish;
if (__start == __finish)
++__finish;
if (isspace(*__finish))
++__finish;
const ptrdiff_t __len = __finish - __start;
assert(__len < __bufsize);
memcpy(__buf, __start, __len);
__buf[__len] = '\0';
_M_print_word(__buf);
__start = __finish;
// Skip extra whitespace
while (*__start == ' ')
++__start;
continue;
}
++__start;
assert(*__start);
if (*__start == '%')
{
_M_print_word("%");
++__start;
continue;
}
// Get the parameter number
assert(*__start >= '1' && *__start <= '9');
size_t __param = *__start - '0';
--__param;
assert(__param < _M_num_parameters);
// '.' separates the parameter number from the field
// name, if there is one.
++__start;
if (*__start != '.')
{
assert(*__start == ';');
++__start;
__buf[0] = '\0';
if (_M_parameters[__param]._M_kind == _Parameter::__integer)
{
_M_format_word(__buf, __bufsize, "%ld",
_M_parameters[__param]._M_variant._M_integer._M_value);
_M_print_word(__buf);
}
else if (_M_parameters[__param]._M_kind == _Parameter::__string)
_M_print_string(_M_parameters[__param]._M_variant._M_string._M_value);
continue;
}
// Extract the field name we want
enum { __max_field_len = 16 };
char __field[__max_field_len];
int __field_idx = 0;
++__start;
while (*__start != ';')
{
assert(*__start);
assert(__field_idx < __max_field_len-1);
__field[__field_idx++] = *__start++;
}
++__start;
__field[__field_idx] = 0;
_M_parameters[__param]._M_print_field(this, __field);
}
}
void
_Error_formatter::_M_get_max_length() const throw ()
{
const char* __nptr = std::getenv("GLIBCXX_DEBUG_MESSAGE_LENGTH");
if (__nptr)
{
char* __endptr;
const unsigned long __ret = std::strtoul(__nptr, &__endptr, 0);
if (*__nptr != '\0' && *__endptr == '\0')
_M_max_length = __ret;
}
}
// Instantiations.
template
void
_Error_formatter::_M_format_word(char*, int, const char*,
const void*) const;
template
void
_Error_formatter::_M_format_word(char*, int, const char*, long) const;
template
void
_Error_formatter::_M_format_word(char*, int, const char*,
std::size_t) const;
template
void
_Error_formatter::_M_format_word(char*, int, const char*,
const char*) const;
} // namespace __gnu_debug

View File

@@ -0,0 +1,48 @@
// Explicit instantiation file.
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:
//
#include <fstream>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template class basic_filebuf<char, char_traits<char> >;
template class basic_ifstream<char>;
template class basic_ofstream<char>;
template class basic_fstream<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
template class basic_filebuf<wchar_t, char_traits<wchar_t> >;
template class basic_ifstream<wchar_t>;
template class basic_ofstream<wchar_t>;
template class basic_fstream<wchar_t>;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,121 @@
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <bits/functexcept.h>
#include <cstdlib>
#include <exception>
#include <stdexcept>
#include <new>
#include <typeinfo>
#include <ios>
#include <system_error>
#include <future>
#include <functional>
#include <regex>
#ifdef _GLIBCXX_USE_NLS
# include <libintl.h>
# define _(msgid) gettext (msgid)
#else
# define _(msgid) (msgid)
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
void
__throw_bad_exception()
{ _GLIBCXX_THROW_OR_ABORT(bad_exception()); }
void
__throw_bad_alloc()
{ _GLIBCXX_THROW_OR_ABORT(bad_alloc()); }
void
__throw_bad_cast()
{ _GLIBCXX_THROW_OR_ABORT(bad_cast()); }
void
__throw_bad_typeid()
{ _GLIBCXX_THROW_OR_ABORT(bad_typeid()); }
void
__throw_logic_error(const char* __s __attribute__((unused)))
{ _GLIBCXX_THROW_OR_ABORT(logic_error(_(__s))); }
void
__throw_domain_error(const char* __s __attribute__((unused)))
{ _GLIBCXX_THROW_OR_ABORT(domain_error(_(__s))); }
void
__throw_invalid_argument(const char* __s __attribute__((unused)))
{ _GLIBCXX_THROW_OR_ABORT(invalid_argument(_(__s))); }
void
__throw_length_error(const char* __s __attribute__((unused)))
{ _GLIBCXX_THROW_OR_ABORT(length_error(_(__s))); }
void
__throw_out_of_range(const char* __s __attribute__((unused)))
{ _GLIBCXX_THROW_OR_ABORT(out_of_range(_(__s))); }
void
__throw_runtime_error(const char* __s __attribute__((unused)))
{ _GLIBCXX_THROW_OR_ABORT(runtime_error(_(__s))); }
void
__throw_range_error(const char* __s __attribute__((unused)))
{ _GLIBCXX_THROW_OR_ABORT(range_error(_(__s))); }
void
__throw_overflow_error(const char* __s __attribute__((unused)))
{ _GLIBCXX_THROW_OR_ABORT(overflow_error(_(__s))); }
void
__throw_underflow_error(const char* __s __attribute__((unused)))
{ _GLIBCXX_THROW_OR_ABORT(underflow_error(_(__s))); }
void
__throw_ios_failure(const char* __s __attribute__((unused)))
{ _GLIBCXX_THROW_OR_ABORT(ios_base::failure(_(__s))); }
void
__throw_system_error(int __i __attribute__((unused)))
{ _GLIBCXX_THROW_OR_ABORT(system_error(error_code(__i,
generic_category()))); }
void
__throw_future_error(int __i __attribute__((unused)))
{ _GLIBCXX_THROW_OR_ABORT(future_error(make_error_code(future_errc(__i)))); }
void
__throw_bad_function_call()
{ _GLIBCXX_THROW_OR_ABORT(bad_function_call()); }
void
__throw_regex_error(regex_constants::error_type __ecode
__attribute__((unused)))
{ _GLIBCXX_THROW_OR_ABORT(regex_error(__ecode)); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,38 @@
// Support for <functional> -*- C++ -*-
// Copyright (C) 2011-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <functional>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
bad_function_call::~bad_function_call() noexcept = default;
const char*
bad_function_call::what() const noexcept
{ return "bad_function_call"; }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,90 @@
// future -*- C++ -*-
// Copyright (C) 2009-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <future>
namespace
{
struct future_error_category : public std::error_category
{
virtual const char*
name() const noexcept
{ return "future"; }
virtual std::string message(int __ec) const
{
std::string __msg;
switch (std::future_errc(__ec))
{
case std::future_errc::broken_promise:
__msg = "Broken promise";
break;
case std::future_errc::future_already_retrieved:
__msg = "Future already retrieved";
break;
case std::future_errc::promise_already_satisfied:
__msg = "Promise already satisfied";
break;
case std::future_errc::no_state:
__msg = "No associated state";
break;
default:
__msg = "Unknown error";
break;
}
return __msg;
}
};
const future_error_category&
__future_category_instance() noexcept
{
static const future_error_category __fec{};
return __fec;
}
}
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
const error_category& future_category() noexcept
{ return __future_category_instance(); }
future_error::~future_error() noexcept { }
const char*
future_error::what() const noexcept { return _M_code.message().c_str(); }
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \
&& (ATOMIC_INT_LOCK_FREE > 1)
__future_base::_Result_base::_Result_base() = default;
__future_base::_Result_base::~_Result_base() = default;
__future_base::_State_base::~_State_base() = default;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std

View File

@@ -0,0 +1,57 @@
// std::hash definitions -*- C++ -*-
// Copyright (C) 2010-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#if __cplusplus < 201103L
# error "hash_c++0x.cc must be compiled with -std=gnu++0x"
#endif
#include <type_traits>
#include <bits/functional_hash.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_PURE size_t
hash<long double>::operator()(long double __val) const noexcept
{
// 0 and -0 both hash to zero.
if (__val == 0.0L)
return 0;
int __exponent;
__val = __builtin_frexpl(__val, &__exponent);
__val = __val < 0.0l ? -(__val + 0.5l) : __val;
const long double __mult = __SIZE_MAX__ + 1.0l;
__val *= __mult;
// Try to use all the bits of the mantissa (really necessary only
// on 32-bit targets, at least for 80-bit floating point formats).
const size_t __hibits = (size_t)__val;
__val = (__val - (long double)__hibits) * __mult;
const size_t __coeff = __SIZE_MAX__ / __LDBL_MAX_EXP__;
return __hibits + (size_t)__val + __coeff * __exponent;
}
}

View File

@@ -0,0 +1,97 @@
// std::__detail definitions -*- C++ -*-
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#if __cplusplus < 201103L
# error "hashtable_c++0x.cc must be compiled with -std=gnu++0x"
#endif
#include <initializer_list>
#include <tuple>
#include <bits/hashtable_policy.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
#include "../shared/hashtable-aux.cc"
namespace __detail
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Return a prime no smaller than n.
std::size_t
_Prime_rehash_policy::_M_next_bkt(std::size_t __n) const
{
// Optimize lookups involving the first elements of __prime_list.
// (useful to speed-up, eg, constructors)
static const unsigned char __fast_bkt[12]
= { 2, 2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11 };
if (__n <= 11)
{
_M_next_resize =
__builtin_ceil(__fast_bkt[__n] * (long double)_M_max_load_factor);
return __fast_bkt[__n];
}
const unsigned long* __next_bkt =
std::lower_bound(__prime_list + 5, __prime_list + _S_n_primes, __n);
_M_next_resize =
__builtin_ceil(*__next_bkt * (long double)_M_max_load_factor);
return *__next_bkt;
}
// Finds the smallest prime p such that alpha p > __n_elt + __n_ins.
// If p > __n_bkt, return make_pair(true, p); otherwise return
// make_pair(false, 0). In principle this isn't very different from
// _M_bkt_for_elements.
// The only tricky part is that we're caching the element count at
// which we need to rehash, so we don't have to do a floating-point
// multiply for every insertion.
std::pair<bool, std::size_t>
_Prime_rehash_policy::
_M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt,
std::size_t __n_ins) const
{
if (__n_elt + __n_ins >= _M_next_resize)
{
long double __min_bkts = (__n_elt + __n_ins)
/ (long double)_M_max_load_factor;
if (__min_bkts >= __n_bkt)
return std::make_pair(true,
_M_next_bkt(std::max<std::size_t>(__builtin_floor(__min_bkts) + 1,
__n_bkt * _S_growth_factor)));
_M_next_resize
= __builtin_floor(__n_bkt * (long double)_M_max_load_factor);
return std::make_pair(false, 0);
}
else
return std::make_pair(false, 0);
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __detail
} // namespace std

View File

@@ -0,0 +1,600 @@
// Static data members of -*- C++ -*- numeric_limits classes
// Copyright (C) 1999-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
//
// ISO C++ 14882:1998
// 18.2.1
//
#include <limits>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#define const _GLIBCXX_USE_CONSTEXPR
const bool __numeric_limits_base::is_specialized;
const int __numeric_limits_base::digits;
const int __numeric_limits_base::digits10;
const int __numeric_limits_base::max_digits10;
const bool __numeric_limits_base::is_signed;
const bool __numeric_limits_base::is_integer;
const bool __numeric_limits_base::is_exact;
const int __numeric_limits_base::radix;
const int __numeric_limits_base::min_exponent;
const int __numeric_limits_base::min_exponent10;
const int __numeric_limits_base::max_exponent;
const int __numeric_limits_base::max_exponent10;
const bool __numeric_limits_base::has_infinity;
const bool __numeric_limits_base::has_quiet_NaN;
const bool __numeric_limits_base::has_signaling_NaN;
const float_denorm_style __numeric_limits_base::has_denorm;
const bool __numeric_limits_base::has_denorm_loss;
const bool __numeric_limits_base::is_iec559;
const bool __numeric_limits_base::is_bounded;
const bool __numeric_limits_base::is_modulo;
const bool __numeric_limits_base::traps;
const bool __numeric_limits_base::tinyness_before;
const float_round_style __numeric_limits_base::round_style;
// bool
const bool numeric_limits<bool>::is_specialized;
const int numeric_limits<bool>::digits;
const int numeric_limits<bool>::digits10;
const int numeric_limits<bool>::max_digits10;
const bool numeric_limits<bool>::is_signed;
const bool numeric_limits<bool>::is_integer;
const bool numeric_limits<bool>::is_exact;
const int numeric_limits<bool>::radix;
const int numeric_limits<bool>::min_exponent;
const int numeric_limits<bool>::min_exponent10;
const int numeric_limits<bool>::max_exponent;
const int numeric_limits<bool>::max_exponent10;
const bool numeric_limits<bool>::has_infinity;
const bool numeric_limits<bool>::has_quiet_NaN;
const bool numeric_limits<bool>::has_signaling_NaN;
const float_denorm_style numeric_limits<bool>::has_denorm;
const bool numeric_limits<bool>::has_denorm_loss;
const bool numeric_limits<bool>::is_iec559;
const bool numeric_limits<bool>::is_bounded;
const bool numeric_limits<bool>::is_modulo;
const bool numeric_limits<bool>::traps;
const bool numeric_limits<bool>::tinyness_before;
const float_round_style numeric_limits<bool>::round_style;
// char
const bool numeric_limits<char>::is_specialized;
const int numeric_limits<char>::digits;
const int numeric_limits<char>::digits10;
const int numeric_limits<char>::max_digits10;
const bool numeric_limits<char>::is_signed;
const bool numeric_limits<char>::is_integer;
const bool numeric_limits<char>::is_exact;
const int numeric_limits<char>::radix;
const int numeric_limits<char>::min_exponent;
const int numeric_limits<char>::min_exponent10;
const int numeric_limits<char>::max_exponent;
const int numeric_limits<char>::max_exponent10;
const bool numeric_limits<char>::has_infinity;
const bool numeric_limits<char>::has_quiet_NaN;
const bool numeric_limits<char>::has_signaling_NaN;
const float_denorm_style numeric_limits<char>::has_denorm;
const bool numeric_limits<char>::has_denorm_loss;
const bool numeric_limits<char>::is_iec559;
const bool numeric_limits<char>::is_bounded;
const bool numeric_limits<char>::is_modulo;
const bool numeric_limits<char>::traps;
const bool numeric_limits<char>::tinyness_before;
const float_round_style numeric_limits<char>::round_style;
// signed char
const bool numeric_limits<signed char>::is_specialized;
const int numeric_limits<signed char>::digits;
const int numeric_limits<signed char>::digits10;
const int numeric_limits<signed char>::max_digits10;
const bool numeric_limits<signed char>::is_signed;
const bool numeric_limits<signed char>::is_integer;
const bool numeric_limits<signed char>::is_exact;
const int numeric_limits<signed char>::radix;
const int numeric_limits<signed char>::min_exponent;
const int numeric_limits<signed char>::min_exponent10;
const int numeric_limits<signed char>::max_exponent;
const int numeric_limits<signed char>::max_exponent10;
const bool numeric_limits<signed char>::has_infinity;
const bool numeric_limits<signed char>::has_quiet_NaN;
const bool numeric_limits<signed char>::has_signaling_NaN;
const float_denorm_style numeric_limits<signed char>::has_denorm;
const bool numeric_limits<signed char>::has_denorm_loss;
const bool numeric_limits<signed char>::is_iec559;
const bool numeric_limits<signed char>::is_bounded;
const bool numeric_limits<signed char>::is_modulo;
const bool numeric_limits<signed char>::traps;
const bool numeric_limits<signed char>::tinyness_before;
const float_round_style numeric_limits<signed char>::round_style;
// unsigned char
const bool numeric_limits<unsigned char>::is_specialized;
const int numeric_limits<unsigned char>::digits;
const int numeric_limits<unsigned char>::digits10;
const int numeric_limits<unsigned char>::max_digits10;
const bool numeric_limits<unsigned char>::is_signed;
const bool numeric_limits<unsigned char>::is_integer;
const bool numeric_limits<unsigned char>::is_exact;
const int numeric_limits<unsigned char>::radix;
const int numeric_limits<unsigned char>::min_exponent;
const int numeric_limits<unsigned char>::min_exponent10;
const int numeric_limits<unsigned char>::max_exponent;
const int numeric_limits<unsigned char>::max_exponent10;
const bool numeric_limits<unsigned char>::has_infinity;
const bool numeric_limits<unsigned char>::has_quiet_NaN;
const bool numeric_limits<unsigned char>::has_signaling_NaN;
const float_denorm_style numeric_limits<unsigned char>::has_denorm;
const bool numeric_limits<unsigned char>::has_denorm_loss;
const bool numeric_limits<unsigned char>::is_iec559;
const bool numeric_limits<unsigned char>::is_bounded;
const bool numeric_limits<unsigned char>::is_modulo;
const bool numeric_limits<unsigned char>::traps;
const bool numeric_limits<unsigned char>::tinyness_before;
const float_round_style numeric_limits<unsigned char>::round_style;
// wchar_t
// This used to be problematic...
#ifdef _GLIBCXX_USE_WCHAR_T
const bool numeric_limits<wchar_t>::is_specialized;
const int numeric_limits<wchar_t>::digits;
const int numeric_limits<wchar_t>::digits10;
const int numeric_limits<wchar_t>::max_digits10;
const bool numeric_limits<wchar_t>::is_signed;
const bool numeric_limits<wchar_t>::is_integer;
const bool numeric_limits<wchar_t>::is_exact;
const int numeric_limits<wchar_t>::radix;
const int numeric_limits<wchar_t>::min_exponent;
const int numeric_limits<wchar_t>::min_exponent10;
const int numeric_limits<wchar_t>::max_exponent;
const int numeric_limits<wchar_t>::max_exponent10;
const bool numeric_limits<wchar_t>::has_infinity;
const bool numeric_limits<wchar_t>::has_quiet_NaN;
const bool numeric_limits<wchar_t>::has_signaling_NaN;
const float_denorm_style numeric_limits<wchar_t>::has_denorm;
const bool numeric_limits<wchar_t>::has_denorm_loss;
const bool numeric_limits<wchar_t>::is_iec559;
const bool numeric_limits<wchar_t>::is_bounded;
const bool numeric_limits<wchar_t>::is_modulo;
const bool numeric_limits<wchar_t>::traps;
const bool numeric_limits<wchar_t>::tinyness_before;
const float_round_style numeric_limits<wchar_t>::round_style;
#endif // _GLIBCXX_USE_WCHAR_T
// short
const bool numeric_limits<short>::is_specialized;
const int numeric_limits<short>::digits;
const int numeric_limits<short>::digits10;
const int numeric_limits<short>::max_digits10;
const bool numeric_limits<short>::is_signed;
const bool numeric_limits<short>::is_integer;
const bool numeric_limits<short>::is_exact;
const int numeric_limits<short>::radix;
const int numeric_limits<short>::min_exponent;
const int numeric_limits<short>::min_exponent10;
const int numeric_limits<short>::max_exponent;
const int numeric_limits<short>::max_exponent10;
const bool numeric_limits<short>::has_infinity;
const bool numeric_limits<short>::has_quiet_NaN;
const bool numeric_limits<short>::has_signaling_NaN;
const float_denorm_style numeric_limits<short>::has_denorm;
const bool numeric_limits<short>::has_denorm_loss;
const bool numeric_limits<short>::is_iec559;
const bool numeric_limits<short>::is_bounded;
const bool numeric_limits<short>::is_modulo;
const bool numeric_limits<short>::traps;
const bool numeric_limits<short>::tinyness_before;
const float_round_style numeric_limits<short>::round_style;
// unsigned short
const bool numeric_limits<unsigned short>::is_specialized;
const int numeric_limits<unsigned short>::digits;
const int numeric_limits<unsigned short>::digits10;
const int numeric_limits<unsigned short>::max_digits10;
const bool numeric_limits<unsigned short>::is_signed;
const bool numeric_limits<unsigned short>::is_integer;
const bool numeric_limits<unsigned short>::is_exact;
const int numeric_limits<unsigned short>::radix;
const int numeric_limits<unsigned short>::min_exponent;
const int numeric_limits<unsigned short>::min_exponent10;
const int numeric_limits<unsigned short>::max_exponent;
const int numeric_limits<unsigned short>::max_exponent10;
const bool numeric_limits<unsigned short>::has_infinity;
const bool numeric_limits<unsigned short>::has_quiet_NaN;
const bool numeric_limits<unsigned short>::has_signaling_NaN;
const float_denorm_style numeric_limits<unsigned short>::has_denorm;
const bool numeric_limits<unsigned short>::has_denorm_loss;
const bool numeric_limits<unsigned short>::is_iec559;
const bool numeric_limits<unsigned short>::is_bounded;
const bool numeric_limits<unsigned short>::is_modulo;
const bool numeric_limits<unsigned short>::traps;
const bool numeric_limits<unsigned short>::tinyness_before;
const float_round_style numeric_limits<unsigned short>::round_style;
// int
const bool numeric_limits<int>::is_specialized;
const int numeric_limits<int>::digits;
const int numeric_limits<int>::digits10;
const int numeric_limits<int>::max_digits10;
const bool numeric_limits<int>::is_signed;
const bool numeric_limits<int>::is_integer;
const bool numeric_limits<int>::is_exact;
const int numeric_limits<int>::radix;
const int numeric_limits<int>::min_exponent;
const int numeric_limits<int>::min_exponent10;
const int numeric_limits<int>::max_exponent;
const int numeric_limits<int>::max_exponent10;
const bool numeric_limits<int>::has_infinity;
const bool numeric_limits<int>::has_quiet_NaN;
const bool numeric_limits<int>::has_signaling_NaN;
const float_denorm_style numeric_limits<int>::has_denorm;
const bool numeric_limits<int>::has_denorm_loss;
const bool numeric_limits<int>::is_iec559;
const bool numeric_limits<int>::is_bounded;
const bool numeric_limits<int>::is_modulo;
const bool numeric_limits<int>::traps;
const bool numeric_limits<int>::tinyness_before;
const float_round_style numeric_limits<int>::round_style;
// unsigned int
const bool numeric_limits<unsigned int>::is_specialized;
const int numeric_limits<unsigned int>::digits;
const int numeric_limits<unsigned int>::digits10;
const int numeric_limits<unsigned int>::max_digits10;
const bool numeric_limits<unsigned int>::is_signed;
const bool numeric_limits<unsigned int>::is_integer;
const bool numeric_limits<unsigned int>::is_exact;
const int numeric_limits<unsigned int>::radix;
const int numeric_limits<unsigned int>::min_exponent;
const int numeric_limits<unsigned int>::min_exponent10;
const int numeric_limits<unsigned int>::max_exponent;
const int numeric_limits<unsigned int>::max_exponent10;
const bool numeric_limits<unsigned int>::has_infinity;
const bool numeric_limits<unsigned int>::has_quiet_NaN;
const bool numeric_limits<unsigned int>::has_signaling_NaN;
const float_denorm_style numeric_limits<unsigned int>::has_denorm;
const bool numeric_limits<unsigned int>::has_denorm_loss;
const bool numeric_limits<unsigned int>::is_iec559;
const bool numeric_limits<unsigned int>::is_bounded;
const bool numeric_limits<unsigned int>::is_modulo;
const bool numeric_limits<unsigned int>::traps;
const bool numeric_limits<unsigned int>::tinyness_before;
const float_round_style numeric_limits<unsigned int>::round_style;
// long
const bool numeric_limits<long>::is_specialized;
const int numeric_limits<long>::digits;
const int numeric_limits<long>::digits10;
const int numeric_limits<long>::max_digits10;
const bool numeric_limits<long>::is_signed;
const bool numeric_limits<long>::is_integer;
const bool numeric_limits<long>::is_exact;
const int numeric_limits<long>::radix;
const int numeric_limits<long>::min_exponent;
const int numeric_limits<long>::min_exponent10;
const int numeric_limits<long>::max_exponent;
const int numeric_limits<long>::max_exponent10;
const bool numeric_limits<long>::has_infinity;
const bool numeric_limits<long>::has_quiet_NaN;
const bool numeric_limits<long>::has_signaling_NaN;
const float_denorm_style numeric_limits<long>::has_denorm;
const bool numeric_limits<long>::has_denorm_loss;
const bool numeric_limits<long>::is_iec559;
const bool numeric_limits<long>::is_bounded;
const bool numeric_limits<long>::is_modulo;
const bool numeric_limits<long>::traps;
const bool numeric_limits<long>::tinyness_before;
const float_round_style numeric_limits<long>::round_style;
// unsigned long
const bool numeric_limits<unsigned long>::is_specialized;
const int numeric_limits<unsigned long>::digits;
const int numeric_limits<unsigned long>::digits10;
const int numeric_limits<unsigned long>::max_digits10;
const bool numeric_limits<unsigned long>::is_signed;
const bool numeric_limits<unsigned long>::is_integer;
const bool numeric_limits<unsigned long>::is_exact;
const int numeric_limits<unsigned long>::radix;
const int numeric_limits<unsigned long>::min_exponent;
const int numeric_limits<unsigned long>::min_exponent10;
const int numeric_limits<unsigned long>::max_exponent;
const int numeric_limits<unsigned long>::max_exponent10;
const bool numeric_limits<unsigned long>::has_infinity;
const bool numeric_limits<unsigned long>::has_quiet_NaN;
const bool numeric_limits<unsigned long>::has_signaling_NaN;
const float_denorm_style numeric_limits<unsigned long>::has_denorm;
const bool numeric_limits<unsigned long>::has_denorm_loss;
const bool numeric_limits<unsigned long>::is_iec559;
const bool numeric_limits<unsigned long>::is_bounded;
const bool numeric_limits<unsigned long>::is_modulo;
const bool numeric_limits<unsigned long>::traps;
const bool numeric_limits<unsigned long>::tinyness_before;
const float_round_style numeric_limits<unsigned long>::round_style;
// NOTA BENE: long long is an extension
const bool numeric_limits<long long>::is_specialized;
const int numeric_limits<long long>::digits;
const int numeric_limits<long long>::digits10;
const int numeric_limits<long long>::max_digits10;
const bool numeric_limits<long long>::is_signed;
const bool numeric_limits<long long>::is_integer;
const bool numeric_limits<long long>::is_exact;
const int numeric_limits<long long>::radix;
const int numeric_limits<long long>::min_exponent;
const int numeric_limits<long long>::min_exponent10;
const int numeric_limits<long long>::max_exponent;
const int numeric_limits<long long>::max_exponent10;
const bool numeric_limits<long long>::has_infinity;
const bool numeric_limits<long long>::has_quiet_NaN;
const bool numeric_limits<long long>::has_signaling_NaN;
const float_denorm_style numeric_limits<long long>::has_denorm;
const bool numeric_limits<long long>::has_denorm_loss;
const bool numeric_limits<long long>::is_iec559;
const bool numeric_limits<long long>::is_bounded;
const bool numeric_limits<long long>::is_modulo;
const bool numeric_limits<long long>::traps;
const bool numeric_limits<long long>::tinyness_before;
const float_round_style numeric_limits<long long>::round_style;
const bool numeric_limits<unsigned long long>::is_specialized;
const int numeric_limits<unsigned long long>::digits;
const int numeric_limits<unsigned long long>::digits10;
const int numeric_limits<unsigned long long>::max_digits10;
const bool numeric_limits<unsigned long long>::is_signed;
const bool numeric_limits<unsigned long long>::is_integer;
const bool numeric_limits<unsigned long long>::is_exact;
const int numeric_limits<unsigned long long>::radix;
const int numeric_limits<unsigned long long>::min_exponent;
const int numeric_limits<unsigned long long>::min_exponent10;
const int numeric_limits<unsigned long long>::max_exponent;
const int numeric_limits<unsigned long long>::max_exponent10;
const bool numeric_limits<unsigned long long>::has_infinity;
const bool numeric_limits<unsigned long long>::has_quiet_NaN;
const bool numeric_limits<unsigned long long>::has_signaling_NaN;
const float_denorm_style numeric_limits<unsigned long long>::has_denorm;
const bool numeric_limits<unsigned long long>::has_denorm_loss;
const bool numeric_limits<unsigned long long>::is_iec559;
const bool numeric_limits<unsigned long long>::is_bounded;
const bool numeric_limits<unsigned long long>::is_modulo;
const bool numeric_limits<unsigned long long>::traps;
const bool numeric_limits<unsigned long long>::tinyness_before;
const float_round_style numeric_limits<unsigned long long>::round_style;
#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
const bool numeric_limits<__int128>::is_specialized;
const int numeric_limits<__int128>::digits;
const int numeric_limits<__int128>::digits10;
const int numeric_limits<__int128>::max_digits10;
const bool numeric_limits<__int128>::is_signed;
const bool numeric_limits<__int128>::is_integer;
const bool numeric_limits<__int128>::is_exact;
const int numeric_limits<__int128>::radix;
const int numeric_limits<__int128>::min_exponent;
const int numeric_limits<__int128>::min_exponent10;
const int numeric_limits<__int128>::max_exponent;
const int numeric_limits<__int128>::max_exponent10;
const bool numeric_limits<__int128>::has_infinity;
const bool numeric_limits<__int128>::has_quiet_NaN;
const bool numeric_limits<__int128>::has_signaling_NaN;
const float_denorm_style numeric_limits<__int128>::has_denorm;
const bool numeric_limits<__int128>::has_denorm_loss;
const bool numeric_limits<__int128>::is_iec559;
const bool numeric_limits<__int128>::is_bounded;
const bool numeric_limits<__int128>::is_modulo;
const bool numeric_limits<__int128>::traps;
const bool numeric_limits<__int128>::tinyness_before;
const float_round_style numeric_limits<__int128>::round_style;
const bool numeric_limits<unsigned __int128>::is_specialized;
const int numeric_limits<unsigned __int128>::digits;
const int numeric_limits<unsigned __int128>::digits10;
const int numeric_limits<unsigned __int128>::max_digits10;
const bool numeric_limits<unsigned __int128>::is_signed;
const bool numeric_limits<unsigned __int128>::is_integer;
const bool numeric_limits<unsigned __int128>::is_exact;
const int numeric_limits<unsigned __int128>::radix;
const int numeric_limits<unsigned __int128>::min_exponent;
const int numeric_limits<unsigned __int128>::min_exponent10;
const int numeric_limits<unsigned __int128>::max_exponent;
const int numeric_limits<unsigned __int128>::max_exponent10;
const bool numeric_limits<unsigned __int128>::has_infinity;
const bool numeric_limits<unsigned __int128>::has_quiet_NaN;
const bool numeric_limits<unsigned __int128>::has_signaling_NaN;
const float_denorm_style numeric_limits<unsigned __int128>::has_denorm;
const bool numeric_limits<unsigned __int128>::has_denorm_loss;
const bool numeric_limits<unsigned __int128>::is_iec559;
const bool numeric_limits<unsigned __int128>::is_bounded;
const bool numeric_limits<unsigned __int128>::is_modulo;
const bool numeric_limits<unsigned __int128>::traps;
const bool numeric_limits<unsigned __int128>::tinyness_before;
const float_round_style numeric_limits<unsigned __int128>::round_style;
#endif
// float
const bool numeric_limits<float>::is_specialized;
const int numeric_limits<float>::digits;
const int numeric_limits<float>::digits10;
const int numeric_limits<float>::max_digits10;
const bool numeric_limits<float>::is_signed;
const bool numeric_limits<float>::is_integer;
const bool numeric_limits<float>::is_exact;
const int numeric_limits<float>::radix;
const int numeric_limits<float>::min_exponent;
const int numeric_limits<float>::min_exponent10;
const int numeric_limits<float>::max_exponent;
const int numeric_limits<float>::max_exponent10;
const bool numeric_limits<float>::has_infinity;
const bool numeric_limits<float>::has_quiet_NaN;
const bool numeric_limits<float>::has_signaling_NaN;
const float_denorm_style numeric_limits<float>::has_denorm;
const bool numeric_limits<float>::has_denorm_loss;
const bool numeric_limits<float>::is_iec559;
const bool numeric_limits<float>::is_bounded;
const bool numeric_limits<float>::is_modulo;
const bool numeric_limits<float>::traps;
const bool numeric_limits<float>::tinyness_before;
const float_round_style numeric_limits<float>::round_style;
// double
const bool numeric_limits<double>::is_specialized;
const int numeric_limits<double>::digits;
const int numeric_limits<double>::digits10;
const int numeric_limits<double>::max_digits10;
const bool numeric_limits<double>::is_signed;
const bool numeric_limits<double>::is_integer;
const bool numeric_limits<double>::is_exact;
const int numeric_limits<double>::radix;
const int numeric_limits<double>::min_exponent;
const int numeric_limits<double>::min_exponent10;
const int numeric_limits<double>::max_exponent;
const int numeric_limits<double>::max_exponent10;
const bool numeric_limits<double>::has_infinity;
const bool numeric_limits<double>::has_quiet_NaN;
const bool numeric_limits<double>::has_signaling_NaN;
const float_denorm_style numeric_limits<double>::has_denorm;
const bool numeric_limits<double>::has_denorm_loss;
const bool numeric_limits<double>::is_iec559;
const bool numeric_limits<double>::is_bounded;
const bool numeric_limits<double>::is_modulo;
const bool numeric_limits<double>::traps;
const bool numeric_limits<double>::tinyness_before;
const float_round_style numeric_limits<double>::round_style;
// long double
const bool numeric_limits<long double>::is_specialized;
const int numeric_limits<long double>::digits;
const int numeric_limits<long double>::digits10;
const int numeric_limits<long double>::max_digits10;
const bool numeric_limits<long double>::is_signed;
const bool numeric_limits<long double>::is_integer;
const bool numeric_limits<long double>::is_exact;
const int numeric_limits<long double>::radix;
const int numeric_limits<long double>::min_exponent;
const int numeric_limits<long double>::min_exponent10;
const int numeric_limits<long double>::max_exponent;
const int numeric_limits<long double>::max_exponent10;
const bool numeric_limits<long double>::has_infinity;
const bool numeric_limits<long double>::has_quiet_NaN;
const bool numeric_limits<long double>::has_signaling_NaN;
const float_denorm_style numeric_limits<long double>::has_denorm;
const bool numeric_limits<long double>::has_denorm_loss;
const bool numeric_limits<long double>::is_iec559;
const bool numeric_limits<long double>::is_bounded;
const bool numeric_limits<long double>::is_modulo;
const bool numeric_limits<long double>::traps;
const bool numeric_limits<long double>::tinyness_before;
const float_round_style numeric_limits<long double>::round_style;
// char16_t
const bool numeric_limits<char16_t>::is_specialized;
const int numeric_limits<char16_t>::digits;
const int numeric_limits<char16_t>::digits10;
const int numeric_limits<char16_t>::max_digits10;
const bool numeric_limits<char16_t>::is_signed;
const bool numeric_limits<char16_t>::is_integer;
const bool numeric_limits<char16_t>::is_exact;
const int numeric_limits<char16_t>::radix;
const int numeric_limits<char16_t>::min_exponent;
const int numeric_limits<char16_t>::min_exponent10;
const int numeric_limits<char16_t>::max_exponent;
const int numeric_limits<char16_t>::max_exponent10;
const bool numeric_limits<char16_t>::has_infinity;
const bool numeric_limits<char16_t>::has_quiet_NaN;
const bool numeric_limits<char16_t>::has_signaling_NaN;
const float_denorm_style numeric_limits<char16_t>::has_denorm;
const bool numeric_limits<char16_t>::has_denorm_loss;
const bool numeric_limits<char16_t>::is_iec559;
const bool numeric_limits<char16_t>::is_bounded;
const bool numeric_limits<char16_t>::is_modulo;
const bool numeric_limits<char16_t>::traps;
const bool numeric_limits<char16_t>::tinyness_before;
const float_round_style numeric_limits<char16_t>::round_style;
// char32_t
const bool numeric_limits<char32_t>::is_specialized;
const int numeric_limits<char32_t>::digits;
const int numeric_limits<char32_t>::digits10;
const int numeric_limits<char32_t>::max_digits10;
const bool numeric_limits<char32_t>::is_signed;
const bool numeric_limits<char32_t>::is_integer;
const bool numeric_limits<char32_t>::is_exact;
const int numeric_limits<char32_t>::radix;
const int numeric_limits<char32_t>::min_exponent;
const int numeric_limits<char32_t>::min_exponent10;
const int numeric_limits<char32_t>::max_exponent;
const int numeric_limits<char32_t>::max_exponent10;
const bool numeric_limits<char32_t>::has_infinity;
const bool numeric_limits<char32_t>::has_quiet_NaN;
const bool numeric_limits<char32_t>::has_signaling_NaN;
const float_denorm_style numeric_limits<char32_t>::has_denorm;
const bool numeric_limits<char32_t>::has_denorm_loss;
const bool numeric_limits<char32_t>::is_iec559;
const bool numeric_limits<char32_t>::is_bounded;
const bool numeric_limits<char32_t>::is_modulo;
const bool numeric_limits<char32_t>::traps;
const bool numeric_limits<char32_t>::tinyness_before;
const float_round_style numeric_limits<char32_t>::round_style;
#undef const
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
// XXX GLIBCXX_ABI Deprecated
#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
#define _GLIBCXX_NUM_LIM_COMPAT(type, member, len) \
extern "C" type _ZNSt14numeric_limitsIeE ## len ## member ## E \
__attribute__ ((alias ("_ZNSt14numeric_limitsIdE" #len #member "E")))
_GLIBCXX_NUM_LIM_COMPAT (bool, is_specialized, 14);
_GLIBCXX_NUM_LIM_COMPAT (int, digits, 6);
_GLIBCXX_NUM_LIM_COMPAT (int, digits10, 8);
_GLIBCXX_NUM_LIM_COMPAT (bool, is_signed, 9);
_GLIBCXX_NUM_LIM_COMPAT (bool, is_integer, 10);
_GLIBCXX_NUM_LIM_COMPAT (bool, is_exact, 8);
_GLIBCXX_NUM_LIM_COMPAT (int, radix, 5);
_GLIBCXX_NUM_LIM_COMPAT (int, min_exponent, 12);
_GLIBCXX_NUM_LIM_COMPAT (int, min_exponent10, 14);
_GLIBCXX_NUM_LIM_COMPAT (int, max_exponent, 12);
_GLIBCXX_NUM_LIM_COMPAT (int, max_exponent10, 14);
_GLIBCXX_NUM_LIM_COMPAT (bool, has_infinity, 12);
_GLIBCXX_NUM_LIM_COMPAT (bool, has_quiet_NaN, 13);
_GLIBCXX_NUM_LIM_COMPAT (bool, has_signaling_NaN, 17);
_GLIBCXX_NUM_LIM_COMPAT (std::float_denorm_style, has_denorm, 10);
_GLIBCXX_NUM_LIM_COMPAT (bool, has_denorm_loss, 15);
_GLIBCXX_NUM_LIM_COMPAT (bool, is_iec559, 9);
_GLIBCXX_NUM_LIM_COMPAT (bool, is_bounded, 10);
_GLIBCXX_NUM_LIM_COMPAT (bool, is_modulo, 9);
_GLIBCXX_NUM_LIM_COMPAT (bool, traps, 5);
_GLIBCXX_NUM_LIM_COMPAT (bool, tinyness_before, 15);
_GLIBCXX_NUM_LIM_COMPAT (std::float_round_style, round_style, 11);
#endif // _GLIBCXX_LONG_DOUBLE_COMPAT

View File

@@ -0,0 +1,97 @@
// mutex -*- C++ -*-
// Copyright (C) 2008-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <mutex>
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
#ifndef _GLIBCXX_HAVE_TLS
namespace
{
inline std::unique_lock<std::mutex>*&
__get_once_functor_lock_ptr()
{
static std::unique_lock<std::mutex>* __once_functor_lock_ptr = 0;
return __once_functor_lock_ptr;
}
}
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#ifdef _GLIBCXX_HAVE_TLS
__thread void* __once_callable;
__thread void (*__once_call)();
#else
// Explicit instantiation due to -fno-implicit-instantiation.
template class function<void()>;
function<void()> __once_functor;
mutex&
__get_once_mutex()
{
static mutex once_mutex;
return once_mutex;
}
// code linked against ABI 3.4.12 and later uses this
void
__set_once_functor_lock_ptr(unique_lock<mutex>* __ptr)
{
__get_once_functor_lock_ptr() = __ptr;
}
// unsafe - retained for compatibility with ABI 3.4.11
unique_lock<mutex>&
__get_once_functor_lock()
{
static unique_lock<mutex> once_functor_lock(__get_once_mutex(), defer_lock);
return once_functor_lock;
}
#endif
extern "C"
{
void __once_proxy()
{
#ifndef _GLIBCXX_HAVE_TLS
function<void()> __once_call = std::move(__once_functor);
if (unique_lock<mutex>* __lock = __get_once_functor_lock_ptr())
{
// caller is using new ABI and provided lock ptr
__get_once_functor_lock_ptr() = 0;
__lock->unlock();
}
else
__get_once_functor_lock().unlock(); // global lock
#endif
__once_call();
}
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1

View File

@@ -0,0 +1,67 @@
// std::placeholders -*- C++ -*-
// Copyright (C) 2011-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#if __cplusplus < 201103L
# error "placeholders.cc must be compiled with -std=gnu++0x"
#endif
#include <functional>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace placeholders
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
extern const _Placeholder<1> _1{};
extern const _Placeholder<2> _2{};
extern const _Placeholder<3> _3{};
extern const _Placeholder<4> _4{};
extern const _Placeholder<5> _5{};
extern const _Placeholder<6> _6{};
extern const _Placeholder<7> _7{};
extern const _Placeholder<8> _8{};
extern const _Placeholder<9> _9{};
extern const _Placeholder<10> _10{};
extern const _Placeholder<11> _11{};
extern const _Placeholder<12> _12{};
extern const _Placeholder<13> _13{};
extern const _Placeholder<14> _14{};
extern const _Placeholder<15> _15{};
extern const _Placeholder<16> _16{};
extern const _Placeholder<17> _17{};
extern const _Placeholder<18> _18{};
extern const _Placeholder<19> _19{};
extern const _Placeholder<20> _20{};
extern const _Placeholder<21> _21{};
extern const _Placeholder<22> _22{};
extern const _Placeholder<23> _23{};
extern const _Placeholder<24> _24{};
extern const _Placeholder<25> _25{};
extern const _Placeholder<26> _26{};
extern const _Placeholder<27> _27{};
extern const _Placeholder<28> _28{};
extern const _Placeholder<29> _29{};
_GLIBCXX_END_NAMESPACE_VERSION
}
}

View File

@@ -0,0 +1,148 @@
// random -*- C++ -*-
// Copyright (C) 2012-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <random>
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
#if defined __i386__ || defined __x86_64__
# include <cpuid.h>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace
{
static unsigned long
_M_strtoul(const std::string& __str)
{
unsigned long __ret = 5489UL;
if (__str != "mt19937")
{
const char* __nptr = __str.c_str();
char* __endptr;
__ret = std::strtoul(__nptr, &__endptr, 0);
if (*__nptr == '\0' || *__endptr != '\0')
std::__throw_runtime_error(__N("random_device::_M_strtoul"
"(const std::string&)"));
}
return __ret;
}
#if (defined __i386__ || defined __x86_64__) && defined _GLIBCXX_X86_RDRAND
unsigned int
__attribute__ ((target("rdrnd")))
__x86_rdrand(void)
{
unsigned int retries = 100;
unsigned int val;
while (__builtin_ia32_rdrand32_step(&val) == 0)
if (--retries == 0)
std::__throw_runtime_error(__N("random_device::__x86_rdrand(void)"));
return val;
}
#endif
}
void
random_device::_M_init(const std::string& token)
{
const char *fname = token.c_str();
if (token == "default")
{
#if (defined __i386__ || defined __x86_64__) && defined _GLIBCXX_X86_RDRAND
unsigned int eax, ebx, ecx, edx;
// Check availability of cpuid and, for now at least, also the
// CPU signature for Intel's
if (__get_cpuid_max(0, &ebx) > 0 && ebx == signature_INTEL_ebx)
{
__cpuid(1, eax, ebx, ecx, edx);
if (ecx & bit_RDRND)
{
_M_file = nullptr;
return;
}
}
#endif
fname = "/dev/urandom";
}
else if (token != "/dev/urandom" && token != "/dev/random")
fail:
std::__throw_runtime_error(__N("random_device::"
"random_device(const std::string&)"));
_M_file = std::fopen(fname, "rb");
if (! _M_file)
goto fail;
}
void
random_device::_M_init_pretr1(const std::string& token)
{
_M_mt.seed(_M_strtoul(token));
}
void
random_device::_M_fini()
{
if (_M_file)
std::fclose(_M_file);
}
random_device::result_type
random_device::_M_getval()
{
#if (defined __i386__ || defined __x86_64__) && defined _GLIBCXX_X86_RDRAND
if (! _M_file)
return __x86_rdrand();
#endif
result_type __ret;
std::fread(reinterpret_cast<void*>(&__ret), sizeof(result_type),
1, _M_file);
return __ret;
}
random_device::result_type
random_device::_M_getval_pretr1()
{
return _M_mt();
}
template class mersenne_twister_engine<
uint_fast32_t,
32, 624, 397, 31,
0x9908b0dfUL, 11,
0xffffffffUL, 7,
0x9d2c5680UL, 15,
0xefc60000UL, 18, 1812433253UL>;
}
#endif

View File

@@ -0,0 +1,38 @@
// regex -*- C++ -*-
// Copyright (C) 2011-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <regex>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
regex_error::regex_error(regex_constants::error_type __ecode)
: std::runtime_error("regex_error"), _M_code(__ecode)
{ }
regex_error::~regex_error() throw() { }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std

View File

@@ -0,0 +1,38 @@
// Support for pointer abstractions -*- C++ -*-
// Copyright (C) 2011-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <memory>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
bad_weak_ptr::~bad_weak_ptr() noexcept = default;
char const*
bad_weak_ptr::what() const noexcept
{ return "bad_weak_ptr"; }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,88 @@
// Components for manipulating sequences of characters -*- C++ -*-
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 21 Strings library
//
// Written by Jason Merrill based upon the specification by Takanori Adachi
// in ANSI X3J16/94-0013R2. Rewritten by Nathan Myers.
#include <string>
// Instantiation configuration.
#ifndef C
# define C char
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef basic_string<C> S;
template class basic_string<C>;
template S operator+(const C*, const S&);
template S operator+(C, const S&);
template S operator+(const S&, const S&);
// Only one template keyword allowed here.
// See core issue #46 (NAD)
// http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#46
template
S::basic_string(C*, C*, const allocator<C>&);
template
S::basic_string(const C*, const C*, const allocator<C>&);
template
S::basic_string(S::iterator, S::iterator, const allocator<C>&);
template
C*
S::_S_construct(S::iterator, S::iterator,
const allocator<C>&, forward_iterator_tag);
template
C*
S::_S_construct(C*, C*, const allocator<C>&, forward_iterator_tag);
template
C*
S::_S_construct(const C*, const C*, const allocator<C>&,
forward_iterator_tag);
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::S;
template bool operator==(const S::iterator&, const S::iterator&);
template bool operator==(const S::const_iterator&, const S::const_iterator&);
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,103 @@
// <system_error> implementation file
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <cstring>
#include <system_error>
#include <bits/functexcept.h>
#include <limits>
namespace
{
using std::string;
struct generic_error_category : public std::error_category
{
virtual const char*
name() const noexcept
{ return "generic"; }
virtual string
message(int i) const
{
// XXX locale issues: how does one get or set loc.
// _GLIBCXX_HAVE_STRERROR_L, strerror_l(i, cloc)
return string(strerror(i));
}
};
struct system_error_category : public std::error_category
{
virtual const char*
name() const noexcept
{ return "system"; }
virtual string
message(int i) const
{
// XXX locale issues: how does one get or set loc.
// _GLIBCXX_HAVE_STRERROR_L, strerror_l(i, cloc)
return string(strerror(i));
}
};
const generic_error_category generic_category_instance{};
const system_error_category system_category_instance{};
}
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
error_category::error_category() noexcept = default;
error_category::~error_category() noexcept = default;
const error_category&
system_category() noexcept { return system_category_instance; }
const error_category&
generic_category() noexcept { return generic_category_instance; }
system_error::~system_error() noexcept = default;
error_condition
error_category::default_error_condition(int __i) const noexcept
{ return error_condition(__i, *this); }
bool
error_category::equivalent(int __i,
const error_condition& __cond) const noexcept
{ return default_error_condition(__i) == __cond; }
bool
error_category::equivalent(const error_code& __code, int __i) const noexcept
{ return *this == __code.category() && __code.value() == __i; }
error_condition
error_code::default_error_condition() const noexcept
{ return category().default_error_condition(value()); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,201 @@
// thread -*- C++ -*-
// Copyright (C) 2008-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <thread>
#include <system_error>
#include <cerrno>
#include <cxxabi_forced.h>
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
#if defined(_GLIBCXX_USE_GET_NPROCS)
# include <sys/sysinfo.h>
# define _GLIBCXX_NPROCS get_nprocs()
#elif defined(_GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP)
# define _GLIBCXX_NPROCS pthread_num_processors_np()
#elif defined(_GLIBCXX_USE_SYSCTL_HW_NCPU)
# include <stddef.h>
# include <sys/sysctl.h>
static inline int get_nprocs()
{
int count;
size_t size = sizeof(count);
int mib[] = { CTL_HW, HW_NCPU };
if (!sysctl(mib, 2, &count, &size, NULL, 0))
return count;
return 0;
}
# define _GLIBCXX_NPROCS get_nprocs()
#elif defined(_GLIBCXX_USE_SC_NPROCESSORS_ONLN)
# include <unistd.h>
# define _GLIBCXX_NPROCS sysconf(_SC_NPROCESSORS_ONLN)
#elif defined(_GLIBCXX_USE_SC_NPROC_ONLN)
# include <unistd.h>
# define _GLIBCXX_NPROCS sysconf(_SC_NPROC_ONLN)
#else
# define _GLIBCXX_NPROCS 0
#endif
#ifndef _GLIBCXX_USE_NANOSLEEP
# ifdef _GLIBCXX_HAVE_SLEEP
# include <unistd.h>
# elif defined(_GLIBCXX_HAVE_WIN32_SLEEP)
# include <windows.h>
# else
# error "No sleep function known for this target"
# endif
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace
{
extern "C" void*
execute_native_thread_routine(void* __p)
{
thread::_Impl_base* __t = static_cast<thread::_Impl_base*>(__p);
thread::__shared_base_type __local;
__local.swap(__t->_M_this_ptr);
__try
{
__t->_M_run();
}
__catch(const __cxxabiv1::__forced_unwind&)
{
__throw_exception_again;
}
__catch(...)
{
std::terminate();
}
return 0;
}
}
_GLIBCXX_BEGIN_NAMESPACE_VERSION
void
thread::join()
{
int __e = EINVAL;
if (_M_id != id())
__e = __gthread_join(_M_id._M_thread, 0);
if (__e)
__throw_system_error(__e);
_M_id = id();
}
void
thread::detach()
{
int __e = EINVAL;
if (_M_id != id())
__e = __gthread_detach(_M_id._M_thread);
if (__e)
__throw_system_error(__e);
_M_id = id();
}
void
thread::_M_start_thread(__shared_base_type __b)
{
if (!__gthread_active_p())
#if __EXCEPTIONS
throw system_error(make_error_code(errc::operation_not_permitted),
"Enable multithreading to use std::thread");
#else
__throw_system_error(int(errc::operation_not_permitted));
#endif
__b->_M_this_ptr = __b;
int __e = __gthread_create(&_M_id._M_thread,
&execute_native_thread_routine, __b.get());
if (__e)
{
__b->_M_this_ptr.reset();
__throw_system_error(__e);
}
}
unsigned int
thread::hardware_concurrency() noexcept
{
int __n = _GLIBCXX_NPROCS;
if (__n < 0)
__n = 0;
return __n;
}
_GLIBCXX_END_NAMESPACE_VERSION
namespace this_thread
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
void
__sleep_for(chrono::seconds __s, chrono::nanoseconds __ns)
{
#ifdef _GLIBCXX_USE_NANOSLEEP
__gthread_time_t __ts =
{
static_cast<std::time_t>(__s.count()),
static_cast<long>(__ns.count())
};
::nanosleep(&__ts, 0);
#elif defined(_GLIBCXX_HAVE_SLEEP)
# ifdef _GLIBCXX_HAVE_USLEEP
::sleep(__s.count());
if (__ns.count() > 0)
{
long __us = __ns.count() / 1000;
if (__us == 0)
__us = 1;
::usleep(__us);
}
# else
::sleep(__s.count() + (__ns >= 1000000));
# endif
#elif defined(_GLIBCXX_HAVE_WIN32_SLEEP)
unsigned long ms = __ns.count() / 1000000;
if (__ns.count() > 0 && ms == 0)
ms = 1;
::Sleep(chrono::milliseconds(__s).count() + ms);
#endif
}
_GLIBCXX_END_NAMESPACE_VERSION
}
} // namespace std
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1

View File

@@ -0,0 +1,34 @@
// wide string support -*- C++ -*-
// Copyright (C) 1999-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 21 Strings library
//
#include <bits/c++config.h>
#ifdef _GLIBCXX_USE_WCHAR_T
#define C wchar_t
#include "string-inst.cc"
#endif

View File

@@ -0,0 +1,39 @@
// Explicit instantiation file.
// Copyright (C) 1999-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:
//
#include <memory>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template class allocator<char>;
template class allocator<wchar_t>;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,44 @@
// Low-level functions for atomic operations: version for CPUs providing
// atomic builtins -*- C++ -*-
// Copyright (C) 2006-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <bits/c++config.h>
#include <bits/atomic_word.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_Atomic_word
__attribute__ ((__unused__))
__exchange_and_add(volatile _Atomic_word* __mem, int __val) throw ()
{ return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
void
__attribute__ ((__unused__))
__atomic_add(volatile _Atomic_word* __mem, int __val) throw ()
{ __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,380 @@
// Wrapper of C-language FILE struct -*- C++ -*-
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 27.8 File-based streams
//
#include <bits/basic_file.h>
#include <fcntl.h>
#include <errno.h>
#ifdef _GLIBCXX_HAVE_POLL
#include <poll.h>
#endif
// Pick up ioctl on Solaris 2.8
#ifdef _GLIBCXX_HAVE_UNISTD_H
#include <unistd.h>
#endif
// Pick up FIONREAD on Solaris 2
#ifdef _GLIBCXX_HAVE_SYS_IOCTL_H
#define BSD_COMP
#include <sys/ioctl.h>
#endif
// Pick up FIONREAD on Solaris 2.5.
#ifdef _GLIBCXX_HAVE_SYS_FILIO_H
#include <sys/filio.h>
#endif
#ifdef _GLIBCXX_HAVE_SYS_UIO_H
#include <sys/uio.h>
#endif
#if defined(_GLIBCXX_HAVE_S_ISREG) || defined(_GLIBCXX_HAVE_S_IFREG)
# include <sys/stat.h>
# ifdef _GLIBCXX_HAVE_S_ISREG
# define _GLIBCXX_ISREG(x) S_ISREG(x)
# else
# define _GLIBCXX_ISREG(x) (((x) & S_IFMT) == S_IFREG)
# endif
#endif
#include <limits> // For <off_t>::max() and min() and <streamsize>::max()
namespace
{
// Map ios_base::openmode flags to a string for use in fopen().
// Table of valid combinations as given in [lib.filebuf.members]/2.
static const char*
fopen_mode(std::ios_base::openmode mode)
{
enum
{
in = std::ios_base::in,
out = std::ios_base::out,
trunc = std::ios_base::trunc,
app = std::ios_base::app,
binary = std::ios_base::binary
};
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 596. 27.8.1.3 Table 112 omits "a+" and "a+b" modes.
switch (mode & (in|out|trunc|app|binary))
{
case ( out ): return "w";
case ( out |app ): return "a";
case ( app ): return "a";
case ( out|trunc ): return "w";
case (in ): return "r";
case (in|out ): return "r+";
case (in|out|trunc ): return "w+";
case (in|out |app ): return "a+";
case (in |app ): return "a+";
case ( out |binary): return "wb";
case ( out |app|binary): return "ab";
case ( app|binary): return "ab";
case ( out|trunc |binary): return "wb";
case (in |binary): return "rb";
case (in|out |binary): return "r+b";
case (in|out|trunc |binary): return "w+b";
case (in|out |app|binary): return "a+b";
case (in |app|binary): return "a+b";
default: return 0; // invalid
}
}
// Wrapper handling partial write.
static std::streamsize
xwrite(int __fd, const char* __s, std::streamsize __n)
{
std::streamsize __nleft = __n;
for (;;)
{
const std::streamsize __ret = write(__fd, __s, __nleft);
if (__ret == -1L && errno == EINTR)
continue;
if (__ret == -1L)
break;
__nleft -= __ret;
if (__nleft == 0)
break;
__s += __ret;
}
return __n - __nleft;
}
#ifdef _GLIBCXX_HAVE_WRITEV
// Wrapper handling partial writev.
static std::streamsize
xwritev(int __fd, const char* __s1, std::streamsize __n1,
const char* __s2, std::streamsize __n2)
{
std::streamsize __nleft = __n1 + __n2;
std::streamsize __n1_left = __n1;
struct iovec __iov[2];
__iov[1].iov_base = const_cast<char*>(__s2);
__iov[1].iov_len = __n2;
for (;;)
{
__iov[0].iov_base = const_cast<char*>(__s1);
__iov[0].iov_len = __n1_left;
const std::streamsize __ret = writev(__fd, __iov, 2);
if (__ret == -1L && errno == EINTR)
continue;
if (__ret == -1L)
break;
__nleft -= __ret;
if (__nleft == 0)
break;
const std::streamsize __off = __ret - __n1_left;
if (__off >= 0)
{
__nleft -= xwrite(__fd, __s2 + __off, __n2 - __off);
break;
}
__s1 += __ret;
__n1_left -= __ret;
}
return __n1 + __n2 - __nleft;
}
#endif
} // anonymous namespace
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Definitions for __basic_file<char>.
__basic_file<char>::__basic_file(__c_lock* /*__lock*/) throw()
: _M_cfile(NULL), _M_cfile_created(false) { }
__basic_file<char>::~__basic_file()
{ this->close(); }
__basic_file<char>*
__basic_file<char>::sys_open(__c_file* __file, ios_base::openmode)
{
__basic_file* __ret = NULL;
if (!this->is_open() && __file)
{
int __err;
errno = 0;
do
__err = this->sync();
while (__err && errno == EINTR);
if (!__err)
{
_M_cfile = __file;
_M_cfile_created = false;
__ret = this;
}
}
return __ret;
}
__basic_file<char>*
__basic_file<char>::sys_open(int __fd, ios_base::openmode __mode) throw ()
{
__basic_file* __ret = NULL;
const char* __c_mode = fopen_mode(__mode);
if (__c_mode && !this->is_open() && (_M_cfile = fdopen(__fd, __c_mode)))
{
char* __buf = NULL;
_M_cfile_created = true;
if (__fd == 0)
setvbuf(_M_cfile, __buf, _IONBF, 0);
__ret = this;
}
return __ret;
}
__basic_file<char>*
__basic_file<char>::open(const char* __name, ios_base::openmode __mode,
int /*__prot*/)
{
__basic_file* __ret = NULL;
const char* __c_mode = fopen_mode(__mode);
if (__c_mode && !this->is_open())
{
#ifdef _GLIBCXX_USE_LFS
if ((_M_cfile = fopen64(__name, __c_mode)))
#else
if ((_M_cfile = fopen(__name, __c_mode)))
#endif
{
_M_cfile_created = true;
__ret = this;
}
}
return __ret;
}
bool
__basic_file<char>::is_open() const throw ()
{ return _M_cfile != 0; }
int
__basic_file<char>::fd() throw ()
{ return fileno(_M_cfile); }
__c_file*
__basic_file<char>::file() throw ()
{ return _M_cfile; }
__basic_file<char>*
__basic_file<char>::close()
{
__basic_file* __ret = static_cast<__basic_file*>(NULL);
if (this->is_open())
{
int __err = 0;
if (_M_cfile_created)
{
// In general, no need to zero errno in advance if checking
// for error first. However, C89/C99 (at variance with IEEE
// 1003.1, f.i.) do not mandate that fclose must set errno
// upon error.
errno = 0;
do
__err = fclose(_M_cfile);
while (__err && errno == EINTR);
}
_M_cfile = 0;
if (!__err)
__ret = this;
}
return __ret;
}
streamsize
__basic_file<char>::xsgetn(char* __s, streamsize __n)
{
streamsize __ret;
do
__ret = read(this->fd(), __s, __n);
while (__ret == -1L && errno == EINTR);
return __ret;
}
streamsize
__basic_file<char>::xsputn(const char* __s, streamsize __n)
{ return xwrite(this->fd(), __s, __n); }
streamsize
__basic_file<char>::xsputn_2(const char* __s1, streamsize __n1,
const char* __s2, streamsize __n2)
{
streamsize __ret = 0;
#ifdef _GLIBCXX_HAVE_WRITEV
__ret = xwritev(this->fd(), __s1, __n1, __s2, __n2);
#else
if (__n1)
__ret = xwrite(this->fd(), __s1, __n1);
if (__ret == __n1)
__ret += xwrite(this->fd(), __s2, __n2);
#endif
return __ret;
}
streamoff
__basic_file<char>::seekoff(streamoff __off, ios_base::seekdir __way) throw ()
{
#ifdef _GLIBCXX_USE_LFS
return lseek64(this->fd(), __off, __way);
#else
if (__off > numeric_limits<off_t>::max()
|| __off < numeric_limits<off_t>::min())
return -1L;
return lseek(this->fd(), __off, __way);
#endif
}
int
__basic_file<char>::sync()
{ return fflush(_M_cfile); }
streamsize
__basic_file<char>::showmanyc()
{
#ifndef _GLIBCXX_NO_IOCTL
#ifdef FIONREAD
// Pipes and sockets.
int __num = 0;
int __r = ioctl(this->fd(), FIONREAD, &__num);
if (!__r && __num >= 0)
return __num;
#endif
#endif
#ifdef _GLIBCXX_HAVE_POLL
// Cheap test.
struct pollfd __pfd[1];
__pfd[0].fd = this->fd();
__pfd[0].events = POLLIN;
if (poll(__pfd, 1, 0) <= 0)
return 0;
#endif
#if defined(_GLIBCXX_HAVE_S_ISREG) || defined(_GLIBCXX_HAVE_S_IFREG)
// Regular files.
#ifdef _GLIBCXX_USE_LFS
struct stat64 __buffer;
const int __err = fstat64(this->fd(), &__buffer);
if (!__err && _GLIBCXX_ISREG(__buffer.st_mode))
{
const streamoff __off = __buffer.st_size - lseek64(this->fd(), 0,
ios_base::cur);
return std::min(__off, streamoff(numeric_limits<streamsize>::max()));
}
#else
struct stat __buffer;
const int __err = fstat(this->fd(), &__buffer);
if (!__err && _GLIBCXX_ISREG(__buffer.st_mode))
return __buffer.st_size - lseek(this->fd(), 0, ios_base::cur);
#endif
#endif
return 0;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,127 @@
// Bitmap Allocator. Out of line function definitions. -*- C++ -*-
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <ext/bitmap_allocator.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
namespace __detail
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template class __mini_vector<
std::pair<bitmap_allocator<char>::_Alloc_block*,
bitmap_allocator<char>::_Alloc_block*> >;
template class __mini_vector<
std::pair<bitmap_allocator<wchar_t>::_Alloc_block*,
bitmap_allocator<wchar_t>::_Alloc_block*> >;
template class __mini_vector<size_t*>;
template size_t** __lower_bound(size_t**, size_t**, size_t const&,
free_list::_LT_pointer_compare);
_GLIBCXX_END_NAMESPACE_VERSION
}
_GLIBCXX_BEGIN_NAMESPACE_VERSION
size_t*
free_list::
_M_get(size_t __sz) throw(std::bad_alloc)
{
#if defined __GTHREADS
__mutex_type& __bfl_mutex = _M_get_mutex();
__bfl_mutex.lock();
#endif
const vector_type& __free_list = _M_get_free_list();
using __gnu_cxx::__detail::__lower_bound;
iterator __tmp = __lower_bound(__free_list.begin(), __free_list.end(),
__sz, _LT_pointer_compare());
if (__tmp == __free_list.end() || !_M_should_i_give(**__tmp, __sz))
{
// We release the lock here, because operator new is
// guaranteed to be thread-safe by the underlying
// implementation.
#if defined __GTHREADS
__bfl_mutex.unlock();
#endif
// Try twice to get the memory: once directly, and the 2nd
// time after clearing the free list. If both fail, then throw
// std::bad_alloc().
int __ctr = 2;
while (__ctr)
{
size_t* __ret = 0;
--__ctr;
__try
{
__ret = reinterpret_cast<size_t*>
(::operator new(__sz + sizeof(size_t)));
}
__catch(const std::bad_alloc&)
{
this->_M_clear();
}
if (!__ret)
continue;
*__ret = __sz;
return __ret + 1;
}
std::__throw_bad_alloc();
}
else
{
size_t* __ret = *__tmp;
_M_get_free_list().erase(__tmp);
#if defined __GTHREADS
__bfl_mutex.unlock();
#endif
return __ret + 1;
}
}
void
free_list::
_M_clear()
{
#if defined __GTHREADS
__gnu_cxx::__scoped_lock __bfl_lock(_M_get_mutex());
#endif
vector_type& __free_list = _M_get_free_list();
iterator __iter = __free_list.begin();
while (__iter != __free_list.end())
{
::operator delete((void*)*__iter);
++__iter;
}
__free_list.clear();
}
// Instantiations.
template class bitmap_allocator<char>;
template class bitmap_allocator<wchar_t>;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,267 @@
// Wrapper for underlying C-language localization -*- C++ -*-
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.8 Standard locale categories.
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <cerrno> // For errno
#include <cmath> // For isinf, finite, finitef, fabs
#include <cstdlib> // For strof, strtold
#include <cstring>
#include <cstdio>
#include <locale>
#include <limits>
#ifdef _GLIBCXX_HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<>
void
__convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
const __c_locale&) throw()
{
// Assumes __s formatted for "C" locale.
char* __old = setlocale(LC_ALL, 0);
const size_t __len = strlen(__old) + 1;
char* __sav = new char[__len];
memcpy(__sav, __old, __len);
setlocale(LC_ALL, "C");
char* __sanity;
bool __overflow = false;
#if !__FLT_HAS_INFINITY__
errno = 0;
#endif
#ifdef _GLIBCXX_HAVE_STRTOF
__v = strtof(__s, &__sanity);
#else
double __d = strtod(__s, &__sanity);
__v = static_cast<float>(__d);
#ifdef _GLIBCXX_HAVE_FINITEF
if (!finitef (__v))
__overflow = true;
#elif defined (_GLIBCXX_HAVE_FINITE)
if (!finite (static_cast<double> (__v)))
__overflow = true;
#elif defined (_GLIBCXX_HAVE_ISINF)
if (isinf (static_cast<double> (__v)))
__overflow = true;
#else
if (fabs(__d) > numeric_limits<float>::max())
__overflow = true;
#endif
#endif // _GLIBCXX_HAVE_STRTOF
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 23. Num_get overflow result.
if (__sanity == __s || *__sanity != '\0')
{
__v = 0.0f;
__err = ios_base::failbit;
}
else if (__overflow
#if __FLT_HAS_INFINITY__
|| __v == numeric_limits<float>::infinity()
|| __v == -numeric_limits<float>::infinity()
#else
|| ((__v > 1.0f || __v < -1.0f) && errno == ERANGE)
#endif
)
{
if (__v > 0.0f)
__v = numeric_limits<float>::max();
else
__v = -numeric_limits<float>::max();
__err = ios_base::failbit;
}
setlocale(LC_ALL, __sav);
delete [] __sav;
}
template<>
void
__convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
const __c_locale&) throw()
{
// Assumes __s formatted for "C" locale.
char* __old = setlocale(LC_ALL, 0);
const size_t __len = strlen(__old) + 1;
char* __sav = new char[__len];
memcpy(__sav, __old, __len);
setlocale(LC_ALL, "C");
char* __sanity;
#if !__DBL_HAS_INFINITY__
errno = 0;
#endif
__v = strtod(__s, &__sanity);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 23. Num_get overflow result.
if (__sanity == __s || *__sanity != '\0')
{
__v = 0.0;
__err = ios_base::failbit;
}
else if (
#if __DBL_HAS_INFINITY__
__v == numeric_limits<double>::infinity()
|| __v == -numeric_limits<double>::infinity())
#else
(__v > 1.0 || __v < -1.0) && errno == ERANGE)
#endif
{
if (__v > 0.0)
__v = numeric_limits<double>::max();
else
__v = -numeric_limits<double>::max();
__err = ios_base::failbit;
}
setlocale(LC_ALL, __sav);
delete [] __sav;
}
template<>
void
__convert_to_v(const char* __s, long double& __v,
ios_base::iostate& __err, const __c_locale&) throw()
{
// Assumes __s formatted for "C" locale.
char* __old = setlocale(LC_ALL, 0);
const size_t __len = strlen(__old) + 1;
char* __sav = new char[__len];
memcpy(__sav, __old, __len);
setlocale(LC_ALL, "C");
#if !__LDBL_HAS_INFINITY__
errno = 0;
#endif
#if defined(_GLIBCXX_HAVE_STRTOLD) && !defined(_GLIBCXX_HAVE_BROKEN_STRTOLD)
char* __sanity;
__v = strtold(__s, &__sanity);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 23. Num_get overflow result.
if (__sanity == __s || *__sanity != '\0')
#else
typedef char_traits<char>::int_type int_type;
int __p = sscanf(__s, "%Lf", &__v);
if (!__p || static_cast<int_type>(__p) == char_traits<char>::eof())
#endif
{
__v = 0.0l;
__err = ios_base::failbit;
}
else if (
#if __LDBL_HAS_INFINITY__
__v == numeric_limits<long double>::infinity()
|| __v == -numeric_limits<long double>::infinity())
#else
(__v > 1.0l || __v < -1.0l) && errno == ERANGE)
#endif
{
if (__v > 0.0l)
__v = numeric_limits<long double>::max();
else
__v = -numeric_limits<long double>::max();
__err = ios_base::failbit;
}
setlocale(LC_ALL, __sav);
delete [] __sav;
}
void
locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
__c_locale)
{
// Currently, the generic model only supports the "C" locale.
// See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
__cloc = 0;
if (strcmp(__s, "C"))
__throw_runtime_error(__N("locale::facet::_S_create_c_locale "
"name not valid"));
}
void
locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
{ __cloc = 0; }
__c_locale
locale::facet::_S_clone_c_locale(__c_locale&) throw()
{ return __c_locale(); }
__c_locale
locale::facet::_S_lc_ctype_c_locale(__c_locale, const char*)
{ return __c_locale(); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
{
"LC_CTYPE",
"LC_NUMERIC",
"LC_TIME",
"LC_COLLATE",
"LC_MONETARY",
"LC_MESSAGES"
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
const char* const* const locale::_S_categories = __gnu_cxx::category_names;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
// XXX GLIBCXX_ABI Deprecated
#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
extern "C" void ldbl (void) __attribute__ ((alias (#dbl)))
_GLIBCXX_LDBL_COMPAT(_ZSt14__convert_to_vIdEvPKcRT_RSt12_Ios_IostateRKPi, _ZSt14__convert_to_vIeEvPKcRT_RSt12_Ios_IostateRKPi);
#endif // _GLIBCXX_LONG_DOUBLE_COMPAT

View File

@@ -0,0 +1,151 @@
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Definitions for locale::id of standard facets that are specialized.
locale::id codecvt<char, char, mbstate_t>::id;
#ifdef _GLIBCXX_USE_WCHAR_T
locale::id codecvt<wchar_t, char, mbstate_t>::id;
#endif
codecvt<char, char, mbstate_t>::
codecvt(size_t __refs)
: __codecvt_abstract_base<char, char, mbstate_t>(__refs),
_M_c_locale_codecvt(_S_get_c_locale())
{ }
codecvt<char, char, mbstate_t>::
codecvt(__c_locale __cloc, size_t __refs)
: __codecvt_abstract_base<char, char, mbstate_t>(__refs),
_M_c_locale_codecvt(_S_clone_c_locale(__cloc))
{ }
codecvt<char, char, mbstate_t>::
~codecvt()
{ _S_destroy_c_locale(_M_c_locale_codecvt); }
codecvt_base::result
codecvt<char, char, mbstate_t>::
do_out(state_type&, const intern_type* __from,
const intern_type*, const intern_type*& __from_next,
extern_type* __to, extern_type*,
extern_type*& __to_next) const
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// According to the resolution of DR19, "If returns noconv [...]
// there are no changes to the values in [to, to_limit)."
__from_next = __from;
__to_next = __to;
return noconv;
}
codecvt_base::result
codecvt<char, char, mbstate_t>::
do_unshift(state_type&, extern_type* __to,
extern_type*, extern_type*& __to_next) const
{
__to_next = __to;
return noconv;
}
codecvt_base::result
codecvt<char, char, mbstate_t>::
do_in(state_type&, const extern_type* __from,
const extern_type*, const extern_type*& __from_next,
intern_type* __to, intern_type*, intern_type*& __to_next) const
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// According to the resolution of DR19, "If returns noconv [...]
// there are no changes to the values in [to, to_limit)."
__from_next = __from;
__to_next = __to;
return noconv;
}
int
codecvt<char, char, mbstate_t>::
do_encoding() const throw()
{ return 1; }
bool
codecvt<char, char, mbstate_t>::
do_always_noconv() const throw()
{ return true; }
int
codecvt<char, char, mbstate_t>::
do_length (state_type&, const extern_type* __from,
const extern_type* __end, size_t __max) const
{
size_t __d = static_cast<size_t>(__end - __from);
return std::min(__max, __d);
}
int
codecvt<char, char, mbstate_t>::
do_max_length() const throw()
{ return 1; }
#ifdef _GLIBCXX_USE_WCHAR_T
// codecvt<wchar_t, char, mbstate_t> required specialization
codecvt<wchar_t, char, mbstate_t>::
codecvt(size_t __refs)
: __codecvt_abstract_base<wchar_t, char, mbstate_t>(__refs),
_M_c_locale_codecvt(_S_get_c_locale())
{ }
codecvt<wchar_t, char, mbstate_t>::
codecvt(__c_locale __cloc, size_t __refs)
: __codecvt_abstract_base<wchar_t, char, mbstate_t>(__refs),
_M_c_locale_codecvt(_S_clone_c_locale(__cloc))
{ }
codecvt<wchar_t, char, mbstate_t>::
~codecvt()
{ _S_destroy_c_locale(_M_c_locale_codecvt); }
codecvt_base::result
codecvt<wchar_t, char, mbstate_t>::
do_unshift(state_type&, extern_type* __to,
extern_type*, extern_type*& __to_next) const
{
// XXX Probably wrong for stateful encodings
__to_next = __to;
return noconv;
}
bool
codecvt<wchar_t, char, mbstate_t>::
do_always_noconv() const throw()
{ return false; }
#endif // _GLIBCXX_USE_WCHAR_T
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,219 @@
// std::codecvt implementation details, generic version -*- C++ -*-
// Copyright (C) 2002-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.1.5 - Template class codecvt
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <cstdlib> // For MB_CUR_MAX
#include <climits> // For MB_LEN_MAX
#include <cstring>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Specializations.
#ifdef _GLIBCXX_USE_WCHAR_T
codecvt_base::result
codecvt<wchar_t, char, mbstate_t>::
do_out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const
{
result __ret = ok;
// The conversion must be done using a temporary destination buffer
// since it is not possible to pass the size of the buffer to wcrtomb
state_type __tmp_state(__state);
// The conversion must be done by calling wcrtomb in a loop rather
// than using wcsrtombs because wcsrtombs assumes that the input is
// zero-terminated.
// Either we can upper bound the total number of external characters to
// something smaller than __to_end - __to or the conversion must be done
// using a temporary destination buffer since it is not possible to
// pass the size of the buffer to wcrtomb
if (MB_CUR_MAX * (__from_end - __from) - (__to_end - __to) <= 0)
while (__from < __from_end)
{
const size_t __conv = wcrtomb(__to, *__from, &__tmp_state);
if (__conv == static_cast<size_t>(-1))
{
__ret = error;
break;
}
__state = __tmp_state;
__to += __conv;
__from++;
}
else
{
extern_type __buf[MB_LEN_MAX];
while (__from < __from_end && __to < __to_end)
{
const size_t __conv = wcrtomb(__buf, *__from, &__tmp_state);
if (__conv == static_cast<size_t>(-1))
{
__ret = error;
break;
}
else if (__conv > static_cast<size_t>(__to_end - __to))
{
__ret = partial;
break;
}
memcpy(__to, __buf, __conv);
__state = __tmp_state;
__to += __conv;
__from++;
}
}
if (__ret == ok && __from < __from_end)
__ret = partial;
__from_next = __from;
__to_next = __to;
return __ret;
}
codecvt_base::result
codecvt<wchar_t, char, mbstate_t>::
do_in(state_type& __state, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const
{
result __ret = ok;
// This temporary state object is neccessary so __state won't be modified
// if [__from, __from_end) is a partial multibyte character.
state_type __tmp_state(__state);
// Conversion must be done by calling mbrtowc in a loop rather than
// by calling mbsrtowcs because mbsrtowcs assumes that the input
// sequence is zero-terminated.
while (__from < __from_end && __to < __to_end)
{
size_t __conv = mbrtowc(__to, __from, __from_end - __from,
&__tmp_state);
if (__conv == static_cast<size_t>(-1))
{
__ret = error;
break;
}
else if (__conv == static_cast<size_t>(-2))
{
// It is unclear what to return in this case (see DR 382).
__ret = partial;
break;
}
else if (__conv == 0)
{
// XXX Probably wrong for stateful encodings
__conv = 1;
*__to = L'\0';
}
__state = __tmp_state;
__to++;
__from += __conv;
}
// It is not clear that __from < __from_end implies __ret != ok
// (see DR 382).
if (__ret == ok && __from < __from_end)
__ret = partial;
__from_next = __from;
__to_next = __to;
return __ret;
}
int
codecvt<wchar_t, char, mbstate_t>::
do_encoding() const throw()
{
// XXX This implementation assumes that the encoding is
// stateless and is either single-byte or variable-width.
int __ret = 0;
if (MB_CUR_MAX == 1)
__ret = 1;
return __ret;
}
int
codecvt<wchar_t, char, mbstate_t>::
do_max_length() const throw()
{
// XXX Probably wrong for stateful encodings.
int __ret = MB_CUR_MAX;
return __ret;
}
int
codecvt<wchar_t, char, mbstate_t>::
do_length(state_type& __state, const extern_type* __from,
const extern_type* __end, size_t __max) const
{
int __ret = 0;
state_type __tmp_state(__state);
while (__from < __end && __max)
{
size_t __conv = mbrtowc(0, __from, __end - __from, &__tmp_state);
if (__conv == static_cast<size_t>(-1))
{
// Invalid source character
break;
}
else if (__conv == static_cast<size_t>(-2))
{
// Remainder of input does not form a complete destination
// character.
break;
}
else if (__conv == 0)
{
// XXX Probably wrong for stateful encodings
__conv = 1;
}
__state = __tmp_state;
__from += __conv;
__ret += __conv;
__max--;
}
return __ret;
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,73 @@
// std::collate implementation details, generic version -*- C++ -*-
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.4.1.2 collate virtual functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <cstring>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// These are basically extensions to char_traits, and perhaps should
// be put there instead of here.
template<>
int
collate<char>::_M_compare(const char* __one,
const char* __two) const throw()
{
int __cmp = strcoll(__one, __two);
return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
}
template<>
size_t
collate<char>::_M_transform(char* __to, const char* __from,
size_t __n) const throw()
{ return strxfrm(__to, __from, __n); }
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
int
collate<wchar_t>::_M_compare(const wchar_t* __one,
const wchar_t* __two) const throw()
{
int __cmp = wcscoll(__one, __two);
return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
}
template<>
size_t
collate<wchar_t>::_M_transform(wchar_t* __to, const wchar_t* __from,
size_t __n) const throw()
{ return wcsxfrm(__to, __from, __n); }
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,28 @@
// Compatibility symbols for previous versions, debug list -*- C++ -*-
// Copyright (C) 2011-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#define _GLIBCXX_BEGIN_NAMESPACE_COMPAT namespace __norm {
#define _GLIBCXX_END_NAMESPACE_COMPAT }
#include "list-aux-2.cc"

View File

@@ -0,0 +1,28 @@
// Compatibility symbols for previous versions, debug list -*- C++ -*-
// Copyright (C) 2010-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#define _GLIBCXX_BEGIN_NAMESPACE_COMPAT namespace __norm {
#define _GLIBCXX_END_NAMESPACE_COMPAT }
#include "list-aux.cc"

View File

@@ -0,0 +1,79 @@
// Compatibility symbols for -mlong-double-64 compatibility -*- C++ -*-
// Copyright (C) 2006-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <locale>
#include <cmath>
#include <tr1/functional>
#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
#ifdef __LONG_DOUBLE_128__
#error "compatibility-ldbl.cc must be compiled with -mlong-double-64"
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
#define C char
template class num_get<C, istreambuf_iterator<C> >;
template class num_put<C, ostreambuf_iterator<C> >;
template class money_get<C, istreambuf_iterator<C> >;
template class money_put<C, ostreambuf_iterator<C> >;
template const num_put<C>& use_facet<num_put<C> >(const locale&);
template const num_get<C>& use_facet<num_get<C> >(const locale&);
template const money_put<C>& use_facet<money_put<C> >(const locale&);
template const money_get<C>& use_facet<money_get<C> >(const locale&);
template bool has_facet<num_put<C> >(const locale&);
template bool has_facet<num_get<C> >(const locale&);
template bool has_facet<money_put<C> >(const locale&);
template bool has_facet<money_get<C> >(const locale&);
#undef C
#ifdef _GLIBCXX_USE_WCHAR_T
#define C wchar_t
template class num_get<C, istreambuf_iterator<C> >;
template class num_put<C, ostreambuf_iterator<C> >;
template class money_get<C, istreambuf_iterator<C> >;
template class money_put<C, ostreambuf_iterator<C> >;
template const num_put<C>& use_facet<num_put<C> >(const locale&);
template const num_get<C>& use_facet<num_get<C> >(const locale&);
template const money_put<C>& use_facet<money_put<C> >(const locale&);
template const money_get<C>& use_facet<money_get<C> >(const locale&);
template bool has_facet<num_put<C> >(const locale&);
template bool has_facet<num_get<C> >(const locale&);
template bool has_facet<money_put<C> >(const locale&);
template bool has_facet<money_get<C> >(const locale&);
#undef C
#endif
}
// For std::tr1::hash<long double>::operator()
#define _GLIBCXX_LONG_DOUBLE_COMPAT_IMPL
#include "hash-long-double-tr1-aux.cc"
// std::tr1::hash<long double>::operator()
// and std::hash<long double>::operator()
// are the same, no need to duplicate them.
extern "C" void _ZNKSt4hashIeEclEe (void)
__attribute__((alias ("_ZNKSt3tr14hashIeEclEe")));
#endif

View File

@@ -0,0 +1,560 @@
// Compatibility symbols for previous versions -*- C++ -*-
// Copyright (C) 2005-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <bits/c++config.h>
#if defined(_GLIBCXX_SYMVER_GNU) && defined(_GLIBCXX_SHARED) \
&& defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE)\
&& defined(_GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT)
#define istreambuf_iterator istreambuf_iteratorXX
#define basic_fstream basic_fstreamXX
#define basic_ifstream basic_ifstreamXX
#define basic_ofstream basic_ofstreamXX
#define _M_copy(a, b, c) _M_copyXX(a, b, c)
#define _M_move(a, b, c) _M_moveXX(a, b, c)
#define _M_assign(a, b, c) _M_assignXX(a, b, c)
#define _M_disjunct(a) _M_disjunctXX(a)
#define _M_check_length(a, b, c) _M_check_lengthXX(a, b, c)
#define _M_set_length_and_sharable(a) _M_set_length_and_sharableXX(a)
#define ignore ignoreXX
#define eq eqXX
#define _List_node_base _List_node_baseXX
#endif
#include <string>
#include <istream>
#include <fstream>
#include <sstream>
#include <cmath>
#include <ext/numeric_traits.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// std::istream ignore explicit specializations.
template<>
basic_istream<char>&
basic_istream<char>::
ignore(streamsize __n)
{
if (__n == 1)
return ignore();
_M_gcount = 0;
sentry __cerb(*this, true);
if ( __n > 0 && __cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
int_type __c = __sb->sgetc();
// See comment in istream.tcc.
bool __large_ignore = false;
while (true)
{
while (_M_gcount < __n
&& !traits_type::eq_int_type(__c, __eof))
{
streamsize __size = std::min(streamsize(__sb->egptr()
- __sb->gptr()),
streamsize(__n - _M_gcount));
if (__size > 1)
{
__sb->__safe_gbump(__size);
_M_gcount += __size;
__c = __sb->sgetc();
}
else
{
++_M_gcount;
__c = __sb->snextc();
}
}
if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
&& !traits_type::eq_int_type(__c, __eof))
{
_M_gcount =
__gnu_cxx::__numeric_traits<streamsize>::__min;
__large_ignore = true;
}
else
break;
}
if (__large_ignore)
_M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
basic_istream<wchar_t>&
basic_istream<wchar_t>::
ignore(streamsize __n)
{
if (__n == 1)
return ignore();
_M_gcount = 0;
sentry __cerb(*this, true);
if (__n > 0 && __cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
int_type __c = __sb->sgetc();
bool __large_ignore = false;
while (true)
{
while (_M_gcount < __n
&& !traits_type::eq_int_type(__c, __eof))
{
streamsize __size = std::min(streamsize(__sb->egptr()
- __sb->gptr()),
streamsize(__n - _M_gcount));
if (__size > 1)
{
__sb->__safe_gbump(__size);
_M_gcount += __size;
__c = __sb->sgetc();
}
else
{
++_M_gcount;
__c = __sb->snextc();
}
}
if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
&& !traits_type::eq_int_type(__c, __eof))
{
_M_gcount =
__gnu_cxx::__numeric_traits<streamsize>::__min;
__large_ignore = true;
}
else
break;
}
if (__large_ignore)
_M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
// NB: These symbols renames should go into the shared library only,
// and only those shared libraries that support versioning.
#if defined(_GLIBCXX_SYMVER_GNU) && defined(_GLIBCXX_SHARED) \
&& defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE) \
&& defined(_GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT)
/* gcc-3.4.4
_ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv
_ZNSt19istreambuf_iteratorIwSt11char_traitsIwEEppEv
*/
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template
istreambuf_iterator<char>&
istreambuf_iterator<char>::operator++();
#ifdef _GLIBCXX_USE_WCHAR_T
template
istreambuf_iterator<wchar_t>&
istreambuf_iterator<wchar_t>::operator++();
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
/* gcc-4.0.0
_ZNSs4_Rep26_M_set_length_and_sharableEj
_ZNSs7_M_copyEPcPKcj
_ZNSs7_M_moveEPcPKcj
_ZNSs9_M_assignEPcjc
_ZNKSs11_M_disjunctEPKc
_ZNKSs15_M_check_lengthEjjPKc
_ZNSbIwSt11char_traitsIwESaIwEE4_Rep26_M_set_length_and_sharableEj
_ZNSbIwSt11char_traitsIwESaIwEE7_M_copyEPwPKwj
_ZNSbIwSt11char_traitsIwESaIwEE7_M_moveEPwPKwj
_ZNSbIwSt11char_traitsIwESaIwEE9_M_assignEPwjw
_ZNKSbIwSt11char_traitsIwESaIwEE11_M_disjunctEPKw
_ZNKSbIwSt11char_traitsIwESaIwEE15_M_check_lengthEjjPKc
_ZNKSt13basic_fstreamIcSt11char_traitsIcEE7is_openEv
_ZNKSt13basic_fstreamIwSt11char_traitsIwEE7is_openEv
_ZNKSt14basic_ifstreamIcSt11char_traitsIcEE7is_openEv
_ZNKSt14basic_ifstreamIwSt11char_traitsIwEE7is_openEv
_ZNKSt14basic_ofstreamIcSt11char_traitsIcEE7is_openEv
_ZNKSt14basic_ofstreamIwSt11char_traitsIwEE7is_openEv
_ZNSi6ignoreEi
_ZNSi6ignoreEv
_ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEi
_ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEv
_ZNSt11char_traitsIcE2eqERKcS2_
_ZNSt11char_traitsIwE2eqERKwS2_
*/
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// std::char_traits is explicitly specialized
bool (* __p1)(const char&, const char&) = &char_traits<char>::eq;
// std::string
template
void
basic_string<char>::_M_copy(char*, const char*, size_t);
template
void
basic_string<char>::_M_move(char*, const char*, size_t);
template
void
basic_string<char>::_M_assign(char*, size_t, char);
template
bool
basic_string<char>::_M_disjunct(const char*) const;
template
void
basic_string<char>::_M_check_length(size_t, size_t, const char*) const;
template
void
basic_string<char>::_Rep::_M_set_length_and_sharable(size_t);
// std::istream
template
basic_istream<char>&
basic_istream<char>::ignore();
template
bool
basic_fstream<char>::is_open() const;
template
bool
basic_ifstream<char>::is_open() const;
template
bool
basic_ofstream<char>::is_open() const;
#ifdef _GLIBCXX_USE_WCHAR_T
bool (* __p2)(const wchar_t&, const wchar_t&) = &char_traits<wchar_t>::eq;
// std::wstring
template
void
basic_string<wchar_t>::_M_copy(wchar_t*, const wchar_t*, size_t);
template
void
basic_string<wchar_t>::_M_move(wchar_t*, const wchar_t*, size_t);
template
void
basic_string<wchar_t>::_M_assign(wchar_t*, size_t, wchar_t);
template
bool
basic_string<wchar_t>::_M_disjunct(const wchar_t*) const;
template
void
basic_string<wchar_t>::_M_check_length(size_t, size_t,
const char*) const;
template
void
basic_string<wchar_t>::_Rep::_M_set_length_and_sharable(size_t);
template
basic_istream<wchar_t>&
basic_istream<wchar_t>::ignore();
template
bool
basic_fstream<wchar_t>::is_open() const;
template
bool
basic_ifstream<wchar_t>::is_open() const;
template
bool
basic_ofstream<wchar_t>::is_open() const;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
// The rename syntax for default exported names is
// asm (".symver name1,exportedname@GLIBCXX_3.4")
// asm (".symver name2,exportedname@@GLIBCXX_3.4.5")
// In the future, GLIBCXX_ABI > 6 should remove all uses of
// _GLIBCXX_*_SYMVER macros in this file.
#define _GLIBCXX_3_4_SYMVER(XXname, name) \
extern "C" void \
_X##name() \
__attribute__ ((alias(#XXname))); \
asm (".symver " "_X" #name "," #name "@GLIBCXX_3.4");
#define _GLIBCXX_3_4_5_SYMVER(XXname, name) \
extern "C" void \
_Y##name() \
__attribute__ ((alias(#XXname))); \
asm (".symver " "_Y" #name "," #name "@@GLIBCXX_3.4.5");
#define _GLIBCXX_ASM_SYMVER(cur, old, version) \
asm (".symver " #cur "," #old "@@" #version);
#define _GLIBCXX_APPLY_SYMVER _GLIBCXX_3_4_SYMVER
#include <bits/compatibility.h>
#undef _GLIBCXX_APPLY_SYMVER
#define _GLIBCXX_APPLY_SYMVER _GLIBCXX_3_4_5_SYMVER
#include <bits/compatibility.h>
#undef _GLIBCXX_APPLY_SYMVER
/* gcc-3.4.0
_ZN10__gnu_norm15_List_node_base4hookEPS0_;
_ZN10__gnu_norm15_List_node_base4swapERS0_S1_;
_ZN10__gnu_norm15_List_node_base6unhookEv;
_ZN10__gnu_norm15_List_node_base7reverseEv;
_ZN10__gnu_norm15_List_node_base8transferEPS0_S1_;
*/
#include "list.cc"
_GLIBCXX_ASM_SYMVER(_ZNSt8__detail17_List_node_baseXX7_M_hookEPS0_, \
_ZN10__gnu_norm15_List_node_base4hookEPS0_, \
GLIBCXX_3.4)
_GLIBCXX_ASM_SYMVER(_ZNSt8__detail17_List_node_baseXX4swapERS0_S1_, \
_ZN10__gnu_norm15_List_node_base4swapERS0_S1_, \
GLIBCXX_3.4)
_GLIBCXX_ASM_SYMVER(_ZNSt8__detail17_List_node_baseXX9_M_unhookEv, \
_ZN10__gnu_norm15_List_node_base6unhookEv, \
GLIBCXX_3.4)
_GLIBCXX_ASM_SYMVER(_ZNSt8__detail17_List_node_baseXX10_M_reverseEv, \
_ZN10__gnu_norm15_List_node_base7reverseEv, \
GLIBCXX_3.4)
_GLIBCXX_ASM_SYMVER(_ZNSt8__detail17_List_node_baseXX11_M_transferEPS0_S1_, \
_ZN10__gnu_norm15_List_node_base8transferEPS0_S1_, \
GLIBCXX_3.4)
#undef _List_node_base
// gcc-4.1.0
// Long double versions of "C" math functions.
#if defined (_GLIBCXX_LONG_DOUBLE_COMPAT) \
|| (defined (__arm__) && defined (__linux__) && defined (__ARM_EABI__)) \
|| (defined (__hppa__) && defined (__linux__)) \
|| (defined (__m68k__) && defined (__mcoldfire__) && defined (__linux__)) \
|| (defined (__mips__) && defined (_ABIO32) && defined (__linux__)) \
|| (defined (__sh__) && defined (__linux__) && __SIZEOF_SIZE_T__ == 4) \
#define _GLIBCXX_MATHL_WRAPPER(name, argdecl, args, ver) \
extern "C" double \
__ ## name ## l_wrapper argdecl \
{ \
return name args; \
} \
asm (".symver __" #name "l_wrapper, " #name "l@" #ver)
#define _GLIBCXX_MATHL_WRAPPER1(name, ver) \
_GLIBCXX_MATHL_WRAPPER (name, (double x), (x), ver)
#define _GLIBCXX_MATHL_WRAPPER2(name, ver) \
_GLIBCXX_MATHL_WRAPPER (name, (double x, double y), (x, y), ver)
#ifdef _GLIBCXX_HAVE_ACOSL
_GLIBCXX_MATHL_WRAPPER1 (acos, GLIBCXX_3.4.3);
#endif
#ifdef _GLIBCXX_HAVE_ASINL
_GLIBCXX_MATHL_WRAPPER1 (asin, GLIBCXX_3.4.3);
#endif
#ifdef _GLIBCXX_HAVE_ATAN2L
_GLIBCXX_MATHL_WRAPPER2 (atan2, GLIBCXX_3.4);
#endif
#ifdef _GLIBCXX_HAVE_ATANL
_GLIBCXX_MATHL_WRAPPER1 (atan, GLIBCXX_3.4.3);
#endif
#ifdef _GLIBCXX_HAVE_CEILL
_GLIBCXX_MATHL_WRAPPER1 (ceil, GLIBCXX_3.4.3);
#endif
#ifdef _GLIBCXX_HAVE_COSHL
_GLIBCXX_MATHL_WRAPPER1 (cosh, GLIBCXX_3.4);
#endif
#ifdef _GLIBCXX_HAVE_COSL
_GLIBCXX_MATHL_WRAPPER1 (cos, GLIBCXX_3.4);
#endif
#ifdef _GLIBCXX_HAVE_EXPL
_GLIBCXX_MATHL_WRAPPER1 (exp, GLIBCXX_3.4);
#endif
#ifdef _GLIBCXX_HAVE_FLOORL
_GLIBCXX_MATHL_WRAPPER1 (floor, GLIBCXX_3.4.3);
#endif
#ifdef _GLIBCXX_HAVE_FMODL
_GLIBCXX_MATHL_WRAPPER2 (fmod, GLIBCXX_3.4.3);
#endif
#ifdef _GLIBCXX_HAVE_FREXPL
_GLIBCXX_MATHL_WRAPPER (frexp, (double x, int *y), (x, y), GLIBCXX_3.4.3);
#endif
#ifdef _GLIBCXX_HAVE_HYPOTL
_GLIBCXX_MATHL_WRAPPER2 (hypot, GLIBCXX_3.4);
#endif
#ifdef _GLIBCXX_HAVE_LDEXPL
_GLIBCXX_MATHL_WRAPPER (ldexp, (double x, int y), (x, y), GLIBCXX_3.4.3);
#endif
#ifdef _GLIBCXX_HAVE_LOG10L
_GLIBCXX_MATHL_WRAPPER1 (log10, GLIBCXX_3.4);
#endif
#ifdef _GLIBCXX_HAVE_LOGL
_GLIBCXX_MATHL_WRAPPER1 (log, GLIBCXX_3.4);
#endif
#ifdef _GLIBCXX_HAVE_MODFL
_GLIBCXX_MATHL_WRAPPER (modf, (double x, double *y), (x, y), GLIBCXX_3.4.3);
#endif
#ifdef _GLIBCXX_HAVE_POWL
_GLIBCXX_MATHL_WRAPPER2 (pow, GLIBCXX_3.4);
#endif
#ifdef _GLIBCXX_HAVE_SINHL
_GLIBCXX_MATHL_WRAPPER1 (sinh, GLIBCXX_3.4);
#endif
#ifdef _GLIBCXX_HAVE_SINL
_GLIBCXX_MATHL_WRAPPER1 (sin, GLIBCXX_3.4);
#endif
#ifdef _GLIBCXX_HAVE_SQRTL
_GLIBCXX_MATHL_WRAPPER1 (sqrt, GLIBCXX_3.4);
#endif
#ifdef _GLIBCXX_HAVE_TANHL
_GLIBCXX_MATHL_WRAPPER1 (tanh, GLIBCXX_3.4);
#endif
#ifdef _GLIBCXX_HAVE_TANL
_GLIBCXX_MATHL_WRAPPER1 (tan, GLIBCXX_3.4);
#endif
#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
#endif
#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
extern void *_ZTVN10__cxxabiv123__fundamental_type_infoE[];
extern void *_ZTVN10__cxxabiv119__pointer_type_infoE[];
extern __attribute__((used, weak)) const char _ZTSe[2] = "e";
extern __attribute__((used, weak)) const char _ZTSPe[3] = "Pe";
extern __attribute__((used, weak)) const char _ZTSPKe[4] = "PKe";
extern __attribute__((used, weak)) const void * const _ZTIe[2]
= { reinterpret_cast<const void *>
(&_ZTVN10__cxxabiv123__fundamental_type_infoE[2]),
reinterpret_cast<const void *>(_ZTSe) };
extern __attribute__((used, weak)) const void * const _ZTIPe[4]
= { reinterpret_cast<const void *>
(&_ZTVN10__cxxabiv119__pointer_type_infoE[2]),
reinterpret_cast<const void *>(_ZTSPe),
reinterpret_cast<const void *>(0L),
reinterpret_cast<const void *>(_ZTIe) };
extern __attribute__((used, weak)) const void * const _ZTIPKe[4]
= { reinterpret_cast<const void *>
(&_ZTVN10__cxxabiv119__pointer_type_infoE[2]),
reinterpret_cast<const void *>(_ZTSPKe),
reinterpret_cast<const void *>(1L),
reinterpret_cast<const void *>(_ZTIe) };
#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
#ifdef _GLIBCXX_SYMVER_DARWIN
#if (defined(__ppc__) || defined(__ppc64__)) && defined(_GLIBCXX_SHARED)
/* __eprintf shouldn't have been made visible from libstdc++, or
anywhere, but on Mac OS X 10.4 it was defined in
libstdc++.6.0.3.dylib; so on that platform we have to keep defining
it to keep binary compatibility. We can't just put the libgcc
version in the export list, because that doesn't work; once a
symbol is marked as hidden, it stays that way. */
#include <cstdio>
#include <cstdlib>
using namespace std;
extern "C" void
__eprintf(const char *string, const char *expression,
unsigned int line, const char *filename)
{
fprintf(stderr, string, expression, line, filename);
fflush(stderr);
abort();
}
#endif
#endif

View File

@@ -0,0 +1,113 @@
// The template and inlines for the -*- C++ -*- complex number classes.
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <complex>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template
basic_istream<char, char_traits<char> >&
operator>>(basic_istream<char, char_traits<char> >&, complex<float>&);
template
basic_ostream<char, char_traits<char> >&
operator<<(basic_ostream<char, char_traits<char> >&,
const complex<float>&);
template
basic_istream<char, char_traits<char> >&
operator>>(basic_istream<char, char_traits<char> >&, complex<double>&);
template
basic_ostream<char, char_traits<char> >&
operator<<(basic_ostream<char, char_traits<char> >&,
const complex<double>&);
template
basic_istream<char, char_traits<char> >&
operator>>(basic_istream<char, char_traits<char> >&,
complex<long double>&);
template
basic_ostream<char, char_traits<char> >&
operator<<(basic_ostream<char, char_traits<char> >&,
const complex<long double>&);
#ifdef _GLIBCXX_USE_WCHAR_T
template
basic_istream<wchar_t, char_traits<wchar_t> >&
operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&,
complex<float>&);
template
basic_ostream<wchar_t, char_traits<wchar_t> >&
operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&,
const complex<float>&);
template
basic_istream<wchar_t, char_traits<wchar_t> >&
operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&,
complex<double>&);
template
basic_ostream<wchar_t, char_traits<wchar_t> >&
operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&,
const complex<double>&);
template
basic_istream<wchar_t, char_traits<wchar_t> >&
operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&,
complex<long double>&);
template
basic_ostream<wchar_t, char_traits<wchar_t> >&
operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&,
const complex<long double>&);
#endif //_GLIBCXX_USE_WCHAR_T
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
// XXX GLIBCXX_ABI Deprecated
#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
extern "C" void ldbl (void) __attribute__ ((alias (#dbl), weak))
_GLIBCXX_LDBL_COMPAT (_ZStlsIdcSt11char_traitsIcEERSt13basic_ostreamIT0_T1_ES6_RKSt7complexIT_E,
_ZStlsIecSt11char_traitsIcEERSt13basic_ostreamIT0_T1_ES6_RKSt7complexIT_E);
#ifdef _GLIBCXX_USE_WCHAR_T
_GLIBCXX_LDBL_COMPAT (_ZStlsIdwSt11char_traitsIwEERSt13basic_ostreamIT0_T1_ES6_RKSt7complexIT_E,
_ZStlsIewSt11char_traitsIwEERSt13basic_ostreamIT0_T1_ES6_RKSt7complexIT_E);
#endif
_GLIBCXX_LDBL_COMPAT (_ZStrsIdcSt11char_traitsIcEERSt13basic_istreamIT0_T1_ES6_RSt7complexIT_E,
_ZStrsIecSt11char_traitsIcEERSt13basic_istreamIT0_T1_ES6_RSt7complexIT_E);
#ifdef _GLIBCXX_USE_WCHAR_T
_GLIBCXX_LDBL_COMPAT (_ZStrsIdwSt11char_traitsIwEERSt13basic_istreamIT0_T1_ES6_RSt7complexIT_E,
_ZStrsIewSt11char_traitsIwEERSt13basic_istreamIT0_T1_ES6_RSt7complexIT_E);
#endif
#endif // _GLIBCXX_LONG_DOUBLE_COMPAT

View File

@@ -0,0 +1,111 @@
// Concept checking instantiations -*- C++ -*-
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// The implementation of some of the more complex checks uses the simple
// checks (good reuse of code), thereby requiring that the simple checks
// be instantiated somewhere. The simple checks use other simple checks,
// and so on, until a couple hundred symbols all need instantiations. We
// explicitly instantiate the initial set of symbols; compiling this file
// with -fimplicit-templates will take care of the rest for us.
#include <bits/concept_check.h>
#ifdef _GLIBCXX_CONCEPT_CHECKS
#include <memory>
#include <iterator>
#include <ostream>
#define _Instantiate(...) template void __function_requires< __VA_ARGS__ > ()
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template void __aux_require_boolean_expr<bool>(bool const&);
_Instantiate(_ConvertibleConcept<unsigned, unsigned> );
_Instantiate(_InputIteratorConcept<char*> );
_Instantiate(_InputIteratorConcept<char const*> );
#ifdef _GLIBCXX_USE_WCHAR_T
_Instantiate(_InputIteratorConcept<wchar_t*> );
_Instantiate(_InputIteratorConcept<wchar_t const*> );
_Instantiate(_LessThanComparableConcept<wchar_t*> );
#endif
_Instantiate(_LessThanComparableConcept<char*> );
_Instantiate(_LessThanComparableConcept<int> );
_Instantiate(_LessThanComparableConcept<long> );
_Instantiate(_LessThanComparableConcept<long long> );
_Instantiate(_LessThanComparableConcept<unsigned> );
_Instantiate(_OutputIteratorConcept<std::ostreambuf_iterator<
char, std::char_traits<char> >, char> );
#ifdef _GLIBCXX_USE_WCHAR_T
_Instantiate(_OutputIteratorConcept<std::ostreambuf_iterator<
wchar_t, std::char_traits<wchar_t> >, wchar_t> );
#endif
_Instantiate(_RandomAccessIteratorConcept<char*> );
_Instantiate(_RandomAccessIteratorConcept<char const*> );
_Instantiate(_RandomAccessIteratorConcept<
__normal_iterator<char const*, std::string> > );
_Instantiate(_RandomAccessIteratorConcept<
__normal_iterator<char*, std::string> > );
#ifdef _GLIBCXX_USE_WCHAR_T
_Instantiate(_RandomAccessIteratorConcept<
__normal_iterator<wchar_t const*,
std::basic_string<wchar_t, std::char_traits<wchar_t>,
std::allocator<wchar_t> > > > );
_Instantiate(_RandomAccessIteratorConcept<
__normal_iterator<wchar_t*,
std::basic_string<wchar_t, std::char_traits<wchar_t>,
std::allocator<wchar_t> > > > );
_Instantiate(_RandomAccessIteratorConcept<wchar_t*> );
_Instantiate(_RandomAccessIteratorConcept<wchar_t const*> );
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#undef _Instantiate
#endif

View File

@@ -0,0 +1,132 @@
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <locale>
#include <cstdlib>
#include <cstring>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Definitions for static const data members of ctype_base.
const ctype_base::mask ctype_base::space;
const ctype_base::mask ctype_base::print;
const ctype_base::mask ctype_base::cntrl;
const ctype_base::mask ctype_base::upper;
const ctype_base::mask ctype_base::lower;
const ctype_base::mask ctype_base::alpha;
const ctype_base::mask ctype_base::digit;
const ctype_base::mask ctype_base::punct;
const ctype_base::mask ctype_base::xdigit;
const ctype_base::mask ctype_base::alnum;
const ctype_base::mask ctype_base::graph;
// Definitions for locale::id of standard facets that are specialized.
locale::id ctype<char>::id;
#ifdef _GLIBCXX_USE_WCHAR_T
locale::id ctype<wchar_t>::id;
#endif
const size_t ctype<char>::table_size;
ctype<char>::~ctype()
{
_S_destroy_c_locale(_M_c_locale_ctype);
if (_M_del)
delete[] this->table();
}
// Fill in the narrowing cache and flag whether all values are
// valid or not. _M_narrow_ok is set to 2 if memcpy can't
// be used.
void
ctype<char>::
_M_narrow_init() const
{
char __tmp[sizeof(_M_narrow)];
for (size_t __i = 0; __i < sizeof(_M_narrow); ++__i)
__tmp[__i] = __i;
do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow);
_M_narrow_ok = 1;
if (__builtin_memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
_M_narrow_ok = 2;
else
{
// Deal with the special case of zero: renarrow with a
// different default and compare.
char __c;
do_narrow(__tmp, __tmp + 1, 1, &__c);
if (__c == 1)
_M_narrow_ok = 2;
}
}
void
ctype<char>::
_M_widen_init() const
{
char __tmp[sizeof(_M_widen)];
for (size_t __i = 0; __i < sizeof(_M_widen); ++__i)
__tmp[__i] = __i;
do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen);
_M_widen_ok = 1;
// Set _M_widen_ok to 2 if memcpy can't be used.
if (__builtin_memcmp(__tmp, _M_widen, sizeof(_M_widen)))
_M_widen_ok = 2;
}
#ifdef _GLIBCXX_USE_WCHAR_T
ctype<wchar_t>::ctype(size_t __refs)
: __ctype_abstract_base<wchar_t>(__refs),
_M_c_locale_ctype(_S_get_c_locale()), _M_narrow_ok(false)
{ _M_initialize_ctype(); }
ctype<wchar_t>::ctype(__c_locale __cloc, size_t __refs)
: __ctype_abstract_base<wchar_t>(__refs),
_M_c_locale_ctype(_S_clone_c_locale(__cloc)), _M_narrow_ok(false)
{ _M_initialize_ctype(); }
ctype<wchar_t>::~ctype()
{ _S_destroy_c_locale(_M_c_locale_ctype); }
ctype_byname<wchar_t>::ctype_byname(const char* __s, size_t __refs)
: ctype<wchar_t>(__refs)
{
if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_ctype);
this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
this->_M_initialize_ctype();
}
}
ctype_byname<wchar_t>::~ctype_byname()
{ }
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,243 @@
// Locale support -*- C++ -*-
// Copyright (C) 2011-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file ctype_configure_char.cc */
//
// ISO C++ 14882: 22.1 Locales
//
#include <locale>
#include <cstdlib>
#include <cstring>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// The classic table used in libstdc++ is *not* the C _ctype table
// used by mscvrt, but is based on the ctype masks defined for libstdc++
// in ctype_base.h.
const ctype_base::mask*
ctype<char>::classic_table() throw()
{
static const ctype_base::mask _S_classic_table[256] =
{
cntrl /* null */,
cntrl /* ^A */,
cntrl /* ^B */,
cntrl /* ^C */,
cntrl /* ^D */,
cntrl /* ^E */,
cntrl /* ^F */,
cntrl /* ^G */,
cntrl /* ^H */,
ctype_base::mask(space | cntrl) /* tab */,
ctype_base::mask(space | cntrl) /* LF */,
ctype_base::mask(space | cntrl) /* ^K */,
ctype_base::mask(space | cntrl) /* FF */,
ctype_base::mask(space | cntrl) /* ^M */,
cntrl /* ^N */,
cntrl /* ^O */,
cntrl /* ^P */,
cntrl /* ^Q */,
cntrl /* ^R */,
cntrl /* ^S */,
cntrl /* ^T */,
cntrl /* ^U */,
cntrl /* ^V */,
cntrl /* ^W */,
cntrl /* ^X */,
cntrl /* ^Y */,
cntrl /* ^Z */,
cntrl /* esc */,
cntrl /* ^\ */,
cntrl /* ^] */,
cntrl /* ^^ */,
cntrl /* ^_ */,
ctype_base::mask(space | print) /* */,
ctype_base::mask(punct | print) /* ! */,
ctype_base::mask(punct | print) /* " */,
ctype_base::mask(punct | print) /* # */,
ctype_base::mask(punct | print) /* $ */,
ctype_base::mask(punct | print) /* % */,
ctype_base::mask(punct | print) /* & */,
ctype_base::mask(punct | print) /* ' */,
ctype_base::mask(punct | print) /* ( */,
ctype_base::mask(punct | print) /* ) */,
ctype_base::mask(punct | print) /* * */,
ctype_base::mask(punct | print) /* + */,
ctype_base::mask(punct | print) /* , */,
ctype_base::mask(punct | print) /* - */,
ctype_base::mask(punct | print) /* . */,
ctype_base::mask(punct | print) /* / */,
ctype_base::mask(digit | xdigit | print) /* 0 */,
ctype_base::mask(digit | xdigit | print) /* 1 */,
ctype_base::mask(digit | xdigit | print) /* 2 */,
ctype_base::mask(digit | xdigit | print) /* 3 */,
ctype_base::mask(digit | xdigit | print) /* 4 */,
ctype_base::mask(digit | xdigit | print) /* 5 */,
ctype_base::mask(digit | xdigit | print) /* 6 */,
ctype_base::mask(digit | xdigit | print) /* 7 */,
ctype_base::mask(digit | xdigit | print) /* 8 */,
ctype_base::mask(digit | xdigit | print) /* 9 */,
ctype_base::mask(punct | print) /* : */,
ctype_base::mask(punct | print) /* ; */,
ctype_base::mask(punct | print) /* < */,
ctype_base::mask(punct | print) /* = */,
ctype_base::mask(punct | print) /* > */,
ctype_base::mask(punct | print) /* ? */,
ctype_base::mask(punct | print) /* ! */,
ctype_base::mask(alpha | upper | xdigit | print) /* A */,
ctype_base::mask(alpha | upper | xdigit | print) /* B */,
ctype_base::mask(alpha | upper | xdigit | print) /* C */,
ctype_base::mask(alpha | upper | xdigit | print) /* D */,
ctype_base::mask(alpha | upper | xdigit | print) /* E */,
ctype_base::mask(alpha | upper | xdigit | print) /* F */,
ctype_base::mask(alpha | upper | print) /* G */,
ctype_base::mask(alpha | upper | print) /* H */,
ctype_base::mask(alpha | upper | print) /* I */,
ctype_base::mask(alpha | upper | print) /* J */,
ctype_base::mask(alpha | upper | print) /* K */,
ctype_base::mask(alpha | upper | print) /* L */,
ctype_base::mask(alpha | upper | print) /* M */,
ctype_base::mask(alpha | upper | print) /* N */,
ctype_base::mask(alpha | upper | print) /* O */,
ctype_base::mask(alpha | upper | print) /* P */,
ctype_base::mask(alpha | upper | print) /* Q */,
ctype_base::mask(alpha | upper | print) /* R */,
ctype_base::mask(alpha | upper | print) /* S */,
ctype_base::mask(alpha | upper | print) /* T */,
ctype_base::mask(alpha | upper | print) /* U */,
ctype_base::mask(alpha | upper | print) /* V */,
ctype_base::mask(alpha | upper | print) /* W */,
ctype_base::mask(alpha | upper | print) /* X */,
ctype_base::mask(alpha | upper | print) /* Y */,
ctype_base::mask(alpha | upper | print) /* Z */,
ctype_base::mask(punct | print) /* [ */,
ctype_base::mask(punct | print) /* \ */,
ctype_base::mask(punct | print) /* ] */,
ctype_base::mask(punct | print) /* ^ */,
ctype_base::mask(punct | print) /* _ */,
ctype_base::mask(punct | print) /* ` */,
ctype_base::mask(alpha | lower | xdigit | print) /* a */,
ctype_base::mask(alpha | lower | xdigit | print) /* b */,
ctype_base::mask(alpha | lower | xdigit | print) /* c */,
ctype_base::mask(alpha | lower | xdigit | print) /* d */,
ctype_base::mask(alpha | lower | xdigit | print) /* e */,
ctype_base::mask(alpha | lower | xdigit | print) /* f */,
ctype_base::mask(alpha | lower | print) /* g */,
ctype_base::mask(alpha | lower | print) /* h */,
ctype_base::mask(alpha | lower | print) /* i */,
ctype_base::mask(alpha | lower | print) /* j */,
ctype_base::mask(alpha | lower | print) /* k */,
ctype_base::mask(alpha | lower | print) /* l */,
ctype_base::mask(alpha | lower | print) /* m */,
ctype_base::mask(alpha | lower | print) /* n */,
ctype_base::mask(alpha | lower | print) /* o */,
ctype_base::mask(alpha | lower | print) /* p */,
ctype_base::mask(alpha | lower | print) /* q */,
ctype_base::mask(alpha | lower | print) /* r */,
ctype_base::mask(alpha | lower | print) /* s */,
ctype_base::mask(alpha | lower | print) /* t */,
ctype_base::mask(alpha | lower | print) /* u */,
ctype_base::mask(alpha | lower | print) /* v */,
ctype_base::mask(alpha | lower | print) /* w */,
ctype_base::mask(alpha | lower | print) /* x */,
ctype_base::mask(alpha | lower | print) /* y */,
ctype_base::mask(alpha | lower | print) /* x */,
ctype_base::mask(punct | print) /* { */,
ctype_base::mask(punct | print) /* | */,
ctype_base::mask(punct | print) /* } */,
ctype_base::mask(punct | print) /* ~ */,
cntrl /* del (0x7f)*/,
/* The next 128 entries are all 0. */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
return _S_classic_table;
}
ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
: facet(__refs), _M_del(__table != 0 && __del),
_M_toupper(NULL), _M_tolower(NULL),
_M_table(__table ? __table : classic_table())
{
memset(_M_widen, 0, sizeof(_M_widen));
_M_widen_ok = 0;
memset(_M_narrow, 0, sizeof(_M_narrow));
_M_narrow_ok = 0;
}
ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
: facet(__refs), _M_del(__table != 0 && __del),
_M_toupper(NULL), _M_tolower(NULL),
_M_table(__table ? __table : classic_table())
{
memset(_M_widen, 0, sizeof(_M_widen));
_M_widen_ok = 0;
memset(_M_narrow, 0, sizeof(_M_narrow));
_M_narrow_ok = 0;
}
char
ctype<char>::do_toupper(char __c) const
{ return (this->is(ctype_base::lower, __c) ? (__c - 'a' + 'A') : __c); }
const char*
ctype<char>::do_toupper(char* __low, const char* __high) const
{
while (__low < __high)
{
*__low = this->do_toupper(*__low);
++__low;
}
return __high;
}
char
ctype<char>::do_tolower(char __c) const
{ return (this->is(ctype_base::upper, __c) ? (__c - 'A' + 'a') : __c); }
const char*
ctype<char>::do_tolower(char* __low, const char* __high) const
{
while (__low < __high)
{
*__low = this->do_tolower(*__low);
++__low;
}
return __high;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,271 @@
// std::ctype implementation details, generic version -*- C++ -*-
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <cstdlib>
#include <cstring>
#include <cstdio>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// NB: The other ctype<char> specializations are in src/locale.cc and
// various /config/os/* files.
ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
: ctype<char>(0, false, __refs)
{
if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_ctype);
this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
}
}
ctype_byname<char>::~ctype_byname()
{ }
#ifdef _GLIBCXX_USE_WCHAR_T
ctype<wchar_t>::__wmask_type
ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const throw()
{
__wmask_type __ret;
switch (__m)
{
case space:
__ret = wctype("space");
break;
case print:
__ret = wctype("print");
break;
case cntrl:
__ret = wctype("cntrl");
break;
case upper:
__ret = wctype("upper");
break;
case lower:
__ret = wctype("lower");
break;
case alpha:
__ret = wctype("alpha");
break;
case digit:
__ret = wctype("digit");
break;
case punct:
__ret = wctype("punct");
break;
case xdigit:
__ret = wctype("xdigit");
break;
case alnum:
__ret = wctype("alnum");
break;
case graph:
__ret = wctype("graph");
break;
default:
__ret = __wmask_type();
}
return __ret;
};
wchar_t
ctype<wchar_t>::do_toupper(wchar_t __c) const
{ return towupper(__c); }
const wchar_t*
ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
{
while (__lo < __hi)
{
*__lo = towupper(*__lo);
++__lo;
}
return __hi;
}
wchar_t
ctype<wchar_t>::do_tolower(wchar_t __c) const
{ return towlower(__c); }
const wchar_t*
ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
{
while (__lo < __hi)
{
*__lo = towlower(*__lo);
++__lo;
}
return __hi;
}
bool
ctype<wchar_t>::
do_is(mask __m, char_type __c) const
{
bool __ret = false;
// Generically, 15 (instead of 10) since we don't know the numerical
// encoding of the various categories in /usr/include/ctype.h.
const size_t __bitmasksize = 15;
for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
if (__m & _M_bit[__bitcur]
&& iswctype(__c, _M_wmask[__bitcur]))
{
__ret = true;
break;
}
return __ret;
}
const wchar_t*
ctype<wchar_t>::
do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
{
for (;__lo < __hi; ++__vec, ++__lo)
{
// Generically, 15 (instead of 10) since we don't know the numerical
// encoding of the various categories in /usr/include/ctype.h.
const size_t __bitmasksize = 15;
mask __m = 0;
for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
if (iswctype(*__lo, _M_wmask[__bitcur]))
__m |= _M_bit[__bitcur];
*__vec = __m;
}
return __hi;
}
const wchar_t*
ctype<wchar_t>::
do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
{
while (__lo < __hi && !this->do_is(__m, *__lo))
++__lo;
return __lo;
}
const wchar_t*
ctype<wchar_t>::
do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
{
while (__lo < __hi && this->do_is(__m, *__lo) != 0)
++__lo;
return __lo;
}
wchar_t
ctype<wchar_t>::
do_widen(char __c) const
{ return _M_widen[static_cast<unsigned char>(__c)]; }
const char*
ctype<wchar_t>::
do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
{
while (__lo < __hi)
{
*__dest = _M_widen[static_cast<unsigned char>(*__lo)];
++__lo;
++__dest;
}
return __hi;
}
char
ctype<wchar_t>::
do_narrow(wchar_t __wc, char __dfault) const
{
if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
return _M_narrow[__wc];
const int __c = wctob(__wc);
return (__c == EOF ? __dfault : static_cast<char>(__c));
}
const wchar_t*
ctype<wchar_t>::
do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
char* __dest) const
{
if (_M_narrow_ok)
while (__lo < __hi)
{
if (*__lo >= 0 && *__lo < 128)
*__dest = _M_narrow[*__lo];
else
{
const int __c = wctob(*__lo);
*__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
}
++__lo;
++__dest;
}
else
while (__lo < __hi)
{
const int __c = wctob(*__lo);
*__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++__lo;
++__dest;
}
return __hi;
}
void
ctype<wchar_t>::_M_initialize_ctype() throw()
{
wint_t __i;
for (__i = 0; __i < 128; ++__i)
{
const int __c = wctob(__i);
if (__c == EOF)
break;
else
_M_narrow[__i] = static_cast<char>(__c);
}
if (__i == 128)
_M_narrow_ok = true;
else
_M_narrow_ok = false;
for (size_t __i = 0;
__i < sizeof(_M_widen) / sizeof(wint_t); ++__i)
_M_widen[__i] = btowc(__i);
for (size_t __i = 0; __i <= 15; ++__i)
{
_M_bit[__i] = static_cast<mask>(1 << __i);
_M_wmask[__i] = _M_convert_to_wmask(_M_bit[__i]);
}
}
#endif // _GLIBCXX_USE_WCHAR_T
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,66 @@
// Explicit instantiation file.
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:
//
#include <ext/rope>
#include <ext/stdio_filebuf.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace
{
const int min_len = __detail::_S_max_rope_depth + 1;
}
template
const unsigned long
rope<char, std::allocator<char> >::_S_min_len[min_len];
template
char
rope<char, std::allocator<char> >::
_S_fetch(_Rope_RopeRep<char, std::allocator<char> >*, size_type);
template class stdio_filebuf<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
template
const unsigned long
rope<wchar_t, std::allocator<wchar_t> >::_S_min_len[min_len];
template
wchar_t
rope<wchar_t, std::allocator<wchar_t> >::
_S_fetch(_Rope_RopeRep<wchar_t, std::allocator<wchar_t> >*, size_type);
template class stdio_filebuf<wchar_t>;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,107 @@
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include "bits/c++config.h"
#include <fstream>
#include <istream>
#include <ostream>
#include <ext/stdio_filebuf.h>
#include <ext/stdio_sync_filebuf.h>
// On AIX, and perhaps other systems, library initialization order is
// not guaranteed. For example, the static initializers for the main
// program might run before the static initializers for this library.
// That means that we cannot rely on static initialization in the
// library; there is no guarantee that things will get initialized in
// time. This file contains definitions of all global variables that
// require initialization as arrays of characters.
// NB: asm directives can rename these non-exported, namespace
// __gnu_cxx symbols into exported, namespace std symbols with the
// appropriate symbol version name.
// The rename syntax is
// asm (".symver currentname,oldname@@GLIBCXX_3.2")
// In macro form:
// _GLIBCXX_ASM_SYMVER(currentname, oldname, GLIBCXX_3.2)
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Standard stream objects.
// NB: Iff <iostream> is included, these definitions become wonky.
typedef char fake_istream[sizeof(istream)]
__attribute__ ((aligned(__alignof__(istream))));
typedef char fake_ostream[sizeof(ostream)]
__attribute__ ((aligned(__alignof__(ostream))));
fake_istream cin;
fake_ostream cout;
fake_ostream cerr;
fake_ostream clog;
#ifdef _GLIBCXX_USE_WCHAR_T
typedef char fake_wistream[sizeof(wistream)]
__attribute__ ((aligned(__alignof__(wistream))));
typedef char fake_wostream[sizeof(wostream)]
__attribute__ ((aligned(__alignof__(wostream))));
fake_wistream wcin;
fake_wostream wcout;
fake_wostream wcerr;
fake_wostream wclog;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace __gnu_internal _GLIBCXX_VISIBILITY(hidden)
{
using namespace std;
using namespace __gnu_cxx;
// We use different stream buffer types depending on whether
// ios_base::sync_with_stdio(false) has been called.
typedef char fake_stdiobuf[sizeof(stdio_sync_filebuf<char>)]
__attribute__ ((aligned(__alignof__(stdio_sync_filebuf<char>))));
fake_stdiobuf buf_cout_sync;
fake_stdiobuf buf_cin_sync;
fake_stdiobuf buf_cerr_sync;
typedef char fake_filebuf[sizeof(stdio_filebuf<char>)]
__attribute__ ((aligned(__alignof__(stdio_filebuf<char>))));
fake_filebuf buf_cout;
fake_filebuf buf_cin;
fake_filebuf buf_cerr;
#ifdef _GLIBCXX_USE_WCHAR_T
typedef char fake_wstdiobuf[sizeof(stdio_sync_filebuf<wchar_t>)]
__attribute__ ((aligned(__alignof__(stdio_sync_filebuf<wchar_t>))));
fake_wstdiobuf buf_wcout_sync;
fake_wstdiobuf buf_wcin_sync;
fake_wstdiobuf buf_wcerr_sync;
typedef char fake_wfilebuf[sizeof(stdio_filebuf<wchar_t>)]
__attribute__ ((aligned(__alignof__(stdio_filebuf<wchar_t>))));
fake_wfilebuf buf_wcout;
fake_wfilebuf buf_wcin;
fake_wfilebuf buf_wcerr;
#endif
} // namespace __gnu_internal

View File

@@ -0,0 +1,56 @@
// std::tr1::hash definitions, long double bits -*- C++ -*-
// Copyright (C) 2010-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace tr1
{
// For long double, careful with random padding bits (e.g., on x86,
// 10 bytes -> 12 bytes) and resort to frexp.
template<>
size_t
hash<long double>::operator()(long double __val) const
{
// 0 and -0 both hash to zero.
if (__val == 0.0L)
return 0;
int __exponent;
__val = __builtin_frexpl(__val, &__exponent);
__val = __val < 0.0l ? -(__val + 0.5l) : __val;
const long double __mult = __SIZE_MAX__ + 1.0l;
__val *= __mult;
// Try to use all the bits of the mantissa (really necessary only
// on 32-bit targets, at least for 80-bit floating point formats).
const size_t __hibits = (size_t)__val;
__val = (__val - (long double)__hibits) * __mult;
const size_t __coeff = __SIZE_MAX__ / __LDBL_MAX_EXP__;
return __hibits + (size_t)__val + __coeff * __exponent;
}
}
}

View File

@@ -0,0 +1,58 @@
// std::tr1::hash definitions -*- C++ -*-
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <string>
#include <tr1/functional>
#include "hash-long-double-tr1-aux.cc"
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace tr1
{
#ifndef _GLIBCXX_LONG_DOUBLE_COMPAT_IMPL
template<>
size_t
hash<string>::operator()(string __s) const
{ return _Fnv_hash::hash(__s.data(), __s.length()); }
template<>
size_t
hash<const string&>::operator()(const string& __s) const
{ return _Fnv_hash::hash(__s.data(), __s.length()); }
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
size_t
hash<wstring>::operator()(wstring __s) const
{ return _Fnv_hash::hash(__s.data(), __s.length() * sizeof(wchar_t)); }
template<>
size_t
hash<const wstring&>::operator()(const wstring& __s) const
{ return _Fnv_hash::hash(__s.data(), __s.length() * sizeof(wchar_t)); }
#endif
#endif
}
}

View File

@@ -0,0 +1,33 @@
// std::__detail definitions -*- C++ -*-
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <bits/c++config.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace tr1
{
#include "../shared/hashtable-aux.cc"
}
}

View File

@@ -0,0 +1,42 @@
// Explicit instantiation file.
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:
//
#include <ios>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template class basic_ios<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
template class basic_ios<wchar_t>;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,191 @@
// Iostreams base classes -*- C++ -*-
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 27.4 Iostreams base classes
//
#include <ios>
#include <limits>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Definitions for static const members of ios_base.
const ios_base::fmtflags ios_base::boolalpha;
const ios_base::fmtflags ios_base::dec;
const ios_base::fmtflags ios_base::fixed;
const ios_base::fmtflags ios_base::hex;
const ios_base::fmtflags ios_base::internal;
const ios_base::fmtflags ios_base::left;
const ios_base::fmtflags ios_base::oct;
const ios_base::fmtflags ios_base::right;
const ios_base::fmtflags ios_base::scientific;
const ios_base::fmtflags ios_base::showbase;
const ios_base::fmtflags ios_base::showpoint;
const ios_base::fmtflags ios_base::showpos;
const ios_base::fmtflags ios_base::skipws;
const ios_base::fmtflags ios_base::unitbuf;
const ios_base::fmtflags ios_base::uppercase;
const ios_base::fmtflags ios_base::adjustfield;
const ios_base::fmtflags ios_base::basefield;
const ios_base::fmtflags ios_base::floatfield;
const ios_base::iostate ios_base::badbit;
const ios_base::iostate ios_base::eofbit;
const ios_base::iostate ios_base::failbit;
const ios_base::iostate ios_base::goodbit;
const ios_base::openmode ios_base::app;
const ios_base::openmode ios_base::ate;
const ios_base::openmode ios_base::binary;
const ios_base::openmode ios_base::in;
const ios_base::openmode ios_base::out;
const ios_base::openmode ios_base::trunc;
const ios_base::seekdir ios_base::beg;
const ios_base::seekdir ios_base::cur;
const ios_base::seekdir ios_base::end;
_Atomic_word ios_base::Init::_S_refcount;
bool ios_base::Init::_S_synced_with_stdio = true;
ios_base::ios_base() throw()
: _M_precision(), _M_width(), _M_flags(), _M_exception(),
_M_streambuf_state(), _M_callbacks(0), _M_word_zero(),
_M_word_size(_S_local_word_size), _M_word(_M_local_word), _M_ios_locale()
{
// Do nothing: basic_ios::init() does it.
// NB: _M_callbacks and _M_word must be zero for non-initialized
// ios_base to go through ~ios_base gracefully.
}
// 27.4.2.7 ios_base constructors/destructors
ios_base::~ios_base()
{
_M_call_callbacks(erase_event);
_M_dispose_callbacks();
if (_M_word != _M_local_word)
{
delete [] _M_word;
_M_word = 0;
}
}
// 27.4.2.5 ios_base storage functions
int
ios_base::xalloc() throw()
{
// Implementation note: Initialize top to zero to ensure that
// initialization occurs before main() is started.
static _Atomic_word _S_top = 0;
return __gnu_cxx::__exchange_and_add_dispatch(&_S_top, 1) + 4;
}
void
ios_base::register_callback(event_callback __fn, int __index)
{ _M_callbacks = new _Callback_list(__fn, __index, _M_callbacks); }
// 27.4.2.5 iword/pword storage
ios_base::_Words&
ios_base::_M_grow_words(int __ix, bool __iword)
{
// Precondition: _M_word_size <= __ix
int __newsize = _S_local_word_size;
_Words* __words = _M_local_word;
if (__ix > _S_local_word_size - 1)
{
if (__ix < numeric_limits<int>::max())
{
__newsize = __ix + 1;
__try
{ __words = new _Words[__newsize]; }
__catch(const std::bad_alloc&)
{
_M_streambuf_state |= badbit;
if (_M_streambuf_state & _M_exception)
__throw_ios_failure(__N("ios_base::_M_grow_words "
"allocation failed"));
if (__iword)
_M_word_zero._M_iword = 0;
else
_M_word_zero._M_pword = 0;
return _M_word_zero;
}
for (int __i = 0; __i < _M_word_size; __i++)
__words[__i] = _M_word[__i];
if (_M_word && _M_word != _M_local_word)
{
delete [] _M_word;
_M_word = 0;
}
}
else
{
_M_streambuf_state |= badbit;
if (_M_streambuf_state & _M_exception)
__throw_ios_failure(__N("ios_base::_M_grow_words is not valid"));
if (__iword)
_M_word_zero._M_iword = 0;
else
_M_word_zero._M_pword = 0;
return _M_word_zero;
}
}
_M_word = __words;
_M_word_size = __newsize;
return _M_word[__ix];
}
void
ios_base::_M_call_callbacks(event __e) throw()
{
_Callback_list* __p = _M_callbacks;
while (__p)
{
__try
{ (*__p->_M_fn) (__e, *this, __p->_M_index); }
__catch(...)
{ }
__p = __p->_M_next;
}
}
void
ios_base::_M_dispose_callbacks(void) throw()
{
_Callback_list* __p = _M_callbacks;
while (__p && __p->_M_remove_reference() == 0)
{
_Callback_list* __next = __p->_M_next;
delete __p;
__p = __next;
}
_M_callbacks = 0;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,46 @@
// Iostreams base classes -*- C++ -*-
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 27.4.2.1.1 Class ios_base::failure
//
#include <ios>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
ios_base::failure::failure(const string& __str) throw()
: _M_msg(__str) { }
ios_base::failure::~failure() throw()
{ }
const char*
ios_base::failure::what() const throw()
{ return _M_msg.c_str(); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,203 @@
// Iostreams base classes -*- C++ -*-
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 27.4 Iostreams base classes
//
#include <ios>
#include <ostream>
#include <istream>
#include <fstream>
#include <ext/stdio_filebuf.h>
#include <ext/stdio_sync_filebuf.h>
namespace __gnu_internal _GLIBCXX_VISIBILITY(hidden)
{
using namespace __gnu_cxx;
// Extern declarations for global objects in src/globals.cc.
extern stdio_sync_filebuf<char> buf_cout_sync;
extern stdio_sync_filebuf<char> buf_cin_sync;
extern stdio_sync_filebuf<char> buf_cerr_sync;
extern stdio_filebuf<char> buf_cout;
extern stdio_filebuf<char> buf_cin;
extern stdio_filebuf<char> buf_cerr;
#ifdef _GLIBCXX_USE_WCHAR_T
extern stdio_sync_filebuf<wchar_t> buf_wcout_sync;
extern stdio_sync_filebuf<wchar_t> buf_wcin_sync;
extern stdio_sync_filebuf<wchar_t> buf_wcerr_sync;
extern stdio_filebuf<wchar_t> buf_wcout;
extern stdio_filebuf<wchar_t> buf_wcin;
extern stdio_filebuf<wchar_t> buf_wcerr;
#endif
} // namespace __gnu_internal
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using namespace __gnu_internal;
extern istream cin;
extern ostream cout;
extern ostream cerr;
extern ostream clog;
#ifdef _GLIBCXX_USE_WCHAR_T
extern wistream wcin;
extern wostream wcout;
extern wostream wcerr;
extern wostream wclog;
#endif
ios_base::Init::Init()
{
if (__gnu_cxx::__exchange_and_add_dispatch(&_S_refcount, 1) == 0)
{
// Standard streams default to synced with "C" operations.
_S_synced_with_stdio = true;
new (&buf_cout_sync) stdio_sync_filebuf<char>(stdout);
new (&buf_cin_sync) stdio_sync_filebuf<char>(stdin);
new (&buf_cerr_sync) stdio_sync_filebuf<char>(stderr);
// The standard streams are constructed once only and never
// destroyed.
new (&cout) ostream(&buf_cout_sync);
new (&cin) istream(&buf_cin_sync);
new (&cerr) ostream(&buf_cerr_sync);
new (&clog) ostream(&buf_cerr_sync);
cin.tie(&cout);
cerr.setf(ios_base::unitbuf);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 455. cerr::tie() and wcerr::tie() are overspecified.
cerr.tie(&cout);
#ifdef _GLIBCXX_USE_WCHAR_T
new (&buf_wcout_sync) stdio_sync_filebuf<wchar_t>(stdout);
new (&buf_wcin_sync) stdio_sync_filebuf<wchar_t>(stdin);
new (&buf_wcerr_sync) stdio_sync_filebuf<wchar_t>(stderr);
new (&wcout) wostream(&buf_wcout_sync);
new (&wcin) wistream(&buf_wcin_sync);
new (&wcerr) wostream(&buf_wcerr_sync);
new (&wclog) wostream(&buf_wcerr_sync);
wcin.tie(&wcout);
wcerr.setf(ios_base::unitbuf);
wcerr.tie(&wcout);
#endif
// NB: Have to set refcount above one, so that standard
// streams are not re-initialized with uses of ios_base::Init
// besides <iostream> static object, ie just using <ios> with
// ios_base::Init objects.
__gnu_cxx::__atomic_add_dispatch(&_S_refcount, 1);
}
}
ios_base::Init::~Init()
{
// Be race-detector-friendly. For more info see bits/c++config.
_GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_S_refcount);
if (__gnu_cxx::__exchange_and_add_dispatch(&_S_refcount, -1) == 2)
{
_GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_S_refcount);
// Catch any exceptions thrown by basic_ostream::flush()
__try
{
// Flush standard output streams as required by 27.4.2.1.6
cout.flush();
cerr.flush();
clog.flush();
#ifdef _GLIBCXX_USE_WCHAR_T
wcout.flush();
wcerr.flush();
wclog.flush();
#endif
}
__catch(...)
{ }
}
}
bool
ios_base::sync_with_stdio(bool __sync)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 49. Underspecification of ios_base::sync_with_stdio
bool __ret = ios_base::Init::_S_synced_with_stdio;
// Turn off sync with C FILE* for cin, cout, cerr, clog iff
// currently synchronized.
if (!__sync && __ret)
{
// Make sure the standard streams are constructed.
ios_base::Init __init;
ios_base::Init::_S_synced_with_stdio = __sync;
// Explicitly call dtors to free any memory that is
// dynamically allocated by filebuf ctor or member functions,
// but don't deallocate all memory by calling operator delete.
buf_cout_sync.~stdio_sync_filebuf<char>();
buf_cin_sync.~stdio_sync_filebuf<char>();
buf_cerr_sync.~stdio_sync_filebuf<char>();
#ifdef _GLIBCXX_USE_WCHAR_T
buf_wcout_sync.~stdio_sync_filebuf<wchar_t>();
buf_wcin_sync.~stdio_sync_filebuf<wchar_t>();
buf_wcerr_sync.~stdio_sync_filebuf<wchar_t>();
#endif
// Create stream buffers for the standard streams and use
// those buffers without destroying and recreating the
// streams.
new (&buf_cout) stdio_filebuf<char>(stdout, ios_base::out);
new (&buf_cin) stdio_filebuf<char>(stdin, ios_base::in);
new (&buf_cerr) stdio_filebuf<char>(stderr, ios_base::out);
cout.rdbuf(&buf_cout);
cin.rdbuf(&buf_cin);
cerr.rdbuf(&buf_cerr);
clog.rdbuf(&buf_cerr);
#ifdef _GLIBCXX_USE_WCHAR_T
new (&buf_wcout) stdio_filebuf<wchar_t>(stdout, ios_base::out);
new (&buf_wcin) stdio_filebuf<wchar_t>(stdin, ios_base::in);
new (&buf_wcerr) stdio_filebuf<wchar_t>(stderr, ios_base::out);
wcout.rdbuf(&buf_wcout);
wcin.rdbuf(&buf_wcin);
wcerr.rdbuf(&buf_wcerr);
wclog.rdbuf(&buf_wcerr);
#endif
}
return __ret;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,58 @@
// Iostreams base classes -*- C++ -*-
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 27.4 Iostreams base classes
//
#include <ios>
#include <locale>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Called only by basic_ios<>::init.
void
ios_base::_M_init() throw()
{
// NB: May be called more than once
_M_precision = 6;
_M_width = 0;
_M_flags = skipws | dec;
_M_ios_locale = locale();
}
// 27.4.2.3 ios_base locale functions
locale
ios_base::imbue(const locale& __loc) throw()
{
locale __old = _M_ios_locale;
_M_ios_locale = __loc;
_M_call_callbacks(imbue_event);
return __old;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,47 @@
// Explicit instantiation file.
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:
//
#include <iomanip>
#include <istream>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template class _Setfill<char>;
template _Setfill<char> setfill(char);
template class basic_iostream<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
template class _Setfill<wchar_t>;
template _Setfill<wchar_t> setfill(wchar_t);
template class basic_iostream<wchar_t>;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,114 @@
// Explicit instantiation file.
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:
//
#include <istream>
#include <iomanip>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template class basic_istream<char>;
template istream& ws(istream&);
template istream& operator>>(istream&, char&);
template istream& operator>>(istream&, unsigned char&);
template istream& operator>>(istream&, signed char&);
template istream& operator>>(istream&, char*);
template istream& operator>>(istream&, unsigned char*);
template istream& operator>>(istream&, signed char*);
template istream& operator>>(istream&, _Setfill<char>);
template istream& operator>>(istream&, _Setiosflags);
template istream& operator>>(istream&, _Resetiosflags);
template istream& operator>>(istream&, _Setbase);
template istream& operator>>(istream&, _Setprecision);
template istream& operator>>(istream&, _Setw);
template istream& istream::_M_extract(unsigned short&);
template istream& istream::_M_extract(unsigned int&);
template istream& istream::_M_extract(long&);
template istream& istream::_M_extract(unsigned long&);
template istream& istream::_M_extract(bool&);
#ifdef _GLIBCXX_USE_LONG_LONG
template istream& istream::_M_extract(long long&);
template istream& istream::_M_extract(unsigned long long&);
#endif
template istream& istream::_M_extract(float&);
template istream& istream::_M_extract(double&);
template istream& istream::_M_extract(long double&);
template istream& istream::_M_extract(void*&);
#ifdef _GLIBCXX_USE_WCHAR_T
template class basic_istream<wchar_t>;
template wistream& ws(wistream&);
template wistream& operator>>(wistream&, wchar_t&);
template wistream& operator>>(wistream&, wchar_t*);
template wistream& operator>>(wistream&, _Setfill<wchar_t>);
template wistream& operator>>(wistream&, _Setiosflags);
template wistream& operator>>(wistream&, _Resetiosflags);
template wistream& operator>>(wistream&, _Setbase);
template wistream& operator>>(wistream&, _Setprecision);
template wistream& operator>>(wistream&, _Setw);
template wistream& wistream::_M_extract(unsigned short&);
template wistream& wistream::_M_extract(unsigned int&);
template wistream& wistream::_M_extract(long&);
template wistream& wistream::_M_extract(unsigned long&);
template wistream& wistream::_M_extract(bool&);
#ifdef _GLIBCXX_USE_LONG_LONG
template wistream& wistream::_M_extract(long long&);
template wistream& wistream::_M_extract(unsigned long long&);
#endif
template wistream& wistream::_M_extract(float&);
template wistream& wistream::_M_extract(double&);
template wistream& wistream::_M_extract(long double&);
template wistream& wistream::_M_extract(void*&);
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
// XXX GLIBCXX_ABI Deprecated
#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
extern "C" void ldbl (void) __attribute__ ((alias (#dbl), weak))
_GLIBCXX_LDBL_COMPAT (_ZNSirsERd, _ZNSirsERe);
#ifdef _GLIBCXX_USE_WCHAR_T
_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_istreamIwSt11char_traitsIwEErsERd,
_ZNSt13basic_istreamIwSt11char_traitsIwEErsERe);
#endif
_GLIBCXX_LDBL_COMPAT (_ZNSi10_M_extractIdEERSiRT_,
_ZNSi10_M_extractIeEERSiRT_);
#ifdef _GLIBCXX_USE_WCHAR_T
_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_istreamIwSt11char_traitsIwEE10_M_extractIdEERS2_RT_,
_ZNSt13basic_istreamIwSt11char_traitsIwEE10_M_extractIeEERS2_RT_);
#endif
#endif // _GLIBCXX_LONG_DOUBLE_COMPAT

View File

@@ -0,0 +1,686 @@
// Input streams -*- C++ -*-
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 27.6.1 Input streams
//
#include <istream>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<>
basic_istream<char>&
basic_istream<char>::
getline(char_type* __s, streamsize __n, char_type __delim)
{
_M_gcount = 0;
ios_base::iostate __err = ios_base::goodbit;
sentry __cerb(*this, true);
if (__cerb)
{
__try
{
const int_type __idelim = traits_type::to_int_type(__delim);
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
int_type __c = __sb->sgetc();
while (_M_gcount + 1 < __n
&& !traits_type::eq_int_type(__c, __eof)
&& !traits_type::eq_int_type(__c, __idelim))
{
streamsize __size = std::min(streamsize(__sb->egptr()
- __sb->gptr()),
streamsize(__n - _M_gcount
- 1));
if (__size > 1)
{
const char_type* __p = traits_type::find(__sb->gptr(),
__size,
__delim);
if (__p)
__size = __p - __sb->gptr();
traits_type::copy(__s, __sb->gptr(), __size);
__s += __size;
__sb->__safe_gbump(__size);
_M_gcount += __size;
__c = __sb->sgetc();
}
else
{
*__s++ = traits_type::to_char_type(__c);
++_M_gcount;
__c = __sb->snextc();
}
}
if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
else if (traits_type::eq_int_type(__c, __idelim))
{
++_M_gcount;
__sb->sbumpc();
}
else
__err |= ios_base::failbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 243. get and getline when sentry reports failure.
if (__n > 0)
*__s = char_type();
if (!_M_gcount)
__err |= ios_base::failbit;
if (__err)
this->setstate(__err);
return *this;
}
template<>
basic_istream<char>&
basic_istream<char>::
ignore(streamsize __n, int_type __delim)
{
if (traits_type::eq_int_type(__delim, traits_type::eof()))
return ignore(__n);
_M_gcount = 0;
sentry __cerb(*this, true);
if (__n > 0 && __cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
const char_type __cdelim = traits_type::to_char_type(__delim);
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
int_type __c = __sb->sgetc();
bool __large_ignore = false;
while (true)
{
while (_M_gcount < __n
&& !traits_type::eq_int_type(__c, __eof)
&& !traits_type::eq_int_type(__c, __delim))
{
streamsize __size = std::min(streamsize(__sb->egptr()
- __sb->gptr()),
streamsize(__n - _M_gcount));
if (__size > 1)
{
const char_type* __p = traits_type::find(__sb->gptr(),
__size,
__cdelim);
if (__p)
__size = __p - __sb->gptr();
__sb->__safe_gbump(__size);
_M_gcount += __size;
__c = __sb->sgetc();
}
else
{
++_M_gcount;
__c = __sb->snextc();
}
}
if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
&& !traits_type::eq_int_type(__c, __eof)
&& !traits_type::eq_int_type(__c, __delim))
{
_M_gcount =
__gnu_cxx::__numeric_traits<streamsize>::__min;
__large_ignore = true;
}
else
break;
}
if (__large_ignore)
_M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
else if (traits_type::eq_int_type(__c, __delim))
{
if (_M_gcount
< __gnu_cxx::__numeric_traits<streamsize>::__max)
++_M_gcount;
__sb->sbumpc();
}
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<>
basic_istream<char>&
operator>>(basic_istream<char>& __in, char* __s)
{
typedef basic_istream<char> __istream_type;
typedef __istream_type::int_type __int_type;
typedef __istream_type::char_type __char_type;
typedef __istream_type::traits_type __traits_type;
typedef __istream_type::__streambuf_type __streambuf_type;
typedef __istream_type::__ctype_type __ctype_type;
streamsize __extracted = 0;
ios_base::iostate __err = ios_base::goodbit;
__istream_type::sentry __cerb(__in, false);
if (__cerb)
{
__try
{
// Figure out how many characters to extract.
streamsize __num = __in.width();
if (__num <= 0)
__num = __gnu_cxx::__numeric_traits<streamsize>::__max;
const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
const __int_type __eof = __traits_type::eof();
__streambuf_type* __sb = __in.rdbuf();
__int_type __c = __sb->sgetc();
while (__extracted < __num - 1
&& !__traits_type::eq_int_type(__c, __eof)
&& !__ct.is(ctype_base::space,
__traits_type::to_char_type(__c)))
{
streamsize __size = std::min(streamsize(__sb->egptr()
- __sb->gptr()),
streamsize(__num - __extracted
- 1));
if (__size > 1)
{
__size = (__ct.scan_is(ctype_base::space,
__sb->gptr() + 1,
__sb->gptr() + __size)
- __sb->gptr());
__traits_type::copy(__s, __sb->gptr(), __size);
__s += __size;
__sb->__safe_gbump(__size);
__extracted += __size;
__c = __sb->sgetc();
}
else
{
*__s++ = __traits_type::to_char_type(__c);
++__extracted;
__c = __sb->snextc();
}
}
if (__traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 68. Extractors for char* should store null at end
*__s = __char_type();
__in.width(0);
}
__catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ __in._M_setstate(ios_base::badbit); }
}
if (!__extracted)
__err |= ios_base::failbit;
if (__err)
__in.setstate(__err);
return __in;
}
template<>
basic_istream<char>&
operator>>(basic_istream<char>& __in, basic_string<char>& __str)
{
typedef basic_istream<char> __istream_type;
typedef __istream_type::int_type __int_type;
typedef __istream_type::traits_type __traits_type;
typedef __istream_type::__streambuf_type __streambuf_type;
typedef __istream_type::__ctype_type __ctype_type;
typedef basic_string<char> __string_type;
typedef __string_type::size_type __size_type;
__size_type __extracted = 0;
ios_base::iostate __err = ios_base::goodbit;
__istream_type::sentry __cerb(__in, false);
if (__cerb)
{
__try
{
__str.erase();
const streamsize __w = __in.width();
const __size_type __n = __w > 0 ? static_cast<__size_type>(__w)
: __str.max_size();
const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
const __int_type __eof = __traits_type::eof();
__streambuf_type* __sb = __in.rdbuf();
__int_type __c = __sb->sgetc();
while (__extracted < __n
&& !__traits_type::eq_int_type(__c, __eof)
&& !__ct.is(ctype_base::space,
__traits_type::to_char_type(__c)))
{
streamsize __size = std::min(streamsize(__sb->egptr()
- __sb->gptr()),
streamsize(__n - __extracted));
if (__size > 1)
{
__size = (__ct.scan_is(ctype_base::space,
__sb->gptr() + 1,
__sb->gptr() + __size)
- __sb->gptr());
__str.append(__sb->gptr(), __size);
__sb->__safe_gbump(__size);
__extracted += __size;
__c = __sb->sgetc();
}
else
{
__str += __traits_type::to_char_type(__c);
++__extracted;
__c = __sb->snextc();
}
}
if (__traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
__in.width(0);
}
__catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 91. Description of operator>> and getline() for string<>
// might cause endless loop
__in._M_setstate(ios_base::badbit);
}
}
if (!__extracted)
__err |= ios_base::failbit;
if (__err)
__in.setstate(__err);
return __in;
}
template<>
basic_istream<char>&
getline(basic_istream<char>& __in, basic_string<char>& __str,
char __delim)
{
typedef basic_istream<char> __istream_type;
typedef __istream_type::int_type __int_type;
typedef __istream_type::char_type __char_type;
typedef __istream_type::traits_type __traits_type;
typedef __istream_type::__streambuf_type __streambuf_type;
typedef basic_string<char> __string_type;
typedef __string_type::size_type __size_type;
__size_type __extracted = 0;
const __size_type __n = __str.max_size();
ios_base::iostate __err = ios_base::goodbit;
__istream_type::sentry __cerb(__in, true);
if (__cerb)
{
__try
{
__str.erase();
const __int_type __idelim = __traits_type::to_int_type(__delim);
const __int_type __eof = __traits_type::eof();
__streambuf_type* __sb = __in.rdbuf();
__int_type __c = __sb->sgetc();
while (__extracted < __n
&& !__traits_type::eq_int_type(__c, __eof)
&& !__traits_type::eq_int_type(__c, __idelim))
{
streamsize __size = std::min(streamsize(__sb->egptr()
- __sb->gptr()),
streamsize(__n - __extracted));
if (__size > 1)
{
const __char_type* __p = __traits_type::find(__sb->gptr(),
__size,
__delim);
if (__p)
__size = __p - __sb->gptr();
__str.append(__sb->gptr(), __size);
__sb->__safe_gbump(__size);
__extracted += __size;
__c = __sb->sgetc();
}
else
{
__str += __traits_type::to_char_type(__c);
++__extracted;
__c = __sb->snextc();
}
}
if (__traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
else if (__traits_type::eq_int_type(__c, __idelim))
{
++__extracted;
__sb->sbumpc();
}
else
__err |= ios_base::failbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 91. Description of operator>> and getline() for string<>
// might cause endless loop
__in._M_setstate(ios_base::badbit);
}
}
if (!__extracted)
__err |= ios_base::failbit;
if (__err)
__in.setstate(__err);
return __in;
}
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
basic_istream<wchar_t>&
basic_istream<wchar_t>::
getline(char_type* __s, streamsize __n, char_type __delim)
{
_M_gcount = 0;
ios_base::iostate __err = ios_base::goodbit;
sentry __cerb(*this, true);
if (__cerb)
{
__try
{
const int_type __idelim = traits_type::to_int_type(__delim);
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
int_type __c = __sb->sgetc();
while (_M_gcount + 1 < __n
&& !traits_type::eq_int_type(__c, __eof)
&& !traits_type::eq_int_type(__c, __idelim))
{
streamsize __size = std::min(streamsize(__sb->egptr()
- __sb->gptr()),
streamsize(__n - _M_gcount
- 1));
if (__size > 1)
{
const char_type* __p = traits_type::find(__sb->gptr(),
__size,
__delim);
if (__p)
__size = __p - __sb->gptr();
traits_type::copy(__s, __sb->gptr(), __size);
__s += __size;
__sb->__safe_gbump(__size);
_M_gcount += __size;
__c = __sb->sgetc();
}
else
{
*__s++ = traits_type::to_char_type(__c);
++_M_gcount;
__c = __sb->snextc();
}
}
if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
else if (traits_type::eq_int_type(__c, __idelim))
{
++_M_gcount;
__sb->sbumpc();
}
else
__err |= ios_base::failbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 243. get and getline when sentry reports failure.
if (__n > 0)
*__s = char_type();
if (!_M_gcount)
__err |= ios_base::failbit;
if (__err)
this->setstate(__err);
return *this;
}
template<>
basic_istream<wchar_t>&
basic_istream<wchar_t>::
ignore(streamsize __n, int_type __delim)
{
if (traits_type::eq_int_type(__delim, traits_type::eof()))
return ignore(__n);
_M_gcount = 0;
sentry __cerb(*this, true);
if (__n > 0 && __cerb)
{
ios_base::iostate __err = ios_base::goodbit;
__try
{
const char_type __cdelim = traits_type::to_char_type(__delim);
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
int_type __c = __sb->sgetc();
bool __large_ignore = false;
while (true)
{
while (_M_gcount < __n
&& !traits_type::eq_int_type(__c, __eof)
&& !traits_type::eq_int_type(__c, __delim))
{
streamsize __size = std::min(streamsize(__sb->egptr()
- __sb->gptr()),
streamsize(__n - _M_gcount));
if (__size > 1)
{
const char_type* __p = traits_type::find(__sb->gptr(),
__size,
__cdelim);
if (__p)
__size = __p - __sb->gptr();
__sb->__safe_gbump(__size);
_M_gcount += __size;
__c = __sb->sgetc();
}
else
{
++_M_gcount;
__c = __sb->snextc();
}
}
if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
&& !traits_type::eq_int_type(__c, __eof)
&& !traits_type::eq_int_type(__c, __delim))
{
_M_gcount =
__gnu_cxx::__numeric_traits<streamsize>::__min;
__large_ignore = true;
}
else
break;
}
if (__large_ignore)
_M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
else if (traits_type::eq_int_type(__c, __delim))
{
if (_M_gcount
< __gnu_cxx::__numeric_traits<streamsize>::__max)
++_M_gcount;
__sb->sbumpc();
}
}
__catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<>
basic_istream<wchar_t>&
getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
wchar_t __delim)
{
typedef basic_istream<wchar_t> __istream_type;
typedef __istream_type::int_type __int_type;
typedef __istream_type::char_type __char_type;
typedef __istream_type::traits_type __traits_type;
typedef __istream_type::__streambuf_type __streambuf_type;
typedef basic_string<wchar_t> __string_type;
typedef __string_type::size_type __size_type;
__size_type __extracted = 0;
const __size_type __n = __str.max_size();
ios_base::iostate __err = ios_base::goodbit;
__istream_type::sentry __cerb(__in, true);
if (__cerb)
{
__try
{
__str.erase();
const __int_type __idelim = __traits_type::to_int_type(__delim);
const __int_type __eof = __traits_type::eof();
__streambuf_type* __sb = __in.rdbuf();
__int_type __c = __sb->sgetc();
while (__extracted < __n
&& !__traits_type::eq_int_type(__c, __eof)
&& !__traits_type::eq_int_type(__c, __idelim))
{
streamsize __size = std::min(streamsize(__sb->egptr()
- __sb->gptr()),
streamsize(__n - __extracted));
if (__size > 1)
{
const __char_type* __p = __traits_type::find(__sb->gptr(),
__size,
__delim);
if (__p)
__size = __p - __sb->gptr();
__str.append(__sb->gptr(), __size);
__sb->__safe_gbump(__size);
__extracted += __size;
__c = __sb->sgetc();
}
else
{
__str += __traits_type::to_char_type(__c);
++__extracted;
__c = __sb->snextc();
}
}
if (__traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
else if (__traits_type::eq_int_type(__c, __idelim))
{
++__extracted;
__sb->sbumpc();
}
else
__err |= ios_base::failbit;
}
__catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(ios_base::badbit);
__throw_exception_again;
}
__catch(...)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 91. Description of operator>> and getline() for string<>
// might cause endless loop
__in._M_setstate(ios_base::badbit);
}
}
if (!__extracted)
__err |= ios_base::failbit;
if (__err)
__in.setstate(__err);
return __in;
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,117 @@
// Compatibility symbols for previous versions, list bits -*- C++ -*-
// Copyright (C) 2011-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <bits/move.h>
#ifdef _GLIBCXX_SHARED
#ifndef _GLIBCXX_BEGIN_NAMESPACE_COMPAT
# define _GLIBCXX_BEGIN_NAMESPACE_COMPAT
#endif
#ifndef _GLIBCXX_END_NAMESPACE_COMPAT
# define _GLIBCXX_END_NAMESPACE_COMPAT
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_COMPAT
struct _List_node_base
{
_List_node_base* _M_next;
_List_node_base* _M_prev;
void
_M_transfer(_List_node_base * const __first,
_List_node_base * const __last) _GLIBCXX_USE_NOEXCEPT;
void
_M_reverse() _GLIBCXX_USE_NOEXCEPT;
void
_M_hook(_List_node_base * const __position) _GLIBCXX_USE_NOEXCEPT;
void
_M_unhook() _GLIBCXX_USE_NOEXCEPT;
};
void
_List_node_base::
_M_transfer(_List_node_base * const __first,
_List_node_base * const __last) _GLIBCXX_USE_NOEXCEPT
{
if (this != __last)
{
// Remove [first, last) from its old position.
__last->_M_prev->_M_next = this;
__first->_M_prev->_M_next = __last;
this->_M_prev->_M_next = __first;
// Splice [first, last) into its new position.
_List_node_base* const __tmp = this->_M_prev;
this->_M_prev = __last->_M_prev;
__last->_M_prev = __first->_M_prev;
__first->_M_prev = __tmp;
}
}
void
_List_node_base::_M_reverse() _GLIBCXX_USE_NOEXCEPT
{
_List_node_base* __tmp = this;
do
{
std::swap(__tmp->_M_next, __tmp->_M_prev);
// Old next node is now prev.
__tmp = __tmp->_M_prev;
}
while (__tmp != this);
}
void
_List_node_base::
_M_hook(_List_node_base* const __position) _GLIBCXX_USE_NOEXCEPT
{
this->_M_next = __position;
this->_M_prev = __position->_M_prev;
__position->_M_prev->_M_next = this;
__position->_M_prev = this;
}
void
_List_node_base::_M_unhook() _GLIBCXX_USE_NOEXCEPT
{
_List_node_base* const __next_node = this->_M_next;
_List_node_base* const __prev_node = this->_M_prev;
__prev_node->_M_next = __next_node;
__next_node->_M_prev = __prev_node;
}
_GLIBCXX_END_NAMESPACE_COMPAT
} // namespace std
#endif

View File

@@ -0,0 +1,146 @@
// Compatibility symbols for previous versions, list bits -*- C++ -*-
// Copyright (C) 2010-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <bits/move.h>
#ifndef _GLIBCXX_BEGIN_NAMESPACE_COMPAT
# define _GLIBCXX_BEGIN_NAMESPACE_COMPAT
#endif
#ifndef _GLIBCXX_END_NAMESPACE_COMPAT
# define _GLIBCXX_END_NAMESPACE_COMPAT
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_COMPAT
struct _List_node_base
{
_List_node_base* _M_next;
_List_node_base* _M_prev;
static void
swap(_List_node_base& __x, _List_node_base& __y) throw ();
void
transfer(_List_node_base * const __first,
_List_node_base * const __last) throw ();
void
reverse() throw ();
void
hook(_List_node_base * const __position) throw ();
void
unhook() throw ();
};
void
_List_node_base::swap(_List_node_base& __x, _List_node_base& __y) throw()
{
if ( __x._M_next != &__x )
{
if ( __y._M_next != &__y )
{
// Both __x and __y are not empty.
std::swap(__x._M_next,__y._M_next);
std::swap(__x._M_prev,__y._M_prev);
__x._M_next->_M_prev = __x._M_prev->_M_next = &__x;
__y._M_next->_M_prev = __y._M_prev->_M_next = &__y;
}
else
{
// __x is not empty, __y is empty.
__y._M_next = __x._M_next;
__y._M_prev = __x._M_prev;
__y._M_next->_M_prev = __y._M_prev->_M_next = &__y;
__x._M_next = __x._M_prev = &__x;
}
}
else if ( __y._M_next != &__y )
{
// __x is empty, __y is not empty.
__x._M_next = __y._M_next;
__x._M_prev = __y._M_prev;
__x._M_next->_M_prev = __x._M_prev->_M_next = &__x;
__y._M_next = __y._M_prev = &__y;
}
}
void
_List_node_base::transfer(_List_node_base * const __first,
_List_node_base * const __last) throw ()
{
if (this != __last)
{
// Remove [first, last) from its old position.
__last->_M_prev->_M_next = this;
__first->_M_prev->_M_next = __last;
this->_M_prev->_M_next = __first;
// Splice [first, last) into its new position.
_List_node_base* const __tmp = this->_M_prev;
this->_M_prev = __last->_M_prev;
__last->_M_prev = __first->_M_prev;
__first->_M_prev = __tmp;
}
}
void
_List_node_base::reverse() throw ()
{
_List_node_base* __tmp = this;
do
{
std::swap(__tmp->_M_next, __tmp->_M_prev);
// Old next node is now prev.
__tmp = __tmp->_M_prev;
}
while (__tmp != this);
}
void
_List_node_base::hook(_List_node_base* const __position) throw ()
{
this->_M_next = __position;
this->_M_prev = __position->_M_prev;
__position->_M_prev->_M_next = this;
__position->_M_prev = this;
}
void
_List_node_base::unhook() throw ()
{
_List_node_base* const __next_node = this->_M_next;
_List_node_base* const __prev_node = this->_M_prev;
__prev_node->_M_next = __next_node;
__next_node->_M_prev = __prev_node;
}
_GLIBCXX_END_NAMESPACE_COMPAT
} // namespace std

View File

@@ -0,0 +1,147 @@
// std::list utilities implementation -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
#include <list>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __detail
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
void
_List_node_base::swap(_List_node_base& __x,
_List_node_base& __y) _GLIBCXX_USE_NOEXCEPT
{
if ( __x._M_next != &__x )
{
if ( __y._M_next != &__y )
{
// Both __x and __y are not empty.
std::swap(__x._M_next,__y._M_next);
std::swap(__x._M_prev,__y._M_prev);
__x._M_next->_M_prev = __x._M_prev->_M_next = &__x;
__y._M_next->_M_prev = __y._M_prev->_M_next = &__y;
}
else
{
// __x is not empty, __y is empty.
__y._M_next = __x._M_next;
__y._M_prev = __x._M_prev;
__y._M_next->_M_prev = __y._M_prev->_M_next = &__y;
__x._M_next = __x._M_prev = &__x;
}
}
else if ( __y._M_next != &__y )
{
// __x is empty, __y is not empty.
__x._M_next = __y._M_next;
__x._M_prev = __y._M_prev;
__x._M_next->_M_prev = __x._M_prev->_M_next = &__x;
__y._M_next = __y._M_prev = &__y;
}
}
void
_List_node_base::
_M_transfer(_List_node_base * const __first,
_List_node_base * const __last) _GLIBCXX_USE_NOEXCEPT
{
if (this != __last)
{
// Remove [first, last) from its old position.
__last->_M_prev->_M_next = this;
__first->_M_prev->_M_next = __last;
this->_M_prev->_M_next = __first;
// Splice [first, last) into its new position.
_List_node_base* const __tmp = this->_M_prev;
this->_M_prev = __last->_M_prev;
__last->_M_prev = __first->_M_prev;
__first->_M_prev = __tmp;
}
}
void
_List_node_base::_M_reverse() _GLIBCXX_USE_NOEXCEPT
{
_List_node_base* __tmp = this;
do
{
std::swap(__tmp->_M_next, __tmp->_M_prev);
// Old next node is now prev.
__tmp = __tmp->_M_prev;
}
while (__tmp != this);
}
void
_List_node_base::
_M_hook(_List_node_base* const __position) _GLIBCXX_USE_NOEXCEPT
{
this->_M_next = __position;
this->_M_prev = __position->_M_prev;
__position->_M_prev->_M_next = this;
__position->_M_prev = this;
}
void
_List_node_base::_M_unhook() _GLIBCXX_USE_NOEXCEPT
{
_List_node_base* const __next_node = this->_M_next;
_List_node_base* const __prev_node = this->_M_prev;
__prev_node->_M_next = __next_node;
__next_node->_M_prev = __prev_node;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __detail
} // namespace std

View File

@@ -0,0 +1,28 @@
// Default definitions when using namespace associations, list -*- C++ -*-
// Copyright (C) 2011-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#define _GLIBCXX_BEGIN_NAMESPACE_COMPAT namespace __cxx1998 {
#define _GLIBCXX_END_NAMESPACE_COMPAT }
#include "list-aux-2.cc"

View File

@@ -0,0 +1,29 @@
// Default definitions when using namespace associations, list -*- C++ -*-
// Copyright (C) 2010-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#define _GLIBCXX_BEGIN_NAMESPACE_COMPAT namespace __cxx1998 {
#define _GLIBCXX_END_NAMESPACE_COMPAT }
#include "list-aux.cc"

View File

@@ -0,0 +1,363 @@
// Locale support -*- C++ -*-
// Copyright (C) 1999-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.1 Locales
//
#include <locale>
// Instantiation configuration.
#ifndef C
# define C char
# define C_is_char
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// moneypunct, money_get, and money_put
template class moneypunct<C, false>;
template class moneypunct<C, true>;
template struct __moneypunct_cache<C, false>;
template struct __moneypunct_cache<C, true>;
template class moneypunct_byname<C, false>;
template class moneypunct_byname<C, true>;
_GLIBCXX_BEGIN_NAMESPACE_LDBL
template class money_get<C, istreambuf_iterator<C> >;
template class money_put<C, ostreambuf_iterator<C> >;
template
istreambuf_iterator<C>
money_get<C, istreambuf_iterator<C> >::
_M_extract<true>(istreambuf_iterator<C>, istreambuf_iterator<C>,
ios_base&, ios_base::iostate&, string&) const;
template
istreambuf_iterator<C>
money_get<C, istreambuf_iterator<C> >::
_M_extract<false>(istreambuf_iterator<C>, istreambuf_iterator<C>,
ios_base&, ios_base::iostate&, string&) const;
template
ostreambuf_iterator<C>
money_put<C, ostreambuf_iterator<C> >::
_M_insert<true>(ostreambuf_iterator<C>, ios_base&, C,
const string_type&) const;
template
ostreambuf_iterator<C>
money_put<C, ostreambuf_iterator<C> >::
_M_insert<false>(ostreambuf_iterator<C>, ios_base&, C,
const string_type&) const;
_GLIBCXX_END_NAMESPACE_LDBL
// numpunct, numpunct_byname, num_get, and num_put
template class numpunct<C>;
template struct __numpunct_cache<C>;
template class numpunct_byname<C>;
_GLIBCXX_BEGIN_NAMESPACE_LDBL
template class num_get<C, istreambuf_iterator<C> >;
template class num_put<C, ostreambuf_iterator<C> >;
template
istreambuf_iterator<C>
num_get<C, istreambuf_iterator<C> >::
_M_extract_int(istreambuf_iterator<C>, istreambuf_iterator<C>,
ios_base&, ios_base::iostate&,
long&) const;
template
istreambuf_iterator<C>
num_get<C, istreambuf_iterator<C> >::
_M_extract_int(istreambuf_iterator<C>, istreambuf_iterator<C>,
ios_base&, ios_base::iostate&,
unsigned short&) const;
template
istreambuf_iterator<C>
num_get<C, istreambuf_iterator<C> >::
_M_extract_int(istreambuf_iterator<C>, istreambuf_iterator<C>,
ios_base&, ios_base::iostate&,
unsigned int&) const;
template
istreambuf_iterator<C>
num_get<C, istreambuf_iterator<C> >::
_M_extract_int(istreambuf_iterator<C>, istreambuf_iterator<C>,
ios_base&, ios_base::iostate&,
unsigned long&) const;
#ifdef _GLIBCXX_USE_LONG_LONG
template
istreambuf_iterator<C>
num_get<C, istreambuf_iterator<C> >::
_M_extract_int(istreambuf_iterator<C>, istreambuf_iterator<C>,
ios_base&, ios_base::iostate&,
long long&) const;
template
istreambuf_iterator<C>
num_get<C, istreambuf_iterator<C> >::
_M_extract_int(istreambuf_iterator<C>, istreambuf_iterator<C>,
ios_base&, ios_base::iostate&,
unsigned long long&) const;
#endif
template
ostreambuf_iterator<C>
num_put<C, ostreambuf_iterator<C> >::
_M_insert_int(ostreambuf_iterator<C>, ios_base&, C,
long) const;
template
ostreambuf_iterator<C>
num_put<C, ostreambuf_iterator<C> >::
_M_insert_int(ostreambuf_iterator<C>, ios_base&, C,
unsigned long) const;
#ifdef _GLIBCXX_USE_LONG_LONG
template
ostreambuf_iterator<C>
num_put<C, ostreambuf_iterator<C> >::
_M_insert_int(ostreambuf_iterator<C>, ios_base&, C,
long long) const;
template
ostreambuf_iterator<C>
num_put<C, ostreambuf_iterator<C> >::
_M_insert_int(ostreambuf_iterator<C>, ios_base&, C,
unsigned long long) const;
#endif
template
ostreambuf_iterator<C>
num_put<C, ostreambuf_iterator<C> >::
_M_insert_float(ostreambuf_iterator<C>, ios_base&, C, char,
double) const;
template
ostreambuf_iterator<C>
num_put<C, ostreambuf_iterator<C> >::
_M_insert_float(ostreambuf_iterator<C>, ios_base&, C, char,
long double) const;
_GLIBCXX_END_NAMESPACE_LDBL
// time_get and time_put
template class __timepunct<C>;
template struct __timepunct_cache<C>;
template class time_put<C, ostreambuf_iterator<C> >;
template class time_put_byname<C, ostreambuf_iterator<C> >;
template class time_get<C, istreambuf_iterator<C> >;
template class time_get_byname<C, istreambuf_iterator<C> >;
// messages
template class messages<C>;
template class messages_byname<C>;
// ctype
inline template class __ctype_abstract_base<C>;
template class ctype_byname<C>;
// codecvt
inline template class __codecvt_abstract_base<C, char, mbstate_t>;
template class codecvt_byname<C, char, mbstate_t>;
// collate
template class collate<C>;
template class collate_byname<C>;
// use_facet
template
const ctype<C>&
use_facet<ctype<C> >(const locale&);
template
const codecvt<C, char, mbstate_t>&
use_facet<codecvt<C, char, mbstate_t> >(const locale&);
template
const collate<C>&
use_facet<collate<C> >(const locale&);
template
const numpunct<C>&
use_facet<numpunct<C> >(const locale&);
template
const num_put<C>&
use_facet<num_put<C> >(const locale&);
template
const num_get<C>&
use_facet<num_get<C> >(const locale&);
template
const moneypunct<C, true>&
use_facet<moneypunct<C, true> >(const locale&);
template
const moneypunct<C, false>&
use_facet<moneypunct<C, false> >(const locale&);
template
const money_put<C>&
use_facet<money_put<C> >(const locale&);
template
const money_get<C>&
use_facet<money_get<C> >(const locale&);
template
const __timepunct<C>&
use_facet<__timepunct<C> >(const locale&);
template
const time_put<C>&
use_facet<time_put<C> >(const locale&);
template
const time_get<C>&
use_facet<time_get<C> >(const locale&);
template
const messages<C>&
use_facet<messages<C> >(const locale&);
// has_facet
template
bool
has_facet<ctype<C> >(const locale&);
template
bool
has_facet<codecvt<C, char, mbstate_t> >(const locale&);
template
bool
has_facet<collate<C> >(const locale&);
template
bool
has_facet<numpunct<C> >(const locale&);
template
bool
has_facet<num_put<C> >(const locale&);
template
bool
has_facet<num_get<C> >(const locale&);
template
bool
has_facet<moneypunct<C> >(const locale&);
template
bool
has_facet<money_put<C> >(const locale&);
template
bool
has_facet<money_get<C> >(const locale&);
template
bool
has_facet<__timepunct<C> >(const locale&);
template
bool
has_facet<time_put<C> >(const locale&);
template
bool
has_facet<time_get<C> >(const locale&);
template
bool
has_facet<messages<C> >(const locale&);
// locale functions.
template
C*
__add_grouping<C>(C*, C, char const*, size_t,
C const*, C const*);
template class __pad<C, char_traits<C> >;
template
int
__int_to_char(C*, unsigned long, const C*,
ios_base::fmtflags, bool);
#ifdef _GLIBCXX_USE_LONG_LONG
template
int
__int_to_char(C*, unsigned long long, const C*,
ios_base::fmtflags, bool);
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
// XXX GLIBCXX_ABI Deprecated
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined C_is_char
#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
extern "C" void ldbl (void) __attribute__ ((alias (#dbl), weak))
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIjEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
_ZNKSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIjEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIlEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
_ZNKSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIlEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intImEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
_ZNKSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intImEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intItEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
_ZNKSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intItEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIxEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
_ZNKSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIxEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIyEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
_ZNKSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIyEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intIlEES4_S4_RSt8ios_basecT_,
_ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intIlEES3_S3_RSt8ios_basecT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intImEES4_S4_RSt8ios_basecT_,
_ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intImEES3_S3_RSt8ios_basecT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intIxEES4_S4_RSt8ios_basecT_,
_ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intIxEES3_S3_RSt8ios_basecT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intIyEES4_S4_RSt8ios_basecT_,
_ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intIyEES3_S3_RSt8ios_basecT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE15_M_insert_floatIdEES4_S4_RSt8ios_baseccT_,
_ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE15_M_insert_floatIdEES3_S3_RSt8ios_baseccT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE15_M_insert_floatIdEES3_S3_RSt8ios_baseccT_,
_ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE15_M_insert_floatIeEES3_S3_RSt8ios_baseccT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE10_M_extractILb0EEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRSs,
_ZNKSt9money_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE10_M_extractILb0EEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRSs);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE10_M_extractILb1EEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRSs,
_ZNKSt9money_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE10_M_extractILb1EEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRSs);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE9_M_insertILb0EEES4_S4_RSt8ios_basecRKSs,
_ZNKSt9money_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE9_M_insertILb0EEES3_S3_RSt8ios_basecRKSs);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE9_M_insertILb1EEES4_S4_RSt8ios_basecRKSs,
_ZNKSt9money_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE9_M_insertILb1EEES3_S3_RSt8ios_basecRKSs);
#endif // _GLIBCXX_LONG_DOUBLE_COMPAT

View File

@@ -0,0 +1,442 @@
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <clocale>
#include <cstring>
#include <cstdlib> // For getenv
#include <cctype>
#include <cwctype> // For towupper, etc.
#include <locale>
#include <ext/concurrence.h>
namespace
{
__gnu_cxx::__mutex&
get_locale_cache_mutex()
{
static __gnu_cxx::__mutex locale_cache_mutex;
return locale_cache_mutex;
}
} // anonymous namespace
// XXX GLIBCXX_ABI Deprecated
#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
# define _GLIBCXX_LOC_ID(mangled) extern std::locale::id mangled
_GLIBCXX_LOC_ID (_ZNSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE2idE);
_GLIBCXX_LOC_ID (_ZNSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE2idE);
_GLIBCXX_LOC_ID (_ZNSt9money_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE2idE);
_GLIBCXX_LOC_ID (_ZNSt9money_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE2idE);
# ifdef _GLIBCXX_USE_WCHAR_T
_GLIBCXX_LOC_ID (_ZNSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE2idE);
_GLIBCXX_LOC_ID (_ZNSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE2idE);
_GLIBCXX_LOC_ID (_ZNSt9money_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE2idE);
_GLIBCXX_LOC_ID (_ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE2idE);
# endif
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Definitions for static const data members of locale.
const locale::category locale::none;
const locale::category locale::ctype;
const locale::category locale::numeric;
const locale::category locale::collate;
const locale::category locale::time;
const locale::category locale::monetary;
const locale::category locale::messages;
const locale::category locale::all;
// These are no longer exported.
locale::_Impl* locale::_S_classic;
locale::_Impl* locale::_S_global;
#ifdef __GTHREADS
__gthread_once_t locale::_S_once = __GTHREAD_ONCE_INIT;
#endif
locale::locale(const locale& __other) throw()
: _M_impl(__other._M_impl)
{ _M_impl->_M_add_reference(); }
// This is used to initialize global and classic locales, and
// assumes that the _Impl objects are constructed correctly.
// The lack of a reference increment is intentional.
locale::locale(_Impl* __ip) throw() : _M_impl(__ip)
{ }
locale::~locale() throw()
{ _M_impl->_M_remove_reference(); }
bool
locale::operator==(const locale& __rhs) const throw()
{
// Deal first with the common cases, fast to process: refcopies,
// unnamed (i.e., !_M_names[0]), "simple" (!_M_names[1] => all the
// categories same name, i.e., _M_names[0]). Otherwise fall back
// to the general locale::name().
bool __ret;
if (_M_impl == __rhs._M_impl)
__ret = true;
else if (!_M_impl->_M_names[0] || !__rhs._M_impl->_M_names[0]
|| std::strcmp(_M_impl->_M_names[0],
__rhs._M_impl->_M_names[0]) != 0)
__ret = false;
else if (!_M_impl->_M_names[1] && !__rhs._M_impl->_M_names[1])
__ret = true;
else
__ret = this->name() == __rhs.name();
return __ret;
}
const locale&
locale::operator=(const locale& __other) throw()
{
__other._M_impl->_M_add_reference();
_M_impl->_M_remove_reference();
_M_impl = __other._M_impl;
return *this;
}
string
locale::name() const
{
string __ret;
if (!_M_impl->_M_names[0])
__ret = '*';
else if (_M_impl->_M_check_same_name())
__ret = _M_impl->_M_names[0];
else
{
__ret.reserve(128);
__ret += _S_categories[0];
__ret += '=';
__ret += _M_impl->_M_names[0];
for (size_t __i = 1; __i < _S_categories_size; ++__i)
{
__ret += ';';
__ret += _S_categories[__i];
__ret += '=';
__ret += _M_impl->_M_names[__i];
}
}
return __ret;
}
locale::category
locale::_S_normalize_category(category __cat)
{
int __ret = 0;
if (__cat == none || ((__cat & all) && !(__cat & ~all)))
__ret = __cat;
else
{
// NB: May be a C-style "LC_ALL" category; convert.
switch (__cat)
{
case LC_COLLATE:
__ret = collate;
break;
case LC_CTYPE:
__ret = ctype;
break;
case LC_MONETARY:
__ret = monetary;
break;
case LC_NUMERIC:
__ret = numeric;
break;
case LC_TIME:
__ret = time;
break;
#ifdef _GLIBCXX_HAVE_LC_MESSAGES
case LC_MESSAGES:
__ret = messages;
break;
#endif
case LC_ALL:
__ret = all;
break;
default:
__throw_runtime_error(__N("locale::_S_normalize_category "
"category not found"));
}
}
return __ret;
}
// locale::facet
__c_locale locale::facet::_S_c_locale;
const char locale::facet::_S_c_name[2] = "C";
#ifdef __GTHREADS
__gthread_once_t locale::facet::_S_once = __GTHREAD_ONCE_INIT;
#endif
void
locale::facet::_S_initialize_once()
{
// Initialize the underlying locale model.
_S_create_c_locale(_S_c_locale, _S_c_name);
}
__c_locale
locale::facet::_S_get_c_locale()
{
#ifdef __GTHREADS
if (__gthread_active_p())
__gthread_once(&_S_once, _S_initialize_once);
else
#endif
{
if (!_S_c_locale)
_S_initialize_once();
}
return _S_c_locale;
}
const char*
locale::facet::_S_get_c_name() throw()
{ return _S_c_name; }
locale::facet::
~facet() { }
// locale::_Impl
locale::_Impl::
~_Impl() throw()
{
if (_M_facets)
for (size_t __i = 0; __i < _M_facets_size; ++__i)
if (_M_facets[__i])
_M_facets[__i]->_M_remove_reference();
delete [] _M_facets;
if (_M_caches)
for (size_t __i = 0; __i < _M_facets_size; ++__i)
if (_M_caches[__i])
_M_caches[__i]->_M_remove_reference();
delete [] _M_caches;
if (_M_names)
for (size_t __i = 0; __i < _S_categories_size; ++__i)
delete [] _M_names[__i];
delete [] _M_names;
}
// Clone existing _Impl object.
locale::_Impl::
_Impl(const _Impl& __imp, size_t __refs)
: _M_refcount(__refs), _M_facets(0), _M_facets_size(__imp._M_facets_size),
_M_caches(0), _M_names(0)
{
__try
{
_M_facets = new const facet*[_M_facets_size];
for (size_t __i = 0; __i < _M_facets_size; ++__i)
{
_M_facets[__i] = __imp._M_facets[__i];
if (_M_facets[__i])
_M_facets[__i]->_M_add_reference();
}
_M_caches = new const facet*[_M_facets_size];
for (size_t __j = 0; __j < _M_facets_size; ++__j)
{
_M_caches[__j] = __imp._M_caches[__j];
if (_M_caches[__j])
_M_caches[__j]->_M_add_reference();
}
_M_names = new char*[_S_categories_size];
for (size_t __k = 0; __k < _S_categories_size; ++__k)
_M_names[__k] = 0;
// Name the categories.
for (size_t __l = 0; (__l < _S_categories_size
&& __imp._M_names[__l]); ++__l)
{
const size_t __len = std::strlen(__imp._M_names[__l]) + 1;
_M_names[__l] = new char[__len];
std::memcpy(_M_names[__l], __imp._M_names[__l], __len);
}
}
__catch(...)
{
this->~_Impl();
__throw_exception_again;
}
}
void
locale::_Impl::
_M_replace_category(const _Impl* __imp,
const locale::id* const* __idpp)
{
for (; *__idpp; ++__idpp)
_M_replace_facet(__imp, *__idpp);
}
void
locale::_Impl::
_M_replace_facet(const _Impl* __imp, const locale::id* __idp)
{
size_t __index = __idp->_M_id();
if ((__index > (__imp->_M_facets_size - 1))
|| !__imp->_M_facets[__index])
__throw_runtime_error(__N("locale::_Impl::_M_replace_facet"));
_M_install_facet(__idp, __imp->_M_facets[__index]);
}
void
locale::_Impl::
_M_install_facet(const locale::id* __idp, const facet* __fp)
{
if (__fp)
{
size_t __index = __idp->_M_id();
// Check size of facet vector to ensure adequate room.
if (__index > _M_facets_size - 1)
{
const size_t __new_size = __index + 4;
// New facet array.
const facet** __oldf = _M_facets;
const facet** __newf;
__newf = new const facet*[__new_size];
for (size_t __i = 0; __i < _M_facets_size; ++__i)
__newf[__i] = _M_facets[__i];
for (size_t __l = _M_facets_size; __l < __new_size; ++__l)
__newf[__l] = 0;
// New cache array.
const facet** __oldc = _M_caches;
const facet** __newc;
__try
{
__newc = new const facet*[__new_size];
}
__catch(...)
{
delete [] __newf;
__throw_exception_again;
}
for (size_t __j = 0; __j < _M_facets_size; ++__j)
__newc[__j] = _M_caches[__j];
for (size_t __k = _M_facets_size; __k < __new_size; ++__k)
__newc[__k] = 0;
_M_facets_size = __new_size;
_M_facets = __newf;
_M_caches = __newc;
delete [] __oldf;
delete [] __oldc;
}
__fp->_M_add_reference();
const facet*& __fpr = _M_facets[__index];
if (__fpr)
{
// Replacing an existing facet. Order matters.
__fpr->_M_remove_reference();
__fpr = __fp;
}
else
{
// Installing a newly created facet into an empty
// _M_facets container, say a newly-constructed,
// swanky-fresh _Impl.
_M_facets[__index] = __fp;
}
// Ideally, it would be nice to only remove the caches that
// are now incorrect. However, some of the caches depend on
// multiple facets, and we only know about one facet
// here. It's no great loss: the first use of the new facet
// will create a new, correctly cached facet anyway.
for (size_t __i = 0; __i < _M_facets_size; ++__i)
{
const facet* __cpr = _M_caches[__i];
if (__cpr)
{
__cpr->_M_remove_reference();
_M_caches[__i] = 0;
}
}
}
}
void
locale::_Impl::
_M_install_cache(const facet* __cache, size_t __index)
{
__gnu_cxx::__scoped_lock sentry(get_locale_cache_mutex());
if (_M_caches[__index] != 0)
{
// Some other thread got in first.
delete __cache;
}
else
{
__cache->_M_add_reference();
_M_caches[__index] = __cache;
}
}
// locale::id
// Definitions for static const data members of locale::id
_Atomic_word locale::id::_S_refcount; // init'd to 0 by linker
size_t
locale::id::_M_id() const throw()
{
if (!_M_index)
{
// XXX GLIBCXX_ABI Deprecated
#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
locale::id *f = 0;
# define _GLIBCXX_SYNC_ID(facet, mangled) \
if (this == &::mangled) \
f = &facet::id
_GLIBCXX_SYNC_ID (num_get<char>, _ZNSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE2idE);
_GLIBCXX_SYNC_ID (num_put<char>, _ZNSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE2idE);
_GLIBCXX_SYNC_ID (money_get<char>, _ZNSt9money_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE2idE);
_GLIBCXX_SYNC_ID (money_put<char>, _ZNSt9money_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE2idE);
# ifdef _GLIBCXX_USE_WCHAR_T
_GLIBCXX_SYNC_ID (num_get<wchar_t>, _ZNSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE2idE);
_GLIBCXX_SYNC_ID (num_put<wchar_t>, _ZNSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE2idE);
_GLIBCXX_SYNC_ID (money_get<wchar_t>, _ZNSt9money_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE2idE);
_GLIBCXX_SYNC_ID (money_put<wchar_t>, _ZNSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE2idE);
# endif
if (f)
_M_index = 1 + f->_M_id();
else
#endif
_M_index = 1 + __gnu_cxx::__exchange_and_add_dispatch(&_S_refcount,
1);
}
return _M_index - 1;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,116 @@
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <locale>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Definitions for static const data members of time_base.
template<>
const char*
__timepunct_cache<char>::_S_timezones[14] =
{
"GMT", "HST", "AKST", "PST", "MST", "CST", "EST", "AST", "NST", "CET",
"IST", "EET", "CST", "JST"
};
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
const wchar_t*
__timepunct_cache<wchar_t>::_S_timezones[14] =
{
L"GMT", L"HST", L"AKST", L"PST", L"MST", L"CST", L"EST", L"AST",
L"NST", L"CET", L"IST", L"EET", L"CST", L"JST"
};
#endif
// Definitions for static const data members of money_base.
const money_base::pattern
money_base::_S_default_pattern = { {symbol, sign, none, value} };
const char* money_base::_S_atoms = "-0123456789";
const char* __num_base::_S_atoms_in = "-+xX0123456789abcdefABCDEF";
const char* __num_base::_S_atoms_out ="-+xX0123456789abcdef0123456789ABCDEF";
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// According to the resolution of DR 231, about 22.2.2.2.2, p11,
// "str.precision() is specified in the conversion specification".
void
__num_base::_S_format_float(const ios_base& __io, char* __fptr,
char __mod) throw()
{
ios_base::fmtflags __flags = __io.flags();
*__fptr++ = '%';
// [22.2.2.2.2] Table 60
if (__flags & ios_base::showpos)
*__fptr++ = '+';
if (__flags & ios_base::showpoint)
*__fptr++ = '#';
// As per DR 231: _always_, not only when
// __flags & ios_base::fixed || __prec > 0
*__fptr++ = '.';
*__fptr++ = '*';
if (__mod)
*__fptr++ = __mod;
ios_base::fmtflags __fltfield = __flags & ios_base::floatfield;
// [22.2.2.2.2] Table 58
if (__fltfield == ios_base::fixed)
*__fptr++ = 'f';
else if (__fltfield == ios_base::scientific)
*__fptr++ = (__flags & ios_base::uppercase) ? 'E' : 'e';
else
*__fptr++ = (__flags & ios_base::uppercase) ? 'G' : 'g';
*__fptr = '\0';
}
bool
__verify_grouping(const char* __grouping, size_t __grouping_size,
const string& __grouping_tmp) throw()
{
const size_t __n = __grouping_tmp.size() - 1;
const size_t __min = std::min(__n, size_t(__grouping_size - 1));
size_t __i = __n;
bool __test = true;
// Parsed number groupings have to match the
// numpunct::grouping string exactly, starting at the
// right-most point of the parsed sequence of elements ...
for (size_t __j = 0; __j < __min && __test; --__i, ++__j)
__test = __grouping_tmp[__i] == __grouping[__j];
for (; __i && __test; --__i)
__test = __grouping_tmp[__i] == __grouping[__min];
// ... but the first parsed grouping can be <= numpunct
// grouping (only do the check if the numpunct char is > 0
// because <= 0 means any size is ok).
if (static_cast<signed char>(__grouping[__min]) > 0
&& __grouping[__min] != __gnu_cxx::__numeric_traits<char>::__max)
__test &= __grouping_tmp[0] <= __grouping[__min];
return __test;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,472 @@
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <clocale>
#include <cstring>
#include <cstdlib> // For getenv, free.
#include <cctype>
#include <cwctype> // For towupper, etc.
#include <locale>
#include <ext/concurrence.h>
namespace
{
__gnu_cxx::__mutex&
get_locale_mutex()
{
static __gnu_cxx::__mutex locale_mutex;
return locale_mutex;
}
using namespace std;
typedef char fake_locale_Impl[sizeof(locale::_Impl)]
__attribute__ ((aligned(__alignof__(locale::_Impl))));
fake_locale_Impl c_locale_impl;
typedef char fake_locale[sizeof(locale)]
__attribute__ ((aligned(__alignof__(locale))));
fake_locale c_locale;
typedef char fake_name_vec[sizeof(char*)]
__attribute__ ((aligned(__alignof__(char*))));
fake_name_vec name_vec[6 + _GLIBCXX_NUM_CATEGORIES];
typedef char fake_names[sizeof(char[2])]
__attribute__ ((aligned(__alignof__(char[2]))));
fake_names name_c[6 + _GLIBCXX_NUM_CATEGORIES];
typedef char fake_facet_vec[sizeof(locale::facet*)]
__attribute__ ((aligned(__alignof__(locale::facet*))));
fake_facet_vec facet_vec[_GLIBCXX_NUM_FACETS];
typedef char fake_cache_vec[sizeof(locale::facet*)]
__attribute__ ((aligned(__alignof__(locale::facet*))));
fake_cache_vec cache_vec[_GLIBCXX_NUM_FACETS];
typedef char fake_ctype_c[sizeof(std::ctype<char>)]
__attribute__ ((aligned(__alignof__(std::ctype<char>))));
fake_ctype_c ctype_c;
typedef char fake_collate_c[sizeof(std::collate<char>)]
__attribute__ ((aligned(__alignof__(std::collate<char>))));
fake_collate_c collate_c;
typedef char fake_numpunct_c[sizeof(numpunct<char>)]
__attribute__ ((aligned(__alignof__(numpunct<char>))));
fake_numpunct_c numpunct_c;
typedef char fake_num_get_c[sizeof(num_get<char>)]
__attribute__ ((aligned(__alignof__(num_get<char>))));
fake_num_get_c num_get_c;
typedef char fake_num_put_c[sizeof(num_put<char>)]
__attribute__ ((aligned(__alignof__(num_put<char>))));
fake_num_put_c num_put_c;
typedef char fake_codecvt_c[sizeof(codecvt<char, char, mbstate_t>)]
__attribute__ ((aligned(__alignof__(codecvt<char, char, mbstate_t>))));
fake_codecvt_c codecvt_c;
typedef char fake_moneypunct_c[sizeof(moneypunct<char, true>)]
__attribute__ ((aligned(__alignof__(moneypunct<char, true>))));
fake_moneypunct_c moneypunct_ct;
fake_moneypunct_c moneypunct_cf;
typedef char fake_money_get_c[sizeof(money_get<char>)]
__attribute__ ((aligned(__alignof__(money_get<char>))));
fake_money_get_c money_get_c;
typedef char fake_money_put_c[sizeof(money_put<char>)]
__attribute__ ((aligned(__alignof__(money_put<char>))));
fake_money_put_c money_put_c;
typedef char fake_timepunct_c[sizeof(__timepunct<char>)]
__attribute__ ((aligned(__alignof__(__timepunct<char>))));
fake_timepunct_c timepunct_c;
typedef char fake_time_get_c[sizeof(time_get<char>)]
__attribute__ ((aligned(__alignof__(time_get<char>))));
fake_time_get_c time_get_c;
typedef char fake_time_put_c[sizeof(time_put<char>)]
__attribute__ ((aligned(__alignof__(time_put<char>))));
fake_time_put_c time_put_c;
typedef char fake_messages_c[sizeof(messages<char>)]
__attribute__ ((aligned(__alignof__(messages<char>))));
fake_messages_c messages_c;
#ifdef _GLIBCXX_USE_WCHAR_T
typedef char fake_wtype_w[sizeof(std::ctype<wchar_t>)]
__attribute__ ((aligned(__alignof__(std::ctype<wchar_t>))));
fake_wtype_w ctype_w;
typedef char fake_wollate_w[sizeof(std::collate<wchar_t>)]
__attribute__ ((aligned(__alignof__(std::collate<wchar_t>))));
fake_wollate_w collate_w;
typedef char fake_numpunct_w[sizeof(numpunct<wchar_t>)]
__attribute__ ((aligned(__alignof__(numpunct<wchar_t>))));
fake_numpunct_w numpunct_w;
typedef char fake_num_get_w[sizeof(num_get<wchar_t>)]
__attribute__ ((aligned(__alignof__(num_get<wchar_t>))));
fake_num_get_w num_get_w;
typedef char fake_num_put_w[sizeof(num_put<wchar_t>)]
__attribute__ ((aligned(__alignof__(num_put<wchar_t>))));
fake_num_put_w num_put_w;
typedef char fake_wodecvt_w[sizeof(codecvt<wchar_t, char, mbstate_t>)]
__attribute__ ((aligned(__alignof__(codecvt<wchar_t, char, mbstate_t>))));
fake_wodecvt_w codecvt_w;
typedef char fake_moneypunct_w[sizeof(moneypunct<wchar_t, true>)]
__attribute__ ((aligned(__alignof__(moneypunct<wchar_t, true>))));
fake_moneypunct_w moneypunct_wt;
fake_moneypunct_w moneypunct_wf;
typedef char fake_money_get_w[sizeof(money_get<wchar_t>)]
__attribute__ ((aligned(__alignof__(money_get<wchar_t>))));
fake_money_get_w money_get_w;
typedef char fake_money_put_w[sizeof(money_put<wchar_t>)]
__attribute__ ((aligned(__alignof__(money_put<wchar_t>))));
fake_money_put_w money_put_w;
typedef char fake_timepunct_w[sizeof(__timepunct<wchar_t>)]
__attribute__ ((aligned(__alignof__(__timepunct<wchar_t>))));
fake_timepunct_w timepunct_w;
typedef char fake_time_get_w[sizeof(time_get<wchar_t>)]
__attribute__ ((aligned(__alignof__(time_get<wchar_t>))));
fake_time_get_w time_get_w;
typedef char fake_time_put_w[sizeof(time_put<wchar_t>)]
__attribute__ ((aligned(__alignof__(time_put<wchar_t>))));
fake_time_put_w time_put_w;
typedef char fake_messages_w[sizeof(messages<wchar_t>)]
__attribute__ ((aligned(__alignof__(messages<wchar_t>))));
fake_messages_w messages_w;
#endif
// Storage for "C" locale caches.
typedef char fake_num_cache_c[sizeof(std::__numpunct_cache<char>)]
__attribute__ ((aligned(__alignof__(std::__numpunct_cache<char>))));
fake_num_cache_c numpunct_cache_c;
typedef char fake_money_cache_c[sizeof(std::__moneypunct_cache<char, true>)]
__attribute__ ((aligned(__alignof__(std::__moneypunct_cache<char, true>))));
fake_money_cache_c moneypunct_cache_ct;
fake_money_cache_c moneypunct_cache_cf;
typedef char fake_time_cache_c[sizeof(std::__timepunct_cache<char>)]
__attribute__ ((aligned(__alignof__(std::__timepunct_cache<char>))));
fake_time_cache_c timepunct_cache_c;
#ifdef _GLIBCXX_USE_WCHAR_T
typedef char fake_num_cache_w[sizeof(std::__numpunct_cache<wchar_t>)]
__attribute__ ((aligned(__alignof__(std::__numpunct_cache<wchar_t>))));
fake_num_cache_w numpunct_cache_w;
typedef char fake_money_cache_w[sizeof(std::__moneypunct_cache<wchar_t,true>)]
__attribute__ ((aligned(__alignof__(std::__moneypunct_cache<wchar_t,true>))));
fake_money_cache_w moneypunct_cache_wt;
fake_money_cache_w moneypunct_cache_wf;
typedef char fake_time_cache_w[sizeof(std::__timepunct_cache<wchar_t>)]
__attribute__ ((aligned(__alignof__(std::__timepunct_cache<wchar_t>))));
fake_time_cache_w timepunct_cache_w;
#endif
} // anonymous namespace
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
locale::locale() throw() : _M_impl(0)
{
_S_initialize();
// Checked locking to optimize the common case where _S_global
// still points to _S_classic (locale::_S_initialize_once()):
// - If they are the same, just increment the reference count and
// we are done. This effectively constructs a C locale object
// identical to the static c_locale.
// - Otherwise, _S_global can and may be destroyed due to
// locale::global() call on another thread, in which case we
// fall back to lock protected access to both _S_global and
// its reference count.
_M_impl = _S_global;
if (_M_impl == _S_classic)
_M_impl->_M_add_reference();
else
{
__gnu_cxx::__scoped_lock sentry(get_locale_mutex());
_S_global->_M_add_reference();
_M_impl = _S_global;
}
}
locale
locale::global(const locale& __other)
{
_S_initialize();
_Impl* __old;
{
__gnu_cxx::__scoped_lock sentry(get_locale_mutex());
__old = _S_global;
__other._M_impl->_M_add_reference();
_S_global = __other._M_impl;
const string __other_name = __other.name();
if (__other_name != "*")
setlocale(LC_ALL, __other_name.c_str());
}
// Reference count sanity check: one reference removed for the
// subsition of __other locale, one added by return-by-value. Net
// difference: zero. When the returned locale object's destrutor
// is called, then the reference count is decremented and possibly
// destroyed.
return locale(__old);
}
const locale&
locale::classic()
{
_S_initialize();
return *(new (&c_locale) locale(_S_classic));
}
void
locale::_S_initialize_once() throw()
{
// 2 references.
// One reference for _S_classic, one for _S_global
_S_classic = new (&c_locale_impl) _Impl(2);
_S_global = _S_classic;
}
void
locale::_S_initialize()
{
#ifdef __GTHREADS
if (__gthread_active_p())
__gthread_once(&_S_once, _S_initialize_once);
#endif
if (!_S_classic)
_S_initialize_once();
}
// Definitions for static const data members of locale::_Impl
const locale::id* const
locale::_Impl::_S_id_ctype[] =
{
&std::ctype<char>::id,
&codecvt<char, char, mbstate_t>::id,
#ifdef _GLIBCXX_USE_WCHAR_T
&std::ctype<wchar_t>::id,
&codecvt<wchar_t, char, mbstate_t>::id,
#endif
0
};
const locale::id* const
locale::_Impl::_S_id_numeric[] =
{
&num_get<char>::id,
&num_put<char>::id,
&numpunct<char>::id,
#ifdef _GLIBCXX_USE_WCHAR_T
&num_get<wchar_t>::id,
&num_put<wchar_t>::id,
&numpunct<wchar_t>::id,
#endif
0
};
const locale::id* const
locale::_Impl::_S_id_collate[] =
{
&std::collate<char>::id,
#ifdef _GLIBCXX_USE_WCHAR_T
&std::collate<wchar_t>::id,
#endif
0
};
const locale::id* const
locale::_Impl::_S_id_time[] =
{
&__timepunct<char>::id,
&time_get<char>::id,
&time_put<char>::id,
#ifdef _GLIBCXX_USE_WCHAR_T
&__timepunct<wchar_t>::id,
&time_get<wchar_t>::id,
&time_put<wchar_t>::id,
#endif
0
};
const locale::id* const
locale::_Impl::_S_id_monetary[] =
{
&money_get<char>::id,
&money_put<char>::id,
&moneypunct<char, false>::id,
&moneypunct<char, true >::id,
#ifdef _GLIBCXX_USE_WCHAR_T
&money_get<wchar_t>::id,
&money_put<wchar_t>::id,
&moneypunct<wchar_t, false>::id,
&moneypunct<wchar_t, true >::id,
#endif
0
};
const locale::id* const
locale::_Impl::_S_id_messages[] =
{
&std::messages<char>::id,
#ifdef _GLIBCXX_USE_WCHAR_T
&std::messages<wchar_t>::id,
#endif
0
};
const locale::id* const* const
locale::_Impl::_S_facet_categories[] =
{
// Order must match the decl order in class locale.
locale::_Impl::_S_id_ctype,
locale::_Impl::_S_id_numeric,
locale::_Impl::_S_id_collate,
locale::_Impl::_S_id_time,
locale::_Impl::_S_id_monetary,
locale::_Impl::_S_id_messages,
0
};
// Construct "C" _Impl.
locale::_Impl::
_Impl(size_t __refs) throw()
: _M_refcount(__refs), _M_facets(0), _M_facets_size(_GLIBCXX_NUM_FACETS),
_M_caches(0), _M_names(0)
{
_M_facets = new (&facet_vec) const facet*[_M_facets_size];
_M_caches = new (&cache_vec) const facet*[_M_facets_size];
for (size_t __i = 0; __i < _M_facets_size; ++__i)
_M_facets[__i] = _M_caches[__i] = 0;
// Name the categories.
_M_names = new (&name_vec) char*[_S_categories_size];
_M_names[0] = new (&name_c[0]) char[2];
std::memcpy(_M_names[0], locale::facet::_S_get_c_name(), 2);
for (size_t __j = 1; __j < _S_categories_size; ++__j)
_M_names[__j] = 0;
// This is needed as presently the C++ version of "C" locales
// != data in the underlying locale model for __timepunct,
// numpunct, and moneypunct. Also, the "C" locales must be
// constructed in a way such that they are pre-allocated.
// NB: Set locale::facets(ref) count to one so that each individual
// facet is not destroyed when the locale (and thus locale::_Impl) is
// destroyed.
_M_init_facet(new (&ctype_c) std::ctype<char>(0, false, 1));
_M_init_facet(new (&codecvt_c) codecvt<char, char, mbstate_t>(1));
typedef __numpunct_cache<char> num_cache_c;
num_cache_c* __npc = new (&numpunct_cache_c) num_cache_c(2);
_M_init_facet(new (&numpunct_c) numpunct<char>(__npc, 1));
_M_init_facet(new (&num_get_c) num_get<char>(1));
_M_init_facet(new (&num_put_c) num_put<char>(1));
_M_init_facet(new (&collate_c) std::collate<char>(1));
typedef __moneypunct_cache<char, false> money_cache_cf;
typedef __moneypunct_cache<char, true> money_cache_ct;
money_cache_cf* __mpcf = new (&moneypunct_cache_cf) money_cache_cf(2);
_M_init_facet(new (&moneypunct_cf) moneypunct<char, false>(__mpcf, 1));
money_cache_ct* __mpct = new (&moneypunct_cache_ct) money_cache_ct(2);
_M_init_facet(new (&moneypunct_ct) moneypunct<char, true>(__mpct, 1));
_M_init_facet(new (&money_get_c) money_get<char>(1));
_M_init_facet(new (&money_put_c) money_put<char>(1));
typedef __timepunct_cache<char> time_cache_c;
time_cache_c* __tpc = new (&timepunct_cache_c) time_cache_c(2);
_M_init_facet(new (&timepunct_c) __timepunct<char>(__tpc, 1));
_M_init_facet(new (&time_get_c) time_get<char>(1));
_M_init_facet(new (&time_put_c) time_put<char>(1));
_M_init_facet(new (&messages_c) std::messages<char>(1));
#ifdef _GLIBCXX_USE_WCHAR_T
_M_init_facet(new (&ctype_w) std::ctype<wchar_t>(1));
_M_init_facet(new (&codecvt_w) codecvt<wchar_t, char, mbstate_t>(1));
typedef __numpunct_cache<wchar_t> num_cache_w;
num_cache_w* __npw = new (&numpunct_cache_w) num_cache_w(2);
_M_init_facet(new (&numpunct_w) numpunct<wchar_t>(__npw, 1));
_M_init_facet(new (&num_get_w) num_get<wchar_t>(1));
_M_init_facet(new (&num_put_w) num_put<wchar_t>(1));
_M_init_facet(new (&collate_w) std::collate<wchar_t>(1));
typedef __moneypunct_cache<wchar_t, false> money_cache_wf;
typedef __moneypunct_cache<wchar_t, true> money_cache_wt;
money_cache_wf* __mpwf = new (&moneypunct_cache_wf) money_cache_wf(2);
_M_init_facet(new (&moneypunct_wf) moneypunct<wchar_t, false>(__mpwf, 1));
money_cache_wt* __mpwt = new (&moneypunct_cache_wt) money_cache_wt(2);
_M_init_facet(new (&moneypunct_wt) moneypunct<wchar_t, true>(__mpwt, 1));
_M_init_facet(new (&money_get_w) money_get<wchar_t>(1));
_M_init_facet(new (&money_put_w) money_put<wchar_t>(1));
typedef __timepunct_cache<wchar_t> time_cache_w;
time_cache_w* __tpw = new (&timepunct_cache_w) time_cache_w(2);
_M_init_facet(new (&timepunct_w) __timepunct<wchar_t>(__tpw, 1));
_M_init_facet(new (&time_get_w) time_get<wchar_t>(1));
_M_init_facet(new (&time_put_w) time_put<wchar_t>(1));
_M_init_facet(new (&messages_w) std::messages<wchar_t>(1));
#endif
// This locale is safe to pre-cache, after all the facets have
// been created and installed.
_M_caches[numpunct<char>::id._M_id()] = __npc;
_M_caches[moneypunct<char, false>::id._M_id()] = __mpcf;
_M_caches[moneypunct<char, true>::id._M_id()] = __mpct;
_M_caches[__timepunct<char>::id._M_id()] = __tpc;
#ifdef _GLIBCXX_USE_WCHAR_T
_M_caches[numpunct<wchar_t>::id._M_id()] = __npw;
_M_caches[moneypunct<wchar_t, false>::id._M_id()] = __mpwf;
_M_caches[moneypunct<wchar_t, true>::id._M_id()] = __mpwt;
_M_caches[__timepunct<wchar_t>::id._M_id()] = __tpw;
#endif
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,352 @@
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <clocale>
#include <cstring>
#include <cstdlib>
#include <locale>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using namespace __gnu_cxx;
locale::locale(const char* __s) : _M_impl(0)
{
if (__s)
{
_S_initialize();
if (std::strcmp(__s, "C") == 0 || std::strcmp(__s, "POSIX") == 0)
(_M_impl = _S_classic)->_M_add_reference();
else if (std::strcmp(__s, "") != 0)
_M_impl = new _Impl(__s, 1);
else
{
// Get it from the environment.
char* __env = std::getenv("LC_ALL");
// If LC_ALL is set we are done.
if (__env && std::strcmp(__env, "") != 0)
{
if (std::strcmp(__env, "C") == 0
|| std::strcmp(__env, "POSIX") == 0)
(_M_impl = _S_classic)->_M_add_reference();
else
_M_impl = new _Impl(__env, 1);
}
else
{
// LANG may set a default different from "C".
string __lang;
__env = std::getenv("LANG");
if (!__env || std::strcmp(__env, "") == 0
|| std::strcmp(__env, "C") == 0
|| std::strcmp(__env, "POSIX") == 0)
__lang = "C";
else
__lang = __env;
// Scan the categories looking for the first one
// different from LANG.
size_t __i = 0;
if (__lang == "C")
for (; __i < _S_categories_size; ++__i)
{
__env = std::getenv(_S_categories[__i]);
if (__env && std::strcmp(__env, "") != 0
&& std::strcmp(__env, "C") != 0
&& std::strcmp(__env, "POSIX") != 0)
break;
}
else
for (; __i < _S_categories_size; ++__i)
{
__env = std::getenv(_S_categories[__i]);
if (__env && std::strcmp(__env, "") != 0
&& __lang != __env)
break;
}
// If one is found, build the complete string of
// the form LC_CTYPE=xxx;LC_NUMERIC=yyy; and so on...
if (__i < _S_categories_size)
{
string __str;
__str.reserve(128);
for (size_t __j = 0; __j < __i; ++__j)
{
__str += _S_categories[__j];
__str += '=';
__str += __lang;
__str += ';';
}
__str += _S_categories[__i];
__str += '=';
__str += __env;
__str += ';';
++__i;
for (; __i < _S_categories_size; ++__i)
{
__env = std::getenv(_S_categories[__i]);
__str += _S_categories[__i];
if (!__env || std::strcmp(__env, "") == 0)
{
__str += '=';
__str += __lang;
__str += ';';
}
else if (std::strcmp(__env, "C") == 0
|| std::strcmp(__env, "POSIX") == 0)
__str += "=C;";
else
{
__str += '=';
__str += __env;
__str += ';';
}
}
__str.erase(__str.end() - 1);
_M_impl = new _Impl(__str.c_str(), 1);
}
// ... otherwise either an additional instance of
// the "C" locale or LANG.
else if (__lang == "C")
(_M_impl = _S_classic)->_M_add_reference();
else
_M_impl = new _Impl(__lang.c_str(), 1);
}
}
}
else
__throw_runtime_error(__N("locale::locale null not valid"));
}
locale::locale(const locale& __base, const char* __s, category __cat)
: _M_impl(0)
{
// NB: There are complicated, yet more efficient ways to do
// this. Building up locales on a per-category way is tedious, so
// let's do it this way until people complain.
locale __add(__s);
_M_coalesce(__base, __add, __cat);
}
locale::locale(const locale& __base, const locale& __add, category __cat)
: _M_impl(0)
{ _M_coalesce(__base, __add, __cat); }
void
locale::_M_coalesce(const locale& __base, const locale& __add,
category __cat)
{
__cat = _S_normalize_category(__cat);
_M_impl = new _Impl(*__base._M_impl, 1);
__try
{ _M_impl->_M_replace_categories(__add._M_impl, __cat); }
__catch(...)
{
_M_impl->_M_remove_reference();
__throw_exception_again;
}
}
// Construct named _Impl.
locale::_Impl::
_Impl(const char* __s, size_t __refs)
: _M_refcount(__refs), _M_facets(0), _M_facets_size(_GLIBCXX_NUM_FACETS),
_M_caches(0), _M_names(0)
{
// Initialize the underlying locale model, which also checks to
// see if the given name is valid.
__c_locale __cloc;
locale::facet::_S_create_c_locale(__cloc, __s);
__c_locale __clocm = __cloc;
__try
{
_M_facets = new const facet*[_M_facets_size];
for (size_t __i = 0; __i < _M_facets_size; ++__i)
_M_facets[__i] = 0;
_M_caches = new const facet*[_M_facets_size];
for (size_t __j = 0; __j < _M_facets_size; ++__j)
_M_caches[__j] = 0;
_M_names = new char*[_S_categories_size];
for (size_t __k = 0; __k < _S_categories_size; ++__k)
_M_names[__k] = 0;
// Name the categories.
const char* __smon = __s;
const size_t __len = std::strlen(__s);
if (!std::memchr(__s, ';', __len))
{
_M_names[0] = new char[__len + 1];
std::memcpy(_M_names[0], __s, __len + 1);
}
else
{
const char* __end = __s;
bool __found_ctype = false;
bool __found_monetary = false;
size_t __ci = 0, __mi = 0;
for (size_t __i = 0; __i < _S_categories_size; ++__i)
{
const char* __beg = std::strchr(__end + 1, '=') + 1;
__end = std::strchr(__beg, ';');
if (!__end)
__end = __s + __len;
_M_names[__i] = new char[__end - __beg + 1];
std::memcpy(_M_names[__i], __beg, __end - __beg);
_M_names[__i][__end - __beg] = '\0';
if (!__found_ctype
&& *(__beg - 2) == 'E' && *(__beg - 3) == 'P')
{
__found_ctype = true;
__ci = __i;
}
else if (!__found_monetary && *(__beg - 2) == 'Y')
{
__found_monetary = true;
__mi = __i;
}
}
if (std::strcmp(_M_names[__ci], _M_names[__mi]))
{
__smon = _M_names[__mi];
__clocm = locale::facet::_S_lc_ctype_c_locale(__cloc,
__smon);
}
}
// Construct all standard facets and add them to _M_facets.
_M_init_facet(new std::ctype<char>(__cloc, 0, false));
_M_init_facet(new codecvt<char, char, mbstate_t>(__cloc));
_M_init_facet(new numpunct<char>(__cloc));
_M_init_facet(new num_get<char>);
_M_init_facet(new num_put<char>);
_M_init_facet(new std::collate<char>(__cloc));
_M_init_facet(new moneypunct<char, false>(__cloc, 0));
_M_init_facet(new moneypunct<char, true>(__cloc, 0));
_M_init_facet(new money_get<char>);
_M_init_facet(new money_put<char>);
_M_init_facet(new __timepunct<char>(__cloc, __s));
_M_init_facet(new time_get<char>);
_M_init_facet(new time_put<char>);
_M_init_facet(new std::messages<char>(__cloc, __s));
#ifdef _GLIBCXX_USE_WCHAR_T
_M_init_facet(new std::ctype<wchar_t>(__cloc));
_M_init_facet(new codecvt<wchar_t, char, mbstate_t>(__cloc));
_M_init_facet(new numpunct<wchar_t>(__cloc));
_M_init_facet(new num_get<wchar_t>);
_M_init_facet(new num_put<wchar_t>);
_M_init_facet(new std::collate<wchar_t>(__cloc));
_M_init_facet(new moneypunct<wchar_t, false>(__clocm, __smon));
_M_init_facet(new moneypunct<wchar_t, true>(__clocm, __smon));
_M_init_facet(new money_get<wchar_t>);
_M_init_facet(new money_put<wchar_t>);
_M_init_facet(new __timepunct<wchar_t>(__cloc, __s));
_M_init_facet(new time_get<wchar_t>);
_M_init_facet(new time_put<wchar_t>);
_M_init_facet(new std::messages<wchar_t>(__cloc, __s));
#endif
locale::facet::_S_destroy_c_locale(__cloc);
if (__clocm != __cloc)
locale::facet::_S_destroy_c_locale(__clocm);
}
__catch(...)
{
locale::facet::_S_destroy_c_locale(__cloc);
if (__clocm != __cloc)
locale::facet::_S_destroy_c_locale(__clocm);
this->~_Impl();
__throw_exception_again;
}
}
void
locale::_Impl::
_M_replace_categories(const _Impl* __imp, category __cat)
{
category __mask = 1;
if (!_M_names[0] || !__imp->_M_names[0])
{
if (_M_names[0])
{
delete [] _M_names[0];
_M_names[0] = 0; // Unnamed.
}
for (size_t __ix = 0; __ix < _S_categories_size; ++__ix, __mask <<= 1)
{
if (__mask & __cat)
// Need to replace entry in _M_facets with other locale's info.
_M_replace_category(__imp, _S_facet_categories[__ix]);
}
}
else
{
if (!_M_names[1])
{
// A full set of _M_names must be prepared, all identical
// to _M_names[0] to begin with. Then, below, a few will
// be replaced by the corresponding __imp->_M_names. I.e.,
// not a "simple" locale anymore (see locale::operator==).
const size_t __len = std::strlen(_M_names[0]) + 1;
for (size_t __i = 1; __i < _S_categories_size; ++__i)
{
_M_names[__i] = new char[__len];
std::memcpy(_M_names[__i], _M_names[0], __len);
}
}
for (size_t __ix = 0; __ix < _S_categories_size; ++__ix, __mask <<= 1)
{
if (__mask & __cat)
{
// Need to replace entry in _M_facets with other locale's info.
_M_replace_category(__imp, _S_facet_categories[__ix]);
// FIXME: Hack for libstdc++/29217: the numerical encodings
// of the time and collate categories are swapped vs the
// order of the names in locale::_S_categories. We'd like to
// adjust the former (the latter is dictated by compatibility
// with glibc) but we can't for binary compatibility.
size_t __ix_name = __ix;
if (__ix == 2 || __ix == 3)
__ix_name = 5 - __ix;
char* __src = __imp->_M_names[__ix_name] ?
__imp->_M_names[__ix_name] : __imp->_M_names[0];
const size_t __len = std::strlen(__src) + 1;
char* __new = new char[__len];
std::memcpy(__new, __src, __len);
delete [] _M_names[__ix_name];
_M_names[__ix_name] = __new;
}
}
}
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,224 @@
// Stub definitions for float math.
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <cmath>
// For targets which do not have support for float versions,
// we use the following crude approximations. We keep saying that we'll do
// better later, but never do.
extern "C"
{
#ifndef _GLIBCXX_HAVE_FABSF
float
fabsf(float x)
{
return (float) fabs(x);
}
#endif
#ifndef _GLIBCXX_HAVE_ACOSF
float
acosf(float x)
{
return (float) acos(x);
}
#endif
#ifndef _GLIBCXX_HAVE_ASINF
float
asinf(float x)
{
return (float) asin(x);
}
#endif
#ifndef _GLIBCXX_HAVE_ATANF
float
atanf(float x)
{
return (float) atan(x);
}
#endif
#ifndef _GLIBCXX_HAVE_ATAN2F
float
atan2f(float x, float y)
{
return (float) atan2(x, y);
}
#endif
#ifndef _GLIBCXX_HAVE_CEILF
float
ceilf(float x)
{
return (float) ceil(x);
}
#endif
#ifndef _GLIBCXX_HAVE_COSF
float
cosf(float x)
{
return (float) cos(x);
}
#endif
#ifndef _GLIBCXX_HAVE_COSHF
float
coshf(float x)
{
return (float) cosh(x);
}
#endif
#ifndef _GLIBCXX_HAVE_EXPF
float
expf(float x)
{
return (float) exp(x);
}
#endif
#ifndef _GLIBCXX_HAVE_FLOORF
float
floorf(float x)
{
return (float) floor(x);
}
#endif
#ifndef _GLIBCXX_HAVE_FMODF
float
fmodf(float x, float y)
{
return (float) fmod(x, y);
}
#endif
#ifndef _GLIBCXX_HAVE_FREXPF
float
frexpf(float x, int *exp)
{
return (float) frexp(x, exp);
}
#endif
#ifndef _GLIBCXX_HAVE_SQRTF
float
sqrtf(float x)
{
return (float) sqrt(x);
}
#endif
#ifndef _GLIBCXX_HAVE_HYPOTF
float
hypotf(float x, float y)
{
float s = fabsf(x) + fabsf(y);
if (s == 0.0F)
return s;
x /= s; y /= s;
return s * sqrtf(x * x + y * y);
}
#endif
#ifndef _GLIBCXX_HAVE_LDEXPF
float
ldexpf(float x, int exp)
{
return (float) ldexp(x, exp);
}
#endif
#ifndef _GLIBCXX_HAVE_LOGF
float
logf(float x)
{
return (float) log(x);
}
#endif
#ifndef _GLIBCXX_HAVE_LOG10F
float
log10f(float x)
{
return (float) log10(x);
}
#endif
#ifndef _GLIBCXX_HAVE_MODFF
float
modff(float x, float *iptr)
{
double result, temp;
result = modf(x, &temp);
*iptr = (float) temp;
return (float) result;
}
#endif
#ifndef _GLIBCXX_HAVE_POWF
float
powf(float x, float y)
{
return (float) pow(x, y);
}
#endif
#ifndef _GLIBCXX_HAVE_SINF
float
sinf(float x)
{
return (float) sin(x);
}
#endif
#ifndef _GLIBCXX_HAVE_SINHF
float
sinhf(float x)
{
return (float) sinh(x);
}
#endif
#ifndef _GLIBCXX_HAVE_TANF
float
tanf(float x)
{
return (float) tan(x);
}
#endif
#ifndef _GLIBCXX_HAVE_TANHF
float
tanhf(float x)
{
return (float) tanh(x);
}
#endif
} // extern "C"

View File

@@ -0,0 +1,224 @@
// Stub definitions for long double math.
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <cmath>
// For targets which do not have support for long double versions,
// we use the following crude approximations. We keep saying that we'll do
// better later, but never do.
extern "C"
{
#ifndef _GLIBCXX_HAVE_FABSL
long double
fabsl(long double x)
{
return fabs((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_ACOSL
long double
acosl(long double x)
{
return acos((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_ASINL
long double
asinl(long double x)
{
return asin((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_ATANL
long double
atanl(long double x)
{
return atan ((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_ATAN2L
long double
atan2l(long double x, long double y)
{
return atan2((double) x, (double) y);
}
#endif
#ifndef _GLIBCXX_HAVE_CEILL
long double
ceill(long double x)
{
return ceil((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_COSL
long double
cosl(long double x)
{
return cos((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_COSHL
long double
coshl(long double x)
{
return cosh((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_EXPL
long double
expl(long double x)
{
return exp((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_FLOORL
long double
floorl(long double x)
{
return floor((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_FMODL
long double
fmodl(long double x, long double y)
{
return fmod((double) x, (double) y);
}
#endif
#ifndef _GLIBCXX_HAVE_FREXPL
long double
frexpl(long double x, int *exp)
{
return frexp((double) x, exp);
}
#endif
#ifndef _GLIBCXX_HAVE_SQRTL
long double
sqrtl(long double x)
{
return sqrt((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_HYPOTL
long double
hypotl(long double x, long double y)
{
long double s = fabsl(x) + fabsl(y);
if (s == 0.0L)
return s;
x /= s; y /= s;
return s * sqrtl(x * x + y * y);
}
#endif
#ifndef _GLIBCXX_HAVE_LDEXPL
long double
ldexpl(long double x, int exp)
{
return ldexp((double) x, exp);
}
#endif
#ifndef _GLIBCXX_HAVE_LOGL
long double
logl(long double x)
{
return log((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_LOG10L
long double
log10l(long double x)
{
return log10((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_MODFL
long double
modfl(long double x, long double *iptr)
{
double result, temp;
result = modf((double) x, &temp);
*iptr = temp;
return result;
}
#endif
#ifndef _GLIBCXX_HAVE_POWL
long double
powl(long double x, long double y)
{
return pow((double) x, (double) y);
}
#endif
#ifndef _GLIBCXX_HAVE_SINL
long double
sinl(long double x)
{
return sin((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_SINHL
long double
sinhl(long double x)
{
return sinh((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_TANL
long double
tanl(long double x)
{
return tan((double) x);
}
#endif
#ifndef _GLIBCXX_HAVE_TANHL
long double
tanhl(long double x)
{
return tanh((double) x);
}
#endif
} // extern "C"

View File

@@ -0,0 +1,51 @@
// std::messages implementation details, generic version -*- C++ -*-
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Specializations
template<>
string
messages<char>::do_get(catalog, int, int, const string& __dfault) const
{ return __dfault; }
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
wstring
messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const
{ return __dfault; }
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,81 @@
// Explicit instantiation file.
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:
//
#include <string>
#include <istream>
#include <ostream>
#include <ext/stdio_sync_filebuf.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// string related to iostreams
template
basic_istream<char>&
operator>>(basic_istream<char>&, string&);
template
basic_ostream<char>&
operator<<(basic_ostream<char>&, const string&);
template
basic_istream<char>&
getline(basic_istream<char>&, string&, char);
template
basic_istream<char>&
getline(basic_istream<char>&, string&);
#ifdef _GLIBCXX_USE_WCHAR_T
template
basic_istream<wchar_t>&
operator>>(basic_istream<wchar_t>&, wstring&);
template
basic_ostream<wchar_t>&
operator<<(basic_ostream<wchar_t>&, const wstring&);
template
basic_istream<wchar_t>&
getline(basic_istream<wchar_t>&, wstring&, wchar_t);
template
basic_istream<wchar_t>&
getline(basic_istream<wchar_t>&, wstring&);
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template class stdio_sync_filebuf<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
template class stdio_sync_filebuf<wchar_t>;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,170 @@
// std::moneypunct implementation details, generic version -*- C++ -*-
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Construct and return valid pattern consisting of some combination of:
// space none symbol sign value
money_base::pattern
money_base::_S_construct_pattern(char, char, char) throw()
{ return _S_default_pattern; }
template<>
void
moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*)
{
// "C" locale.
if (!_M_data)
_M_data = new __moneypunct_cache<char, true>;
_M_data->_M_decimal_point = '.';
_M_data->_M_thousands_sep = ',';
_M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_curr_symbol = "";
_M_data->_M_curr_symbol_size = 0;
_M_data->_M_positive_sign = "";
_M_data->_M_positive_sign_size = 0;
_M_data->_M_negative_sign = "";
_M_data->_M_negative_sign_size = 0;
_M_data->_M_frac_digits = 0;
_M_data->_M_pos_format = money_base::_S_default_pattern;
_M_data->_M_neg_format = money_base::_S_default_pattern;
for (size_t __i = 0; __i < money_base::_S_end; ++__i)
_M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
}
template<>
void
moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*)
{
// "C" locale.
if (!_M_data)
_M_data = new __moneypunct_cache<char, false>;
_M_data->_M_decimal_point = '.';
_M_data->_M_thousands_sep = ',';
_M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_curr_symbol = "";
_M_data->_M_curr_symbol_size = 0;
_M_data->_M_positive_sign = "";
_M_data->_M_positive_sign_size = 0;
_M_data->_M_negative_sign = "";
_M_data->_M_negative_sign_size = 0;
_M_data->_M_frac_digits = 0;
_M_data->_M_pos_format = money_base::_S_default_pattern;
_M_data->_M_neg_format = money_base::_S_default_pattern;
for (size_t __i = 0; __i < money_base::_S_end; ++__i)
_M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
}
template<>
moneypunct<char, true>::~moneypunct()
{ delete _M_data; }
template<>
moneypunct<char, false>::~moneypunct()
{ delete _M_data; }
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
void
moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale,
const char*)
{
// "C" locale
if (!_M_data)
_M_data = new __moneypunct_cache<wchar_t, true>;
_M_data->_M_decimal_point = L'.';
_M_data->_M_thousands_sep = L',';
_M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_curr_symbol = L"";
_M_data->_M_curr_symbol_size = 0;
_M_data->_M_positive_sign = L"";
_M_data->_M_positive_sign_size = 0;
_M_data->_M_negative_sign = L"";
_M_data->_M_negative_sign_size = 0;
_M_data->_M_frac_digits = 0;
_M_data->_M_pos_format = money_base::_S_default_pattern;
_M_data->_M_neg_format = money_base::_S_default_pattern;
for (size_t __i = 0; __i < money_base::_S_end; ++__i)
_M_data->_M_atoms[__i] =
static_cast<wchar_t>(money_base::_S_atoms[__i]);
}
template<>
void
moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale,
const char*)
{
// "C" locale
if (!_M_data)
_M_data = new __moneypunct_cache<wchar_t, false>;
_M_data->_M_decimal_point = L'.';
_M_data->_M_thousands_sep = L',';
_M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_curr_symbol = L"";
_M_data->_M_curr_symbol_size = 0;
_M_data->_M_positive_sign = L"";
_M_data->_M_positive_sign_size = 0;
_M_data->_M_negative_sign = L"";
_M_data->_M_negative_sign_size = 0;
_M_data->_M_frac_digits = 0;
_M_data->_M_pos_format = money_base::_S_default_pattern;
_M_data->_M_neg_format = money_base::_S_default_pattern;
for (size_t __i = 0; __i < money_base::_S_end; ++__i)
_M_data->_M_atoms[__i] =
static_cast<wchar_t>(money_base::_S_atoms[__i]);
}
template<>
moneypunct<wchar_t, true>::~moneypunct()
{ delete _M_data; }
template<>
moneypunct<wchar_t, false>::~moneypunct()
{ delete _M_data; }
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,819 @@
// Allocator details.
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:
//
#include <bits/c++config.h>
#include <ext/concurrence.h>
#include <ext/mt_allocator.h>
#include <cstring>
namespace
{
#ifdef __GTHREADS
struct __freelist
{
typedef __gnu_cxx::__pool<true>::_Thread_record _Thread_record;
_Thread_record* _M_thread_freelist;
_Thread_record* _M_thread_freelist_array;
size_t _M_max_threads;
__gthread_key_t _M_key;
~__freelist()
{
if (_M_thread_freelist_array)
{
__gthread_key_delete(_M_key);
::operator delete(static_cast<void*>(_M_thread_freelist_array));
_M_thread_freelist = 0;
}
}
};
__freelist&
get_freelist()
{
static __freelist freelist;
return freelist;
}
__gnu_cxx::__mutex&
get_freelist_mutex()
{
static __gnu_cxx::__mutex freelist_mutex;
return freelist_mutex;
}
static void
_M_destroy_thread_key(void* __id)
{
// Return this thread id record to the front of thread_freelist.
__freelist& freelist = get_freelist();
{
__gnu_cxx::__scoped_lock sentry(get_freelist_mutex());
size_t _M_id = reinterpret_cast<size_t>(__id);
typedef __gnu_cxx::__pool<true>::_Thread_record _Thread_record;
_Thread_record* __tr = &freelist._M_thread_freelist_array[_M_id - 1];
__tr->_M_next = freelist._M_thread_freelist;
freelist._M_thread_freelist = __tr;
}
}
#endif
} // anonymous namespace
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
void
__pool<false>::_M_destroy() throw()
{
if (_M_init && !_M_options._M_force_new)
{
for (size_t __n = 0; __n < _M_bin_size; ++__n)
{
_Bin_record& __bin = _M_bin[__n];
while (__bin._M_address)
{
_Block_address* __tmp = __bin._M_address->_M_next;
::operator delete(__bin._M_address->_M_initial);
__bin._M_address = __tmp;
}
::operator delete(__bin._M_first);
}
::operator delete(_M_bin);
::operator delete(_M_binmap);
}
}
void
__pool<false>::_M_reclaim_block(char* __p, size_t __bytes) throw ()
{
// Round up to power of 2 and figure out which bin to use.
const size_t __which = _M_binmap[__bytes];
_Bin_record& __bin = _M_bin[__which];
char* __c = __p - _M_get_align();
_Block_record* __block = reinterpret_cast<_Block_record*>(__c);
// Single threaded application - return to global pool.
__block->_M_next = __bin._M_first[0];
__bin._M_first[0] = __block;
}
char*
__pool<false>::_M_reserve_block(size_t __bytes, const size_t __thread_id)
{
// Round up to power of 2 and figure out which bin to use.
const size_t __which = _M_binmap[__bytes];
_Bin_record& __bin = _M_bin[__which];
const _Tune& __options = _M_get_options();
const size_t __bin_size = (__options._M_min_bin << __which)
+ __options._M_align;
size_t __block_count = __options._M_chunk_size - sizeof(_Block_address);
__block_count /= __bin_size;
// Get a new block dynamically, set it up for use.
void* __v = ::operator new(__options._M_chunk_size);
_Block_address* __address = static_cast<_Block_address*>(__v);
__address->_M_initial = __v;
__address->_M_next = __bin._M_address;
__bin._M_address = __address;
char* __c = static_cast<char*>(__v) + sizeof(_Block_address);
_Block_record* __block = reinterpret_cast<_Block_record*>(__c);
__bin._M_first[__thread_id] = __block;
while (--__block_count > 0)
{
__c += __bin_size;
__block->_M_next = reinterpret_cast<_Block_record*>(__c);
__block = __block->_M_next;
}
__block->_M_next = 0;
__block = __bin._M_first[__thread_id];
__bin._M_first[__thread_id] = __block->_M_next;
// NB: For alignment reasons, we can't use the first _M_align
// bytes, even when sizeof(_Block_record) < _M_align.
return reinterpret_cast<char*>(__block) + __options._M_align;
}
void
__pool<false>::_M_initialize()
{
// _M_force_new must not change after the first allocate(), which
// in turn calls this method, so if it's false, it's false forever
// and we don't need to return here ever again.
if (_M_options._M_force_new)
{
_M_init = true;
return;
}
// Create the bins.
// Calculate the number of bins required based on _M_max_bytes.
// _M_bin_size is statically-initialized to one.
size_t __bin_size = _M_options._M_min_bin;
while (_M_options._M_max_bytes > __bin_size)
{
__bin_size <<= 1;
++_M_bin_size;
}
// Setup the bin map for quick lookup of the relevant bin.
const size_t __j = (_M_options._M_max_bytes + 1) * sizeof(_Binmap_type);
_M_binmap = static_cast<_Binmap_type*>(::operator new(__j));
_Binmap_type* __bp = _M_binmap;
_Binmap_type __bin_max = _M_options._M_min_bin;
_Binmap_type __bint = 0;
for (_Binmap_type __ct = 0; __ct <= _M_options._M_max_bytes; ++__ct)
{
if (__ct > __bin_max)
{
__bin_max <<= 1;
++__bint;
}
*__bp++ = __bint;
}
// Initialize _M_bin and its members.
void* __v = ::operator new(sizeof(_Bin_record) * _M_bin_size);
_M_bin = static_cast<_Bin_record*>(__v);
for (size_t __n = 0; __n < _M_bin_size; ++__n)
{
_Bin_record& __bin = _M_bin[__n];
__v = ::operator new(sizeof(_Block_record*));
__bin._M_first = static_cast<_Block_record**>(__v);
__bin._M_first[0] = 0;
__bin._M_address = 0;
}
_M_init = true;
}
#ifdef __GTHREADS
void
__pool<true>::_M_destroy() throw()
{
if (_M_init && !_M_options._M_force_new)
{
if (__gthread_active_p())
{
for (size_t __n = 0; __n < _M_bin_size; ++__n)
{
_Bin_record& __bin = _M_bin[__n];
while (__bin._M_address)
{
_Block_address* __tmp = __bin._M_address->_M_next;
::operator delete(__bin._M_address->_M_initial);
__bin._M_address = __tmp;
}
::operator delete(__bin._M_first);
::operator delete(__bin._M_free);
::operator delete(__bin._M_used);
::operator delete(__bin._M_mutex);
}
}
else
{
for (size_t __n = 0; __n < _M_bin_size; ++__n)
{
_Bin_record& __bin = _M_bin[__n];
while (__bin._M_address)
{
_Block_address* __tmp = __bin._M_address->_M_next;
::operator delete(__bin._M_address->_M_initial);
__bin._M_address = __tmp;
}
::operator delete(__bin._M_first);
}
}
::operator delete(_M_bin);
::operator delete(_M_binmap);
}
}
void
__pool<true>::_M_reclaim_block(char* __p, size_t __bytes) throw ()
{
// Round up to power of 2 and figure out which bin to use.
const size_t __which = _M_binmap[__bytes];
const _Bin_record& __bin = _M_bin[__which];
// Know __p not null, assume valid block.
char* __c = __p - _M_get_align();
_Block_record* __block = reinterpret_cast<_Block_record*>(__c);
if (__gthread_active_p())
{
// Calculate the number of records to remove from our freelist:
// in order to avoid too much contention we wait until the
// number of records is "high enough".
const size_t __thread_id = _M_get_thread_id();
const _Tune& __options = _M_get_options();
const size_t __limit = (100 * (_M_bin_size - __which)
* __options._M_freelist_headroom);
size_t __remove = __bin._M_free[__thread_id];
__remove *= __options._M_freelist_headroom;
// NB: We assume that reads of _Atomic_words are atomic.
const size_t __max_threads = __options._M_max_threads + 1;
_Atomic_word* const __reclaimed_base =
reinterpret_cast<_Atomic_word*>(__bin._M_used + __max_threads);
const _Atomic_word __reclaimed = __reclaimed_base[__thread_id];
const size_t __net_used = __bin._M_used[__thread_id] - __reclaimed;
// NB: For performance sake we don't resync every time, in order
// to spare atomic ops. Note that if __reclaimed increased by,
// say, 1024, since the last sync, it means that the other
// threads executed the atomic in the else below at least the
// same number of times (at least, because _M_reserve_block may
// have decreased the counter), therefore one more cannot hurt.
if (__reclaimed > 1024)
{
__bin._M_used[__thread_id] -= __reclaimed;
__atomic_add(&__reclaimed_base[__thread_id], -__reclaimed);
}
if (__remove >= __net_used)
__remove -= __net_used;
else
__remove = 0;
if (__remove > __limit && __remove > __bin._M_free[__thread_id])
{
_Block_record* __first = __bin._M_first[__thread_id];
_Block_record* __tmp = __first;
__remove /= __options._M_freelist_headroom;
const size_t __removed = __remove;
while (--__remove > 0)
__tmp = __tmp->_M_next;
__bin._M_first[__thread_id] = __tmp->_M_next;
__bin._M_free[__thread_id] -= __removed;
__gthread_mutex_lock(__bin._M_mutex);
__tmp->_M_next = __bin._M_first[0];
__bin._M_first[0] = __first;
__bin._M_free[0] += __removed;
__gthread_mutex_unlock(__bin._M_mutex);
}
// Return this block to our list and update counters and
// owner id as needed.
if (__block->_M_thread_id == __thread_id)
--__bin._M_used[__thread_id];
else
__atomic_add(&__reclaimed_base[__block->_M_thread_id], 1);
__block->_M_next = __bin._M_first[__thread_id];
__bin._M_first[__thread_id] = __block;
++__bin._M_free[__thread_id];
}
else
{
// Not using threads, so single threaded application - return
// to global pool.
__block->_M_next = __bin._M_first[0];
__bin._M_first[0] = __block;
}
}
char*
__pool<true>::_M_reserve_block(size_t __bytes, const size_t __thread_id)
{
// Round up to power of 2 and figure out which bin to use.
const size_t __which = _M_binmap[__bytes];
const _Tune& __options = _M_get_options();
const size_t __bin_size = ((__options._M_min_bin << __which)
+ __options._M_align);
size_t __block_count = __options._M_chunk_size - sizeof(_Block_address);
__block_count /= __bin_size;
// Are we using threads?
// - Yes, check if there are free blocks on the global
// list. If so, grab up to __block_count blocks in one
// lock and change ownership. If the global list is
// empty, we allocate a new chunk and add those blocks
// directly to our own freelist (with us as owner).
// - No, all operations are made directly to global pool 0
// no need to lock or change ownership but check for free
// blocks on global list (and if not add new ones) and
// get the first one.
_Bin_record& __bin = _M_bin[__which];
_Block_record* __block = 0;
if (__gthread_active_p())
{
// Resync the _M_used counters.
const size_t __max_threads = __options._M_max_threads + 1;
_Atomic_word* const __reclaimed_base =
reinterpret_cast<_Atomic_word*>(__bin._M_used + __max_threads);
const _Atomic_word __reclaimed = __reclaimed_base[__thread_id];
__bin._M_used[__thread_id] -= __reclaimed;
__atomic_add(&__reclaimed_base[__thread_id], -__reclaimed);
__gthread_mutex_lock(__bin._M_mutex);
if (__bin._M_first[0] == 0)
{
void* __v = ::operator new(__options._M_chunk_size);
_Block_address* __address = static_cast<_Block_address*>(__v);
__address->_M_initial = __v;
__address->_M_next = __bin._M_address;
__bin._M_address = __address;
__gthread_mutex_unlock(__bin._M_mutex);
// No need to hold the lock when we are adding a whole
// chunk to our own list.
char* __c = static_cast<char*>(__v) + sizeof(_Block_address);
__block = reinterpret_cast<_Block_record*>(__c);
__bin._M_free[__thread_id] = __block_count;
__bin._M_first[__thread_id] = __block;
while (--__block_count > 0)
{
__c += __bin_size;
__block->_M_next = reinterpret_cast<_Block_record*>(__c);
__block = __block->_M_next;
}
__block->_M_next = 0;
}
else
{
// Is the number of required blocks greater than or equal
// to the number that can be provided by the global free
// list?
__bin._M_first[__thread_id] = __bin._M_first[0];
if (__block_count >= __bin._M_free[0])
{
__bin._M_free[__thread_id] = __bin._M_free[0];
__bin._M_free[0] = 0;
__bin._M_first[0] = 0;
}
else
{
__bin._M_free[__thread_id] = __block_count;
__bin._M_free[0] -= __block_count;
__block = __bin._M_first[0];
while (--__block_count > 0)
__block = __block->_M_next;
__bin._M_first[0] = __block->_M_next;
__block->_M_next = 0;
}
__gthread_mutex_unlock(__bin._M_mutex);
}
}
else
{
void* __v = ::operator new(__options._M_chunk_size);
_Block_address* __address = static_cast<_Block_address*>(__v);
__address->_M_initial = __v;
__address->_M_next = __bin._M_address;
__bin._M_address = __address;
char* __c = static_cast<char*>(__v) + sizeof(_Block_address);
__block = reinterpret_cast<_Block_record*>(__c);
__bin._M_first[0] = __block;
while (--__block_count > 0)
{
__c += __bin_size;
__block->_M_next = reinterpret_cast<_Block_record*>(__c);
__block = __block->_M_next;
}
__block->_M_next = 0;
}
__block = __bin._M_first[__thread_id];
__bin._M_first[__thread_id] = __block->_M_next;
if (__gthread_active_p())
{
__block->_M_thread_id = __thread_id;
--__bin._M_free[__thread_id];
++__bin._M_used[__thread_id];
}
// NB: For alignment reasons, we can't use the first _M_align
// bytes, even when sizeof(_Block_record) < _M_align.
return reinterpret_cast<char*>(__block) + __options._M_align;
}
void
__pool<true>::_M_initialize()
{
// _M_force_new must not change after the first allocate(),
// which in turn calls this method, so if it's false, it's false
// forever and we don't need to return here ever again.
if (_M_options._M_force_new)
{
_M_init = true;
return;
}
// Create the bins.
// Calculate the number of bins required based on _M_max_bytes.
// _M_bin_size is statically-initialized to one.
size_t __bin_size = _M_options._M_min_bin;
while (_M_options._M_max_bytes > __bin_size)
{
__bin_size <<= 1;
++_M_bin_size;
}
// Setup the bin map for quick lookup of the relevant bin.
const size_t __j = (_M_options._M_max_bytes + 1) * sizeof(_Binmap_type);
_M_binmap = static_cast<_Binmap_type*>(::operator new(__j));
_Binmap_type* __bp = _M_binmap;
_Binmap_type __bin_max = _M_options._M_min_bin;
_Binmap_type __bint = 0;
for (_Binmap_type __ct = 0; __ct <= _M_options._M_max_bytes; ++__ct)
{
if (__ct > __bin_max)
{
__bin_max <<= 1;
++__bint;
}
*__bp++ = __bint;
}
// Initialize _M_bin and its members.
void* __v = ::operator new(sizeof(_Bin_record) * _M_bin_size);
_M_bin = static_cast<_Bin_record*>(__v);
// If __gthread_active_p() create and initialize the list of
// free thread ids. Single threaded applications use thread id 0
// directly and have no need for this.
if (__gthread_active_p())
{
__freelist& freelist = get_freelist();
{
__gnu_cxx::__scoped_lock sentry(get_freelist_mutex());
if (!freelist._M_thread_freelist_array
|| freelist._M_max_threads < _M_options._M_max_threads)
{
const size_t __k = sizeof(_Thread_record)
* _M_options._M_max_threads;
__v = ::operator new(__k);
_M_thread_freelist = static_cast<_Thread_record*>(__v);
// NOTE! The first assignable thread id is 1 since the
// global pool uses id 0
size_t __i;
for (__i = 1; __i < _M_options._M_max_threads; ++__i)
{
_Thread_record& __tr = _M_thread_freelist[__i - 1];
__tr._M_next = &_M_thread_freelist[__i];
__tr._M_id = __i;
}
// Set last record.
_M_thread_freelist[__i - 1]._M_next = 0;
_M_thread_freelist[__i - 1]._M_id = __i;
if (!freelist._M_thread_freelist_array)
{
// Initialize per thread key to hold pointer to
// _M_thread_freelist.
__gthread_key_create(&freelist._M_key,
::_M_destroy_thread_key);
freelist._M_thread_freelist = _M_thread_freelist;
}
else
{
_Thread_record* _M_old_freelist
= freelist._M_thread_freelist;
_Thread_record* _M_old_array
= freelist._M_thread_freelist_array;
freelist._M_thread_freelist
= &_M_thread_freelist[_M_old_freelist - _M_old_array];
while (_M_old_freelist)
{
size_t next_id;
if (_M_old_freelist->_M_next)
next_id = _M_old_freelist->_M_next - _M_old_array;
else
next_id = freelist._M_max_threads;
_M_thread_freelist[_M_old_freelist->_M_id - 1]._M_next
= &_M_thread_freelist[next_id];
_M_old_freelist = _M_old_freelist->_M_next;
}
::operator delete(static_cast<void*>(_M_old_array));
}
freelist._M_thread_freelist_array = _M_thread_freelist;
freelist._M_max_threads = _M_options._M_max_threads;
}
}
const size_t __max_threads = _M_options._M_max_threads + 1;
for (size_t __n = 0; __n < _M_bin_size; ++__n)
{
_Bin_record& __bin = _M_bin[__n];
__v = ::operator new(sizeof(_Block_record*) * __max_threads);
std::memset(__v, 0, sizeof(_Block_record*) * __max_threads);
__bin._M_first = static_cast<_Block_record**>(__v);
__bin._M_address = 0;
__v = ::operator new(sizeof(size_t) * __max_threads);
std::memset(__v, 0, sizeof(size_t) * __max_threads);
__bin._M_free = static_cast<size_t*>(__v);
__v = ::operator new(sizeof(size_t) * __max_threads
+ sizeof(_Atomic_word) * __max_threads);
std::memset(__v, 0, (sizeof(size_t) * __max_threads
+ sizeof(_Atomic_word) * __max_threads));
__bin._M_used = static_cast<size_t*>(__v);
__v = ::operator new(sizeof(__gthread_mutex_t));
__bin._M_mutex = static_cast<__gthread_mutex_t*>(__v);
#ifdef __GTHREAD_MUTEX_INIT
{
// Do not copy a POSIX/gthr mutex once in use.
__gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
*__bin._M_mutex = __tmp;
}
#else
{ __GTHREAD_MUTEX_INIT_FUNCTION(__bin._M_mutex); }
#endif
}
}
else
{
for (size_t __n = 0; __n < _M_bin_size; ++__n)
{
_Bin_record& __bin = _M_bin[__n];
__v = ::operator new(sizeof(_Block_record*));
__bin._M_first = static_cast<_Block_record**>(__v);
__bin._M_first[0] = 0;
__bin._M_address = 0;
}
}
_M_init = true;
}
size_t
__pool<true>::_M_get_thread_id()
{
// If we have thread support and it's active we check the thread
// key value and return its id or if it's not set we take the
// first record from _M_thread_freelist and sets the key and
// returns its id.
if (__gthread_active_p())
{
__freelist& freelist = get_freelist();
void* v = __gthread_getspecific(freelist._M_key);
size_t _M_id = (size_t)v;
if (_M_id == 0)
{
{
__gnu_cxx::__scoped_lock sentry(get_freelist_mutex());
if (freelist._M_thread_freelist)
{
_M_id = freelist._M_thread_freelist->_M_id;
freelist._M_thread_freelist
= freelist._M_thread_freelist->_M_next;
}
}
__gthread_setspecific(freelist._M_key, (void*)_M_id);
}
return _M_id >= _M_options._M_max_threads ? 0 : _M_id;
}
// Otherwise (no thread support or inactive) all requests are
// served from the global pool 0.
return 0;
}
// XXX GLIBCXX_ABI Deprecated
void
__pool<true>::_M_destroy_thread_key(void*) throw () { }
// XXX GLIBCXX_ABI Deprecated
void
__pool<true>::_M_initialize(__destroy_handler)
{
// _M_force_new must not change after the first allocate(),
// which in turn calls this method, so if it's false, it's false
// forever and we don't need to return here ever again.
if (_M_options._M_force_new)
{
_M_init = true;
return;
}
// Create the bins.
// Calculate the number of bins required based on _M_max_bytes.
// _M_bin_size is statically-initialized to one.
size_t __bin_size = _M_options._M_min_bin;
while (_M_options._M_max_bytes > __bin_size)
{
__bin_size <<= 1;
++_M_bin_size;
}
// Setup the bin map for quick lookup of the relevant bin.
const size_t __j = (_M_options._M_max_bytes + 1) * sizeof(_Binmap_type);
_M_binmap = static_cast<_Binmap_type*>(::operator new(__j));
_Binmap_type* __bp = _M_binmap;
_Binmap_type __bin_max = _M_options._M_min_bin;
_Binmap_type __bint = 0;
for (_Binmap_type __ct = 0; __ct <= _M_options._M_max_bytes; ++__ct)
{
if (__ct > __bin_max)
{
__bin_max <<= 1;
++__bint;
}
*__bp++ = __bint;
}
// Initialize _M_bin and its members.
void* __v = ::operator new(sizeof(_Bin_record) * _M_bin_size);
_M_bin = static_cast<_Bin_record*>(__v);
// If __gthread_active_p() create and initialize the list of
// free thread ids. Single threaded applications use thread id 0
// directly and have no need for this.
if (__gthread_active_p())
{
__freelist& freelist = get_freelist();
{
__gnu_cxx::__scoped_lock sentry(get_freelist_mutex());
if (!freelist._M_thread_freelist_array
|| freelist._M_max_threads < _M_options._M_max_threads)
{
const size_t __k = sizeof(_Thread_record)
* _M_options._M_max_threads;
__v = ::operator new(__k);
_M_thread_freelist = static_cast<_Thread_record*>(__v);
// NOTE! The first assignable thread id is 1 since the
// global pool uses id 0
size_t __i;
for (__i = 1; __i < _M_options._M_max_threads; ++__i)
{
_Thread_record& __tr = _M_thread_freelist[__i - 1];
__tr._M_next = &_M_thread_freelist[__i];
__tr._M_id = __i;
}
// Set last record.
_M_thread_freelist[__i - 1]._M_next = 0;
_M_thread_freelist[__i - 1]._M_id = __i;
if (!freelist._M_thread_freelist_array)
{
// Initialize per thread key to hold pointer to
// _M_thread_freelist.
__gthread_key_create(&freelist._M_key,
::_M_destroy_thread_key);
freelist._M_thread_freelist = _M_thread_freelist;
}
else
{
_Thread_record* _M_old_freelist
= freelist._M_thread_freelist;
_Thread_record* _M_old_array
= freelist._M_thread_freelist_array;
freelist._M_thread_freelist
= &_M_thread_freelist[_M_old_freelist - _M_old_array];
while (_M_old_freelist)
{
size_t next_id;
if (_M_old_freelist->_M_next)
next_id = _M_old_freelist->_M_next - _M_old_array;
else
next_id = freelist._M_max_threads;
_M_thread_freelist[_M_old_freelist->_M_id - 1]._M_next
= &_M_thread_freelist[next_id];
_M_old_freelist = _M_old_freelist->_M_next;
}
::operator delete(static_cast<void*>(_M_old_array));
}
freelist._M_thread_freelist_array = _M_thread_freelist;
freelist._M_max_threads = _M_options._M_max_threads;
}
}
const size_t __max_threads = _M_options._M_max_threads + 1;
for (size_t __n = 0; __n < _M_bin_size; ++__n)
{
_Bin_record& __bin = _M_bin[__n];
__v = ::operator new(sizeof(_Block_record*) * __max_threads);
std::memset(__v, 0, sizeof(_Block_record*) * __max_threads);
__bin._M_first = static_cast<_Block_record**>(__v);
__bin._M_address = 0;
__v = ::operator new(sizeof(size_t) * __max_threads);
std::memset(__v, 0, sizeof(size_t) * __max_threads);
__bin._M_free = static_cast<size_t*>(__v);
__v = ::operator new(sizeof(size_t) * __max_threads +
sizeof(_Atomic_word) * __max_threads);
std::memset(__v, 0, (sizeof(size_t) * __max_threads
+ sizeof(_Atomic_word) * __max_threads));
__bin._M_used = static_cast<size_t*>(__v);
__v = ::operator new(sizeof(__gthread_mutex_t));
__bin._M_mutex = static_cast<__gthread_mutex_t*>(__v);
#ifdef __GTHREAD_MUTEX_INIT
{
// Do not copy a POSIX/gthr mutex once in use.
__gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
*__bin._M_mutex = __tmp;
}
#else
{ __GTHREAD_MUTEX_INIT_FUNCTION(__bin._M_mutex); }
#endif
}
}
else
{
for (size_t __n = 0; __n < _M_bin_size; ++__n)
{
_Bin_record& __bin = _M_bin[__n];
__v = ::operator new(sizeof(_Block_record*));
__bin._M_first = static_cast<_Block_record**>(__v);
__bin._M_first[0] = 0;
__bin._M_address = 0;
}
}
_M_init = true;
}
#endif
// Instantiations.
template class __mt_alloc<char>;
template class __mt_alloc<wchar_t>;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,106 @@
// std::numpunct implementation details, generic version -*- C++ -*-
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.3.1.2 numpunct virtual functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<>
void
numpunct<char>::_M_initialize_numpunct(__c_locale)
{
// "C" locale
if (!_M_data)
_M_data = new __numpunct_cache<char>;
_M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_use_grouping = false;
_M_data->_M_decimal_point = '.';
_M_data->_M_thousands_sep = ',';
for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
_M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i];
for (size_t __i = 0; __i < __num_base::_S_iend; ++__i)
_M_data->_M_atoms_in[__i] = __num_base::_S_atoms_in[__i];
_M_data->_M_truename = "true";
_M_data->_M_truename_size = 4;
_M_data->_M_falsename = "false";
_M_data->_M_falsename_size = 5;
}
template<>
numpunct<char>::~numpunct()
{ delete _M_data; }
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
void
numpunct<wchar_t>::_M_initialize_numpunct(__c_locale)
{
// "C" locale
if (!_M_data)
_M_data = new __numpunct_cache<wchar_t>;
_M_data->_M_grouping = "";
_M_data->_M_grouping_size = 0;
_M_data->_M_use_grouping = false;
_M_data->_M_decimal_point = L'.';
_M_data->_M_thousands_sep = L',';
// Use ctype::widen code without the facet...
for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
_M_data->_M_atoms_out[__i] =
static_cast<wchar_t>(__num_base::_S_atoms_out[__i]);
for (size_t __i = 0; __i < __num_base::_S_iend; ++__i)
_M_data->_M_atoms_in[__i] =
static_cast<wchar_t>(__num_base::_S_atoms_in[__i]);
_M_data->_M_truename = L"true";
_M_data->_M_truename_size = 4;
_M_data->_M_falsename = L"false";
_M_data->_M_falsename_size = 5;
}
template<>
numpunct<wchar_t>::~numpunct()
{ delete _M_data; }
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,117 @@
// Explicit instantiation file.
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:
//
#include <ostream>
#include <iomanip>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// ostream
template class basic_ostream<char>;
template ostream& endl(ostream&);
template ostream& ends(ostream&);
template ostream& flush(ostream&);
template ostream& operator<<(ostream&, char);
template ostream& operator<<(ostream&, unsigned char);
template ostream& operator<<(ostream&, signed char);
template ostream& operator<<(ostream&, const char*);
template ostream& operator<<(ostream&, const unsigned char*);
template ostream& operator<<(ostream&, const signed char*);
template ostream& operator<<(ostream&, _Setfill<char>);
template ostream& operator<<(ostream&, _Setiosflags);
template ostream& operator<<(ostream&, _Resetiosflags);
template ostream& operator<<(ostream&, _Setbase);
template ostream& operator<<(ostream&, _Setprecision);
template ostream& operator<<(ostream&, _Setw);
template ostream& __ostream_insert(ostream&, const char*, streamsize);
template ostream& ostream::_M_insert(long);
template ostream& ostream::_M_insert(unsigned long);
template ostream& ostream::_M_insert(bool);
#ifdef _GLIBCXX_USE_LONG_LONG
template ostream& ostream::_M_insert(long long);
template ostream& ostream::_M_insert(unsigned long long);
#endif
template ostream& ostream::_M_insert(double);
template ostream& ostream::_M_insert(long double);
template ostream& ostream::_M_insert(const void*);
#ifdef _GLIBCXX_USE_WCHAR_T
template class basic_ostream<wchar_t>;
template wostream& endl(wostream&);
template wostream& ends(wostream&);
template wostream& flush(wostream&);
template wostream& operator<<(wostream&, wchar_t);
template wostream& operator<<(wostream&, char);
template wostream& operator<<(wostream&, const wchar_t*);
template wostream& operator<<(wostream&, const char*);
template wostream& operator<<(wostream&, _Setfill<wchar_t>);
template wostream& operator<<(wostream&, _Setiosflags);
template wostream& operator<<(wostream&, _Resetiosflags);
template wostream& operator<<(wostream&, _Setbase);
template wostream& operator<<(wostream&, _Setprecision);
template wostream& operator<<(wostream&, _Setw);
template wostream& __ostream_insert(wostream&, const wchar_t*, streamsize);
template wostream& wostream::_M_insert(long);
template wostream& wostream::_M_insert(unsigned long);
template wostream& wostream::_M_insert(bool);
#ifdef _GLIBCXX_USE_LONG_LONG
template wostream& wostream::_M_insert(long long);
template wostream& wostream::_M_insert(unsigned long long);
#endif
template wostream& wostream::_M_insert(double);
template wostream& wostream::_M_insert(long double);
template wostream& wostream::_M_insert(const void*);
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
// XXX GLIBCXX_ABI Deprecated
#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
extern "C" void ldbl (void) __attribute__ ((alias (#dbl), weak))
_GLIBCXX_LDBL_COMPAT (_ZNSolsEd, _ZNSolsEe);
#ifdef _GLIBCXX_USE_WCHAR_T
_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEd,
_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEe);
#endif
_GLIBCXX_LDBL_COMPAT (_ZNSo9_M_insertIdEERSoT_,
_ZNSo9_M_insertIeEERSoT_);
#ifdef _GLIBCXX_USE_WCHAR_T
_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIdEERS2_T_,
_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIeEERS2_T_);
#endif
#endif // _GLIBCXX_LONG_DOUBLE_COMPAT

View File

@@ -0,0 +1,42 @@
// Default settings for parallel mode -*- C++ -*-
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <parallel/settings.h>
namespace
{
__gnu_parallel::_Settings s;
}
namespace __gnu_parallel
{
const _Settings&
_Settings::get() throw()
{ return s; }
// XXX MT
void
_Settings::set(_Settings& obj) throw()
{ s = obj; }
}

View File

@@ -0,0 +1,177 @@
// Allocator details.
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:
//
#include <bits/c++config.h>
#include <cstdlib>
#include <ext/pool_allocator.h>
namespace
{
__gnu_cxx::__mutex&
get_palloc_mutex()
{
static __gnu_cxx::__mutex palloc_mutex;
return palloc_mutex;
}
} // anonymous namespace
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Definitions for __pool_alloc_base.
__pool_alloc_base::_Obj* volatile*
__pool_alloc_base::_M_get_free_list(size_t __bytes) throw ()
{
size_t __i = ((__bytes + (size_t)_S_align - 1) / (size_t)_S_align - 1);
return _S_free_list + __i;
}
__mutex&
__pool_alloc_base::_M_get_mutex() throw ()
{ return get_palloc_mutex(); }
// Allocate memory in large chunks in order to avoid fragmenting the
// heap too much. Assume that __n is properly aligned. We hold the
// allocation lock.
char*
__pool_alloc_base::_M_allocate_chunk(size_t __n, int& __nobjs)
{
char* __result;
size_t __total_bytes = __n * __nobjs;
size_t __bytes_left = _S_end_free - _S_start_free;
if (__bytes_left >= __total_bytes)
{
__result = _S_start_free;
_S_start_free += __total_bytes;
return __result ;
}
else if (__bytes_left >= __n)
{
__nobjs = (int)(__bytes_left / __n);
__total_bytes = __n * __nobjs;
__result = _S_start_free;
_S_start_free += __total_bytes;
return __result;
}
else
{
// Try to make use of the left-over piece.
if (__bytes_left > 0)
{
_Obj* volatile* __free_list = _M_get_free_list(__bytes_left);
((_Obj*)(void*)_S_start_free)->_M_free_list_link = *__free_list;
*__free_list = (_Obj*)(void*)_S_start_free;
}
size_t __bytes_to_get = (2 * __total_bytes
+ _M_round_up(_S_heap_size >> 4));
__try
{
_S_start_free = static_cast<char*>(::operator new(__bytes_to_get));
}
__catch(const std::bad_alloc&)
{
// Try to make do with what we have. That can't hurt. We
// do not try smaller requests, since that tends to result
// in disaster on multi-process machines.
size_t __i = __n;
for (; __i <= (size_t) _S_max_bytes; __i += (size_t) _S_align)
{
_Obj* volatile* __free_list = _M_get_free_list(__i);
_Obj* __p = *__free_list;
if (__p != 0)
{
*__free_list = __p->_M_free_list_link;
_S_start_free = (char*)__p;
_S_end_free = _S_start_free + __i;
return _M_allocate_chunk(__n, __nobjs);
// Any leftover piece will eventually make it to the
// right free list.
}
}
// What we have wasn't enough. Rethrow.
_S_start_free = _S_end_free = 0; // We have no chunk.
__throw_exception_again;
}
_S_heap_size += __bytes_to_get;
_S_end_free = _S_start_free + __bytes_to_get;
return _M_allocate_chunk(__n, __nobjs);
}
}
// Returns an object of size __n, and optionally adds to "size
// __n"'s free list. We assume that __n is properly aligned. We
// hold the allocation lock.
void*
__pool_alloc_base::_M_refill(size_t __n)
{
int __nobjs = 20;
char* __chunk = _M_allocate_chunk(__n, __nobjs);
_Obj* volatile* __free_list;
_Obj* __result;
_Obj* __current_obj;
_Obj* __next_obj;
if (__nobjs == 1)
return __chunk;
__free_list = _M_get_free_list(__n);
// Build free list in chunk.
__result = (_Obj*)(void*)__chunk;
*__free_list = __next_obj = (_Obj*)(void*)(__chunk + __n);
for (int __i = 1; ; __i++)
{
__current_obj = __next_obj;
__next_obj = (_Obj*)(void*)((char*)__next_obj + __n);
if (__nobjs - 1 == __i)
{
__current_obj->_M_free_list_link = 0;
break;
}
else
__current_obj->_M_free_list_link = __next_obj;
}
return __result;
}
__pool_alloc_base::_Obj* volatile __pool_alloc_base::_S_free_list[_S_free_list_size];
char* __pool_alloc_base::_S_start_free = 0;
char* __pool_alloc_base::_S_end_free = 0;
size_t __pool_alloc_base::_S_heap_size = 0;
// Instantiations.
template class __pool_alloc<char>;
template class __pool_alloc<wchar_t>;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,48 @@
// Explicit instantiation file.
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:
//
#include <sstream>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template class basic_stringbuf<char>;
template class basic_istringstream<char>;
template class basic_ostringstream<char>;
template class basic_stringstream<char>;
#ifdef _GLIBCXX_USE_WCHAR_T
template class basic_stringbuf<wchar_t>;
template class basic_istringstream<wchar_t>;
template class basic_ostringstream<wchar_t>;
template class basic_stringstream<wchar_t>;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,90 @@
// Methods for Exception Support for -*- C++ -*-
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 19.1 Exception classes
//
#include <string>
#include <stdexcept>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
logic_error::logic_error(const string& __arg)
: exception(), _M_msg(__arg) { }
logic_error::~logic_error() _GLIBCXX_USE_NOEXCEPT { }
const char*
logic_error::what() const _GLIBCXX_USE_NOEXCEPT
{ return _M_msg.c_str(); }
domain_error::domain_error(const string& __arg)
: logic_error(__arg) { }
domain_error::~domain_error() _GLIBCXX_USE_NOEXCEPT { }
invalid_argument::invalid_argument(const string& __arg)
: logic_error(__arg) { }
invalid_argument::~invalid_argument() _GLIBCXX_USE_NOEXCEPT { }
length_error::length_error(const string& __arg)
: logic_error(__arg) { }
length_error::~length_error() _GLIBCXX_USE_NOEXCEPT { }
out_of_range::out_of_range(const string& __arg)
: logic_error(__arg) { }
out_of_range::~out_of_range() _GLIBCXX_USE_NOEXCEPT { }
runtime_error::runtime_error(const string& __arg)
: exception(), _M_msg(__arg) { }
runtime_error::~runtime_error() _GLIBCXX_USE_NOEXCEPT { }
const char*
runtime_error::what() const _GLIBCXX_USE_NOEXCEPT
{ return _M_msg.c_str(); }
range_error::range_error(const string& __arg)
: runtime_error(__arg) { }
range_error::~range_error() _GLIBCXX_USE_NOEXCEPT { }
overflow_error::overflow_error(const string& __arg)
: runtime_error(__arg) { }
overflow_error::~overflow_error() _GLIBCXX_USE_NOEXCEPT { }
underflow_error::underflow_error(const string& __arg)
: runtime_error(__arg) { }
underflow_error::~underflow_error() _GLIBCXX_USE_NOEXCEPT { }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,63 @@
// Explicit instantiation file.
// Copyright (C) 1997-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:
//
#include <ios>
#include <streambuf>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// streambuf
template class basic_streambuf<char>;
template
streamsize
__copy_streambufs(basic_streambuf<char>*, basic_streambuf<char>*);
template
streamsize
__copy_streambufs_eof(basic_streambuf<char>*,
basic_streambuf<char>*, bool&);
#ifdef _GLIBCXX_USE_WCHAR_T
// wstreambuf
template class basic_streambuf<wchar_t>;
template
streamsize
__copy_streambufs(basic_streambuf<wchar_t>*, basic_streambuf<wchar_t>*);
template
streamsize
__copy_streambufs_eof(basic_streambuf<wchar_t>*,
basic_streambuf<wchar_t>*, bool&);
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,116 @@
// Stream buffer classes -*- C++ -*-
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 27.5 Stream buffers
//
#include <streambuf>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<>
streamsize
__copy_streambufs_eof(basic_streambuf<char>* __sbin,
basic_streambuf<char>* __sbout, bool& __ineof)
{
typedef basic_streambuf<char>::traits_type traits_type;
streamsize __ret = 0;
__ineof = true;
traits_type::int_type __c = __sbin->sgetc();
while (!traits_type::eq_int_type(__c, traits_type::eof()))
{
const streamsize __n = __sbin->egptr() - __sbin->gptr();
if (__n > 1)
{
const streamsize __wrote = __sbout->sputn(__sbin->gptr(), __n);
__sbin->__safe_gbump(__wrote);
__ret += __wrote;
if (__wrote < __n)
{
__ineof = false;
break;
}
__c = __sbin->underflow();
}
else
{
__c = __sbout->sputc(traits_type::to_char_type(__c));
if (traits_type::eq_int_type(__c, traits_type::eof()))
{
__ineof = false;
break;
}
++__ret;
__c = __sbin->snextc();
}
}
return __ret;
}
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
streamsize
__copy_streambufs_eof(basic_streambuf<wchar_t>* __sbin,
basic_streambuf<wchar_t>* __sbout, bool& __ineof)
{
typedef basic_streambuf<wchar_t>::traits_type traits_type;
streamsize __ret = 0;
__ineof = true;
traits_type::int_type __c = __sbin->sgetc();
while (!traits_type::eq_int_type(__c, traits_type::eof()))
{
const streamsize __n = __sbin->egptr() - __sbin->gptr();
if (__n > 1)
{
const streamsize __wrote = __sbout->sputn(__sbin->gptr(), __n);
__sbin->__safe_gbump(__wrote);
__ret += __wrote;
if (__wrote < __n)
{
__ineof = false;
break;
}
__c = __sbin->underflow();
}
else
{
__c = __sbout->sputc(traits_type::to_char_type(__c));
if (traits_type::eq_int_type(__c, traits_type::eof()))
{
__ineof = false;
break;
}
++__ret;
__c = __sbin->snextc();
}
}
return __ret;
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,417 @@
// strstream definitions -*- C++ -*-
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
* Copyright (c) 1998
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
// Implementation of the classes in header <strstream>.
// WARNING: The classes defined in <strstream> are DEPRECATED. This
// header is defined in section D.7.1 of the C++ standard, and it
// MAY BE REMOVED in a future standard revision. You should use the
// header <sstream> instead.
#include <strstream>
#include <algorithm>
#include <new>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
strstreambuf::strstreambuf(streamsize initial_capacity)
: _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(true),
_M_frozen(false), _M_constant(false)
{
streamsize n = std::max(initial_capacity, streamsize(16));
char* buf = _M_alloc(n);
if (buf)
{
setp(buf, buf + n);
setg(buf, buf, buf);
}
}
strstreambuf::strstreambuf(void* (*alloc_f)(size_t), void (*free_f)(void*))
: _Base(), _M_alloc_fun(alloc_f), _M_free_fun(free_f), _M_dynamic(true),
_M_frozen(false), _M_constant(false)
{
streamsize n = 16;
char* buf = _M_alloc(n);
if (buf)
{
setp(buf, buf + n);
setg(buf, buf, buf);
}
}
strstreambuf::strstreambuf(char* get, streamsize n, char* put) throw ()
: _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false),
_M_frozen(false), _M_constant(false)
{ _M_setup(get, put, n); }
strstreambuf::strstreambuf(signed char* get, streamsize n, signed char* put) throw ()
: _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false),
_M_frozen(false), _M_constant(false)
{ _M_setup(reinterpret_cast<char*>(get), reinterpret_cast<char*>(put), n); }
strstreambuf::strstreambuf(unsigned char* get, streamsize n,
unsigned char* put) throw ()
: _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false),
_M_frozen(false), _M_constant(false)
{ _M_setup(reinterpret_cast<char*>(get), reinterpret_cast<char*>(put), n); }
strstreambuf::strstreambuf(const char* get, streamsize n) throw ()
: _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false),
_M_frozen(false), _M_constant(true)
{ _M_setup(const_cast<char*>(get), 0, n); }
strstreambuf::strstreambuf(const signed char* get, streamsize n) throw ()
: _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false),
_M_frozen(false), _M_constant(true)
{ _M_setup(reinterpret_cast<char*>(const_cast<signed char*>(get)), 0, n); }
strstreambuf::strstreambuf(const unsigned char* get, streamsize n) throw ()
: _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false),
_M_frozen(false), _M_constant(true)
{ _M_setup(reinterpret_cast<char*>(const_cast<unsigned char*>(get)), 0, n); }
strstreambuf::~strstreambuf()
{
if (_M_dynamic && !_M_frozen)
_M_free(eback());
}
void
strstreambuf::freeze(bool frozenflag) throw ()
{
if (_M_dynamic)
_M_frozen = frozenflag;
}
char*
strstreambuf::str() throw ()
{
freeze(true);
return eback();
}
int
strstreambuf::pcount() const throw ()
{ return pptr() ? pptr() - pbase() : 0; }
strstreambuf::int_type
strstreambuf::overflow(int_type c)
{
if (c == traits_type::eof())
return traits_type::not_eof(c);
// Try to expand the buffer.
if (pptr() == epptr() && _M_dynamic && !_M_frozen && !_M_constant)
{
ptrdiff_t old_size = epptr() - pbase();
ptrdiff_t new_size = std::max(ptrdiff_t(2 * old_size), ptrdiff_t(1));
char* buf = _M_alloc(new_size);
if (buf)
{
memcpy(buf, pbase(), old_size);
char* old_buffer = pbase();
bool reposition_get = false;
ptrdiff_t old_get_offset;
if (gptr() != 0)
{
reposition_get = true;
old_get_offset = gptr() - eback();
}
setp(buf, buf + new_size);
__safe_pbump(old_size);
if (reposition_get)
setg(buf, buf + old_get_offset, buf +
std::max(old_get_offset, old_size));
_M_free(old_buffer);
}
}
if (pptr() != epptr())
{
*pptr() = c;
pbump(1);
return c;
}
else
return traits_type::eof();
}
strstreambuf::int_type
strstreambuf::pbackfail(int_type c)
{
if (gptr() != eback())
{
if (c == _Traits::eof())
{
gbump(-1);
return _Traits::not_eof(c);
}
else if (c == _Traits::to_int_type(gptr()[-1]))
{ // KLUDGE
gbump(-1);
return c;
}
else if (!_M_constant)
{
gbump(-1);
*gptr() = c;
return c;
}
}
return _Traits::eof();
}
strstreambuf::int_type
strstreambuf::underflow()
{
if (gptr() == egptr() && pptr() && pptr() > egptr())
setg(eback(), gptr(), pptr());
if (gptr() != egptr())
return (unsigned char) *gptr();
else
return _Traits::eof();
}
basic_streambuf<char, char_traits<char> >*
strstreambuf::setbuf(char*, streamsize)
{ return this; }
strstreambuf::pos_type
strstreambuf::seekoff(off_type off, ios_base::seekdir dir,
ios_base::openmode mode)
{
bool do_get = false;
bool do_put = false;
if ((mode & (ios_base::in | ios_base::out))
== (ios_base::in | ios_base::out) &&
(dir == ios_base::beg || dir == ios_base::end))
do_get = do_put = true;
else if (mode & ios_base::in)
do_get = true;
else if (mode & ios_base::out)
do_put = true;
// !gptr() is here because, according to D.7.1 paragraph 4, the seekable
// area is undefined if there is no get area.
if ((!do_get && !do_put) || (do_put && !pptr()) || !gptr())
return pos_type(off_type(-1));
char* seeklow = eback();
char* seekhigh = epptr() ? epptr() : egptr();
off_type newoff;
switch (dir)
{
case ios_base::beg:
newoff = 0;
break;
case ios_base::end:
newoff = seekhigh - seeklow;
break;
case ios_base::cur:
newoff = do_put ? pptr() - seeklow : gptr() - seeklow;
break;
default:
return pos_type(off_type(-1));
}
off += newoff;
if (off < 0 || off > seekhigh - seeklow)
return pos_type(off_type(-1));
if (do_put)
{
if (seeklow + off < pbase())
{
setp(seeklow, epptr());
__safe_pbump(off);
}
else
{
setp(pbase(), epptr());
__safe_pbump(off - (pbase() - seeklow));
}
}
if (do_get)
{
if (off <= egptr() - seeklow)
setg(seeklow, seeklow + off, egptr());
else if (off <= pptr() - seeklow)
setg(seeklow, seeklow + off, pptr());
else
setg(seeklow, seeklow + off, epptr());
}
return pos_type(newoff);
}
strstreambuf::pos_type
strstreambuf::seekpos(pos_type pos, ios_base::openmode mode)
{ return seekoff(pos - pos_type(off_type(0)), ios_base::beg, mode); }
char*
strstreambuf::_M_alloc(size_t n)
{
if (_M_alloc_fun)
return static_cast<char*>(_M_alloc_fun(n));
else
return new char[n];
}
void
strstreambuf::_M_free(char* p)
{
if (p)
{
if (_M_free_fun)
_M_free_fun(p);
else
delete[] p;
}
}
void
strstreambuf::_M_setup(char* get, char* put, streamsize n) throw ()
{
if (get)
{
size_t N = n > 0 ? size_t(n) : n == 0 ? strlen(get) : size_t(INT_MAX);
if (put)
{
setg(get, get, put);
setp(put, put + N);
}
else
setg(get, get, get + N);
}
}
istrstream::istrstream(char* s)
: basic_ios<char>(), basic_istream<char>(0), _M_buf(s, 0)
{ basic_ios<char>::init(&_M_buf); }
istrstream::istrstream(const char* s)
: basic_ios<char>(), basic_istream<char>(0), _M_buf(s, 0)
{ basic_ios<char>::init(&_M_buf); }
istrstream::istrstream(char* s, streamsize n)
: basic_ios<char>(), basic_istream<char>(0), _M_buf(s, n)
{ basic_ios<char>::init(&_M_buf); }
istrstream::istrstream(const char* s, streamsize n)
: basic_ios<char>(), basic_istream<char>(0), _M_buf(s, n)
{ basic_ios<char>::init(&_M_buf); }
istrstream::~istrstream() { }
strstreambuf*
istrstream::rdbuf() const throw ()
{ return const_cast<strstreambuf*>(&_M_buf); }
char*
istrstream::str() throw ()
{ return _M_buf.str(); }
ostrstream::ostrstream()
: basic_ios<char>(), basic_ostream<char>(0), _M_buf()
{ basic_ios<char>::init(&_M_buf); }
ostrstream::ostrstream(char* s, int n, ios_base::openmode mode)
: basic_ios<char>(), basic_ostream<char>(0),
_M_buf(s, n, mode & ios_base::app ? s + strlen(s) : s)
{ basic_ios<char>::init(&_M_buf); }
ostrstream::~ostrstream() {}
strstreambuf*
ostrstream::rdbuf() const throw ()
{ return const_cast<strstreambuf*>(&_M_buf); }
void
ostrstream::freeze(bool freezeflag) throw ()
{ _M_buf.freeze(freezeflag); }
char*
ostrstream::str() throw ()
{ return _M_buf.str(); }
int
ostrstream::pcount() const throw ()
{ return _M_buf.pcount(); }
strstream::strstream()
: basic_ios<char>(), basic_iostream<char>(0), _M_buf()
{ basic_ios<char>::init(&_M_buf); }
strstream::strstream(char* s, int n, ios_base::openmode mode)
: basic_ios<char>(), basic_iostream<char>(0),
_M_buf(s, n, mode & ios_base::app ? s + strlen(s) : s)
{ basic_ios<char>::init(&_M_buf); }
strstream::~strstream() { }
strstreambuf*
strstream::rdbuf() const throw ()
{ return const_cast<strstreambuf*>(&_M_buf); }
void
strstream::freeze(bool freezeflag) throw ()
{ _M_buf.freeze(freezeflag); }
int
strstream::pcount() const throw ()
{ return _M_buf.pcount(); }
char*
strstream::str() throw ()
{ return _M_buf.str(); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,211 @@
// std::time_get, std::time_put implementation, generic version -*- C++ -*-
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <cstdlib>
#include <cstring>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<>
void
__timepunct<char>::
_M_put(char* __s, size_t __maxlen, const char* __format,
const tm* __tm) const throw()
{
char* __old = setlocale(LC_ALL, 0);
const size_t __llen = strlen(__old) + 1;
char* __sav = new char[__llen];
memcpy(__sav, __old, __llen);
setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = strftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __sav);
delete [] __sav;
// Make sure __s is null terminated.
if (__len == 0)
__s[0] = '\0';
}
template<>
void
__timepunct<char>::_M_initialize_timepunct(__c_locale)
{
// "C" locale.
if (!_M_data)
_M_data = new __timepunct_cache<char>;
_M_data->_M_date_format = "%m/%d/%y";
_M_data->_M_date_era_format = "%m/%d/%y";
_M_data->_M_time_format = "%H:%M:%S";
_M_data->_M_time_era_format = "%H:%M:%S";
_M_data->_M_date_time_format = "";
_M_data->_M_date_time_era_format = "";
_M_data->_M_am = "AM";
_M_data->_M_pm = "PM";
_M_data->_M_am_pm_format = "";
// Day names, starting with "C"'s Sunday.
_M_data->_M_day1 = "Sunday";
_M_data->_M_day2 = "Monday";
_M_data->_M_day3 = "Tuesday";
_M_data->_M_day4 = "Wednesday";
_M_data->_M_day5 = "Thursday";
_M_data->_M_day6 = "Friday";
_M_data->_M_day7 = "Saturday";
// Abbreviated day names, starting with "C"'s Sun.
_M_data->_M_aday1 = "Sun";
_M_data->_M_aday2 = "Mon";
_M_data->_M_aday3 = "Tue";
_M_data->_M_aday4 = "Wed";
_M_data->_M_aday5 = "Thu";
_M_data->_M_aday6 = "Fri";
_M_data->_M_aday7 = "Sat";
// Month names, starting with "C"'s January.
_M_data->_M_month01 = "January";
_M_data->_M_month02 = "February";
_M_data->_M_month03 = "March";
_M_data->_M_month04 = "April";
_M_data->_M_month05 = "May";
_M_data->_M_month06 = "June";
_M_data->_M_month07 = "July";
_M_data->_M_month08 = "August";
_M_data->_M_month09 = "September";
_M_data->_M_month10 = "October";
_M_data->_M_month11 = "November";
_M_data->_M_month12 = "December";
// Abbreviated month names, starting with "C"'s Jan.
_M_data->_M_amonth01 = "Jan";
_M_data->_M_amonth02 = "Feb";
_M_data->_M_amonth03 = "Mar";
_M_data->_M_amonth04 = "Apr";
_M_data->_M_amonth05 = "May";
_M_data->_M_amonth06 = "Jun";
_M_data->_M_amonth07 = "Jul";
_M_data->_M_amonth08 = "Aug";
_M_data->_M_amonth09 = "Sep";
_M_data->_M_amonth10 = "Oct";
_M_data->_M_amonth11 = "Nov";
_M_data->_M_amonth12 = "Dec";
}
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
void
__timepunct<wchar_t>::
_M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
const tm* __tm) const throw()
{
char* __old = setlocale(LC_ALL, 0);
const size_t __llen = strlen(__old) + 1;
char* __sav = new char[__llen];
memcpy(__sav, __old, __llen);
setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __sav);
delete [] __sav;
// Make sure __s is null terminated.
if (__len == 0)
__s[0] = L'\0';
}
template<>
void
__timepunct<wchar_t>::_M_initialize_timepunct(__c_locale)
{
// "C" locale.
if (!_M_data)
_M_data = new __timepunct_cache<wchar_t>;
_M_data->_M_date_format = L"%m/%d/%y";
_M_data->_M_date_era_format = L"%m/%d/%y";
_M_data->_M_time_format = L"%H:%M:%S";
_M_data->_M_time_era_format = L"%H:%M:%S";
_M_data->_M_date_time_format = L"";
_M_data->_M_date_time_era_format = L"";
_M_data->_M_am = L"AM";
_M_data->_M_pm = L"PM";
_M_data->_M_am_pm_format = L"";
// Day names, starting with "C"'s Sunday.
_M_data->_M_day1 = L"Sunday";
_M_data->_M_day2 = L"Monday";
_M_data->_M_day3 = L"Tuesday";
_M_data->_M_day4 = L"Wednesday";
_M_data->_M_day5 = L"Thursday";
_M_data->_M_day6 = L"Friday";
_M_data->_M_day7 = L"Saturday";
// Abbreviated day names, starting with "C"'s Sun.
_M_data->_M_aday1 = L"Sun";
_M_data->_M_aday2 = L"Mon";
_M_data->_M_aday3 = L"Tue";
_M_data->_M_aday4 = L"Wed";
_M_data->_M_aday5 = L"Thu";
_M_data->_M_aday6 = L"Fri";
_M_data->_M_aday7 = L"Sat";
// Month names, starting with "C"'s January.
_M_data->_M_month01 = L"January";
_M_data->_M_month02 = L"February";
_M_data->_M_month03 = L"March";
_M_data->_M_month04 = L"April";
_M_data->_M_month05 = L"May";
_M_data->_M_month06 = L"June";
_M_data->_M_month07 = L"July";
_M_data->_M_month08 = L"August";
_M_data->_M_month09 = L"September";
_M_data->_M_month10 = L"October";
_M_data->_M_month11 = L"November";
_M_data->_M_month12 = L"December";
// Abbreviated month names, starting with "C"'s Jan.
_M_data->_M_amonth01 = L"Jan";
_M_data->_M_amonth02 = L"Feb";
_M_data->_M_amonth03 = L"Mar";
_M_data->_M_amonth04 = L"Apr";
_M_data->_M_amonth05 = L"May";
_M_data->_M_amonth06 = L"Jun";
_M_data->_M_amonth07 = L"Jul";
_M_data->_M_amonth08 = L"Aug";
_M_data->_M_amonth09 = L"Sep";
_M_data->_M_amonth10 = L"Oct";
_M_data->_M_amonth11 = L"Nov";
_M_data->_M_amonth12 = L"Dec";
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,466 @@
// RB tree utilities implementation -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
*/
#include <bits/stl_tree.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
static _Rb_tree_node_base*
local_Rb_tree_increment(_Rb_tree_node_base* __x) throw ()
{
if (__x->_M_right != 0)
{
__x = __x->_M_right;
while (__x->_M_left != 0)
__x = __x->_M_left;
}
else
{
_Rb_tree_node_base* __y = __x->_M_parent;
while (__x == __y->_M_right)
{
__x = __y;
__y = __y->_M_parent;
}
if (__x->_M_right != __y)
__x = __y;
}
return __x;
}
_Rb_tree_node_base*
_Rb_tree_increment(_Rb_tree_node_base* __x) throw ()
{
return local_Rb_tree_increment(__x);
}
const _Rb_tree_node_base*
_Rb_tree_increment(const _Rb_tree_node_base* __x) throw ()
{
return local_Rb_tree_increment(const_cast<_Rb_tree_node_base*>(__x));
}
static _Rb_tree_node_base*
local_Rb_tree_decrement(_Rb_tree_node_base* __x) throw ()
{
if (__x->_M_color == _S_red
&& __x->_M_parent->_M_parent == __x)
__x = __x->_M_right;
else if (__x->_M_left != 0)
{
_Rb_tree_node_base* __y = __x->_M_left;
while (__y->_M_right != 0)
__y = __y->_M_right;
__x = __y;
}
else
{
_Rb_tree_node_base* __y = __x->_M_parent;
while (__x == __y->_M_left)
{
__x = __y;
__y = __y->_M_parent;
}
__x = __y;
}
return __x;
}
_Rb_tree_node_base*
_Rb_tree_decrement(_Rb_tree_node_base* __x) throw ()
{
return local_Rb_tree_decrement(__x);
}
const _Rb_tree_node_base*
_Rb_tree_decrement(const _Rb_tree_node_base* __x) throw ()
{
return local_Rb_tree_decrement(const_cast<_Rb_tree_node_base*>(__x));
}
static void
local_Rb_tree_rotate_left(_Rb_tree_node_base* const __x,
_Rb_tree_node_base*& __root)
{
_Rb_tree_node_base* const __y = __x->_M_right;
__x->_M_right = __y->_M_left;
if (__y->_M_left !=0)
__y->_M_left->_M_parent = __x;
__y->_M_parent = __x->_M_parent;
if (__x == __root)
__root = __y;
else if (__x == __x->_M_parent->_M_left)
__x->_M_parent->_M_left = __y;
else
__x->_M_parent->_M_right = __y;
__y->_M_left = __x;
__x->_M_parent = __y;
}
/* Static keyword was missing on _Rb_tree_rotate_left.
Export the symbol for backward compatibility until
next ABI change. */
void
_Rb_tree_rotate_left(_Rb_tree_node_base* const __x,
_Rb_tree_node_base*& __root)
{
local_Rb_tree_rotate_left (__x, __root);
}
static void
local_Rb_tree_rotate_right(_Rb_tree_node_base* const __x,
_Rb_tree_node_base*& __root)
{
_Rb_tree_node_base* const __y = __x->_M_left;
__x->_M_left = __y->_M_right;
if (__y->_M_right != 0)
__y->_M_right->_M_parent = __x;
__y->_M_parent = __x->_M_parent;
if (__x == __root)
__root = __y;
else if (__x == __x->_M_parent->_M_right)
__x->_M_parent->_M_right = __y;
else
__x->_M_parent->_M_left = __y;
__y->_M_right = __x;
__x->_M_parent = __y;
}
/* Static keyword was missing on _Rb_tree_rotate_right
Export the symbol for backward compatibility until
next ABI change. */
void
_Rb_tree_rotate_right(_Rb_tree_node_base* const __x,
_Rb_tree_node_base*& __root)
{
local_Rb_tree_rotate_right (__x, __root);
}
void
_Rb_tree_insert_and_rebalance(const bool __insert_left,
_Rb_tree_node_base* __x,
_Rb_tree_node_base* __p,
_Rb_tree_node_base& __header) throw ()
{
_Rb_tree_node_base *& __root = __header._M_parent;
// Initialize fields in new node to insert.
__x->_M_parent = __p;
__x->_M_left = 0;
__x->_M_right = 0;
__x->_M_color = _S_red;
// Insert.
// Make new node child of parent and maintain root, leftmost and
// rightmost nodes.
// N.B. First node is always inserted left.
if (__insert_left)
{
__p->_M_left = __x; // also makes leftmost = __x when __p == &__header
if (__p == &__header)
{
__header._M_parent = __x;
__header._M_right = __x;
}
else if (__p == __header._M_left)
__header._M_left = __x; // maintain leftmost pointing to min node
}
else
{
__p->_M_right = __x;
if (__p == __header._M_right)
__header._M_right = __x; // maintain rightmost pointing to max node
}
// Rebalance.
while (__x != __root
&& __x->_M_parent->_M_color == _S_red)
{
_Rb_tree_node_base* const __xpp = __x->_M_parent->_M_parent;
if (__x->_M_parent == __xpp->_M_left)
{
_Rb_tree_node_base* const __y = __xpp->_M_right;
if (__y && __y->_M_color == _S_red)
{
__x->_M_parent->_M_color = _S_black;
__y->_M_color = _S_black;
__xpp->_M_color = _S_red;
__x = __xpp;
}
else
{
if (__x == __x->_M_parent->_M_right)
{
__x = __x->_M_parent;
local_Rb_tree_rotate_left(__x, __root);
}
__x->_M_parent->_M_color = _S_black;
__xpp->_M_color = _S_red;
local_Rb_tree_rotate_right(__xpp, __root);
}
}
else
{
_Rb_tree_node_base* const __y = __xpp->_M_left;
if (__y && __y->_M_color == _S_red)
{
__x->_M_parent->_M_color = _S_black;
__y->_M_color = _S_black;
__xpp->_M_color = _S_red;
__x = __xpp;
}
else
{
if (__x == __x->_M_parent->_M_left)
{
__x = __x->_M_parent;
local_Rb_tree_rotate_right(__x, __root);
}
__x->_M_parent->_M_color = _S_black;
__xpp->_M_color = _S_red;
local_Rb_tree_rotate_left(__xpp, __root);
}
}
}
__root->_M_color = _S_black;
}
_Rb_tree_node_base*
_Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z,
_Rb_tree_node_base& __header) throw ()
{
_Rb_tree_node_base *& __root = __header._M_parent;
_Rb_tree_node_base *& __leftmost = __header._M_left;
_Rb_tree_node_base *& __rightmost = __header._M_right;
_Rb_tree_node_base* __y = __z;
_Rb_tree_node_base* __x = 0;
_Rb_tree_node_base* __x_parent = 0;
if (__y->_M_left == 0) // __z has at most one non-null child. y == z.
__x = __y->_M_right; // __x might be null.
else
if (__y->_M_right == 0) // __z has exactly one non-null child. y == z.
__x = __y->_M_left; // __x is not null.
else
{
// __z has two non-null children. Set __y to
__y = __y->_M_right; // __z's successor. __x might be null.
while (__y->_M_left != 0)
__y = __y->_M_left;
__x = __y->_M_right;
}
if (__y != __z)
{
// relink y in place of z. y is z's successor
__z->_M_left->_M_parent = __y;
__y->_M_left = __z->_M_left;
if (__y != __z->_M_right)
{
__x_parent = __y->_M_parent;
if (__x) __x->_M_parent = __y->_M_parent;
__y->_M_parent->_M_left = __x; // __y must be a child of _M_left
__y->_M_right = __z->_M_right;
__z->_M_right->_M_parent = __y;
}
else
__x_parent = __y;
if (__root == __z)
__root = __y;
else if (__z->_M_parent->_M_left == __z)
__z->_M_parent->_M_left = __y;
else
__z->_M_parent->_M_right = __y;
__y->_M_parent = __z->_M_parent;
std::swap(__y->_M_color, __z->_M_color);
__y = __z;
// __y now points to node to be actually deleted
}
else
{ // __y == __z
__x_parent = __y->_M_parent;
if (__x)
__x->_M_parent = __y->_M_parent;
if (__root == __z)
__root = __x;
else
if (__z->_M_parent->_M_left == __z)
__z->_M_parent->_M_left = __x;
else
__z->_M_parent->_M_right = __x;
if (__leftmost == __z)
{
if (__z->_M_right == 0) // __z->_M_left must be null also
__leftmost = __z->_M_parent;
// makes __leftmost == _M_header if __z == __root
else
__leftmost = _Rb_tree_node_base::_S_minimum(__x);
}
if (__rightmost == __z)
{
if (__z->_M_left == 0) // __z->_M_right must be null also
__rightmost = __z->_M_parent;
// makes __rightmost == _M_header if __z == __root
else // __x == __z->_M_left
__rightmost = _Rb_tree_node_base::_S_maximum(__x);
}
}
if (__y->_M_color != _S_red)
{
while (__x != __root && (__x == 0 || __x->_M_color == _S_black))
if (__x == __x_parent->_M_left)
{
_Rb_tree_node_base* __w = __x_parent->_M_right;
if (__w->_M_color == _S_red)
{
__w->_M_color = _S_black;
__x_parent->_M_color = _S_red;
local_Rb_tree_rotate_left(__x_parent, __root);
__w = __x_parent->_M_right;
}
if ((__w->_M_left == 0 ||
__w->_M_left->_M_color == _S_black) &&
(__w->_M_right == 0 ||
__w->_M_right->_M_color == _S_black))
{
__w->_M_color = _S_red;
__x = __x_parent;
__x_parent = __x_parent->_M_parent;
}
else
{
if (__w->_M_right == 0
|| __w->_M_right->_M_color == _S_black)
{
__w->_M_left->_M_color = _S_black;
__w->_M_color = _S_red;
local_Rb_tree_rotate_right(__w, __root);
__w = __x_parent->_M_right;
}
__w->_M_color = __x_parent->_M_color;
__x_parent->_M_color = _S_black;
if (__w->_M_right)
__w->_M_right->_M_color = _S_black;
local_Rb_tree_rotate_left(__x_parent, __root);
break;
}
}
else
{
// same as above, with _M_right <-> _M_left.
_Rb_tree_node_base* __w = __x_parent->_M_left;
if (__w->_M_color == _S_red)
{
__w->_M_color = _S_black;
__x_parent->_M_color = _S_red;
local_Rb_tree_rotate_right(__x_parent, __root);
__w = __x_parent->_M_left;
}
if ((__w->_M_right == 0 ||
__w->_M_right->_M_color == _S_black) &&
(__w->_M_left == 0 ||
__w->_M_left->_M_color == _S_black))
{
__w->_M_color = _S_red;
__x = __x_parent;
__x_parent = __x_parent->_M_parent;
}
else
{
if (__w->_M_left == 0 || __w->_M_left->_M_color == _S_black)
{
__w->_M_right->_M_color = _S_black;
__w->_M_color = _S_red;
local_Rb_tree_rotate_left(__w, __root);
__w = __x_parent->_M_left;
}
__w->_M_color = __x_parent->_M_color;
__x_parent->_M_color = _S_black;
if (__w->_M_left)
__w->_M_left->_M_color = _S_black;
local_Rb_tree_rotate_right(__x_parent, __root);
break;
}
}
if (__x) __x->_M_color = _S_black;
}
return __y;
}
unsigned int
_Rb_tree_black_count(const _Rb_tree_node_base* __node,
const _Rb_tree_node_base* __root) throw ()
{
if (__node == 0)
return 0;
unsigned int __sum = 0;
do
{
if (__node->_M_color == _S_black)
++__sum;
if (__node == __root)
break;
__node = __node->_M_parent;
}
while (1);
return __sum;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,107 @@
// Explicit instantiation file.
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882:
//
#include <valarray>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Some explicit instantiations.
template void
__valarray_fill(size_t* __restrict__, size_t, const size_t&);
template void
__valarray_copy(const size_t* __restrict__, size_t, size_t* __restrict__);
template valarray<size_t>::valarray(size_t);
template valarray<size_t>::valarray(const valarray<size_t>&);
template valarray<size_t>::~valarray();
template size_t valarray<size_t>::size() const;
template size_t& valarray<size_t>::operator[](size_t);
inline size_t
__valarray_product(const valarray<size_t>& __a)
{
const size_t __n = __a.size();
// XXX: This ugly cast is necessary because
// valarray::operator[]() const return a VALUE!
// Try to get the committee to correct that gross error.
valarray<size_t>& __t = const_cast<valarray<size_t>&>(__a);
return __valarray_product(&__t[0], &__t[0] + __n);
}
// Map a gslice, described by its multidimensional LENGTHS
// and corresponding STRIDES, to a linear array of INDEXES
// for the purpose of indexing a flat, one-dimensional array
// representation of a gslice_array.
void
__gslice_to_index(size_t __o, const valarray<size_t>& __l,
const valarray<size_t>& __s, valarray<size_t>& __i)
{
// There are as many dimensions as there are strides.
const size_t __n = __l.size();
// Holds current multi-index as we go through the gslice for the
// purpose of computing its linear-image.
valarray<size_t> __t(__l);
// Note that this should match the product of all numbers appearing
// in __l which describes the multidimensional sizes of the
// generalized slice.
const size_t __z = __i.size();
for (size_t __j = 0; __j < __z; ++__j)
{
// Compute the linear-index image of (t_0, ... t_{n-1}).
__i[__j] = __o;
--__t[__n - 1];
__o += __s[__n - 1];
// Process the next multi-index. The loop ought to be
// backward since we're making a lexicographical visit.
for (size_t __k2 = __n - 1; __k2 && !__t[__k2]; --__k2)
{
__o -= __s[__k2] * __l[__k2];
__t[__k2] = __l[__k2];
--__t[__k2 - 1];
__o += __s[__k2 - 1];
}
}
}
gslice::_Indexer::_Indexer(size_t __o, const valarray<size_t>& __l,
const valarray<size_t>& __s)
: _M_count(1), _M_start(__o), _M_size(__l), _M_stride(__s),
_M_index(__l.size() == 0 ? 0 : __valarray_product(__l))
{ __gslice_to_index(__o, __l, __s, _M_index); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,75 @@
// Locale support -*- C++ -*-
// Copyright (C) 1999-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.1 Locales
//
#include <bits/c++config.h>
#ifdef _GLIBCXX_USE_WCHAR_T
#define C wchar_t
#include "locale-inst.cc"
// XXX GLIBCXX_ABI Deprecated
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT
#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
extern "C" void ldbl (void) __attribute__ ((alias (#dbl), weak))
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIjEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
_ZNKSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIjEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIlEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
_ZNKSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIlEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intImEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
_ZNKSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intImEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intItEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
_ZNKSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intItEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIxEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
_ZNKSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIxEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIyEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
_ZNKSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIyEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intIlEES4_S4_RSt8ios_basewT_,
_ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intIlEES3_S3_RSt8ios_basewT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intImEES4_S4_RSt8ios_basewT_,
_ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intImEES3_S3_RSt8ios_basewT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intIxEES4_S4_RSt8ios_basewT_,
_ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intIxEES3_S3_RSt8ios_basewT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intIyEES4_S4_RSt8ios_basewT_,
_ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intIyEES3_S3_RSt8ios_basewT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE15_M_insert_floatIdEES4_S4_RSt8ios_basewcT_,
_ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE15_M_insert_floatIdEES3_S3_RSt8ios_basewcT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE15_M_insert_floatIdEES3_S3_RSt8ios_basewcT_,
_ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE15_M_insert_floatIeEES3_S3_RSt8ios_basewcT_);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE10_M_extractILb0EEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRSs,
_ZNKSt9money_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE10_M_extractILb0EEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRSs);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE10_M_extractILb1EEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRSs,
_ZNKSt9money_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE10_M_extractILb1EEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRSs);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE9_M_insertILb0EEES4_S4_RSt8ios_basewRKSbIwS3_SaIwEE,
_ZNKSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE9_M_insertILb0EEES3_S3_RSt8ios_basewRKSbIwS2_SaIwEE);
_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE9_M_insertILb1EEES4_S4_RSt8ios_basewRKSbIwS3_SaIwEE,
_ZNKSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE9_M_insertILb1EEES3_S3_RSt8ios_basewRKSbIwS2_SaIwEE);
#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
#endif

View File

@@ -0,0 +1,93 @@
// std::__detail and std::tr1::__detail definitions -*- C++ -*-
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
namespace __detail
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
extern const unsigned long __prime_list[] = // 256 + 1 or 256 + 48 + 1
{
2ul, 3ul, 5ul, 7ul, 11ul, 13ul, 17ul, 19ul, 23ul, 29ul, 31ul,
37ul, 41ul, 43ul, 47ul, 53ul, 59ul, 61ul, 67ul, 71ul, 73ul, 79ul,
83ul, 89ul, 97ul, 103ul, 109ul, 113ul, 127ul, 137ul, 139ul, 149ul,
157ul, 167ul, 179ul, 193ul, 199ul, 211ul, 227ul, 241ul, 257ul,
277ul, 293ul, 313ul, 337ul, 359ul, 383ul, 409ul, 439ul, 467ul,
503ul, 541ul, 577ul, 619ul, 661ul, 709ul, 761ul, 823ul, 887ul,
953ul, 1031ul, 1109ul, 1193ul, 1289ul, 1381ul, 1493ul, 1613ul,
1741ul, 1879ul, 2029ul, 2179ul, 2357ul, 2549ul, 2753ul, 2971ul,
3209ul, 3469ul, 3739ul, 4027ul, 4349ul, 4703ul, 5087ul, 5503ul,
5953ul, 6427ul, 6949ul, 7517ul, 8123ul, 8783ul, 9497ul, 10273ul,
11113ul, 12011ul, 12983ul, 14033ul, 15173ul, 16411ul, 17749ul,
19183ul, 20753ul, 22447ul, 24281ul, 26267ul, 28411ul, 30727ul,
33223ul, 35933ul, 38873ul, 42043ul, 45481ul, 49201ul, 53201ul,
57557ul, 62233ul, 67307ul, 72817ul, 78779ul, 85229ul, 92203ul,
99733ul, 107897ul, 116731ul, 126271ul, 136607ul, 147793ul,
159871ul, 172933ul, 187091ul, 202409ul, 218971ul, 236897ul,
256279ul, 277261ul, 299951ul, 324503ul, 351061ul, 379787ul,
410857ul, 444487ul, 480881ul, 520241ul, 562841ul, 608903ul,
658753ul, 712697ul, 771049ul, 834181ul, 902483ul, 976369ul,
1056323ul, 1142821ul, 1236397ul, 1337629ul, 1447153ul, 1565659ul,
1693859ul, 1832561ul, 1982627ul, 2144977ul, 2320627ul, 2510653ul,
2716249ul, 2938679ul, 3179303ul, 3439651ul, 3721303ul, 4026031ul,
4355707ul, 4712381ul, 5098259ul, 5515729ul, 5967347ul, 6456007ul,
6984629ul, 7556579ul, 8175383ul, 8844859ul, 9569143ul, 10352717ul,
11200489ul, 12117689ul, 13109983ul, 14183539ul, 15345007ul,
16601593ul, 17961079ul, 19431899ul, 21023161ul, 22744717ul,
24607243ul, 26622317ul, 28802401ul, 31160981ul, 33712729ul,
36473443ul, 39460231ul, 42691603ul, 46187573ul, 49969847ul,
54061849ul, 58488943ul, 63278561ul, 68460391ul, 74066549ul,
80131819ul, 86693767ul, 93793069ul, 101473717ul, 109783337ul,
118773397ul, 128499677ul, 139022417ul, 150406843ul, 162723577ul,
176048909ul, 190465427ul, 206062531ul, 222936881ul, 241193053ul,
260944219ul, 282312799ul, 305431229ul, 330442829ul, 357502601ul,
386778277ul, 418451333ul, 452718089ul, 489790921ul, 529899637ul,
573292817ul, 620239453ul, 671030513ul, 725980837ul, 785430967ul,
849749479ul, 919334987ul, 994618837ul, 1076067617ul, 1164186217ul,
1259520799ul, 1362662261ul, 1474249943ul, 1594975441ul, 1725587117ul,
1866894511ul, 2019773507ul, 2185171673ul, 2364114217ul, 2557710269ul,
2767159799ul, 2993761039ul, 3238918481ul, 3504151727ul, 3791104843ul,
4101556399ul, 4294967291ul,
// Sentinel, so we don't have to test the result of lower_bound,
// or, on 64-bit machines, rest of the table.
#if __SIZEOF_LONG__ != 8
4294967291ul
#else
6442450933ul, 8589934583ul, 12884901857ul, 17179869143ul,
25769803693ul, 34359738337ul, 51539607367ul, 68719476731ul,
103079215087ul, 137438953447ul, 206158430123ul, 274877906899ul,
412316860387ul, 549755813881ul, 824633720731ul, 1099511627689ul,
1649267441579ul, 2199023255531ul, 3298534883309ul, 4398046511093ul,
6597069766607ul, 8796093022151ul, 13194139533241ul, 17592186044399ul,
26388279066581ul, 35184372088777ul, 52776558133177ul, 70368744177643ul,
105553116266399ul, 140737488355213ul, 211106232532861ul, 281474976710597ul,
562949953421231ul, 1125899906842597ul, 2251799813685119ul,
4503599627370449ul, 9007199254740881ul, 18014398509481951ul,
36028797018963913ul, 72057594037927931ul, 144115188075855859ul,
288230376151711717ul, 576460752303423433ul,
1152921504606846883ul, 2305843009213693951ul,
4611686018427387847ul, 9223372036854775783ul,
18446744073709551557ul, 18446744073709551557ul
#endif
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __detail