diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-02-10 17:20:51 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-02-10 17:20:51 +0000 |
commit | 2d9d01985a7a7866916fafa19c5c296702e69714 (patch) | |
tree | 259c095c65fc0c6279b7a17755b3f851f51babb3 /libstdc++-v3 | |
parent | c8ebeb0e3c6b093e649592be7d51d1c0032a1dc7 (diff) | |
download | gcc-2d9d01985a7a7866916fafa19c5c296702e69714.tar.gz |
2016-02-10 Basile Starynkevitch <basile@starynkevitch.net>
{{merging with even more of GCC 6, using subversion 1.9
svn merge -r227001:227400 ^/trunk ;
there is some gengtype issue before svn r228000... }}
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@233281 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
55 files changed, 3868 insertions, 390 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 22876060de7..d9c9d49353f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,189 @@ +2015-09-02 Sebastian Huber <sebastian.huber@embedded-brains.de> + + PR libstdc++/67408 + * include/std/mutex (__timed_mutex_impl::_M_try_lock_until): Use + _Derived::_M_timedlock(). + (timed_mutex): Add _M_timedlock() and make base class a friend. + (recursive_timed_mutex): Likewise. + +2015-08-28 Tim Shen <timshen@google.com> + + PR libstdc++/67362 + * include/bits/regex_scanner.tcc (_Scanner<>::_M_scan_normal): + Always returns ordinary char token if the char isn't + considered a special char. + * testsuite/28_regex/regression.cc: New test file for collecting + regression testcases from, typically, bugzilla. + +2015-08-27 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/67374 + * include/bits/range_access.h (valarray, begin, end): Declare. + * testsuite/26_numerics/valarray/range_access.cc: Test const + overloads. + * testsuite/26_numerics/valarray/range_access2.cc: New. + +2015-08-27 John Marino <gnugcc@marino.st> + + * acinclude.m4 (*-*-dragonfly*): Change 7 locale support files + from generic to new DragonFly versions. + * configure: Regenerate. + * config/locale/dragonfly/c_locale.cc: Improve locale support. + * config/locale/dragonfly/ctype_members.cc: Likewise. + * config/os/bsd/dragonfly/ctype_configure_char.cc: Likewise. + * config/os/bsd/dragonfly/os_defines.h: Define _GLIBCXX_USE_C99. + * config/locale/dragonfly/c_locale.h: New. + * config/locale/dragonfly/codecvt_members.cc: New. + * config/locale/dragonfly/collate_members.cc: New. + * config/locale/dragonfly/monetary_members.cc: New. + * config/locale/dragonfly/numeric_members.cc: New. + * config/locale/dragonfly/time_members.cc: New. + * config/locale/dragonfly/time_members.h: New. + +2015-08-27 Jonathan Wakely <jwakely@redhat.com> + + * configure: Regenerate. + +2015-08-26 Edward Smith-Rowland <3dw4rd@verizon.net> + Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/64351 + PR libstdc++/63176 + * include/bits/random.tcc (generate_canonical): Loop until we get a + result less than one. + * testsuite/26_numerics/random/uniform_real_distribution/operators/ + 64351.cc: New. + +2015-08-26 Jonathan Wakely <jwakely@redhat.com> + + * include/bits/shared_ptr.h (__enable_shared_from_this_helper): Use + nullptr. + * include/bits/shared_ptr_base.h (weak_ptr::_M_assign): Don't assign + if ownership is already shared with a shared_ptr object. + (__enable_shared_from_this_helper): Use nullptr. + * testsuite/20_util/enable_shared_from_this/members/const.cc: New. + * testsuite/20_util/enable_shared_from_this/members/reinit.cc: New. + * testsuite/20_util/enable_shared_from_this/requirements/ + explicit_instantiation.cc: Instantiate with const and incomplete types. + + * include/debug/map.h (map::try_emplace, map::insert_or_assign): + Define. + * include/debug/unordered_map (unordered_map::try_emplace, + unordered_map::insert_or_assign): Define. + + PR libstdc++/66902 + * src/c++11/debug.cc (_S_debug_messages): Give internal linkage. + +2015-08-24 François Dumont <fdumont@gcc.gnu.org> + + PR libstdc++/60519 + * include/debug/formatter.h (_Debug_msg_id::__msg_irreflexive_ordering): + New enum entry. + * include/debug/functions.h (_Irreflexive_checker): New. + (__is_irreflexive, __is_irreflexive_pred): New. + * include/debug/macros.h + (__glibcxx_check_irreflexive, __glibcxx_check_irreflexive_pred): New + macros. + (__glibcxx_check_irreflexive2, __glibcxx_check_irreflexive_pred2): New + macros limited to post-C++11 mode. + * include/debug/debug.h + (__glibcxx_requires_irreflexive, __glibcxx_requires_irreflexive_pred): + New macros, use latter. + (__glibcxx_requires_irreflexive2, __glibcxx_requires_irreflexive_pred2): + Likewise. + * include/bits/stl_algo.h + (partial_sort_copy): Add irreflexive debug check. + (partial_sort_copy): Likewise. + (lower_bound): Likewise. + (upper_bound): Likewise. + (equal_range): Likewise. + (binary_search): Likewise. + (inplace_merge): Likewise. + (includes): Likewise. + (next_permutation): Likewise. + (prev_permutation): Likewise. + (is_sorted_until): Likewise. + (minmax_element): Likewise. + (partial_sort): Likewise. + (nth_element): Likewise. + (sort): Likewise. + (merge): Likewise. + (stable_sort): Likewise. + (set_union): Likewise. + (set_intersection): Likewise. + (set_difference): Likewise. + (set_symmetric_difference): Likewise. + (min_element): Likewise. + (max_element): Likewise. + * include/bits/stl_algobase.h + (lower_bound): Likewise. + (lexicographical_compare): Likewise. + * include/bits/stl_heap.h + (push_heap): Likewise. + (pop_heap): Likewise. + (make_heap): Likewise. + (sort_heap): Likewise. + (is_heap_until): Likewise. + * testsuite/25_algorithms/lexicographical_compare/debug/ + irreflexive_neg.cc: New. + * testsuite/25_algorithms/lower_bound/debug/irreflexive.cc: New. + * testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc: + New. + +2015-08-24 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/65049 + * include/bits/char_traits.h (char_traits<char>::compare, + char_traits<char>::find, char_traits<char>::move, + char_traits<char>::copy, char_traits<char>::assign): Check for zero + length. + (char_traits<wchar_t>::compare, char_traits<wchar_t>::find, + char_traits<wchar_t>::move, char_traits<wchar_t>::copy, + char_traits<wchar_t>::assign): Likewise. + (char_traits<char16_t>::move, char_traits<char16_t>::copy): Likewise. + (char_traits<char32_t>::move, char_traits<char32_t>::copy): Likewise. + * include/ext/pod_char_traits.h (char_traits<character<>>::move, + char_traits<character<>>::copy): Likewise. + * testsuite/21_strings/char_traits/requirements/char/65049.cc: New. + * testsuite/21_strings/char_traits/requirements/char16_t/65049.cc: + New. + * testsuite/21_strings/char_traits/requirements/char32_t/65049.cc: + New. + * testsuite/21_strings/char_traits/requirements/wchar_t/65049.cc: + New. + + PR libstdc++/67309 + * include/bits/random.tcc + (poisson_distribution::param_type::_M_initialize): Use max<double>. + (binomial_distribution::param_type::_M_initialize): Likewise. + * testsuite/17_intro/headers/c++200x/67309.cc: New. + * testsuite/17_intro/headers/c++200x/all_attributes.cc: Remove + redundant header. + +2015-08-20 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/67294 + * testsuite/30_threads/recursive_timed_mutex/unlock/2.cc: Do not run + on Darwin. + * testsuite/30_threads/timed_mutex/unlock/2.cc: Likewise. + + * include/experimental/any (__any_caster): Define at namespace scope + so the name is visible to name lookup. + * testsuite/experimental/any/misc/any_cast_neg.cc: Adjust dg-error. + + * python/Makefile.am: Ensure gdb.py is installed for libstdc++ not + libstdc++fs. + * python/Makefile.in: Regenerate. + +2015-08-19 Paolo Carlini <paolo.carlini@oracle.com> + + * include/c_global/cmath: Fix typo in comment. + +2015-08-19 Paolo Carlini <paolo.carlini@oracle.com> + + * include/c_global/cmath: Revert fix for libstdc++/58625, no + longer necessary (__builtin_signbit is now type-generic). + 2015-08-18 Jonathan Wakely <jwakely@redhat.com> PR c++/67216 diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 78c1a8255fe..789bc5894a0 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -2087,17 +2087,17 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [ dragonfly) AC_MSG_RESULT(dragonfly) - CLOCALE_H=config/locale/generic/c_locale.h + CLOCALE_H=config/locale/dragonfly/c_locale.h CLOCALE_CC=config/locale/dragonfly/c_locale.cc - CCODECVT_CC=config/locale/generic/codecvt_members.cc - CCOLLATE_CC=config/locale/generic/collate_members.cc + CCODECVT_CC=config/locale/dragonfly/codecvt_members.cc + CCOLLATE_CC=config/locale/dragonfly/collate_members.cc CCTYPE_CC=config/locale/dragonfly/ctype_members.cc CMESSAGES_H=config/locale/generic/messages_members.h CMESSAGES_CC=config/locale/generic/messages_members.cc - CMONEY_CC=config/locale/generic/monetary_members.cc - CNUMERIC_CC=config/locale/generic/numeric_members.cc - CTIME_H=config/locale/generic/time_members.h - CTIME_CC=config/locale/generic/time_members.cc + CMONEY_CC=config/locale/dragonfly/monetary_members.cc + CNUMERIC_CC=config/locale/dragonfly/numeric_members.cc + CTIME_H=config/locale/dragonfly/time_members.h + CTIME_CC=config/locale/dragonfly/time_members.cc CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h ;; diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.cc b/libstdc++-v3/config/locale/dragonfly/c_locale.cc index dea7a391c76..500cf7e47ba 100644 --- a/libstdc++-v3/config/locale/dragonfly/c_locale.cc +++ b/libstdc++-v3/config/locale/dragonfly/c_locale.cc @@ -1,4 +1,4 @@ -// Wrapper for underlying C-language localization -*- C++ -*- +// localization implementation details, DragonFly version -*- C++ -*- // Copyright (C) 2014-2015 Free Software Foundation, Inc. // @@ -27,18 +27,14 @@ // // Written by Benjamin Kosnik <bkoz@redhat.com> +// Modified for DragonFly by John Marino <gnugcc@marino.st> -#include <cerrno> // For errno -#include <cmath> // For isinf, finite, finitef, fabs -#include <cstdlib> // For strof, strtold -#include <cstring> -#include <cstdio> +#include <cstdlib> #include <locale> +#include <stdexcept> #include <limits> - -#ifdef _GLIBCXX_HAVE_IEEEFP_H -#include <ieeefp.h> -#endif +#include <langinfo.h> +#include <xlocale.h> namespace std _GLIBCXX_VISIBILITY(default) { @@ -47,40 +43,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<> void __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err, - const __c_locale&) throw() + const __c_locale& __cloc) 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 + __v = strtof_l(__s, &__sanity, (locale_t)__cloc); // _GLIBCXX_RESOLVE_LIB_DEFECTS // 23. Num_get overflow result. @@ -89,44 +55,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __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 - ) + else if (__v == numeric_limits<float>::infinity()) { - if (__v > 0.0f) - __v = numeric_limits<float>::max(); - else - __v = -numeric_limits<float>::max(); + __v = numeric_limits<float>::max(); + __err = ios_base::failbit; + } + else if (__v == -numeric_limits<float>::infinity()) + { + __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() + const __c_locale& __cloc) 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); + __v = strtod_l(__s, &__sanity, (locale_t)__cloc); // _GLIBCXX_RESOLVE_LIB_DEFECTS // 23. Num_get overflow result. @@ -135,132 +82,86 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __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 + else if (__v == numeric_limits<double>::infinity()) { - if (__v > 0.0) - __v = numeric_limits<double>::max(); - else - __v = -numeric_limits<double>::max(); + __v = numeric_limits<double>::max(); + __err = ios_base::failbit; + } + else if (__v == -numeric_limits<double>::infinity()) + { + __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() + __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err, + const __c_locale& __cloc) 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); + __v = strtold_l(__s, &__sanity, (locale_t)__cloc); // _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 + else if (__v == numeric_limits<long double>::infinity()) { - if (__v > 0.0l) - __v = numeric_limits<long double>::max(); - else - __v = -numeric_limits<long double>::max(); + __v = numeric_limits<long double>::max(); + __err = ios_base::failbit; + } + else if (__v == -numeric_limits<long double>::infinity()) + { + __v = -numeric_limits<long double>::max(); __err = ios_base::failbit; } - - setlocale(LC_ALL, __sav); - delete [] __sav; } - - /* DragonFly's implementation of setlocale won't accept something like - "de_DE". According to nls manpage, the expected format is: - language[_territory][.codeset][@modifier], but it seems that both - the _territory and .codeset components are required. - - As an attempt to correct for this, we'll tack on ".UTF-8" if - a period is not detected in the locale string. - - There are no locales with modifiers on DragonFly so if found, they - will just be stripped off silently. e.g "de_DE@euro" will be reduced - to "de_DE". The UTF-8 default would be added after that. - */ - void locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s, - __c_locale) + __c_locale __old) { - const size_t size__s = (__s == NULL) ? 1 : strlen (__s); - const char UTF8[] = ".UTF-8"; - char localspec[size__s + 6 + 1]; - - if (__s == NULL) { - localspec[0] = '\0'; - } else { - strcpy (localspec, __s); - char * pch = strchr (localspec, '@'); - if (pch != NULL) - *pch = 0; - - if ( (strchr (__s, '.') == NULL) - && (strcmp (__s, "C") != 0) - && (strcmp (__s, "POSIX") != 0)) - strncat (localspec, UTF8, 6); - } - - const char * result = std::setlocale(LC_ALL, localspec); - - if ((strcmp(result, "C") != 0) && (strcmp (result, localspec) != 0)) - __throw_runtime_error(__N("locale::facet::_S_create_c_locale " - "name not valid")); - __cloc = 0; + __cloc = (__c_locale)newlocale(LC_ALL_MASK, __s, (locale_t)__old); + if (!__cloc) + { + // This named locale is not supported by the underlying OS. + __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; } + { + if (__cloc && _S_get_c_locale() != __cloc) + freelocale((locale_t)__cloc); + } __c_locale - locale::facet::_S_clone_c_locale(__c_locale&) throw() - { return __c_locale(); } + locale::facet::_S_clone_c_locale(__c_locale& __cloc) throw() + { return (__c_locale)duplocale((locale_t)__cloc); } __c_locale - locale::facet::_S_lc_ctype_c_locale(__c_locale, const char*) - { return __c_locale(); } + locale::facet::_S_lc_ctype_c_locale(__c_locale __cloc, const char* __s) + { + __c_locale __dup = (__c_locale)duplocale((locale_t)__cloc); + if (__dup == __c_locale(0)) + __throw_runtime_error(__N("locale::facet::_S_lc_ctype_c_locale " + "duplocale error")); + __c_locale __changed = (__c_locale)newlocale(LC_CTYPE_MASK, __s, + (locale_t)__dup); + if (__changed == __c_locale(0)) + { + freelocale((locale_t)__dup); + __throw_runtime_error(__N("locale::facet::_S_lc_ctype_c_locale " + "newlocale error")); + } + return __changed; + } _GLIBCXX_END_NAMESPACE_VERSION } // namespace @@ -295,5 +196,5 @@ _GLIBCXX_END_NAMESPACE_VERSION #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); +_GLIBCXX_LDBL_COMPAT(_ZSt14__convert_to_vIdEvPKcRT_RSt12_Ios_IostateRKP15__locale_struct, _ZSt14__convert_to_vIeEvPKcRT_RSt12_Ios_IostateRKP15__locale_struct); #endif // _GLIBCXX_LONG_DOUBLE_COMPAT diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.h b/libstdc++-v3/config/locale/dragonfly/c_locale.h new file mode 100644 index 00000000000..5c17cfe10c3 --- /dev/null +++ b/libstdc++-v3/config/locale/dragonfly/c_locale.h @@ -0,0 +1,82 @@ +// localization implementation details, DragonFly version -*- C++ -*- + +// Copyright (C) 2001-2015 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 bits/c++locale.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.8 Standard locale categories. +// + +// Written by Benjamin Kosnik <bkoz@redhat.com> +// Modified for DragonFly by John Marino <gnugcc@marino.st> + +#ifndef _GLIBCXX_CXX_LOCALE_H +#define _GLIBCXX_CXX_LOCALE_H 1 + +#pragma GCC system_header + +#include <clocale> +#include <xlocale.h> + +#define _GLIBCXX_NUM_CATEGORIES 0 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + typedef int* __c_locale; + + // Convert numeric value of type double and long double to string and + // return length of string. If vsnprintf is available use it, otherwise + // fall back to the unsafe vsprintf which, in general, can be dangerous + // and should be avoided. + inline int + __convert_from_v(const __c_locale& __cloc, char* __out, + const int __size __attribute__ ((__unused__)), + const char* __fmt, ...) + { + __c_locale __old = (__c_locale)uselocale((locale_t)__cloc); + + __builtin_va_list __args; + __builtin_va_start(__args, __fmt); + +#ifdef _GLIBCXX_USE_C99 + const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args); +#else + const int __ret = __builtin_vsprintf(__out, __fmt, __args); +#endif + + __builtin_va_end(__args); + + uselocale((locale_t)__old); + return __ret; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc b/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc new file mode 100644 index 00000000000..9aef8755638 --- /dev/null +++ b/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc @@ -0,0 +1,288 @@ +// std::codecvt implementation details, DragonFly version -*- C++ -*- + +// Copyright (C) 2015 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> +// Modified for DragonFly by John Marino <gnugcc@marino.st> + +#include <locale> +#include <cstring> +#include <cstdlib> // For MB_CUR_MAX +#include <climits> // For MB_LEN_MAX + +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; + state_type __tmp_state(__state); + + __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_codecvt); + + // wcsnrtombs is *very* fast but stops if encounters NUL characters: + // in case we fall back to wcrtomb and then continue, in a loop. + // NB: wcsnrtombs is a GNU extension + for (__from_next = __from, __to_next = __to; + __from_next < __from_end && __to_next < __to_end + && __ret == ok;) + { + const intern_type* __from_chunk_end = wmemchr(__from_next, L'\0', + __from_end - __from_next); + if (!__from_chunk_end) + __from_chunk_end = __from_end; + + __from = __from_next; + const size_t __conv = wcsnrtombs(__to_next, &__from_next, + __from_chunk_end - __from_next, + __to_end - __to_next, &__state); + if (__conv == static_cast<size_t>(-1)) + { + // In case of error, in order to stop at the exact place we + // have to start again from the beginning with a series of + // wcrtomb. + for (; __from < __from_next; ++__from) + __to_next += wcrtomb(__to_next, *__from, &__tmp_state); + __state = __tmp_state; + __ret = error; + } + else if (__from_next && __from_next < __from_chunk_end) + { + __to_next += __conv; + __ret = partial; + } + else + { + __from_next = __from_chunk_end; + __to_next += __conv; + } + + if (__from_next < __from_end && __ret == ok) + { + extern_type __buf[MB_LEN_MAX]; + __tmp_state = __state; + const size_t __conv2 = wcrtomb(__buf, *__from_next, &__tmp_state); + if (__conv2 > static_cast<size_t>(__to_end - __to_next)) + __ret = partial; + else + { + memcpy(__to_next, __buf, __conv2); + __state = __tmp_state; + __to_next += __conv2; + ++__from_next; + } + } + } + + uselocale((locale_t)__old); + + 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; + state_type __tmp_state(__state); + + __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_codecvt); + + // mbsnrtowcs is *very* fast but stops if encounters NUL characters: + // in case we store a L'\0' and then continue, in a loop. + // NB: mbsnrtowcs is a GNU extension + for (__from_next = __from, __to_next = __to; + __from_next < __from_end && __to_next < __to_end + && __ret == ok;) + { + const extern_type* __from_chunk_end; + __from_chunk_end = static_cast<const extern_type*>(memchr(__from_next, '\0', + __from_end + - __from_next)); + if (!__from_chunk_end) + __from_chunk_end = __from_end; + + __from = __from_next; + size_t __conv = mbsnrtowcs(__to_next, &__from_next, + __from_chunk_end - __from_next, + __to_end - __to_next, &__state); + if (__conv == static_cast<size_t>(-1)) + { + // In case of error, in order to stop at the exact place we + // have to start again from the beginning with a series of + // mbrtowc. + for (;; ++__to_next, __from += __conv) + { + __conv = mbrtowc(__to_next, __from, __from_end - __from, + &__tmp_state); + if (__conv == static_cast<size_t>(-1) + || __conv == static_cast<size_t>(-2)) + break; + } + __from_next = __from; + __state = __tmp_state; + __ret = error; + } + else if (__from_next && __from_next < __from_chunk_end) + { + // It is unclear what to return in this case (see DR 382). + __to_next += __conv; + __ret = partial; + } + else + { + __from_next = __from_chunk_end; + __to_next += __conv; + } + + if (__from_next < __from_end && __ret == ok) + { + if (__to_next < __to_end) + { + // XXX Probably wrong for stateful encodings + __tmp_state = __state; + ++__from_next; + *__to_next++ = L'\0'; + } + else + __ret = partial; + } + } + + uselocale((locale_t)__old); + + 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; + __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_codecvt); + if (MB_CUR_MAX == 1) + __ret = 1; + uselocale((locale_t)__old); + return __ret; + } + + int + codecvt<wchar_t, char, mbstate_t>:: + do_max_length() const throw() + { + __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_codecvt); + // XXX Probably wrong for stateful encodings. + int __ret = MB_CUR_MAX; + uselocale((locale_t)__old); + 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); + + __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_codecvt); + + // mbsnrtowcs is *very* fast but stops if encounters NUL characters: + // in case we advance past it and then continue, in a loop. + // NB: mbsnrtowcs is a GNU extension + + // A dummy internal buffer is needed in order for mbsnrtocws to consider + // its fourth parameter (it wouldn't with NULL as first parameter). + wchar_t* __to = static_cast<wchar_t*>(__builtin_alloca(sizeof(wchar_t) + * __max)); + while (__from < __end && __max) + { + const extern_type* __from_chunk_end; + __from_chunk_end = static_cast<const extern_type*>(memchr(__from, '\0', + __end + - __from)); + if (!__from_chunk_end) + __from_chunk_end = __end; + + const extern_type* __tmp_from = __from; + size_t __conv = mbsnrtowcs(__to, &__from, + __from_chunk_end - __from, + __max, &__state); + if (__conv == static_cast<size_t>(-1)) + { + // In case of error, in order to stop at the exact place we + // have to start again from the beginning with a series of + // mbrtowc. + for (__from = __tmp_from;; __from += __conv) + { + __conv = mbrtowc(0, __from, __end - __from, + &__tmp_state); + if (__conv == static_cast<size_t>(-1) + || __conv == static_cast<size_t>(-2)) + break; + } + __state = __tmp_state; + __ret += __from - __tmp_from; + break; + } + if (!__from) + __from = __from_chunk_end; + + __ret += __from - __tmp_from; + __max -= __conv; + + if (__from < __end && __max) + { + // XXX Probably wrong for stateful encodings + __tmp_state = __state; + ++__from; + ++__ret; + --__max; + } + } + + uselocale((locale_t)__old); + + return __ret; + } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/config/locale/dragonfly/collate_members.cc b/libstdc++-v3/config/locale/dragonfly/collate_members.cc new file mode 100644 index 00000000000..7cd6c5baf19 --- /dev/null +++ b/libstdc++-v3/config/locale/dragonfly/collate_members.cc @@ -0,0 +1,74 @@ +// std::collate implementation details, DragonFly version -*- C++ -*- + +// Copyright (C) 2015 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> +// Modified for DragonFly by John Marino <gnugcc@marino.st> + +#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_l(__one, __two, (locale_t)_M_c_locale_collate); + 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_l(__to, __from, __n, (locale_t)_M_c_locale_collate); } + +#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_l(__one, __two, (locale_t)_M_c_locale_collate); + 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_l(__to, __from, __n, (locale_t)_M_c_locale_collate); } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc b/libstdc++-v3/config/locale/dragonfly/ctype_members.cc index a44b6170c7b..7b6b34f23a6 100644 --- a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc +++ b/libstdc++-v3/config/locale/dragonfly/ctype_members.cc @@ -1,4 +1,4 @@ -// std::ctype implementation details, GNU version -*- C++ -*- +// std::ctype implementation details, DragonFly version -*- C++ -*- // Copyright (C) 2014-2015 Free Software Foundation, Inc. // @@ -27,18 +27,22 @@ // // Written by Benjamin Kosnik <bkoz@redhat.com> +// Modified for DragonFly by John Marino <gnugcc@marino.st> #include <locale> -#include <bits/c++locale_internal.h> -#include <cstdlib> #include <cstring> #include <cstdio> +#ifndef _ISbit +#define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8)) +#endif + 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) { @@ -54,24 +58,63 @@ namespace std _GLIBCXX_VISIBILITY(default) #ifdef _GLIBCXX_USE_WCHAR_T ctype<wchar_t>::__wmask_type - ctype<wchar_t>::_M_convert_to_wmask( - const mask __attribute__((__unused__)) __m) const throw() + ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const throw() { - // DragonFly uses the same codes for 'char' as 'wchar_t', so this routine - // never gets called. - return __wmask_type(); - }; + __wmask_type __ret; + switch (__m) + { + case space: + __ret = wctype_l("space", (locale_t)_M_c_locale_ctype); + break; + case print: + __ret = wctype_l("print", (locale_t)_M_c_locale_ctype); + break; + case cntrl: + __ret = wctype_l("cntrl", (locale_t)_M_c_locale_ctype); + break; + case upper: + __ret = wctype_l("upper", (locale_t)_M_c_locale_ctype); + break; + case lower: + __ret = wctype_l("lower", (locale_t)_M_c_locale_ctype); + break; + case alpha: + __ret = wctype_l("alpha", (locale_t)_M_c_locale_ctype); + break; + case digit: + __ret = wctype_l("digit", (locale_t)_M_c_locale_ctype); + break; + case punct: + __ret = wctype_l("punct", (locale_t)_M_c_locale_ctype); + break; + case xdigit: + __ret = wctype_l("xdigit", (locale_t)_M_c_locale_ctype); + break; + case alnum: + __ret = wctype_l("alnum", (locale_t)_M_c_locale_ctype); + break; + case graph: + __ret = wctype_l("graph", (locale_t)_M_c_locale_ctype); + break; + case blank: + __ret = wctype_l("blank", (locale_t)_M_c_locale_ctype); + break; + default: + __ret = __wmask_type(); + } + return __ret; + } wchar_t ctype<wchar_t>::do_toupper(wchar_t __c) const - { return towupper(__c); } + { return towupper_l(__c, (locale_t)_M_c_locale_ctype); } const wchar_t* ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const { while (__lo < __hi) { - *__lo = towupper(*__lo); + *__lo = towupper_l(*__lo, (locale_t)_M_c_locale_ctype); ++__lo; } return __hi; @@ -79,14 +122,14 @@ namespace std _GLIBCXX_VISIBILITY(default) wchar_t ctype<wchar_t>::do_tolower(wchar_t __c) const - { return towlower(__c); } + { return towlower_l(__c, (locale_t)_M_c_locale_ctype); } const wchar_t* ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const { while (__lo < __hi) { - *__lo = towlower(*__lo); + *__lo = towlower_l(*__lo, (locale_t)_M_c_locale_ctype); ++__lo; } return __hi; @@ -113,10 +156,12 @@ namespace std _GLIBCXX_VISIBILITY(default) char ctype<wchar_t>:: do_narrow(wchar_t __wc, char __dfault) const - { + { if (__wc >= 0 && __wc < 128 && _M_narrow_ok) return _M_narrow[__wc]; + __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_ctype); const int __c = wctob(__wc); + uselocale((locale_t)__old); return (__c == EOF ? __dfault : static_cast<char>(__c)); } @@ -125,6 +170,7 @@ namespace std _GLIBCXX_VISIBILITY(default) do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault, char* __dest) const { + __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_ctype); if (_M_narrow_ok) while (__lo < __hi) { @@ -146,12 +192,14 @@ namespace std _GLIBCXX_VISIBILITY(default) ++__lo; ++__dest; } + uselocale((locale_t)__old); return __hi; } void ctype<wchar_t>::_M_initialize_ctype() throw() { + __c_locale __old = (__c_locale)uselocale((locale_t)_M_c_locale_ctype); wint_t __i; for (__i = 0; __i < 128; ++__i) { @@ -165,9 +213,18 @@ namespace std _GLIBCXX_VISIBILITY(default) _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 __j = 0; + __j < sizeof(_M_widen) / sizeof(wint_t); ++__j) + _M_widen[__j] = btowc(__j); + + for (size_t __k = 0; __k <= 11; ++__k) + { + _M_bit[__k] = static_cast<mask>(_ISbit(__k)); + _M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]); + } + uselocale((locale_t)__old); } #endif // _GLIBCXX_USE_WCHAR_T -} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc b/libstdc++-v3/config/locale/dragonfly/monetary_members.cc new file mode 100644 index 00000000000..5c07c7335b7 --- /dev/null +++ b/libstdc++-v3/config/locale/dragonfly/monetary_members.cc @@ -0,0 +1,903 @@ +// std::moneypunct implementation details, DragonFly version -*- C++ -*- + +// Copyright (C) 2015 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> +// Modified for DragonFly by John Marino <gnugcc@marino.st> + +#include <locale> +#include <cstring> +#include <xlocale.h> + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +// This file might be compiled twice, but we only want to define the members +// of money_base once. +#if ! _GLIBCXX_USE_CXX11_ABI + + // Construct and return valid pattern consisting of some combination of: + // space none symbol sign value + money_base::pattern + money_base::_S_construct_pattern(char __precedes, char __space, + char __posn) throw() + { + pattern __ret; + + // This insanely complicated routine attempts to construct a valid + // pattern for use with moneypunct. A couple of invariants: + + // if (__precedes) symbol -> value + // else value -> symbol + + // if (__space) space + // else none + + // none == never first + // space never first or last + + // Any elegant implementations of this are welcome. + switch (__posn) + { + case 0: + case 1: + // 1 The sign precedes the value and symbol. + __ret.field[0] = sign; + if (__space) + { + // Pattern starts with sign. + if (__precedes) + { + __ret.field[1] = symbol; + __ret.field[3] = value; + } + else + { + __ret.field[1] = value; + __ret.field[3] = symbol; + } + __ret.field[2] = space; + } + else + { + // Pattern starts with sign and ends with none. + if (__precedes) + { + __ret.field[1] = symbol; + __ret.field[2] = value; + } + else + { + __ret.field[1] = value; + __ret.field[2] = symbol; + } + __ret.field[3] = none; + } + break; + case 2: + // 2 The sign follows the value and symbol. + if (__space) + { + // Pattern either ends with sign. + if (__precedes) + { + __ret.field[0] = symbol; + __ret.field[2] = value; + } + else + { + __ret.field[0] = value; + __ret.field[2] = symbol; + } + __ret.field[1] = space; + __ret.field[3] = sign; + } + else + { + // Pattern ends with sign then none. + if (__precedes) + { + __ret.field[0] = symbol; + __ret.field[1] = value; + } + else + { + __ret.field[0] = value; + __ret.field[1] = symbol; + } + __ret.field[2] = sign; + __ret.field[3] = none; + } + break; + case 3: + // 3 The sign immediately precedes the symbol. + if (__precedes) + { + __ret.field[0] = sign; + __ret.field[1] = symbol; + if (__space) + { + __ret.field[2] = space; + __ret.field[3] = value; + } + else + { + __ret.field[2] = value; + __ret.field[3] = none; + } + } + else + { + __ret.field[0] = value; + if (__space) + { + __ret.field[1] = space; + __ret.field[2] = sign; + __ret.field[3] = symbol; + } + else + { + __ret.field[1] = sign; + __ret.field[2] = symbol; + __ret.field[3] = none; + } + } + break; + case 4: + // 4 The sign immediately follows the symbol. + if (__precedes) + { + __ret.field[0] = symbol; + __ret.field[1] = sign; + if (__space) + { + __ret.field[2] = space; + __ret.field[3] = value; + } + else + { + __ret.field[2] = value; + __ret.field[3] = none; + } + } + else + { + __ret.field[0] = value; + if (__space) + { + __ret.field[1] = space; + __ret.field[2] = symbol; + __ret.field[3] = sign; + } + else + { + __ret.field[1] = symbol; + __ret.field[2] = sign; + __ret.field[3] = none; + } + } + break; + default: + __ret = pattern(); + } + return __ret; + } +#endif + + template<> + void + moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc, + const char*) + { + if (!_M_data) + _M_data = new __moneypunct_cache<char, true>; + + if (!__cloc) + { + // "C" locale + _M_data->_M_decimal_point = '.'; + _M_data->_M_thousands_sep = ','; + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + _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]; + } + else + { + // Named locale. + lconv* lc = localeconv_l((locale_t) __cloc); + + // Check for NULL, which implies no fractional digits. + if (lc->mon_decimal_point == NULL || + lc->mon_decimal_point[0] == '\0') + { + // Like in "C" locale. + _M_data->_M_frac_digits = 0; + _M_data->_M_decimal_point = '.'; + } + else + { + _M_data->_M_decimal_point = lc->mon_decimal_point[0]; + _M_data->_M_frac_digits = lc->int_frac_digits; + } + + const char* __cgroup = lc->mon_grouping; + const char* __cpossign = lc->positive_sign; + const char* __cnegsign = lc->negative_sign; + // _Intl == true + const char* __ccurr = lc->int_curr_symbol; + + char* __group = 0; + char* __ps = 0; + char* __ns = 0; + const char __nposn = lc->int_n_sign_posn; + __try + { + size_t __len; + + // Check for NULL, which implies no grouping. + if (lc->mon_thousands_sep == NULL || + lc->mon_thousands_sep[0] == '\0') + { + // Like in "C" locale. + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + _M_data->_M_thousands_sep = ','; + } + else + { + _M_data->_M_thousands_sep = lc->mon_thousands_sep[0]; + + __len = strlen(__cgroup); + if (__len) + { + __group = new char[__len + 1]; + memcpy(__group, __cgroup, __len + 1); + _M_data->_M_grouping = __group; + } + else + { + _M_data->_M_grouping = ""; + _M_data->_M_use_grouping = false; + } + _M_data->_M_grouping_size = __len; + } + + __len = strlen(__cpossign); + if (__len) + { + __ps = new char[__len + 1]; + memcpy(__ps, __cpossign, __len + 1); + _M_data->_M_positive_sign = __ps; + } + else + _M_data->_M_positive_sign = ""; + _M_data->_M_positive_sign_size = __len; + + if (!__nposn) + { + _M_data->_M_negative_sign = "()"; + _M_data->_M_negative_sign_size = 2; + } + else + { + __len = strlen(__cnegsign); + if (__len) + { + __ns = new char[__len + 1]; + memcpy(__ns, __cnegsign, __len + 1); + _M_data->_M_negative_sign = __ns; + } + else + _M_data->_M_negative_sign = ""; + _M_data->_M_negative_sign_size = __len; + } + + __len = strlen(__ccurr); + if (__len) + { + char* __curr = new char[__len + 1]; + memcpy(__curr, __ccurr, __len + 1); + _M_data->_M_curr_symbol = __curr; + } + else + _M_data->_M_curr_symbol = ""; + _M_data->_M_curr_symbol_size = __len; + } + __catch(...) + { + delete _M_data; + _M_data = 0; + delete [] __group; + delete [] __ps; + delete [] __ns; + __throw_exception_again; + } + + char __pprecedes = lc->int_p_cs_precedes; + char __pspace = lc->int_p_sep_by_space; + char __pposn = lc->int_p_sign_posn; + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + __pposn); + char __nprecedes = lc->int_n_cs_precedes; + char __nspace = lc->int_n_sep_by_space; + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + __nposn); + } + } + + template<> + void + moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc, + const char*) + { + if (!_M_data) + _M_data = new __moneypunct_cache<char, false>; + + if (!__cloc) + { + // "C" locale + _M_data->_M_decimal_point = '.'; + _M_data->_M_thousands_sep = ','; + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + _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]; + } + else + { + // Named locale. + lconv* lc = localeconv_l((locale_t) __cloc); + + // Check for NULL, which implies no fractional digits. + if (lc->mon_decimal_point == NULL || + lc->mon_decimal_point[0] == '\0') + { + // Like in "C" locale. + _M_data->_M_frac_digits = 0; + _M_data->_M_decimal_point = '.'; + } + else + { + _M_data->_M_decimal_point = lc->mon_decimal_point[0]; + _M_data->_M_frac_digits = lc->frac_digits; + } + + const char* __cgroup = lc->mon_grouping; + const char* __cpossign = lc->positive_sign; + const char* __cnegsign = lc->negative_sign; + // _Intl == false + const char* __ccurr = lc->currency_symbol; + + char* __group = 0; + char* __ps = 0; + char* __ns = 0; + const char __nposn = lc->n_sign_posn; + __try + { + size_t __len; + + // Check for NULL, which implies no grouping. + if (lc->mon_thousands_sep == NULL || + lc->mon_thousands_sep[0] == '\0') + { + // Like in "C" locale. + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + _M_data->_M_thousands_sep = ','; + } + else + { + _M_data->_M_thousands_sep = lc->mon_thousands_sep[0]; + + __len = strlen(__cgroup); + if (__len) + { + __group = new char[__len + 1]; + memcpy(__group, __cgroup, __len + 1); + _M_data->_M_grouping = __group; + } + else + { + _M_data->_M_grouping = ""; + _M_data->_M_use_grouping = false; + } + _M_data->_M_grouping_size = __len; + } + + __len = strlen(__cpossign); + if (__len) + { + __ps = new char[__len + 1]; + memcpy(__ps, __cpossign, __len + 1); + _M_data->_M_positive_sign = __ps; + } + else + _M_data->_M_positive_sign = ""; + _M_data->_M_positive_sign_size = __len; + + if (!__nposn) + { + _M_data->_M_negative_sign = "()"; + _M_data->_M_negative_sign_size = 2; + } + else + { + __len = strlen(__cnegsign); + if (__len) + { + __ns = new char[__len + 1]; + memcpy(__ns, __cnegsign, __len + 1); + _M_data->_M_negative_sign = __ns; + } + else + _M_data->_M_negative_sign = ""; + _M_data->_M_negative_sign_size = __len; + } + + __len = strlen(__ccurr); + if (__len) + { + char* __curr = new char[__len + 1]; + memcpy(__curr, __ccurr, __len + 1); + _M_data->_M_curr_symbol = __curr; + } + else + _M_data->_M_curr_symbol = ""; + _M_data->_M_curr_symbol_size = __len; + } + __catch(...) + { + delete _M_data; + _M_data = 0; + delete [] __group; + delete [] __ps; + delete [] __ns; + __throw_exception_again; + } + + char __pprecedes = lc->p_cs_precedes; + char __pspace = lc->p_sep_by_space; + char __pposn = lc->p_sign_posn; + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + __pposn); + char __nprecedes = lc->n_cs_precedes; + char __nspace = lc->n_sep_by_space; + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + __nposn); + } + } + + template<> + moneypunct<char, true>::~moneypunct() + { + if (_M_data->_M_grouping_size) + delete [] _M_data->_M_grouping; + if (_M_data->_M_positive_sign_size) + delete [] _M_data->_M_positive_sign; + if (_M_data->_M_negative_sign_size + && strcmp(_M_data->_M_negative_sign, "()") != 0) + delete [] _M_data->_M_negative_sign; + if (_M_data->_M_curr_symbol_size) + delete [] _M_data->_M_curr_symbol; + delete _M_data; + } + + template<> + moneypunct<char, false>::~moneypunct() + { + if (_M_data->_M_grouping_size) + delete [] _M_data->_M_grouping; + if (_M_data->_M_positive_sign_size) + delete [] _M_data->_M_positive_sign; + if (_M_data->_M_negative_sign_size + && strcmp(_M_data->_M_negative_sign, "()") != 0) + delete [] _M_data->_M_negative_sign; + if (_M_data->_M_curr_symbol_size) + delete [] _M_data->_M_curr_symbol; + delete _M_data; + } + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + void + moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc, + const char*) + { + if (!_M_data) + _M_data = new __moneypunct_cache<wchar_t, true>; + + if (!__cloc) + { + // "C" locale + _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_use_grouping = false; + _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; + + // Use ctype::widen code without the facet... + 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]); + } + else + { + __c_locale __old = (__c_locale)uselocale((locale_t)__cloc); + // Named locale. + lconv* lc = localeconv_l((locale_t) __cloc); + + // Check for NULL, which implies no fractional digits. + if (lc->mon_decimal_point == NULL || + lc->mon_decimal_point[0] == '\0') + { + // Like in "C" locale. + _M_data->_M_frac_digits = 0; + _M_data->_M_decimal_point = L'.'; + } + else + { + _M_data->_M_frac_digits = lc->int_frac_digits; + _M_data->_M_decimal_point = (wchar_t)lc->mon_decimal_point[0]; + } + + const char* __cgroup = lc->mon_grouping; + const char* __cpossign = lc->positive_sign; + const char* __cnegsign = lc->negative_sign; + const char* __ccurr = lc->int_curr_symbol; + + char* __group = 0; + wchar_t* __wcs_ps = 0; + wchar_t* __wcs_ns = 0; + const char __nposn = lc->int_n_sign_posn; + __try + { + size_t __len; + + // Check for NULL, which implies no grouping. + if (lc->mon_thousands_sep == NULL || + lc->mon_thousands_sep[0] == '\0') + { + // Like in "C" locale. + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + _M_data->_M_thousands_sep = L','; + } + else + { + _M_data->_M_thousands_sep = + (wchar_t)lc->mon_thousands_sep[0]; + __len = strlen(__cgroup); + if (__len) + { + __group = new char[__len + 1]; + memcpy(__group, __cgroup, __len + 1); + _M_data->_M_grouping = __group; + } + else + { + _M_data->_M_grouping = ""; + _M_data->_M_use_grouping = false; + } + _M_data->_M_grouping_size = __len; + } + + mbstate_t __state; + __len = strlen(__cpossign); + if (__len) + { + memset(&__state, 0, sizeof(mbstate_t)); + __wcs_ps = new wchar_t[__len + 1]; + mbsrtowcs(__wcs_ps, &__cpossign, __len + 1, &__state); + _M_data->_M_positive_sign = __wcs_ps; + } + else + _M_data->_M_positive_sign = L""; + _M_data->_M_positive_sign_size = + wcslen(_M_data->_M_positive_sign); + + __len = strlen(__cnegsign); + if (!__nposn) + _M_data->_M_negative_sign = L"()"; + else if (__len) + { + memset(&__state, 0, sizeof(mbstate_t)); + __wcs_ns = new wchar_t[__len + 1]; + mbsrtowcs(__wcs_ns, &__cnegsign, __len + 1, &__state); + _M_data->_M_negative_sign = __wcs_ns; + } + else + _M_data->_M_negative_sign = L""; + _M_data->_M_negative_sign_size = + wcslen(_M_data->_M_negative_sign); + + // _Intl == true. + __len = strlen(__ccurr); + if (__len) + { + memset(&__state, 0, sizeof(mbstate_t)); + wchar_t* __wcs = new wchar_t[__len + 1]; + mbsrtowcs(__wcs, &__ccurr, __len + 1, &__state); + _M_data->_M_curr_symbol = __wcs; + } + else + _M_data->_M_curr_symbol = L""; + _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol); + } + __catch(...) + { + delete _M_data; + _M_data = 0; + delete [] __group; + delete [] __wcs_ps; + delete [] __wcs_ns; + uselocale((locale_t)__old); + __throw_exception_again; + } + + char __pprecedes = lc->int_p_cs_precedes; + char __pspace = lc->int_p_sep_by_space; + char __pposn = lc->int_p_sign_posn; + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + __pposn); + char __nprecedes = lc->int_n_cs_precedes; + char __nspace = lc->int_n_sep_by_space; + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + __nposn); + + uselocale((locale_t)__old); + } + } + + template<> + void + moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc, + const char*) + { + if (!_M_data) + _M_data = new __moneypunct_cache<wchar_t, false>; + + if (!__cloc) + { + // "C" locale + _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_use_grouping = false; + _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; + + // Use ctype::widen code without the facet... + 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]); + } + else + { + __c_locale __old = (__c_locale)uselocale((locale_t)__cloc); + // Named locale. + lconv* lc = localeconv_l((locale_t) __cloc); + + // Check for NULL, which implies no fractional digits. + if (lc->mon_decimal_point == NULL || + lc->mon_decimal_point[0] == '\0') + { + // Like in "C" locale. + _M_data->_M_frac_digits = 0; + _M_data->_M_decimal_point = L'.'; + } + else + { + _M_data->_M_frac_digits = lc->frac_digits; + _M_data->_M_decimal_point = (wchar_t)lc->mon_decimal_point[0]; + } + + const char* __cgroup = lc->mon_grouping; + const char* __cpossign = lc->positive_sign; + const char* __cnegsign = lc->negative_sign; + const char* __ccurr = lc->currency_symbol; + + char* __group = 0; + wchar_t* __wcs_ps = 0; + wchar_t* __wcs_ns = 0; + const char __nposn = lc->n_sign_posn; + __try + { + size_t __len; + + // Check for NULL, which implies no grouping. + if (lc->mon_thousands_sep == NULL || + lc->mon_thousands_sep[0] == '\0') + { + // Like in "C" locale. + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + _M_data->_M_thousands_sep = L','; + } + else + { + _M_data->_M_thousands_sep = + (wchar_t)lc->mon_thousands_sep[0]; + __len = strlen(__cgroup); + if (__len) + { + __group = new char[__len + 1]; + memcpy(__group, __cgroup, __len + 1); + _M_data->_M_grouping = __group; + } + else + { + _M_data->_M_grouping = ""; + _M_data->_M_use_grouping = false; + } + _M_data->_M_grouping_size = __len; + } + + mbstate_t __state; + __len = strlen(__cpossign); + if (__len) + { + memset(&__state, 0, sizeof(mbstate_t)); + __wcs_ps = new wchar_t[__len + 1]; + mbsrtowcs(__wcs_ps, &__cpossign, __len + 1, &__state); + _M_data->_M_positive_sign = __wcs_ps; + } + else + _M_data->_M_positive_sign = L""; + _M_data->_M_positive_sign_size = + wcslen(_M_data->_M_positive_sign); + + __len = strlen(__cnegsign); + if (!__nposn) + _M_data->_M_negative_sign = L"()"; + else if (__len) + { + memset(&__state, 0, sizeof(mbstate_t)); + __wcs_ns = new wchar_t[__len + 1]; + mbsrtowcs(__wcs_ns, &__cnegsign, __len + 1, &__state); + _M_data->_M_negative_sign = __wcs_ns; + } + else + _M_data->_M_negative_sign = L""; + _M_data->_M_negative_sign_size = + wcslen(_M_data->_M_negative_sign); + + // _Intl == true. + __len = strlen(__ccurr); + if (__len) + { + memset(&__state, 0, sizeof(mbstate_t)); + wchar_t* __wcs = new wchar_t[__len + 1]; + mbsrtowcs(__wcs, &__ccurr, __len + 1, &__state); + _M_data->_M_curr_symbol = __wcs; + } + else + _M_data->_M_curr_symbol = L""; + _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol); + } + __catch(...) + { + delete _M_data; + _M_data = 0; + delete [] __group; + delete [] __wcs_ps; + delete [] __wcs_ns; + uselocale((locale_t)__old); + __throw_exception_again; + } + + char __pprecedes = lc->p_cs_precedes; + char __pspace = lc->p_sep_by_space; + char __pposn = lc->p_sign_posn; + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + __pposn); + char __nprecedes = lc->n_cs_precedes; + char __nspace = lc->n_sep_by_space; + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + __nposn); + + uselocale((locale_t)__old); + } + } + + template<> + moneypunct<wchar_t, true>::~moneypunct() + { + if (_M_data->_M_grouping_size) + delete [] _M_data->_M_grouping; + if (_M_data->_M_positive_sign_size) + delete [] _M_data->_M_positive_sign; + if (_M_data->_M_negative_sign_size + && wcscmp(_M_data->_M_negative_sign, L"()") != 0) + delete [] _M_data->_M_negative_sign; + if (_M_data->_M_curr_symbol_size) + delete [] _M_data->_M_curr_symbol; + delete _M_data; + } + + template<> + moneypunct<wchar_t, false>::~moneypunct() + { + if (_M_data->_M_grouping_size) + delete [] _M_data->_M_grouping; + if (_M_data->_M_positive_sign_size) + delete [] _M_data->_M_positive_sign; + if (_M_data->_M_negative_sign_size + && wcscmp(_M_data->_M_negative_sign, L"()") != 0) + delete [] _M_data->_M_negative_sign; + if (_M_data->_M_curr_symbol_size) + delete [] _M_data->_M_curr_symbol; + delete _M_data; + } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc b/libstdc++-v3/config/locale/dragonfly/numeric_members.cc new file mode 100644 index 00000000000..ba44045cd70 --- /dev/null +++ b/libstdc++-v3/config/locale/dragonfly/numeric_members.cc @@ -0,0 +1,235 @@ +// std::numpunct implementation details, DragonFly version -*- C++ -*- + +// Copyright (C) 2015 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> +// Modified for DragonFly by John Marino <gnugcc@marino.st> + +#include <locale> +#include <cstring> +#include <xlocale.h> + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template<> + void + numpunct<char>::_M_initialize_numpunct(__c_locale __cloc) + { + if (!_M_data) + _M_data = new __numpunct_cache<char>; + + if (!__cloc) + { + // "C" locale + _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 __j = 0; __j < __num_base::_S_iend; ++__j) + _M_data->_M_atoms_in[__j] = __num_base::_S_atoms_in[__j]; + } + else + { + // Named locale. + lconv* lc = localeconv_l((locale_t) __cloc); + + // Decimal point should always be defined, but check null anyway + if (lc->decimal_point == NULL) + { + // Not defined, so use "C" locale default + _M_data->_M_decimal_point = '.'; + } + else + { + _M_data->_M_decimal_point = lc->decimal_point[0]; + } + // Check for NULL, which implies no grouping. + if (lc->thousands_sep == NULL || lc->thousands_sep[0] == '\0') + { + // Like in "C" locale. + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + _M_data->_M_thousands_sep = ','; + } + else + { + _M_data->_M_thousands_sep = lc->thousands_sep[0]; + + const char* __src = lc->grouping; + const size_t __len = strlen(__src); + if (__len) + { + __try + { + char* __dst = new char[__len + 1]; + memcpy(__dst, __src, __len + 1); + _M_data->_M_grouping = __dst; + _M_data->_M_use_grouping = true; + } + __catch(...) + { + delete _M_data; + _M_data = 0; + __throw_exception_again; + } + } + else + { + _M_data->_M_grouping = ""; + _M_data->_M_use_grouping = false; + } + _M_data->_M_grouping_size = __len; + } + } + + // NB: There is no way to extact this info from posix locales. + // _M_truename = __nl_langinfo_l(YESSTR, __cloc); + _M_data->_M_truename = "true"; + _M_data->_M_truename_size = 4; + // _M_falsename = __nl_langinfo_l(NOSTR, __cloc); + _M_data->_M_falsename = "false"; + _M_data->_M_falsename_size = 5; + } + + template<> + numpunct<char>::~numpunct() + { + if (_M_data->_M_grouping_size) + delete [] _M_data->_M_grouping; + delete _M_data; + } + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + void + numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc) + { + if (!_M_data) + _M_data = new __numpunct_cache<wchar_t>; + + if (!__cloc) + { + // "C" locale + _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 __j = 0; __j < __num_base::_S_iend; ++__j) + _M_data->_M_atoms_in[__j] = + static_cast<wchar_t>(__num_base::_S_atoms_in[__j]); + } + else + { + // Named locale. + lconv* lc = localeconv_l((locale_t) __cloc); + + // Decimal point should always be defined, but check null anyway + if (lc->decimal_point == NULL) + { + // Not defined, so use "C" locale default + _M_data->_M_decimal_point = L'.'; + } + else + { + _M_data->_M_decimal_point = (wchar_t)lc->decimal_point[0]; + } + // Check for NULL, which implies no grouping. + if (lc->thousands_sep == NULL || lc->thousands_sep[0] == '\0') + { + // Like in "C" locale. + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + _M_data->_M_thousands_sep = L','; + } + else + { + _M_data->_M_thousands_sep = (wchar_t)lc->thousands_sep[0]; + + const char* __src = lc->grouping; + const size_t __len = strlen(__src); + if (__len) + { + __try + { + char* __dst = new char[__len + 1]; + memcpy(__dst, __src, __len + 1); + _M_data->_M_grouping = __dst; + } + __catch(...) + { + delete _M_data; + _M_data = 0; + __throw_exception_again; + } + } + else + { + _M_data->_M_grouping = ""; + _M_data->_M_use_grouping = false; + } + _M_data->_M_grouping_size = __len; + } + } + + // NB: There is no way to extact this info from posix locales. + // _M_truename = __nl_langinfo_l(YESSTR, __cloc); + _M_data->_M_truename = L"true"; + _M_data->_M_truename_size = 4; + // _M_falsename = __nl_langinfo_l(NOSTR, __cloc); + _M_data->_M_falsename = L"false"; + _M_data->_M_falsename_size = 5; + } + + template<> + numpunct<wchar_t>::~numpunct() + { + if (_M_data->_M_grouping_size) + delete [] _M_data->_M_grouping; + delete _M_data; + } + #endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.cc b/libstdc++-v3/config/locale/dragonfly/time_members.cc new file mode 100644 index 00000000000..1812e50b5be --- /dev/null +++ b/libstdc++-v3/config/locale/dragonfly/time_members.cc @@ -0,0 +1,404 @@ +// std::time_get, std::time_put implementation, DragonFly version -*- C++ -*- + +// Copyright (C) 2001-2015 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> +// Modified for DragonFly by John Marino <gnugcc@marino.st> + +#include <locale> +#include <ctime> +#include <cwchar> +#include <stdlib.h> +#include <langinfo.h> +#include <xlocale.h> + +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() + { + const size_t __len = strftime_l(__s, __maxlen, __format, __tm, + (locale_t)_M_c_locale_timepunct); + // Make sure __s is null terminated. + if (__len == 0) + __s[0] = '\0'; + } + + template<> + void + __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc) + { + if (!_M_data) + _M_data = new __timepunct_cache<char>; + + if (!__cloc) + { + // "C" locale + _M_c_locale_timepunct = _S_get_c_locale(); + + _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"; + } + else + { + _M_c_locale_timepunct = _S_clone_c_locale(__cloc); + + _M_data->_M_date_format = nl_langinfo_l(D_FMT, (locale_t)__cloc); + _M_data->_M_date_era_format = nl_langinfo_l(ERA_D_FMT, + (locale_t)__cloc); + _M_data->_M_time_format = nl_langinfo_l(T_FMT, (locale_t)__cloc); + _M_data->_M_time_era_format = nl_langinfo_l(ERA_T_FMT, + (locale_t)__cloc); + _M_data->_M_date_time_format = nl_langinfo_l(D_T_FMT, + (locale_t)__cloc); + _M_data->_M_date_time_era_format = nl_langinfo_l(ERA_D_T_FMT, + (locale_t)__cloc); + _M_data->_M_am = nl_langinfo_l(AM_STR, (locale_t)__cloc); + _M_data->_M_pm = nl_langinfo_l(PM_STR, (locale_t)__cloc); + _M_data->_M_am_pm_format = nl_langinfo_l(T_FMT_AMPM, + (locale_t)__cloc); + + // Day names, starting with "C"'s Sunday. + _M_data->_M_day1 = nl_langinfo_l(DAY_1, (locale_t)__cloc); + _M_data->_M_day2 = nl_langinfo_l(DAY_2, (locale_t)__cloc); + _M_data->_M_day3 = nl_langinfo_l(DAY_3, (locale_t)__cloc); + _M_data->_M_day4 = nl_langinfo_l(DAY_4, (locale_t)__cloc); + _M_data->_M_day5 = nl_langinfo_l(DAY_5, (locale_t)__cloc); + _M_data->_M_day6 = nl_langinfo_l(DAY_6, (locale_t)__cloc); + _M_data->_M_day7 = nl_langinfo_l(DAY_7, (locale_t)__cloc); + + // Abbreviated day names, starting with "C"'s Sun. + _M_data->_M_aday1 = nl_langinfo_l(ABDAY_1, (locale_t)__cloc); + _M_data->_M_aday2 = nl_langinfo_l(ABDAY_2, (locale_t)__cloc); + _M_data->_M_aday3 = nl_langinfo_l(ABDAY_3, (locale_t)__cloc); + _M_data->_M_aday4 = nl_langinfo_l(ABDAY_4, (locale_t)__cloc); + _M_data->_M_aday5 = nl_langinfo_l(ABDAY_5, (locale_t)__cloc); + _M_data->_M_aday6 = nl_langinfo_l(ABDAY_6, (locale_t)__cloc); + _M_data->_M_aday7 = nl_langinfo_l(ABDAY_7, (locale_t)__cloc); + + // Month names, starting with "C"'s January. + _M_data->_M_month01 = nl_langinfo_l(MON_1, (locale_t)__cloc); + _M_data->_M_month02 = nl_langinfo_l(MON_2, (locale_t)__cloc); + _M_data->_M_month03 = nl_langinfo_l(MON_3, (locale_t)__cloc); + _M_data->_M_month04 = nl_langinfo_l(MON_4, (locale_t)__cloc); + _M_data->_M_month05 = nl_langinfo_l(MON_5, (locale_t)__cloc); + _M_data->_M_month06 = nl_langinfo_l(MON_6, (locale_t)__cloc); + _M_data->_M_month07 = nl_langinfo_l(MON_7, (locale_t)__cloc); + _M_data->_M_month08 = nl_langinfo_l(MON_8, (locale_t)__cloc); + _M_data->_M_month09 = nl_langinfo_l(MON_9, (locale_t)__cloc); + _M_data->_M_month10 = nl_langinfo_l(MON_10, (locale_t)__cloc); + _M_data->_M_month11 = nl_langinfo_l(MON_11, (locale_t)__cloc); + _M_data->_M_month12 = nl_langinfo_l(MON_12, (locale_t)__cloc); + + // Abbreviated month names, starting with "C"'s Jan. + _M_data->_M_amonth01 = nl_langinfo_l(ABMON_1, (locale_t)__cloc); + _M_data->_M_amonth02 = nl_langinfo_l(ABMON_2, (locale_t)__cloc); + _M_data->_M_amonth03 = nl_langinfo_l(ABMON_3, (locale_t)__cloc); + _M_data->_M_amonth04 = nl_langinfo_l(ABMON_4, (locale_t)__cloc); + _M_data->_M_amonth05 = nl_langinfo_l(ABMON_5, (locale_t)__cloc); + _M_data->_M_amonth06 = nl_langinfo_l(ABMON_6, (locale_t)__cloc); + _M_data->_M_amonth07 = nl_langinfo_l(ABMON_7, (locale_t)__cloc); + _M_data->_M_amonth08 = nl_langinfo_l(ABMON_8, (locale_t)__cloc); + _M_data->_M_amonth09 = nl_langinfo_l(ABMON_9, (locale_t)__cloc); + _M_data->_M_amonth10 = nl_langinfo_l(ABMON_10, (locale_t)__cloc); + _M_data->_M_amonth11 = nl_langinfo_l(ABMON_11, (locale_t)__cloc); + _M_data->_M_amonth12 = nl_langinfo_l(ABMON_12, (locale_t)__cloc); + } + } + +#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() + { + const size_t __len = wcsftime_l(__s, __maxlen, __format, __tm, + (locale_t)_M_c_locale_timepunct); + // Make sure __s is null terminated. + if (__len == 0) + __s[0] = L'\0'; + } + +#define WIDE_LANGINFO(M,FMT) \ + fmtlen = mbstowcs_l (holder, nl_langinfo_l(FMT, (locale_t)__cloc), \ + 128, (locale_t)__cloc); \ + langstring = new wchar_t[fmtlen + 1]; \ + wcsncpy (langstring, holder, fmtlen); \ + langstring[fmtlen] = L'\0'; \ + _M_data->M = langstring; + + template<> + void + __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc) + { + if (!_M_data) + _M_data = new __timepunct_cache<wchar_t>; + + if (!__cloc) + { + // "C" locale + _M_c_locale_timepunct = _S_get_c_locale(); + + _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"; + } + else + { + wchar_t *langstring = 0; + wchar_t holder[128]; + size_t fmtlen; + + _M_c_locale_timepunct = _S_clone_c_locale(__cloc); + + WIDE_LANGINFO(_M_date_format, D_FMT) + WIDE_LANGINFO(_M_date_era_format, ERA_D_FMT) + WIDE_LANGINFO(_M_time_format, T_FMT) + WIDE_LANGINFO(_M_time_era_format, ERA_T_FMT) + WIDE_LANGINFO(_M_date_time_format, D_T_FMT) + WIDE_LANGINFO(_M_date_time_era_format, ERA_D_T_FMT) + WIDE_LANGINFO(_M_am, AM_STR) + WIDE_LANGINFO(_M_pm, PM_STR) + WIDE_LANGINFO(_M_am_pm_format, T_FMT_AMPM) + + // Day names, starting with "C"'s Sunday. + WIDE_LANGINFO(_M_day1, DAY_1) + WIDE_LANGINFO(_M_day2, DAY_2) + WIDE_LANGINFO(_M_day3, DAY_3) + WIDE_LANGINFO(_M_day4, DAY_4) + WIDE_LANGINFO(_M_day5, DAY_5) + WIDE_LANGINFO(_M_day6, DAY_6) + WIDE_LANGINFO(_M_day7, DAY_7) + + // Abbreviated day names, starting with "C"'s Sun. + WIDE_LANGINFO(_M_aday1, ABDAY_1) + WIDE_LANGINFO(_M_aday2, ABDAY_2) + WIDE_LANGINFO(_M_aday3, ABDAY_3) + WIDE_LANGINFO(_M_aday4, ABDAY_4) + WIDE_LANGINFO(_M_aday5, ABDAY_5) + WIDE_LANGINFO(_M_aday6, ABDAY_6) + WIDE_LANGINFO(_M_aday7, ABDAY_7) + + // Month names, starting with "C"'s January. + WIDE_LANGINFO(_M_month01, MON_1) + WIDE_LANGINFO(_M_month02, MON_2) + WIDE_LANGINFO(_M_month03, MON_3) + WIDE_LANGINFO(_M_month04, MON_4) + WIDE_LANGINFO(_M_month05, MON_5) + WIDE_LANGINFO(_M_month06, MON_6) + WIDE_LANGINFO(_M_month07, MON_7) + WIDE_LANGINFO(_M_month08, MON_8) + WIDE_LANGINFO(_M_month09, MON_9) + WIDE_LANGINFO(_M_month10, MON_10) + WIDE_LANGINFO(_M_month11, MON_11) + WIDE_LANGINFO(_M_month12, MON_12) + + // Abbreviated month names, starting with "C"'s Jan. + WIDE_LANGINFO(_M_amonth01, ABMON_1) + WIDE_LANGINFO(_M_amonth02, ABMON_2) + WIDE_LANGINFO(_M_amonth03, ABMON_3) + WIDE_LANGINFO(_M_amonth04, ABMON_4) + WIDE_LANGINFO(_M_amonth05, ABMON_5) + WIDE_LANGINFO(_M_amonth06, ABMON_6) + WIDE_LANGINFO(_M_amonth07, ABMON_7) + WIDE_LANGINFO(_M_amonth08, ABMON_8) + WIDE_LANGINFO(_M_amonth09, ABMON_9) + WIDE_LANGINFO(_M_amonth10, ABMON_10) + WIDE_LANGINFO(_M_amonth11, ABMON_11) + WIDE_LANGINFO(_M_amonth12, ABMON_12) + } + } + + template<> + __timepunct<wchar_t>::~__timepunct() + { + delete [] _M_data->_M_date_format; + delete [] _M_data->_M_date_era_format; + delete [] _M_data->_M_time_format; + delete [] _M_data->_M_time_era_format; + delete [] _M_data->_M_date_time_format; + delete [] _M_data->_M_date_time_era_format; + delete [] _M_data->_M_am; + delete [] _M_data->_M_pm; + delete [] _M_data->_M_am_pm_format; + delete [] _M_data->_M_day1; + delete [] _M_data->_M_day2; + delete [] _M_data->_M_day3; + delete [] _M_data->_M_day4; + delete [] _M_data->_M_day5; + delete [] _M_data->_M_day6; + delete [] _M_data->_M_day7; + delete [] _M_data->_M_aday1; + delete [] _M_data->_M_aday2; + delete [] _M_data->_M_aday3; + delete [] _M_data->_M_aday4; + delete [] _M_data->_M_aday5; + delete [] _M_data->_M_aday6; + delete [] _M_data->_M_aday7; + delete [] _M_data->_M_month01; + delete [] _M_data->_M_month02; + delete [] _M_data->_M_month03; + delete [] _M_data->_M_month04; + delete [] _M_data->_M_month05; + delete [] _M_data->_M_month06; + delete [] _M_data->_M_month07; + delete [] _M_data->_M_month08; + delete [] _M_data->_M_month09; + delete [] _M_data->_M_month10; + delete [] _M_data->_M_month11; + delete [] _M_data->_M_month12; + delete [] _M_data->_M_amonth01; + delete [] _M_data->_M_amonth02; + delete [] _M_data->_M_amonth03; + delete [] _M_data->_M_amonth04; + delete [] _M_data->_M_amonth05; + delete [] _M_data->_M_amonth06; + delete [] _M_data->_M_amonth07; + delete [] _M_data->_M_amonth08; + delete [] _M_data->_M_amonth09; + delete [] _M_data->_M_amonth10; + delete [] _M_data->_M_amonth11; + delete [] _M_data->_M_amonth12; + delete _M_data; + } + +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.h b/libstdc++-v3/config/locale/dragonfly/time_members.h new file mode 100644 index 00000000000..fb78bc6e45f --- /dev/null +++ b/libstdc++-v3/config/locale/dragonfly/time_members.h @@ -0,0 +1,95 @@ +// std::time_get, std::time_put implementation, DragonFly version -*- C++ -*- + +// Copyright (C) 2015 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 bits/time_members.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.2.5.1.2 - time_get functions +// ISO C++ 14882: 22.2.5.3.2 - time_put functions +// + +// Written by Benjamin Kosnik <bkoz@redhat.com> +// Modified for DragonFly by John Marino <gnugcc@marino.st> + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template<typename _CharT> + __timepunct<_CharT>::__timepunct(size_t __refs) + : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), + _M_name_timepunct(_S_get_c_name()) + { _M_initialize_timepunct(); } + + template<typename _CharT> + __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) + : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(0), + _M_name_timepunct(_S_get_c_name()) + { _M_initialize_timepunct(); } + + template<typename _CharT> + __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, + size_t __refs) + : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), + _M_name_timepunct(0) + { + if (__builtin_strcmp(__s, _S_get_c_name()) != 0) + { + const size_t __len = __builtin_strlen(__s) + 1; + char* __tmp = new char[__len]; + __builtin_memcpy(__tmp, __s, __len); + _M_name_timepunct = __tmp; + } + else + _M_name_timepunct = _S_get_c_name(); + + __try + { _M_initialize_timepunct(__cloc); } + __catch(...) + { + if (_M_name_timepunct != _S_get_c_name()) + delete [] _M_name_timepunct; + __throw_exception_again; + } + } + + template<typename _CharT> + __timepunct<_CharT>::~__timepunct() + { + if (_M_name_timepunct != _S_get_c_name()) + delete [] _M_name_timepunct; + delete _M_data; + _S_destroy_c_locale(_M_c_locale_timepunct); + } + + // specialization + template<> + __timepunct<wchar_t>::~__timepunct(); + + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/config/os/bsd/dragonfly/ctype_configure_char.cc b/libstdc++-v3/config/os/bsd/dragonfly/ctype_configure_char.cc index 043d1365b39..b1c24a2e1a5 100644 --- a/libstdc++-v3/config/os/bsd/dragonfly/ctype_configure_char.cc +++ b/libstdc++-v3/config/os/bsd/dragonfly/ctype_configure_char.cc @@ -37,32 +37,60 @@ namespace std _GLIBCXX_VISIBILITY(default) _GLIBCXX_BEGIN_NAMESPACE_VERSION // Information as gleaned from /usr/include/ctype.h - + const ctype_base::mask* ctype<char>::classic_table() throw() - { return 0; } - - 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()) - { + { return NULL; } + + ctype<char>::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()), + _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0) + { + char* __old = setlocale(LC_CTYPE, NULL); + char* __sav = NULL; + if (strcmp(__old, "C")) + { + const size_t __len = strlen(__old) + 1; + __sav = new char[__len]; + memcpy(__sav, __old, __len); + setlocale(LC_CTYPE, "C"); + } + _M_toupper = NULL; + _M_tolower = NULL; + _M_table = __table ? __table : classic_table(); + if (__sav) + { + setlocale(LC_CTYPE, __sav); + delete [] __sav; + } 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()) - { + ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) + : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()), + _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0) + { + char* __old = setlocale(LC_CTYPE, NULL); + char* __sav = NULL; + if (strcmp(__old, "C")) + { + const size_t __len = strlen(__old) + 1; + __sav = new char[__len]; + memcpy(__sav, __old, __len); + setlocale(LC_CTYPE, "C"); + } + _M_toupper = NULL; + _M_tolower = NULL; + _M_table = __table ? __table : classic_table(); + if (__sav) + { + setlocale(LC_CTYPE, __sav); + delete [] __sav; + } memset(_M_widen, 0, sizeof(_M_widen)); - _M_widen_ok = 0; memset(_M_narrow, 0, sizeof(_M_narrow)); - _M_narrow_ok = 0; } char @@ -84,7 +112,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ctype<char>::do_tolower(char __c) const { return ::tolower((int) __c); } - const char* + const char* ctype<char>::do_tolower(char* __low, const char* __high) const { while (__low < __high) diff --git a/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h b/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h index 5e11c451ec2..2209129145a 100644 --- a/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h +++ b/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h @@ -29,6 +29,7 @@ // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. +#define _GLIBCXX_USE_C99 1 #define _GLIBCXX_USE_C99_CHECK 1 #define _GLIBCXX_USE_C99_DYNAMIC (!(__ISO_C_VISIBLE >= 1999)) #define _GLIBCXX_USE_C99_LONG_LONG_CHECK 1 diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 3bee21204f6..8646465fbbe 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -15986,17 +15986,17 @@ $as_echo "darwin or freebsd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: dragonfly" >&5 $as_echo "dragonfly" >&6; } - CLOCALE_H=config/locale/generic/c_locale.h + CLOCALE_H=config/locale/dragonfly/c_locale.h CLOCALE_CC=config/locale/dragonfly/c_locale.cc - CCODECVT_CC=config/locale/generic/codecvt_members.cc - CCOLLATE_CC=config/locale/generic/collate_members.cc + CCODECVT_CC=config/locale/dragonfly/codecvt_members.cc + CCOLLATE_CC=config/locale/dragonfly/collate_members.cc CCTYPE_CC=config/locale/dragonfly/ctype_members.cc CMESSAGES_H=config/locale/generic/messages_members.h CMESSAGES_CC=config/locale/generic/messages_members.cc - CMONEY_CC=config/locale/generic/monetary_members.cc - CNUMERIC_CC=config/locale/generic/numeric_members.cc - CTIME_H=config/locale/generic/time_members.h - CTIME_CC=config/locale/generic/time_members.cc + CMONEY_CC=config/locale/dragonfly/monetary_members.cc + CNUMERIC_CC=config/locale/dragonfly/numeric_members.cc + CTIME_H=config/locale/dragonfly/time_members.h + CTIME_CC=config/locale/dragonfly/time_members.cc CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h ;; @@ -27602,31 +27602,6 @@ fi - am_save_CPPFLAGS="$CPPFLAGS" - - for element in $INCICONV; do - haveit= - for x in $CPPFLAGS; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" - fi - done - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 $as_echo_n "checking for iconv... " >&6; } if test "${am_cv_func_iconv+set}" = set; then : @@ -27635,6 +27610,8 @@ else am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no + am_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCICONV" if test x$gcc_no_link = xyes; then as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 fi @@ -27657,8 +27634,52 @@ if ac_fn_c_try_link "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + CPPFLAGS="$am_save_CPPFLAGS" + + if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then + for _libs in .libs _libs; do + am_save_CPPFLAGS="$CPPFLAGS" + am_save_LIBS="$LIBS" + CPPFLAGS="$CPPFLAGS -I../libiconv/include" + LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a" + if test x$gcc_no_link = xyes; then + as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdlib.h> +#include <iconv.h> +int +main () +{ +iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + INCICONV="-I../libiconv/include" + LIBICONV='${top_builddir}'/../libiconv/lib/$_libs/libiconv.a + LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la + am_cv_lib_iconv=yes + am_cv_func_iconv=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CPPFLAGS="$am_save_CPPFLAGS" + LIBS="$am_save_LIBS" + if test "$am_cv_func_iconv" = "yes"; then + break + fi + done + fi + if test "$am_cv_func_iconv" != yes; then + am_save_CPPFLAGS="$CPPFLAGS" am_save_LIBS="$LIBS" + CPPFLAGS="$LIBS $INCICONV" LIBS="$LIBS $LIBICONV" if test x$gcc_no_link = xyes; then as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 @@ -27683,6 +27704,7 @@ if ac_fn_c_try_link "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + CPPFLAGS="$am_save_CPPFLAGS" LIBS="$am_save_LIBS" fi @@ -27695,12 +27717,34 @@ $as_echo "#define HAVE_ICONV 1" >>confdefs.h fi if test "$am_cv_lib_iconv" = yes; then + + for element in $INCICONV; do + haveit= + for x in $CPPFLAGS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" + fi + done + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 $as_echo_n "checking how to link with libiconv... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 $as_echo "$LIBICONV" >&6; } else - CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi @@ -39833,31 +39877,6 @@ done - am_save_CPPFLAGS="$CPPFLAGS" - - for element in $INCICONV; do - haveit= - for x in $CPPFLAGS; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" - fi - done - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 $as_echo_n "checking for iconv... " >&6; } if test "${am_cv_func_iconv+set}" = set; then : @@ -39866,6 +39885,8 @@ else am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no + am_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCICONV" if test x$gcc_no_link = xyes; then as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 fi @@ -39888,8 +39909,52 @@ if ac_fn_c_try_link "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + CPPFLAGS="$am_save_CPPFLAGS" + + if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then + for _libs in .libs _libs; do + am_save_CPPFLAGS="$CPPFLAGS" + am_save_LIBS="$LIBS" + CPPFLAGS="$CPPFLAGS -I../libiconv/include" + LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a" + if test x$gcc_no_link = xyes; then + as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdlib.h> +#include <iconv.h> +int +main () +{ +iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + INCICONV="-I../libiconv/include" + LIBICONV='${top_builddir}'/../libiconv/lib/$_libs/libiconv.a + LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la + am_cv_lib_iconv=yes + am_cv_func_iconv=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CPPFLAGS="$am_save_CPPFLAGS" + LIBS="$am_save_LIBS" + if test "$am_cv_func_iconv" = "yes"; then + break + fi + done + fi + if test "$am_cv_func_iconv" != yes; then + am_save_CPPFLAGS="$CPPFLAGS" am_save_LIBS="$LIBS" + CPPFLAGS="$LIBS $INCICONV" LIBS="$LIBS $LIBICONV" if test x$gcc_no_link = xyes; then as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 @@ -39914,6 +39979,7 @@ if ac_fn_c_try_link "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + CPPFLAGS="$am_save_CPPFLAGS" LIBS="$am_save_LIBS" fi @@ -39926,12 +39992,34 @@ $as_echo "#define HAVE_ICONV 1" >>confdefs.h fi if test "$am_cv_lib_iconv" = yes; then + + for element in $INCICONV; do + haveit= + for x in $CPPFLAGS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" + fi + done + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 $as_echo_n "checking how to link with libiconv... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 $as_echo "$LIBICONV" >&6; } else - CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi @@ -45913,31 +46001,6 @@ done - am_save_CPPFLAGS="$CPPFLAGS" - - for element in $INCICONV; do - haveit= - for x in $CPPFLAGS; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" - fi - done - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 $as_echo_n "checking for iconv... " >&6; } if test "${am_cv_func_iconv+set}" = set; then : @@ -45946,6 +46009,8 @@ else am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no + am_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCICONV" if test x$gcc_no_link = xyes; then as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 fi @@ -45968,8 +46033,52 @@ if ac_fn_c_try_link "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + CPPFLAGS="$am_save_CPPFLAGS" + + if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then + for _libs in .libs _libs; do + am_save_CPPFLAGS="$CPPFLAGS" + am_save_LIBS="$LIBS" + CPPFLAGS="$CPPFLAGS -I../libiconv/include" + LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a" + if test x$gcc_no_link = xyes; then + as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdlib.h> +#include <iconv.h> +int +main () +{ +iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + INCICONV="-I../libiconv/include" + LIBICONV='${top_builddir}'/../libiconv/lib/$_libs/libiconv.a + LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la + am_cv_lib_iconv=yes + am_cv_func_iconv=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CPPFLAGS="$am_save_CPPFLAGS" + LIBS="$am_save_LIBS" + if test "$am_cv_func_iconv" = "yes"; then + break + fi + done + fi + if test "$am_cv_func_iconv" != yes; then + am_save_CPPFLAGS="$CPPFLAGS" am_save_LIBS="$LIBS" + CPPFLAGS="$LIBS $INCICONV" LIBS="$LIBS $LIBICONV" if test x$gcc_no_link = xyes; then as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 @@ -45994,6 +46103,7 @@ if ac_fn_c_try_link "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + CPPFLAGS="$am_save_CPPFLAGS" LIBS="$am_save_LIBS" fi @@ -46006,12 +46116,34 @@ $as_echo "#define HAVE_ICONV 1" >>confdefs.h fi if test "$am_cv_lib_iconv" = yes; then + + for element in $INCICONV; do + haveit= + for x in $CPPFLAGS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" + fi + done + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 $as_echo_n "checking how to link with libiconv... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 $as_echo "$LIBICONV" >&6; } else - CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi @@ -58685,31 +58817,6 @@ $as_echo "#define HAVE_TLS 1" >>confdefs.h - am_save_CPPFLAGS="$CPPFLAGS" - - for element in $INCICONV; do - haveit= - for x in $CPPFLAGS; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" - fi - done - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 $as_echo_n "checking for iconv... " >&6; } if test "${am_cv_func_iconv+set}" = set; then : @@ -58718,6 +58825,8 @@ else am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no + am_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCICONV" if test x$gcc_no_link = xyes; then as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 fi @@ -58740,8 +58849,52 @@ if ac_fn_c_try_link "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + CPPFLAGS="$am_save_CPPFLAGS" + + if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then + for _libs in .libs _libs; do + am_save_CPPFLAGS="$CPPFLAGS" + am_save_LIBS="$LIBS" + CPPFLAGS="$CPPFLAGS -I../libiconv/include" + LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a" + if test x$gcc_no_link = xyes; then + as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdlib.h> +#include <iconv.h> +int +main () +{ +iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + INCICONV="-I../libiconv/include" + LIBICONV='${top_builddir}'/../libiconv/lib/$_libs/libiconv.a + LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la + am_cv_lib_iconv=yes + am_cv_func_iconv=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CPPFLAGS="$am_save_CPPFLAGS" + LIBS="$am_save_LIBS" + if test "$am_cv_func_iconv" = "yes"; then + break + fi + done + fi + if test "$am_cv_func_iconv" != yes; then + am_save_CPPFLAGS="$CPPFLAGS" am_save_LIBS="$LIBS" + CPPFLAGS="$LIBS $INCICONV" LIBS="$LIBS $LIBICONV" if test x$gcc_no_link = xyes; then as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 @@ -58766,6 +58919,7 @@ if ac_fn_c_try_link "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + CPPFLAGS="$am_save_CPPFLAGS" LIBS="$am_save_LIBS" fi @@ -58778,12 +58932,34 @@ $as_echo "#define HAVE_ICONV 1" >>confdefs.h fi if test "$am_cv_lib_iconv" = yes; then + + for element in $INCICONV; do + haveit= + for x in $CPPFLAGS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" + fi + done + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 $as_echo_n "checking how to link with libiconv... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 $as_echo "$LIBICONV" >&6; } else - CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h index 369c636d8fd..0d0063bcee6 100644 --- a/libstdc++-v3/include/bits/char_traits.h +++ b/libstdc++-v3/include/bits/char_traits.h @@ -256,7 +256,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static int compare(const char_type* __s1, const char_type* __s2, size_t __n) - { return __builtin_memcmp(__s1, __s2, __n); } + { + if (__n == 0) + return 0; + return __builtin_memcmp(__s1, __s2, __n); + } static size_t length(const char_type* __s) @@ -264,19 +268,35 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static const char_type* find(const char_type* __s, size_t __n, const char_type& __a) - { return static_cast<const char_type*>(__builtin_memchr(__s, __a, __n)); } + { + if (__n == 0) + return 0; + return static_cast<const char_type*>(__builtin_memchr(__s, __a, __n)); + } static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) - { return static_cast<char_type*>(__builtin_memmove(__s1, __s2, __n)); } + { + if (__n == 0) + return __s1; + return static_cast<char_type*>(__builtin_memmove(__s1, __s2, __n)); + } static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) - { return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n)); } + { + if (__n == 0) + return __s1; + return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n)); + } static char_type* assign(char_type* __s, size_t __n, char_type __a) - { return static_cast<char_type*>(__builtin_memset(__s, __a, __n)); } + { + if (__n == 0) + return __s; + return static_cast<char_type*>(__builtin_memset(__s, __a, __n)); + } static _GLIBCXX_CONSTEXPR char_type to_char_type(const int_type& __c) _GLIBCXX_NOEXCEPT @@ -327,7 +347,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static int compare(const char_type* __s1, const char_type* __s2, size_t __n) - { return wmemcmp(__s1, __s2, __n); } + { + if (__n == 0) + return 0; + return wmemcmp(__s1, __s2, __n); + } static size_t length(const char_type* __s) @@ -335,19 +359,35 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static const char_type* find(const char_type* __s, size_t __n, const char_type& __a) - { return wmemchr(__s, __a, __n); } + { + if (__n == 0) + return 0; + return wmemchr(__s, __a, __n); + } static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) - { return wmemmove(__s1, __s2, __n); } + { + if (__n == 0) + return __s1; + return wmemmove(__s1, __s2, __n); + } static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) - { return wmemcpy(__s1, __s2, __n); } + { + if (__n == 0) + return __s1; + return wmemcpy(__s1, __s2, __n); + } static char_type* assign(char_type* __s, size_t __n, char_type __a) - { return wmemset(__s, __a, __n); } + { + if (__n == 0) + return __s; + return wmemset(__s, __a, __n); + } static _GLIBCXX_CONSTEXPR char_type to_char_type(const int_type& __c) _GLIBCXX_NOEXCEPT @@ -436,6 +476,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) { + if (__n == 0) + return __s1; return (static_cast<char_type*> (__builtin_memmove(__s1, __s2, __n * sizeof(char_type)))); } @@ -443,6 +485,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) { + if (__n == 0) + return __s1; return (static_cast<char_type*> (__builtin_memcpy(__s1, __s2, __n * sizeof(char_type)))); } @@ -529,6 +573,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) { + if (__n == 0) + return __s1; return (static_cast<char_type*> (__builtin_memmove(__s1, __s2, __n * sizeof(char_type)))); } @@ -536,6 +582,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) { + if (__n == 0) + return __s1; return (static_cast<char_type*> (__builtin_memcpy(__s1, __s2, __n * sizeof(char_type)))); } diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc index f10d052f909..a6d966b28d7 100644 --- a/libstdc++-v3/include/bits/random.tcc +++ b/libstdc++-v3/include/bits/random.tcc @@ -1405,7 +1405,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const double __pi_4 = 0.7853981633974483096156608458198757L; const double __dx = std::sqrt(2 * __m * std::log(32 * __m / __pi_4)); - _M_d = std::round(std::max(6.0, std::min(__m, __dx))); + _M_d = std::round(std::max<double>(6.0, std::min(__m, __dx))); const double __cx = 2 * __m + _M_d; _M_scx = std::sqrt(__cx / 2); _M_1cx = 1 / __cx; @@ -1613,11 +1613,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const double __d1x = std::sqrt(__np * __1p * std::log(32 * __np / (81 * __pi_4 * __1p))); - _M_d1 = std::round(std::max(1.0, __d1x)); + _M_d1 = std::round(std::max<double>(1.0, __d1x)); const double __d2x = std::sqrt(__np * __1p * std::log(32 * _M_t * __1p / (__pi_4 * __pa))); - _M_d2 = std::round(std::max(1.0, __d2x)); + _M_d2 = std::round(std::max<double>(1.0, __d2x)); // sqrt(pi / 2) const double __spi_2 = 1.2533141373155002512078826424055226L; @@ -3472,15 +3472,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const long double __r = static_cast<long double>(__urng.max()) - static_cast<long double>(__urng.min()) + 1.0L; const size_t __log2r = std::log(__r) / std::log(2.0L); - size_t __k = std::max<size_t>(1UL, (__b + __log2r - 1UL) / __log2r); - _RealType __sum = _RealType(0); - _RealType __tmp = _RealType(1); - for (; __k != 0; --__k) + const size_t __m = std::max<size_t>(1UL, + (__b + __log2r - 1UL) / __log2r); + _RealType __ret; + do { - __sum += _RealType(__urng() - __urng.min()) * __tmp; - __tmp *= __r; + _RealType __sum = _RealType(0); + _RealType __tmp = _RealType(1); + for (size_t __k = __m; __k != 0; --__k) + { + __sum += _RealType(__urng() - __urng.min()) * __tmp; + __tmp *= __r; + } + __ret = __sum / __tmp; } - return __sum / __tmp; + while (__builtin_expect(__ret >= _RealType(1), 0)); + return __ret; } _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/bits/range_access.h b/libstdc++-v3/include/bits/range_access.h index aa78afb7ed8..01a05bc13fd 100644 --- a/libstdc++-v3/include/bits/range_access.h +++ b/libstdc++-v3/include/bits/range_access.h @@ -98,6 +98,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __arr + _Nm; } #if __cplusplus >= 201402L + + template<typename _Tp> class valarray; + // These overloads must be declared for cbegin and cend to use them. + template<typename _Tp> _Tp* begin(valarray<_Tp>&); + template<typename _Tp> const _Tp* begin(const valarray<_Tp>&); + template<typename _Tp> _Tp* end(valarray<_Tp>&); + template<typename _Tp> const _Tp* end(const valarray<_Tp>&); + /** * @brief Return an iterator pointing to the first element of * the const container. diff --git a/libstdc++-v3/include/bits/regex_scanner.tcc b/libstdc++-v3/include/bits/regex_scanner.tcc index 3bcbd0f0483..15556693931 100644 --- a/libstdc++-v3/include/bits/regex_scanner.tcc +++ b/libstdc++-v3/include/bits/regex_scanner.tcc @@ -99,6 +99,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION auto __c = *_M_current++; const char* __pos; + if (std::strchr(_M_spec_char, _M_ctype.narrow(__c, '\0')) == nullptr) + { + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); + return; + } if (__c == '\\') { if (_M_current == _M_end) diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h index f96c07835b6..2413b1b8e10 100644 --- a/libstdc++-v3/include/bits/shared_ptr.h +++ b/libstdc++-v3/include/bits/shared_ptr.h @@ -588,7 +588,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const enable_shared_from_this* __pe, const _Tp1* __px) noexcept { - if (__pe != 0) + if (__pe != nullptr) __pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn); } diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index aec10fecdbf..820edcb5d4b 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -1468,8 +1468,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void _M_assign(_Tp* __ptr, const __shared_count<_Lp>& __refcount) noexcept { - _M_ptr = __ptr; - _M_refcount = __refcount; + if (use_count() == 0) + { + _M_ptr = __ptr; + _M_refcount = __refcount; + } } template<typename _Tp1, _Lock_policy _Lp1> friend class __shared_ptr; @@ -1549,7 +1552,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const __enable_shared_from_this* __pe, const _Tp1* __px) noexcept { - if (__pe != 0) + if (__pe != nullptr) __pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn); } diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 93e834abeb7..f7f3e84dc82 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -1750,6 +1750,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _OutputValueType>) __glibcxx_function_requires(_LessThanComparableConcept<_OutputValueType>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); __glibcxx_requires_valid_range(__result_first, __result_last); return std::__partial_sort_copy(__first, __last, @@ -1803,6 +1804,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, _OutputValueType, _OutputValueType>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); __glibcxx_requires_valid_range(__result_first, __result_last); return std::__partial_sort_copy(__first, __last, @@ -2027,6 +2029,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _ValueType, _Tp>) __glibcxx_requires_partitioned_lower_pred(__first, __last, __val, __comp); + __glibcxx_requires_irreflexive_pred2(__first, __last, __comp); return std::__lower_bound(__first, __last, __val, __gnu_cxx::__ops::__iter_comp_val(__comp)); @@ -2082,6 +2085,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) __glibcxx_function_requires(_LessThanOpConcept<_Tp, _ValueType>) __glibcxx_requires_partitioned_upper(__first, __last, __val); + __glibcxx_requires_irreflexive2(__first, __last); return std::__upper_bound(__first, __last, __val, __gnu_cxx::__ops::__val_less_iter()); @@ -2116,6 +2120,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp, _ValueType>) __glibcxx_requires_partitioned_upper_pred(__first, __last, __val, __comp); + __glibcxx_requires_irreflexive_pred2(__first, __last, __comp); return std::__upper_bound(__first, __last, __val, __gnu_cxx::__ops::__val_comp_iter(__comp)); @@ -2189,7 +2194,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanOpConcept<_ValueType, _Tp>) __glibcxx_function_requires(_LessThanOpConcept<_Tp, _ValueType>) __glibcxx_requires_partitioned_lower(__first, __last, __val); - __glibcxx_requires_partitioned_upper(__first, __last, __val); + __glibcxx_requires_partitioned_upper(__first, __last, __val); + __glibcxx_requires_irreflexive2(__first, __last); return std::__equal_range(__first, __last, __val, __gnu_cxx::__ops::__iter_less_val(), @@ -2231,6 +2237,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __val, __comp); __glibcxx_requires_partitioned_upper_pred(__first, __last, __val, __comp); + __glibcxx_requires_irreflexive_pred2(__first, __last, __comp); return std::__equal_range(__first, __last, __val, __gnu_cxx::__ops::__iter_comp_val(__comp), @@ -2262,6 +2269,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanOpConcept<_Tp, _ValueType>) __glibcxx_requires_partitioned_lower(__first, __last, __val); __glibcxx_requires_partitioned_upper(__first, __last, __val); + __glibcxx_requires_irreflexive2(__first, __last); _ForwardIterator __i = std::__lower_bound(__first, __last, __val, @@ -2300,6 +2308,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __val, __comp); __glibcxx_requires_partitioned_upper_pred(__first, __last, __val, __comp); + __glibcxx_requires_irreflexive_pred2(__first, __last, __comp); _ForwardIterator __i = std::__lower_bound(__first, __last, __val, @@ -2594,6 +2603,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename iterator_traits<_BidirectionalIterator>::value_type>) __glibcxx_requires_sorted(__first, __middle); __glibcxx_requires_sorted(__middle, __last); + __glibcxx_requires_irreflexive(__first, __last); std::__inplace_merge(__first, __middle, __last, __gnu_cxx::__ops::__iter_less_iter()); @@ -2636,6 +2646,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename iterator_traits<_BidirectionalIterator>::value_type>) __glibcxx_requires_sorted_pred(__first, __middle, __comp); __glibcxx_requires_sorted_pred(__middle, __last, __comp); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); std::__inplace_merge(__first, __middle, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); @@ -2847,6 +2858,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename iterator_traits<_InputIterator1>::value_type>) __glibcxx_requires_sorted_set(__first1, __last1, __first2); __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); return std::__includes(__first1, __last1, __first2, __last2, __gnu_cxx::__ops::__iter_less_iter()); @@ -2891,6 +2904,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename iterator_traits<_InputIterator1>::value_type>) __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); return std::__includes(__first1, __last1, __first2, __last2, __gnu_cxx::__ops::__iter_comp_iter(__comp)); @@ -2966,6 +2981,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanComparableConcept< typename iterator_traits<_BidirectionalIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); return std::__next_permutation (__first, __last, __gnu_cxx::__ops::__iter_less_iter()); @@ -2998,6 +3014,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename iterator_traits<_BidirectionalIterator>::value_type, typename iterator_traits<_BidirectionalIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); return std::__next_permutation (__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); @@ -3064,6 +3081,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanComparableConcept< typename iterator_traits<_BidirectionalIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); return std::__prev_permutation(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); @@ -3096,6 +3114,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename iterator_traits<_BidirectionalIterator>::value_type, typename iterator_traits<_BidirectionalIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); return std::__prev_permutation(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); @@ -3258,6 +3277,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanComparableConcept< typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); return std::__is_sorted_until(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); @@ -3283,6 +3303,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename iterator_traits<_ForwardIterator>::value_type, typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); return std::__is_sorted_until(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); @@ -3407,6 +3428,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanComparableConcept< typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); return std::__minmax_element(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); @@ -3436,6 +3458,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename iterator_traits<_ForwardIterator>::value_type, typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); return std::__minmax_element(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); @@ -4556,6 +4579,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_RandomAccessIterator>::value_type>) __glibcxx_requires_valid_range(__first, __middle); __glibcxx_requires_valid_range(__middle, __last); + __glibcxx_requires_irreflexive(__first, __last); std::__partial_sort(__first, __middle, __last, __gnu_cxx::__ops::__iter_less_iter()); @@ -4595,6 +4619,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_RandomAccessIterator>::value_type>) __glibcxx_requires_valid_range(__first, __middle); __glibcxx_requires_valid_range(__middle, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); std::__partial_sort(__first, __middle, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); @@ -4627,6 +4652,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_RandomAccessIterator>::value_type>) __glibcxx_requires_valid_range(__first, __nth); __glibcxx_requires_valid_range(__nth, __last); + __glibcxx_requires_irreflexive(__first, __last); if (__first == __last || __nth == __last) return; @@ -4666,6 +4692,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_RandomAccessIterator>::value_type>) __glibcxx_requires_valid_range(__first, __nth); __glibcxx_requires_valid_range(__nth, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); if (__first == __last || __nth == __last) return; @@ -4699,6 +4726,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO __glibcxx_function_requires(_LessThanComparableConcept< typename iterator_traits<_RandomAccessIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); } @@ -4730,6 +4758,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_RandomAccessIterator>::value_type, typename iterator_traits<_RandomAccessIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); } @@ -4797,6 +4826,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_InputIterator1>::value_type>) __glibcxx_requires_sorted_set(__first1, __last1, __first2); __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); return _GLIBCXX_STD_A::__merge(__first1, __last1, __first2, __last2, __result, @@ -4845,6 +4876,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_InputIterator1>::value_type>) __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); return _GLIBCXX_STD_A::__merge(__first1, __last1, __first2, __last2, __result, @@ -4898,6 +4931,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO __glibcxx_function_requires(_LessThanComparableConcept< typename iterator_traits<_RandomAccessIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); _GLIBCXX_STD_A::__stable_sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); @@ -4933,6 +4967,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_RandomAccessIterator>::value_type, typename iterator_traits<_RandomAccessIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); _GLIBCXX_STD_A::__stable_sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); @@ -5010,6 +5045,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_InputIterator1>::value_type>) __glibcxx_requires_sorted_set(__first1, __last1, __first2); __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); return _GLIBCXX_STD_A::__set_union(__first1, __last1, __first2, __last2, __result, @@ -5057,6 +5094,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_InputIterator1>::value_type>) __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); return _GLIBCXX_STD_A::__set_union(__first1, __last1, __first2, __last2, __result, @@ -5123,6 +5162,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_InputIterator1>::value_type>) __glibcxx_requires_sorted_set(__first1, __last1, __first2); __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); return _GLIBCXX_STD_A::__set_intersection(__first1, __last1, __first2, __last2, __result, @@ -5169,6 +5210,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_InputIterator1>::value_type>) __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); return _GLIBCXX_STD_A::__set_intersection(__first1, __last1, __first2, __last2, __result, @@ -5239,6 +5282,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_InputIterator1>::value_type>) __glibcxx_requires_sorted_set(__first1, __last1, __first2); __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); return _GLIBCXX_STD_A::__set_difference(__first1, __last1, __first2, __last2, __result, @@ -5287,6 +5332,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_InputIterator1>::value_type>) __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); return _GLIBCXX_STD_A::__set_difference(__first1, __last1, __first2, __last2, __result, @@ -5365,6 +5412,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_InputIterator1>::value_type>) __glibcxx_requires_sorted_set(__first1, __last1, __first2); __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); return _GLIBCXX_STD_A::__set_symmetric_difference(__first1, __last1, __first2, __last2, __result, @@ -5414,6 +5463,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_InputIterator1>::value_type>) __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); return _GLIBCXX_STD_A::__set_symmetric_difference(__first1, __last1, __first2, __last2, __result, @@ -5452,6 +5503,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO __glibcxx_function_requires(_LessThanComparableConcept< typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); return _GLIBCXX_STD_A::__min_element(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); @@ -5478,6 +5530,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_ForwardIterator>::value_type, typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); return _GLIBCXX_STD_A::__min_element(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); @@ -5514,6 +5567,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO __glibcxx_function_requires(_LessThanComparableConcept< typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); return _GLIBCXX_STD_A::__max_element(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); @@ -5540,6 +5594,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO typename iterator_traits<_ForwardIterator>::value_type, typename iterator_traits<_ForwardIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); return _GLIBCXX_STD_A::__max_element(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 75a15167e93..99f3cc4cfe9 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -985,6 +985,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanOpConcept< typename iterator_traits<_ForwardIterator>::value_type, _Tp>) __glibcxx_requires_partitioned_lower(__first, __last, __val); + __glibcxx_requires_irreflexive2(__first, __last); return std::__lower_bound(__first, __last, __val, __gnu_cxx::__ops::__iter_less_val()); @@ -1209,7 +1210,9 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>) __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>) __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_irreflexive2(__first1, __last1); __glibcxx_requires_valid_range(__first2, __last2); + __glibcxx_requires_irreflexive2(__first2, __last2); return std::__lexicographical_compare_aux(std::__niter_base(__first1), std::__niter_base(__last1), @@ -1239,7 +1242,9 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO __glibcxx_function_requires(_InputIteratorConcept<_II1>) __glibcxx_function_requires(_InputIteratorConcept<_II2>) __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); __glibcxx_requires_valid_range(__first2, __last2); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); return std::__lexicographical_compare_impl (__first1, __last1, __first2, __last2, diff --git a/libstdc++-v3/include/bits/stl_heap.h b/libstdc++-v3/include/bits/stl_heap.h index 3ab37c75753..e13b6bed9ae 100644 --- a/libstdc++-v3/include/bits/stl_heap.h +++ b/libstdc++-v3/include/bits/stl_heap.h @@ -159,6 +159,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _RandomAccessIterator>) __glibcxx_function_requires(_LessThanComparableConcept<_ValueType>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); __glibcxx_requires_heap(__first, __last - 1); _ValueType __value = _GLIBCXX_MOVE(*(__last - 1)); @@ -193,6 +194,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< _RandomAccessIterator>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); __glibcxx_requires_heap_pred(__first, __last - 1, __comp); _ValueType __value = _GLIBCXX_MOVE(*(__last - 1)); @@ -271,6 +273,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanComparableConcept<_ValueType>) __glibcxx_requires_non_empty_range(__first, __last); __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); __glibcxx_requires_heap(__first, __last); if (__last - __first > 1) @@ -301,6 +304,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< _RandomAccessIterator>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); __glibcxx_requires_non_empty_range(__first, __last); __glibcxx_requires_heap_pred(__first, __last, __comp); @@ -356,6 +360,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanComparableConcept< typename iterator_traits<_RandomAccessIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); std::__make_heap(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); @@ -380,6 +385,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< _RandomAccessIterator>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); std::__make_heap(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); @@ -415,6 +421,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanComparableConcept< typename iterator_traits<_RandomAccessIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); __glibcxx_requires_heap(__first, __last); std::__sort_heap(__first, __last, @@ -440,6 +447,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< _RandomAccessIterator>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); __glibcxx_requires_heap_pred(__first, __last, __comp); std::__sort_heap(__first, __last, @@ -467,6 +475,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_LessThanComparableConcept< typename iterator_traits<_RandomAccessIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); return __first + std::__is_heap_until(__first, std::distance(__first, __last), @@ -493,6 +502,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_RandomAccessIteratorConcept< _RandomAccessIterator>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); return __first + std::__is_heap_until(__first, std::distance(__first, __last), diff --git a/libstdc++-v3/include/c_global/cmath b/libstdc++-v3/include/c_global/cmath index 1c9926484a0..7718ea2e225 100644 --- a/libstdc++-v3/include/c_global/cmath +++ b/libstdc++-v3/include/c_global/cmath @@ -650,10 +650,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION isnormal(_Tp __x) { return __x != 0 ? true : false; } - // The front-end doesn't provide a type generic builtin (libstdc++/58625). + // Note: middle-end/36757 is fixed, __builtin_signbit is type-generic. constexpr bool signbit(float __x) - { return __builtin_signbitf(__x); } + { return __builtin_signbit(__x); } constexpr bool signbit(double __x) @@ -661,7 +661,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr bool signbit(long double __x) - { return __builtin_signbitl(__x); } + { return __builtin_signbit(__x); } template<typename _Tp> constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, diff --git a/libstdc++-v3/include/debug/debug.h b/libstdc++-v3/include/debug/debug.h index b6623e62ecc..6b52b0ab312 100644 --- a/libstdc++-v3/include/debug/debug.h +++ b/libstdc++-v3/include/debug/debug.h @@ -77,41 +77,53 @@ namespace __gnu_debug # define __glibcxx_requires_string(_String) # define __glibcxx_requires_string_len(_String,_Len) # define __glibcxx_requires_subscript(_N) +# define __glibcxx_requires_irreflexive(_First,_Last) +# define __glibcxx_requires_irreflexive2(_First,_Last) +# define __glibcxx_requires_irreflexive_pred(_First,_Last,_Pred) +# define __glibcxx_requires_irreflexive_pred2(_First,_Last,_Pred) #else # include <debug/macros.h> # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg) -# define __glibcxx_requires_valid_range(_First,_Last) \ - __glibcxx_check_valid_range(_First,_Last) -# define __glibcxx_requires_non_empty_range(_First,_Last) \ - __glibcxx_check_non_empty_range(_First,_Last) -# define __glibcxx_requires_sorted(_First,_Last) \ - __glibcxx_check_sorted(_First,_Last) -# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \ - __glibcxx_check_sorted_pred(_First,_Last,_Pred) -# define __glibcxx_requires_sorted_set(_First1,_Last1,_First2) \ - __glibcxx_check_sorted_set(_First1,_Last1,_First2) +# define __glibcxx_requires_valid_range(_First,_Last) \ + __glibcxx_check_valid_range(_First,_Last) +# define __glibcxx_requires_non_empty_range(_First,_Last) \ + __glibcxx_check_non_empty_range(_First,_Last) +# define __glibcxx_requires_sorted(_First,_Last) \ + __glibcxx_check_sorted(_First,_Last) +# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \ + __glibcxx_check_sorted_pred(_First,_Last,_Pred) +# define __glibcxx_requires_sorted_set(_First1,_Last1,_First2) \ + __glibcxx_check_sorted_set(_First1,_Last1,_First2) # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred) \ - __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) + __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value) \ - __glibcxx_check_partitioned_lower(_First,_Last,_Value) + __glibcxx_check_partitioned_lower(_First,_Last,_Value) # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value) \ - __glibcxx_check_partitioned_upper(_First,_Last,_Value) + __glibcxx_check_partitioned_upper(_First,_Last,_Value) # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred) \ - __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) + __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred) \ - __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) -# define __glibcxx_requires_heap(_First,_Last) \ - __glibcxx_check_heap(_First,_Last) -# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \ - __glibcxx_check_heap_pred(_First,_Last,_Pred) + __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) +# define __glibcxx_requires_heap(_First,_Last) \ + __glibcxx_check_heap(_First,_Last) +# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \ + __glibcxx_check_heap_pred(_First,_Last,_Pred) # define __glibcxx_requires_nonempty() __glibcxx_check_nonempty() # define __glibcxx_requires_string(_String) __glibcxx_check_string(_String) # define __glibcxx_requires_string_len(_String,_Len) \ - __glibcxx_check_string_len(_String,_Len) + __glibcxx_check_string_len(_String,_Len) # define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N) +# define __glibcxx_requires_irreflexive(_First,_Last) \ + __glibcxx_check_irreflexive(_First,_Last) +# define __glibcxx_requires_irreflexive2(_First,_Last) \ + __glibcxx_check_irreflexive2(_First,_Last) +# define __glibcxx_requires_irreflexive_pred(_First,_Last,_Pred) \ + __glibcxx_check_irreflexive_pred(_First,_Last,_Pred) +# define __glibcxx_requires_irreflexive_pred2(_First,_Last,_Pred) \ + __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred) # include <debug/functions.h> diff --git a/libstdc++-v3/include/debug/formatter.h b/libstdc++-v3/include/debug/formatter.h index 56ee8078681..9fc23c828fc 100644 --- a/libstdc++-v3/include/debug/formatter.h +++ b/libstdc++-v3/include/debug/formatter.h @@ -126,7 +126,8 @@ namespace __gnu_debug __msg_valid_load_factor, // others __msg_equal_allocs, - __msg_insert_range_from_self + __msg_insert_range_from_self, + __msg_irreflexive_ordering }; class _Error_formatter diff --git a/libstdc++-v3/include/debug/functions.h b/libstdc++-v3/include/debug/functions.h index a9f234b0723..218092af86a 100644 --- a/libstdc++-v3/include/debug/functions.h +++ b/libstdc++-v3/include/debug/functions.h @@ -445,6 +445,49 @@ namespace __gnu_debug return __first == __last; } +#if __cplusplus >= 201103L + struct _Irreflexive_checker + { + template<typename _It> + static typename std::iterator_traits<_It>::reference + __deref(); + + template<typename _It, + typename = decltype(__deref<_It>() < __deref<_It>())> + static bool + _S_is_valid(_It __it) + { return !(*__it < *__it); } + + // Fallback method if operator doesn't exist. + template<typename... _Args> + static bool + _S_is_valid(_Args...) + { return true; } + + template<typename _It, typename _Pred, typename + = decltype(std::declval<_Pred>()(__deref<_It>(), __deref<_It>()))> + static bool + _S_is_valid_pred(_It __it, _Pred __pred) + { return !__pred(*__it, *__it); } + + // Fallback method if predicate can't be invoked. + template<typename... _Args> + static bool + _S_is_valid_pred(_Args...) + { return true; } + }; + + template<typename _Iterator> + inline bool + __is_irreflexive(_Iterator __it) + { return _Irreflexive_checker::_S_is_valid(__it); } + + template<typename _Iterator, typename _Pred> + inline bool + __is_irreflexive_pred(_Iterator __it, _Pred __pred) + { return _Irreflexive_checker::_S_is_valid_pred(__it, __pred); } +#endif + } // namespace __gnu_debug #endif diff --git a/libstdc++-v3/include/debug/macros.h b/libstdc++-v3/include/debug/macros.h index a4c2649c843..c6366636ce3 100644 --- a/libstdc++-v3/include/debug/macros.h +++ b/libstdc++-v3/include/debug/macros.h @@ -362,4 +362,37 @@ _GLIBCXX_DEBUG_VERIFY(_This.get_allocator() == _Other.get_allocator(), \ #define __glibcxx_check_string_len(_String,_Len) \ _GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0) +// Verify that a predicate is irreflexive +#define __glibcxx_check_irreflexive(_First,_Last) \ + _GLIBCXX_DEBUG_VERIFY(_First == _Last || !(*_First < *_First), \ + _M_message(__gnu_debug::__msg_irreflexive_ordering) \ + ._M_iterator_value_type(_First, "< operator type")) + +#if __cplusplus >= 201103L +# define __glibcxx_check_irreflexive2(_First,_Last) \ + _GLIBCXX_DEBUG_VERIFY(_First == _Last \ + || __gnu_debug::__is_irreflexive(_First), \ + _M_message(__gnu_debug::__msg_irreflexive_ordering) \ + ._M_iterator_value_type(_First, "< operator type")) +#else +# define __glibcxx_check_irreflexive2(_First,_Last) +#endif + +#define __glibcxx_check_irreflexive_pred(_First,_Last,_Pred) \ + _GLIBCXX_DEBUG_VERIFY(_First == _Last || !_Pred(*_First, *_First), \ + _M_message(__gnu_debug::__msg_irreflexive_ordering) \ + ._M_instance(_Pred, "functor") \ + ._M_iterator_value_type(_First, "ordered type")) + +#if __cplusplus >= 201103L +# define __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred) \ + _GLIBCXX_DEBUG_VERIFY(_First == _Last \ + ||__gnu_debug::__is_irreflexive_pred(_First, _Pred), \ + _M_message(__gnu_debug::__msg_irreflexive_ordering) \ + ._M_instance(_Pred, "functor") \ + ._M_iterator_value_type(_First, "ordered type")) +#else +# define __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred) +#endif + #endif diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h index d45cf793e9d..914d7215037 100644 --- a/libstdc++-v3/include/debug/map.h +++ b/libstdc++-v3/include/debug/map.h @@ -317,6 +317,89 @@ namespace __debug _Base::insert(__first, __last); } + +#if __cplusplus > 201402L + template <typename... _Args> + pair<iterator, bool> + try_emplace(const key_type& __k, _Args&&... __args) + { + auto __res = _Base::try_emplace(__k, + std::forward<_Args>(__args)...); + return { iterator(__res.first, this), __res.second }; + } + + template <typename... _Args> + pair<iterator, bool> + try_emplace(key_type&& __k, _Args&&... __args) + { + auto __res = _Base::try_emplace(std::move(__k), + std::forward<_Args>(__args)...); + return { iterator(__res.first, this), __res.second }; + } + + template <typename... _Args> + iterator + try_emplace(const_iterator __hint, const key_type& __k, + _Args&&... __args) + { + __glibcxx_check_insert(__hint); + return iterator(_Base::try_emplace(__hint.base(), __k, + std::forward<_Args>(__args)...), + this); + } + + template <typename... _Args> + iterator + try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args) + { + __glibcxx_check_insert(__hint); + return iterator(_Base::try_emplace(__hint.base(), std::move(__k), + std::forward<_Args>(__args)...), + this); + } + + template <typename _Obj> + std::pair<iterator, bool> + insert_or_assign(const key_type& __k, _Obj&& __obj) + { + auto __res = _Base::insert_or_assign(__k, + std::forward<_Obj>(__obj)); + return { iterator(__res.first, this), __res.second }; + } + + template <typename _Obj> + std::pair<iterator, bool> + insert_or_assign(key_type&& __k, _Obj&& __obj) + { + auto __res = _Base::insert_or_assign(std::move(__k), + std::forward<_Obj>(__obj)); + return { iterator(__res.first, this), __res.second }; + } + + template <typename _Obj> + iterator + insert_or_assign(const_iterator __hint, + const key_type& __k, _Obj&& __obj) + { + __glibcxx_check_insert(__hint); + return iterator(_Base::insert_or_assign(__hint.base(), __k, + std::forward<_Obj>(__obj)), + this); + } + + template <typename _Obj> + iterator + insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj) + { + __glibcxx_check_insert(__hint); + return iterator(_Base::insert_or_assign(__hint.base(), + std::move(__k), + std::forward<_Obj>(__obj)), + this); + } +#endif + + #if __cplusplus >= 201103L iterator erase(const_iterator __position) diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map index cc3bc3fb7bc..1bbdb614af3 100644 --- a/libstdc++-v3/include/debug/unordered_map +++ b/libstdc++-v3/include/debug/unordered_map @@ -377,6 +377,88 @@ namespace __debug _M_check_rehashed(__bucket_count); } +#if __cplusplus > 201402L + template <typename... _Args> + pair<iterator, bool> + try_emplace(const key_type& __k, _Args&&... __args) + { + auto __res = _Base::try_emplace(__k, + std::forward<_Args>(__args)...); + return { iterator(__res.first, this), __res.second }; + } + + template <typename... _Args> + pair<iterator, bool> + try_emplace(key_type&& __k, _Args&&... __args) + { + auto __res = _Base::try_emplace(std::move(__k), + std::forward<_Args>(__args)...); + return { iterator(__res.first, this), __res.second }; + } + + template <typename... _Args> + iterator + try_emplace(const_iterator __hint, const key_type& __k, + _Args&&... __args) + { + __glibcxx_check_insert(__hint); + return iterator(_Base::try_emplace(__hint.base(), __k, + std::forward<_Args>(__args)...), + this); + } + + template <typename... _Args> + iterator + try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args) + { + __glibcxx_check_insert(__hint); + return iterator(_Base::try_emplace(__hint.base(), std::move(__k), + std::forward<_Args>(__args)...), + this); + } + + template <typename _Obj> + pair<iterator, bool> + insert_or_assign(const key_type& __k, _Obj&& __obj) + { + auto __res = _Base::insert_or_assign(__k, + std::forward<_Obj>(__obj)); + return { iterator(__res.first, this), __res.second }; + } + + template <typename _Obj> + pair<iterator, bool> + insert_or_assign(key_type&& __k, _Obj&& __obj) + { + auto __res = _Base::insert_or_assign(std::move(__k), + std::forward<_Obj>(__obj)); + return { iterator(__res.first, this), __res.second }; + } + + template <typename _Obj> + iterator + insert_or_assign(const_iterator __hint, const key_type& __k, + _Obj&& __obj) + { + __glibcxx_check_insert(__hint); + return iterator(_Base::insert_or_assign(__hint.base(), __k, + std::forward<_Obj>(__obj)), + this); + } + + template <typename _Obj> + iterator + insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj) + { + __glibcxx_check_insert(__hint); + return iterator(_Base::insert_or_assign(__hint.base(), + std::move(__k), + std::forward<_Obj>(__obj)), + this); + } +#endif + + iterator find(const key_type& __key) { return iterator(_Base::find(__key), this); } diff --git a/libstdc++-v3/include/experimental/any b/libstdc++-v3/include/experimental/any index dae82b56e2f..4cdc1dc12c2 100644 --- a/libstdc++-v3/include/experimental/any +++ b/libstdc++-v3/include/experimental/any @@ -296,14 +296,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Storage _M_storage; template<typename _Tp> - friend void* __any_caster(const any* __any) - { - if (__any->_M_manager != &_Manager<decay_t<_Tp>>::_S_manage) - return nullptr; - _Arg __arg; - __any->_M_manager(_Op_access, __any, &__arg); - return __arg._M_obj; - } + friend void* __any_caster(const any* __any); // Manage in-place contained object. template<typename _Tp> @@ -396,6 +389,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } // @} + template<typename _Tp> + void* __any_caster(const any* __any) + { + if (__any->_M_manager != &any::_Manager<decay_t<_Tp>>::_S_manage) + return nullptr; + any::_Arg __arg; + __any->_M_manager(any::_Op_access, __any, &__arg); + return __arg._M_obj; + } + /** * @brief Access the contained object. * diff --git a/libstdc++-v3/include/ext/pod_char_traits.h b/libstdc++-v3/include/ext/pod_char_traits.h index c941080f54a..38a84c80d5b 100644 --- a/libstdc++-v3/include/ext/pod_char_traits.h +++ b/libstdc++-v3/include/ext/pod_char_traits.h @@ -144,6 +144,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) { + if (__n == 0) + return __s1; return static_cast<char_type*> (__builtin_memmove(__s1, __s2, __n * sizeof(char_type))); } @@ -151,6 +153,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) { + if (__n == 0) + return __s1; std::copy(__s2, __s2 + __n, __s1); return __s1; } diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex index deb85dfefe0..790508c65c2 100644 --- a/libstdc++-v3/include/std/mutex +++ b/libstdc++-v3/include/std/mutex @@ -230,8 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static_cast<long>(__ns.count()) }; - auto __mutex = static_cast<_Derived*>(this)->native_handle(); - return !__gthread_mutex_timedlock(__mutex, &__ts); + return static_cast<_Derived*>(this)->_M_timedlock(__ts); } template<typename _Clock, typename _Duration> @@ -293,6 +292,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION native_handle_type native_handle() { return &_M_mutex; } + + private: + friend class __timed_mutex_impl<timed_mutex>; + + bool + _M_timedlock(const __gthread_time_t& __ts) + { return !__gthread_mutex_timedlock(&_M_mutex, &__ts); } }; /// recursive_timed_mutex @@ -346,6 +352,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION native_handle_type native_handle() { return &_M_mutex; } + + private: + friend class __timed_mutex_impl<recursive_timed_mutex>; + + bool + _M_timedlock(const __gthread_time_t& __ts) + { return !__gthread_recursive_mutex_timedlock(&_M_mutex, &__ts); } }; #endif #endif // _GLIBCXX_HAS_GTHREADS diff --git a/libstdc++-v3/python/Makefile.am b/libstdc++-v3/python/Makefile.am index 5d782249619..ccb942705e4 100644 --- a/libstdc++-v3/python/Makefile.am +++ b/libstdc++-v3/python/Makefile.am @@ -49,7 +49,7 @@ install-data-local: gdb.py ## fragile, but there does not seem to be a better option, because ## libtool hides the real names from us. @here=`pwd`; cd $(DESTDIR)$(toolexeclibdir); \ - for file in libstdc++*; do \ + for file in libstdc++.*; do \ case $$file in \ *-gdb.py) ;; \ *.la) ;; \ diff --git a/libstdc++-v3/python/Makefile.in b/libstdc++-v3/python/Makefile.in index 1fe2ecb5bbf..25b2ed487b2 100644 --- a/libstdc++-v3/python/Makefile.in +++ b/libstdc++-v3/python/Makefile.in @@ -547,7 +547,7 @@ gdb.py: hook.in Makefile install-data-local: gdb.py @$(mkdir_p) $(DESTDIR)$(toolexeclibdir) @here=`pwd`; cd $(DESTDIR)$(toolexeclibdir); \ - for file in libstdc++*; do \ + for file in libstdc++.*; do \ case $$file in \ *-gdb.py) ;; \ *.la) ;; \ diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc index f60e31f845b..c435de70b51 100644 --- a/libstdc++-v3/src/c++11/debug.cc +++ b/libstdc++-v3/src/c++11/debug.cc @@ -103,7 +103,7 @@ namespace namespace __gnu_debug { - const char* _S_debug_messages[] = + static const char* _S_debug_messages[] = { // General Checks "function requires a valid iterator range [%1.name;, %2.name;)", @@ -185,7 +185,8 @@ namespace __gnu_debug "load factor shall be positive", "allocators must be equal", "attempt to insert with an iterator range [%1.name;, %2.name;) from this" - " container" + " container", + "comparison doesn't meet irreflexive requirements, assert(!(a < a))" }; void @@ -592,11 +593,13 @@ namespace { const int __bufsize = 64; char __buf[__bufsize]; - __formatter->_M_format_word(__buf, __bufsize, "\"%s\" ", + __formatter->_M_format_word(__buf, __bufsize, "\"%s\"", __variant._M_name); __formatter->_M_print_word(__buf); } + __formatter->_M_print_word(" {\n"); + if (__variant._M_type) { __formatter->_M_print_word(" type = "); @@ -768,6 +771,7 @@ namespace __gnu_debug _M_variant._M_iterator._M_sequence); __formatter->_M_print_word(__buf); } + __formatter->_M_print_word("}\n"); break; case __sequence: @@ -786,10 +790,12 @@ namespace __gnu_debug if (_M_variant._M_instance._M_type) __formatter->_M_print_word(";\n"); + __formatter->_M_print_word("}\n"); break; case __iterator_value_type: __formatter->_M_print_word("iterator::value_type "); print_description(__formatter, _M_variant._M_iterator_value_type); + __formatter->_M_print_word("}\n"); break; default: break; diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++200x/67309.cc b/libstdc++-v3/testsuite/17_intro/headers/c++200x/67309.cc new file mode 100644 index 00000000000..97df10f649f --- /dev/null +++ b/libstdc++-v3/testsuite/17_intro/headers/c++200x/67309.cc @@ -0,0 +1,23 @@ +// Copyright (C) 2015 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11 -fsingle-precision-constant" } +// { dg-do compile } + +// libstdc++/67309 +#include <bits/stdc++.h> // TODO: this is missing from <bits/extc++.h> +#include <bits/extc++.h> diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++200x/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++200x/all_attributes.cc index 8d93fd9dc19..ae15f31b11c 100644 --- a/libstdc++-v3/testsuite/17_intro/headers/c++200x/all_attributes.cc +++ b/libstdc++-v3/testsuite/17_intro/headers/c++200x/all_attributes.cc @@ -35,7 +35,6 @@ #endif #include <bits/stdc++.h> // TODO: this is missing from <bits/extc++.h> -#include <codecvt> // TODO: this is missing from <bits/stdc++.h> #include <bits/extc++.h> int diff --git a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/const.cc b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/const.cc new file mode 100644 index 00000000000..fdf39c7916e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/const.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2015 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <memory> +#include <testsuite_hooks.h> + +template<typename T, typename U> + bool + share_ownership(const std::shared_ptr<T>& p1, const std::shared_ptr<U>& p2) + { + return !p1.owner_before(p2) && !p2.owner_before(p1); + } + +void +test01() +{ + struct X : public std::enable_shared_from_this<X> { }; + using CX = const X; + std::shared_ptr<CX> p(new X); + VERIFY( share_ownership(p->shared_from_this(), p) ); + p.reset(new CX); + VERIFY( share_ownership(p->shared_from_this(), p) ); + auto p2 = std::const_pointer_cast<X>(p)->shared_from_this(); + VERIFY( share_ownership(p2, p) ); +} + +void +test02() +{ + struct X; + using CX = const X; + struct X : public std::enable_shared_from_this<CX> { }; + std::shared_ptr<CX> p(new X); + VERIFY( share_ownership(p->shared_from_this(), p) ); + p.reset(new CX); + VERIFY( share_ownership(p->shared_from_this(), p) ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/reinit.cc b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/reinit.cc new file mode 100644 index 00000000000..3740db8ac36 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/reinit.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2015 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +#include <memory> +#include <testsuite_hooks.h> + +struct X : public std::enable_shared_from_this<X> { }; + +bool +share_ownership(const std::shared_ptr<X>& p1, const std::shared_ptr<X>& p2) +{ + return !p1.owner_before(p2) && !p2.owner_before(p1); +} + +void +test01() +{ + std::shared_ptr<X> p1(new X); + VERIFY( share_ownership( p1->shared_from_this(), p1 ) ); + { + std::shared_ptr<X> p2(p1.get(), [](X*){}); + // The weak_ptr member of the enable_shared_from_this base should not + // be reset by creating a second control block that owns the pointer. + VERIFY( share_ownership( p2->shared_from_this(), p1 ) ); + } + VERIFY( share_ownership( p1->shared_from_this(), p1 ) ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc index 270ee8409b9..94638e19242 100644 --- a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc @@ -21,3 +21,8 @@ #include <memory> template class std::enable_shared_from_this<int>; +template class std::enable_shared_from_this<const int>; + +class Incomplete; +template class std::enable_shared_from_this<Incomplete>; +template class std::enable_shared_from_this<const Incomplete>; diff --git a/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char/65049.cc b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char/65049.cc new file mode 100644 index 00000000000..1aa00ddc1fc --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char/65049.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2015 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +// libstdc++/65049 + +#include <string> +#include <testsuite_hooks.h> + +using C = char; + +void +test01() +{ + const C* p = 0; + C* q = 0; + auto c = std::char_traits<C>::compare(p, q, 0); + VERIFY( c == 0 ); + auto r = std::char_traits<C>::find(p, 0, '0'); + VERIFY( r == nullptr ); + r = std::char_traits<C>::move(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::copy(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::assign(q, 0, '0'); + VERIFY( r == q ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char16_t/65049.cc b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char16_t/65049.cc new file mode 100644 index 00000000000..7af6db3ff42 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char16_t/65049.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2015 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +// libstdc++/65049 + +#include <string> +#include <testsuite_hooks.h> + +using C = char16_t; + +void +test01() +{ + const C* p = 0; + C* q = 0; + auto c = std::char_traits<C>::compare(p, q, 0); + VERIFY( c == 0 ); + auto r = std::char_traits<C>::find(p, 0, '0'); + VERIFY( r == nullptr ); + r = std::char_traits<C>::move(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::copy(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::assign(q, 0, '0'); + VERIFY( r == q ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char32_t/65049.cc b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char32_t/65049.cc new file mode 100644 index 00000000000..a7730ec2582 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/char32_t/65049.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2015 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +// libstdc++/65049 + +#include <string> +#include <testsuite_hooks.h> + +using C = char32_t; + +void +test01() +{ + const C* p = 0; + C* q = 0; + auto c = std::char_traits<C>::compare(p, q, 0); + VERIFY( c == 0 ); + auto r = std::char_traits<C>::find(p, 0, '0'); + VERIFY( r == nullptr ); + r = std::char_traits<C>::move(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::copy(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::assign(q, 0, '0'); + VERIFY( r == q ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/21_strings/char_traits/requirements/wchar_t/65049.cc b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/wchar_t/65049.cc new file mode 100644 index 00000000000..22dfdf03513 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/wchar_t/65049.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2015 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } + +// libstdc++/65049 + +#include <string> +#include <testsuite_hooks.h> + +using C = wchar_t; + +void +test01() +{ + const C* p = 0; + C* q = 0; + auto c = std::char_traits<C>::compare(p, q, 0); + VERIFY( c == 0 ); + auto r = std::char_traits<C>::find(p, 0, '0'); + VERIFY( r == nullptr ); + r = std::char_traits<C>::move(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::copy(q, p, 0); + VERIFY( r == q ); + r = std::char_traits<C>::assign(q, 0, '0'); + VERIFY( r == q ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/debug/irreflexive_neg.cc b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/debug/irreflexive_neg.cc new file mode 100644 index 00000000000..07ee8bef6de --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/debug/irreflexive_neg.cc @@ -0,0 +1,70 @@ +// Copyright (C) 2015 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. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++11" } +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <algorithm> +#include <testsuite_hooks.h> + +struct A +{ + A(int i) : _i(i) + { } + + int _i; +}; + +bool +operator<(A a, int i) +{ return a._i < i; } + +bool +operator<(int i, A a) +{ return i < a._i; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + A as[] { 0, 1, 2, 3 }; + int is[] { 0, 1, 2, 3 }; + VERIFY( !std::lexicographical_compare(as, as + 4, is, is + 4) ); +} + +bool +bad_lower(int lhs, int rhs) +{ + if (lhs == 0) + return true; + + return lhs < rhs; +} + +void test02() +{ + int is[] { 0, 1, 2, 3 }; + std::lexicographical_compare(is, is + 4, is, is + 4, bad_lower); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/debug/irreflexive.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/debug/irreflexive.cc new file mode 100644 index 00000000000..c87b3e17dbd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/debug/irreflexive.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2015 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. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do compile } + +#include <algorithm> + +struct A +{ + A(int i) : _i(i) + { } + + int _i; +}; + +// Only knowns how to compare an A with an int. +struct A_int_comparer +{ + bool + operator()(A a, int i) const + { return a._i < i; } + + bool + operator()(int i, A a) const + { return i < a._i; } +}; + +void test01() +{ + A as[] { 0, 1, 2, 3 }; + std::lower_bound(as, as + 4, 1, A_int_comparer()); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc new file mode 100644 index 00000000000..0218a269e19 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2015 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. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <algorithm> + +bool +bad_lower(int lhs, int rhs) +{ + if (lhs == 0) + return true; + + return lhs < rhs; +} + +void test01() +{ + int ins[] { 0, 1, 2, 3 }; + int outs[] { 9, 9 }; + std::partial_sort_copy(ins, ins + 4, outs, outs + 2, bad_lower); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/64351.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/64351.cc new file mode 100644 index 00000000000..3de441234b5 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/64351.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2015 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++11" } +// { dg-do run { target { ! simulator } } } + +#include <random> +#include <testsuite_hooks.h> + +// libstdc++/64351 +void +test01() +{ + std::mt19937 rng(8890); + std::uniform_real_distribution<float> dist; + + rng.discard(30e6); + for (long i = 0; i < 10e6; ++i) + { + auto n = dist(rng); + VERIFY( n != 1.f ); + } +} + +// libstdc++/63176 +void +test02() +{ + std::mt19937 rng(8890); + std::seed_seq sequence{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + rng.seed(sequence); + rng.discard(12 * 629143 + 6); + float n = + std::generate_canonical<float, std::numeric_limits<float>::digits>(rng); + VERIFY( n != 1.f ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc b/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc index eb8ca3e9dbb..2a929b537ed 100644 --- a/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc +++ b/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc @@ -28,4 +28,7 @@ test01() std::valarray<double> va{1.0, 2.0, 3.0}; std::begin(va); std::end(va); + const auto& cva = va; + std::begin(cva); + std::end(cva); } diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/range_access2.cc b/libstdc++-v3/testsuite/26_numerics/valarray/range_access2.cc new file mode 100644 index 00000000000..1c7a48581ba --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/range_access2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++14" } + +// Copyright (C) 2015 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 26.6.10 valarray range access: [valarray.range] + +#include <iterator> +#include <valarray> + +// PR libstdc++/67374 +void +test01() +{ + std::valarray<double> va{1.0, 2.0, 3.0}; + std::cbegin(va); + std::cend(va); + const auto& cva = va; + std::cbegin(cva); + std::cend(cva); +} diff --git a/libstdc++-v3/testsuite/28_regex/regression.cc b/libstdc++-v3/testsuite/28_regex/regression.cc new file mode 100644 index 00000000000..71d82d50459 --- /dev/null +++ b/libstdc++-v3/testsuite/28_regex/regression.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++11" } + +// +// Copyright (C) 2015 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. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <testsuite_hooks.h> +#include <testsuite_regex.h> + +using namespace __gnu_test; +using namespace std; + +// PR libstdc++/67362 +void +test01() +{ + bool test __attribute__((unused)) = true; + + regex re("((.)", regex_constants::basic); +} + +int +main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/unlock/2.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/unlock/2.cc index ac51f433271..de5592a6e4c 100644 --- a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/unlock/2.cc +++ b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/unlock/2.cc @@ -1,7 +1,7 @@ -// { dg-do run { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-do run { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin powerpc-ibm-aix* } } // { dg-options " -std=gnu++11 -pthread" { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } // { dg-options " -std=gnu++11 -pthreads" { target *-*-solaris* } } -// { dg-options " -std=gnu++11 " { target *-*-cygwin *-*-darwin* } } +// { dg-options " -std=gnu++11 " { target *-*-cygwin } } // { dg-require-cstdint "" } // { dg-require-gthreads "" } diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/unlock/2.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/unlock/2.cc index 10fdc537a9b..14e39dee625 100644 --- a/libstdc++-v3/testsuite/30_threads/timed_mutex/unlock/2.cc +++ b/libstdc++-v3/testsuite/30_threads/timed_mutex/unlock/2.cc @@ -1,7 +1,7 @@ -// { dg-do run { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } } +// { dg-do run { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin powerpc-ibm-aix* } } // { dg-options " -std=gnu++11 -pthread" { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } } // { dg-options " -std=gnu++11 -pthreads" { target *-*-solaris* } } -// { dg-options " -std=gnu++11 " { target *-*-cygwin *-*-darwin* } } +// { dg-options " -std=gnu++11 " { target *-*-cygwin } } // { dg-require-cstdint "" } // { dg-require-gthreads "" } diff --git a/libstdc++-v3/testsuite/experimental/any/misc/any_cast_neg.cc b/libstdc++-v3/testsuite/experimental/any/misc/any_cast_neg.cc index 1d1180c36db..5c7595d79ef 100644 --- a/libstdc++-v3/testsuite/experimental/any/misc/any_cast_neg.cc +++ b/libstdc++-v3/testsuite/experimental/any/misc/any_cast_neg.cc @@ -26,5 +26,5 @@ void test01() using std::experimental::any_cast; const any y(1); - any_cast<int&>(y); // { dg-error "qualifiers" "" { target { *-*-* } } 360 } + any_cast<int&>(y); // { dg-error "qualifiers" "" { target { *-*-* } } 353 } } |