l4re-base-25.08.0

This commit is contained in:
2025-09-12 15:55:45 +02:00
commit d959eaab98
37938 changed files with 9382688 additions and 0 deletions

View File

@@ -0,0 +1,213 @@
// Compatibility symbols for previous versions -*- C++ -*-
// Copyright (C) 2005-2021 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/compatibility.h
* This is an internal header file, included by other library sources.
* You should not attempt to use it directly.
*/
// Switch for symbol version macro.
#ifndef _GLIBCXX_APPLY_SYMVER
#error must define _GLIBCXX_APPLY_SYMVER before including __FILE__
#endif
/* gcc-3.4.4
_ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv
_ZNSt19istreambuf_iteratorIwSt11char_traitsIwEEppEv
*/
namespace
{
_GLIBCXX_APPLY_SYMVER(_ZNSt21istreambuf_iteratorXXIcSt11char_traitsIcEEppEv,
_ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv)
#ifdef _GLIBCXX_USE_WCHAR_T
_GLIBCXX_APPLY_SYMVER(_ZNSt21istreambuf_iteratorXXIwSt11char_traitsIwEEppEv,
_ZNSt19istreambuf_iteratorIwSt11char_traitsIwEEppEv)
#endif
} // anonymous namespace
/* gcc-4.0.0
_ZNSs4_Rep26_M_set_length_and_sharableEj
_ZNSs7_M_copyEPcPKcj
_ZNSs7_M_moveEPcPKcj
_ZNSs9_M_assignEPcjc
_ZNKSs11_M_disjunctEPKc
_ZNKSs15_M_check_lengthEjjPKc
_ZNSbIwSt11char_traitsIwESaIwEE4_Rep26_M_set_length_and_sharableEj
_ZNSbIwSt11char_traitsIwESaIwEE7_M_copyEPwPKwj
_ZNSbIwSt11char_traitsIwESaIwEE7_M_moveEPwPKwj
_ZNSbIwSt11char_traitsIwESaIwEE9_M_assignEPwjw
_ZNKSbIwSt11char_traitsIwESaIwEE11_M_disjunctEPKw
_ZNKSbIwSt11char_traitsIwESaIwEE15_M_check_lengthEjjPKc
_ZNKSt13basic_fstreamIcSt11char_traitsIcEE7is_openEv
_ZNKSt13basic_fstreamIwSt11char_traitsIwEE7is_openEv
_ZNKSt14basic_ifstreamIcSt11char_traitsIcEE7is_openEv
_ZNKSt14basic_ifstreamIwSt11char_traitsIwEE7is_openEv
_ZNKSt14basic_ofstreamIcSt11char_traitsIcEE7is_openEv
_ZNKSt14basic_ofstreamIwSt11char_traitsIwEE7is_openEv
_ZNSi6ignoreEi
_ZNSi6ignoreEv
_ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEi
_ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEv
_ZNSt11char_traitsIcE2eqERKcS2_
_ZNSt11char_traitsIwE2eqERKwS2_
*/
namespace
{
_GLIBCXX_APPLY_SYMVER(_ZNSt11char_traitsIcE4eqXXERKcS2_,
_ZNSt11char_traitsIcE2eqERKcS2_)
#ifdef _GLIBCXX_SIZE_T_IS_UINT
_GLIBCXX_APPLY_SYMVER(_ZNSs9_M_copyXXEPcPKcj,
_ZNSs7_M_copyEPcPKcj)
#else
_GLIBCXX_APPLY_SYMVER(_ZNSs9_M_copyXXEPcPKcm,
_ZNSs7_M_copyEPcPKcm)
#endif
#ifdef _GLIBCXX_SIZE_T_IS_UINT
_GLIBCXX_APPLY_SYMVER(_ZNSs9_M_moveXXEPcPKcj,
_ZNSs7_M_moveEPcPKcj)
#else
_GLIBCXX_APPLY_SYMVER(_ZNSs9_M_moveXXEPcPKcm,
_ZNSs7_M_moveEPcPKcm)
#endif
#ifdef _GLIBCXX_SIZE_T_IS_UINT
_GLIBCXX_APPLY_SYMVER(_ZNSs11_M_assignXXEPcjc,
_ZNSs9_M_assignEPcjc)
#else
_GLIBCXX_APPLY_SYMVER(_ZNSs11_M_assignXXEPcmc,
_ZNSs9_M_assignEPcmc)
#endif
_GLIBCXX_APPLY_SYMVER(_ZNKSs13_M_disjunctXXEPKc,
_ZNKSs11_M_disjunctEPKc)
#ifdef _GLIBCXX_SIZE_T_IS_UINT
_GLIBCXX_APPLY_SYMVER(_ZNKSs17_M_check_lengthXXEjjPKc,
_ZNKSs15_M_check_lengthEjjPKc)
#else
_GLIBCXX_APPLY_SYMVER(_ZNKSs17_M_check_lengthXXEmmPKc,
_ZNKSs15_M_check_lengthEmmPKc)
#endif
#ifdef _GLIBCXX_SIZE_T_IS_UINT
_GLIBCXX_APPLY_SYMVER(_ZNSs4_Rep28_M_set_length_and_sharableXXEj,
_ZNSs4_Rep26_M_set_length_and_sharableEj)
#else
_GLIBCXX_APPLY_SYMVER(_ZNSs4_Rep28_M_set_length_and_sharableXXEm,
_ZNSs4_Rep26_M_set_length_and_sharableEm)
#endif
_GLIBCXX_APPLY_SYMVER(_ZNSi8ignoreXXEv, _ZNSi6ignoreEv)
#ifdef _GLIBCXX_PTRDIFF_T_IS_INT
_GLIBCXX_APPLY_SYMVER(_ZNSi8ignoreXXEi, _ZNSi6ignoreEi)
#else
_GLIBCXX_APPLY_SYMVER(_ZNSi8ignoreXXEl, _ZNSi6ignoreEl)
#endif
_GLIBCXX_APPLY_SYMVER(_ZNKSt15basic_fstreamXXIcSt11char_traitsIcEE7is_openEv,
_ZNKSt13basic_fstreamIcSt11char_traitsIcEE7is_openEv)
_GLIBCXX_APPLY_SYMVER(_ZNKSt16basic_ifstreamXXIcSt11char_traitsIcEE7is_openEv,
_ZNKSt14basic_ifstreamIcSt11char_traitsIcEE7is_openEv)
_GLIBCXX_APPLY_SYMVER(_ZNKSt16basic_ofstreamXXIcSt11char_traitsIcEE7is_openEv,
_ZNKSt14basic_ofstreamIcSt11char_traitsIcEE7is_openEv)
// Support for wchar_t.
#ifdef _GLIBCXX_USE_WCHAR_T
_GLIBCXX_APPLY_SYMVER(_ZNSt11char_traitsIwE4eqXXERKwS2_,
_ZNSt11char_traitsIwE2eqERKwS2_)
#ifdef _GLIBCXX_SIZE_T_IS_UINT
_GLIBCXX_APPLY_SYMVER(_ZNSbIwSt11char_traitsIwESaIwEE9_M_copyXXEPwPKwj,
_ZNSbIwSt11char_traitsIwESaIwEE7_M_copyEPwPKwj)
#else
_GLIBCXX_APPLY_SYMVER(_ZNSbIwSt11char_traitsIwESaIwEE9_M_copyXXEPwPKwm,
_ZNSbIwSt11char_traitsIwESaIwEE7_M_copyEPwPKwm)
#endif
#ifdef _GLIBCXX_SIZE_T_IS_UINT
_GLIBCXX_APPLY_SYMVER(_ZNSbIwSt11char_traitsIwESaIwEE9_M_moveXXEPwPKwj,
_ZNSbIwSt11char_traitsIwESaIwEE7_M_moveEPwPKwj)
#else
_GLIBCXX_APPLY_SYMVER(_ZNSbIwSt11char_traitsIwESaIwEE9_M_moveXXEPwPKwm,
_ZNSbIwSt11char_traitsIwESaIwEE7_M_moveEPwPKwm)
#endif
#ifdef _GLIBCXX_SIZE_T_IS_UINT
_GLIBCXX_APPLY_SYMVER(_ZNSbIwSt11char_traitsIwESaIwEE11_M_assignXXEPwjw,
_ZNSbIwSt11char_traitsIwESaIwEE9_M_assignEPwjw)
#else
_GLIBCXX_APPLY_SYMVER(_ZNSbIwSt11char_traitsIwESaIwEE11_M_assignXXEPwmw,
_ZNSbIwSt11char_traitsIwESaIwEE9_M_assignEPwmw)
#endif
_GLIBCXX_APPLY_SYMVER(_ZNKSbIwSt11char_traitsIwESaIwEE13_M_disjunctXXEPKw,
_ZNKSbIwSt11char_traitsIwESaIwEE11_M_disjunctEPKw)
#ifdef _GLIBCXX_SIZE_T_IS_UINT
_GLIBCXX_APPLY_SYMVER(_ZNKSbIwSt11char_traitsIwESaIwEE17_M_check_lengthXXEjjPKc,
_ZNKSbIwSt11char_traitsIwESaIwEE15_M_check_lengthEjjPKc)
#else
_GLIBCXX_APPLY_SYMVER(_ZNKSbIwSt11char_traitsIwESaIwEE17_M_check_lengthXXEmmPKc,
_ZNKSbIwSt11char_traitsIwESaIwEE15_M_check_lengthEmmPKc)
#endif
#ifdef _GLIBCXX_SIZE_T_IS_UINT
_GLIBCXX_APPLY_SYMVER(_ZNSbIwSt11char_traitsIwESaIwEE4_Rep28_M_set_length_and_sharableXXEj,
_ZNSbIwSt11char_traitsIwESaIwEE4_Rep26_M_set_length_and_sharableEj)
#else
_GLIBCXX_APPLY_SYMVER(_ZNSbIwSt11char_traitsIwESaIwEE4_Rep28_M_set_length_and_sharableXXEm,
_ZNSbIwSt11char_traitsIwESaIwEE4_Rep26_M_set_length_and_sharableEm)
#endif
_GLIBCXX_APPLY_SYMVER(_ZNSt13basic_istreamIwSt11char_traitsIwEE8ignoreXXEv,
_ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEv)
#ifdef _GLIBCXX_PTRDIFF_T_IS_INT
_GLIBCXX_APPLY_SYMVER(_ZNSt13basic_istreamIwSt11char_traitsIwEE8ignoreXXEi,
_ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEi)
#else
_GLIBCXX_APPLY_SYMVER(_ZNSt13basic_istreamIwSt11char_traitsIwEE8ignoreXXEl,
_ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEl)
#endif
_GLIBCXX_APPLY_SYMVER(_ZNKSt15basic_fstreamXXIwSt11char_traitsIwEE7is_openEv,
_ZNKSt13basic_fstreamIwSt11char_traitsIwEE7is_openEv)
_GLIBCXX_APPLY_SYMVER(_ZNKSt16basic_ifstreamXXIwSt11char_traitsIwEE7is_openEv,
_ZNKSt14basic_ifstreamIwSt11char_traitsIwEE7is_openEv)
_GLIBCXX_APPLY_SYMVER(_ZNKSt16basic_ofstreamXXIwSt11char_traitsIwEE7is_openEv,
_ZNKSt14basic_ofstreamIwSt11char_traitsIwEE7is_openEv)
#endif
} // anonymous namespace

View File

@@ -0,0 +1,10 @@
# Appended to version file.
CXXABI_FLOAT128 {
# typeinfo and typeinfo name for __float128
_ZT[IS]g;
_ZT[IS]Pg;
_ZT[IS]PKg;
};

View File

@@ -0,0 +1,375 @@
## Linker script for GNU namespace versioning.
##
## Copyright (C) 2002-2021 Free Software Foundation, Inc.
##
## This file is part of the libstdc++ version 3 distribution.
##
## 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/>.
GLIBCXX_8.0 {
global:
# Names inside the 'extern' block are demangled names.
extern "C++"
{
std::*;
std::__8::*;
std::random_device::*
};
# operator new(size_t)
_Znw[jmy];
# operator new(size_t, std::nothrow_t const&)
_Znw[jmy]RKSt9nothrow_t;
# operator delete(void*)
_ZdlPv;
# operator delete(void*, std::nothrow_t const&)
_ZdlPvRKSt9nothrow_t;
# operator new[](size_t)
_Zna[jmy];
# operator new[](size_t, std::nothrow_t const&)
_Zna[jmy]RKSt9nothrow_t;
# operator delete[](void*)
_ZdaPv;
# operator delete[](void*, std::nothrow_t const&)
_ZdaPvRKSt9nothrow_t;
# function-scope static objects requires a guard variable.
_ZGVNSt*;
# VTT structure
_ZTTNSt*;
# vtable
_ZTVSt*;
_ZTVNSt*;
_ZTVN9__gnu_cxx3__818stdio_sync_filebufI[cw]NSt3__811char_traitsI[cw]EEEE;
# thunk
_ZTv0_n12_NS*;
_ZTv0_n24_NS*;
# typeinfo structure
_ZTISt*;
_ZTINSt*;
# typeinfo name
_ZTSSt*;
_ZTSNSt*;
# locale
_ZNSt3__89has_facetINS_*;
# hash
_ZNSt8__detail3__812__prime_listE;
_ZNSt3tr18__detail3__812__prime_listE;
# thread/mutex/condition_variable/future
__once_proxy;
# std::__detail::_List_node_base
_ZNSt8__detail3__815_List_node_base7_M_hook*;
_ZNSt8__detail3__815_List_node_base9_M_unhookEv;
_ZNSt8__detail3__815_List_node_base10_M_reverseEv;
_ZNSt8__detail3__815_List_node_base11_M_transfer*;
_ZNSt8__detail3__815_List_node_base4swapER*;
# std::__convert_to_v
_ZNSt3__814__convert_to_v*;
# std::__copy_streambufs
_ZNSt3__817__copy_streambufsI*;
_ZNSt3__821__copy_streambufs_eofI*;
# std::__istream_extract(wistream&, wchar_t*, streamsize)
_ZNSt3__817__istream_extractIwNS_11char_traitsIwEEEEvRNS_13basic_istreamIT_T0_EEPS4_[ilx];
# __gnu_cxx::__atomic_add
# __gnu_cxx::__exchange_and_add
_ZN9__gnu_cxx3__812__atomic_addEPV[il][il];
_ZN9__gnu_cxx3__818__exchange_and_addEPV[li][il];
# __gnu_cxx::__pool
_ZN9__gnu_cxx3__86__poolILb[01]EE13_M_initializeEv;
_ZN9__gnu_cxx3__86__poolILb[01]EE16_M_reserve_blockE[jmy][jmy];
_ZN9__gnu_cxx3__86__poolILb[01]EE16_M_reclaim_blockEPc[jmy];
_ZN9__gnu_cxx3__86__poolILb[01]EE10_M_destroyEv;
_ZN9__gnu_cxx3__86__poolILb1EE16_M_get_thread_idEv;
_ZN9__gnu_cxx3__817__pool_alloc_base9_M_refillE[jmy];
_ZN9__gnu_cxx3__817__pool_alloc_base16_M_get_free_listE[jmy];
_ZN9__gnu_cxx3__817__pool_alloc_base12_M_get_mutexEv;
_ZN9__gnu_cxx3__89free_list6_M_getE[jmy];
_ZN9__gnu_cxx3__89free_list8_M_clearEv;
# __gnu_cxx::stdio_sync_filebuf
_ZTVN9__gnu_cxx3__818stdio_sync_filebufI[cw]St3__811char_traitsI[cw]EEE;
_ZN9__gnu_cxx3__818stdio_sync_filebufI[cw]NSt3__811char_traitsI[cw]EEE[5-9]*;
# debug mode
_ZN11__gnu_debug19_Safe_sequence_base12_M_get_mutexEv;
_ZN11__gnu_debug19_Safe_sequence_base13_M_detach_allEv;
_ZN11__gnu_debug19_Safe_sequence_base18_M_detach_singularEv;
_ZN11__gnu_debug19_Safe_sequence_base22_M_revalidate_singularEv;
_ZN11__gnu_debug19_Safe_sequence_base7_M_swapERS0_;
_ZN11__gnu_debug19_Safe_iterator_base9_M_attach*;
_ZN11__gnu_debug19_Safe_iterator_base16_M_attach_single*;
_ZN11__gnu_debug19_Safe_iterator_base9_M_detachEv;
_ZN11__gnu_debug19_Safe_iterator_base16_M_detach_singleEv;
_ZN11__gnu_debug19_Safe_iterator_base12_M_get_mutexEv;
_ZNK11__gnu_debug19_Safe_iterator_base11_M_singularEv;
_ZNK11__gnu_debug19_Safe_iterator_base14_M_can_compareERKS0_;
_ZNK11__gnu_debug16_Error_formatter10_M_message*;
_ZNK11__gnu_debug16_Error_formatter8_M_error*;
# __gnu_debug::_Safe_unordered_container_base
# __gnu_debug::_Safe_local_iterator_base
_ZN11__gnu_debug30_Safe_unordered_container_base7_M_swapERS0_;
_ZN11__gnu_debug30_Safe_unordered_container_base13_M_detach_allEv;
_ZN11__gnu_debug25_Safe_local_iterator_base9_M_attachEPNS_19_Safe_sequence_baseEb;
_ZN11__gnu_debug25_Safe_local_iterator_base9_M_detachEv;
_ZN11__gnu_debug25_Safe_local_iterator_base16_M_attach_singleEPNS_19_Safe_sequence_baseEb;
# parallel mode
_ZN14__gnu_parallel9_Settings3getEv;
_ZN14__gnu_parallel9_Settings3setERS0_;
local:
*;
};
# Symbols in the support library (libsupc++) have their own tag.
CXXABI_2.0 {
global:
__cxa_allocate_exception;
__cxa_allocate_dependent_exception;
__cxa_bad_cast;
__cxa_bad_typeid;
__cxa_begin_catch;
__cxa_begin_cleanup;
__cxa_call_unexpected;
__cxa_current_exception_type;
__cxa_deleted_virtual;
__cxa_demangle;
__cxa_end_catch;
__cxa_end_cleanup;
__cxa_free_exception;
__cxa_free_dependent_exception;
__cxa_get_exception_ptr;
__cxa_init_primary_exception;
__cxa_get_globals;
__cxa_get_globals_fast;
__cxa_guard_abort;
__cxa_guard_acquire;
__cxa_guard_release;
__cxa_pure_virtual;
__cxa_rethrow;
__cxa_thread_atexit;
__cxa_throw;
__cxa_type_match;
__cxa_vec_cctor;
__cxa_vec_cleanup;
__cxa_vec_ctor;
__cxa_vec_delete2;
__cxa_vec_delete3;
__cxa_vec_delete;
__cxa_vec_dtor;
__cxa_vec_new2;
__cxa_vec_new3;
__cxa_vec_new;
__gxx_personality_v0;
__gxx_personality_sj0;
__dynamic_cast;
# std::exception_ptr
_ZNSt15__exception_ptr13exception_ptrC1Ev;
_ZNSt15__exception_ptr13exception_ptrC2Ev;
_ZNSt15__exception_ptr13exception_ptrC1EPv;
_ZNSt15__exception_ptr13exception_ptrC1ERKS0_;
_ZNSt15__exception_ptr13exception_ptrC2ERKS0_;
_ZNSt15__exception_ptr13exception_ptrC1EMS0_FvvE;
_ZNSt15__exception_ptr13exception_ptrC2EMS0_FvvE;
_ZNSt15__exception_ptr13exception_ptrD1Ev;
_ZNSt15__exception_ptr13exception_ptrD2Ev;
_ZNSt15__exception_ptr13exception_ptraSERKS0_;
_ZNKSt15__exception_ptr13exception_ptrcvMS0_FvvEEv;
_ZNKSt15__exception_ptr13exception_ptrntEv;
_ZNKSt15__exception_ptr13exception_ptr20__cxa_exception_typeEv;
_ZNSt15__exception_ptr13exception_ptr4swapERS0_;
_ZNSt15__exception_ptreqERKNS_13exception_ptrES2_;
_ZNSt15__exception_ptrneERKNS_13exception_ptrES2_;
_ZSt17current_exceptionv;
_ZSt17rethrow_exceptionNSt15__exception_ptr13exception_ptrE;
# std::nested_exception
_ZNSt16nested_exceptionD*;
_ZTISt16nested_exception;
_ZTVSt16nested_exception;
# std::bad_function_call.
_ZNSt17bad_function_callD*;
_ZTISt17bad_function_call;
_ZTSSt17bad_function_call;
_ZTVSt17bad_function_call;
__cxa_throw_bad_array_new_length;
_Z*St20bad_array_new_length*;
__cxa_throw_bad_array_length;
_Z*St16bad_array_length*;
# Default function.
_ZSt11_Hash_bytesPKv*;
# FNV hash.
_ZSt15_Fnv_hash_bytesPKv*;
# __gnu_cxx::_verbose_terminate_handler()
_ZN9__gnu_cxx3__827__verbose_terminate_handlerEv;
# *_type_info classes, ctor and dtor
_ZN10__cxxabiv117__array_type_info*;
_ZN10__cxxabiv117__class_type_info*;
_ZN10__cxxabiv116__enum_type_info*;
_ZN10__cxxabiv120__function_type_info*;
_ZN10__cxxabiv123__fundamental_type_info*;
_ZN10__cxxabiv117__pbase_type_info*;
_ZN10__cxxabiv129__pointer_to_member_type_info*;
_ZN10__cxxabiv119__pointer_type_info*;
_ZN10__cxxabiv120__si_class_type_info*;
_ZN10__cxxabiv121__vmi_class_type_info*;
# *_type_info classes, member functions
_ZNK10__cxxabiv117__class_type_info*;
_ZNK10__cxxabiv120__function_type_info*;
_ZNK10__cxxabiv117__pbase_type_info*;
_ZNK10__cxxabiv129__pointer_to_member_type_info*;
_ZNK10__cxxabiv119__pointer_type_info*;
_ZNK10__cxxabiv120__si_class_type_info*;
_ZNK10__cxxabiv121__vmi_class_type_info*;
# typeinfo structure
_ZTI[a-z];
_ZTIP[a-z];
_ZTIPK[a-z];
_ZTIN10__cxxabiv117__array_type_infoE;
_ZTIN10__cxxabiv117__class_type_infoE;
_ZTIN10__cxxabiv116__enum_type_infoE;
_ZTIN10__cxxabiv120__function_type_infoE;
_ZTIN10__cxxabiv123__fundamental_type_infoE;
_ZTIN10__cxxabiv117__pbase_type_infoE;
_ZTIN10__cxxabiv129__pointer_to_member_type_infoE;
_ZTIN10__cxxabiv119__pointer_type_infoE;
_ZTIN10__cxxabiv120__si_class_type_infoE;
_ZTIN10__cxxabiv121__vmi_class_type_infoE;
_ZTIN10__cxxabiv115__forced_unwindE;
_ZTIN10__cxxabiv119__foreign_exceptionE;
_ZTIN10__cxxabiv115__forced_unwindE;
_ZTIN10__cxxabiv119__foreign_exceptionE;
# typeinfo name
_ZTS[a-z];
_ZTSP[a-z];
_ZTSPK[a-z];
_ZTSN10__cxxabiv117__array_type_infoE;
_ZTSN10__cxxabiv117__class_type_infoE;
_ZTSN10__cxxabiv116__enum_type_infoE;
_ZTSN10__cxxabiv120__function_type_infoE;
_ZTSN10__cxxabiv123__fundamental_type_infoE;
_ZTSN10__cxxabiv117__pbase_type_infoE;
_ZTSN10__cxxabiv129__pointer_to_member_type_infoE;
_ZTSN10__cxxabiv119__pointer_type_infoE;
_ZTSN10__cxxabiv120__si_class_type_infoE;
_ZTSN10__cxxabiv121__vmi_class_type_infoE;
# typeinfo for char8_t
_ZTIDu;
_ZTIPDu;
_ZTIPKDu;
# typeinfo for char16_t and char32_t
_ZTIDs;
_ZTIPDs;
_ZTIPKDs;
_ZTIDi;
_ZTIPDi;
_ZTIPKDi;
# typeinfo for decimal floating point types
_ZTID[fde];
_ZTIPD[fde];
_ZTIPKD[fde];
# typeinfo for decltype(nullptr)
_ZTIDn;
_ZTIPDn;
_ZTIPKDn;
# typeinfo for __int128 and unsigned __int128
_ZTI[no];
_ZTIP[no];
_ZTIPK[no];
# virtual table
_ZTVN10__cxxabiv117__array_type_infoE;
_ZTVN10__cxxabiv117__class_type_infoE;
_ZTVN10__cxxabiv116__enum_type_infoE;
_ZTVN10__cxxabiv120__function_type_infoE;
_ZTVN10__cxxabiv123__fundamental_type_infoE;
_ZTVN10__cxxabiv117__pbase_type_infoE;
_ZTVN10__cxxabiv129__pointer_to_member_type_infoE;
_ZTVN10__cxxabiv119__pointer_type_infoE;
_ZTVN10__cxxabiv120__si_class_type_infoE;
_ZTVN10__cxxabiv121__vmi_class_type_infoE;
# operator delete(void*, std::size_t)
_ZdlPv[jmy];
# operator delete[](void*, std::size_t)
_ZdaPv[jmy];
# __gnu_cxx::__freeres()
_ZN9__gnu_cxx9__freeresEv;
# C++17 aligned new/delete
_Znw[jmy]St11align_val_t;
_Znw[jmy]St11align_val_tRKSt9nothrow_t;
_Zna[jmy]St11align_val_t;
_Zna[jmy]St11align_val_tRKSt9nothrow_t;
_ZdlPvSt11align_val_t;
_ZdlPvSt11align_val_tRKSt9nothrow_t;
_ZdlPv[jmy]St11align_val_t;
_ZdaPvSt11align_val_t;
_ZdaPvSt11align_val_tRKSt9nothrow_t;
_ZdaPv[jmy]St11align_val_t;
};
# Symbols in the support library (libsupc++) supporting trans-mem.
CXXABI_TM_1 {
global:
__cxa_tm_cleanup;
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
#
# This is a placeholder file. It does nothing and is not used.
#
# If you are seeing this file as your linker script (named
# libstdc++-symbols.ver), then either 1) the configuration process
# determined that symbol versioning should not be done, or 2) you
# specifically turned it off. (ie, --disable-symvers).

View File

@@ -0,0 +1,55 @@
// Base to std::allocator -*- C++ -*-
// Copyright (C) 2004-2021 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++allocator.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _GLIBCXX_CXX_ALLOCATOR_H
#define _GLIBCXX_CXX_ALLOCATOR_H 1
#include <ext/bitmap_allocator.h>
#if __cplusplus >= 201103L
namespace std
{
/**
* @brief An alias to the base class for std::allocator.
* @ingroup allocators
*
* Used to set the std::allocator base class to
* __gnu_cxx::bitmap_allocator.
*
* @tparam _Tp Type of allocated object.
*/
template<typename _Tp>
using __allocator_base = __gnu_cxx::bitmap_allocator<_Tp>;
}
#else
// Define bitmap_allocator as the base class to std::allocator.
# define __allocator_base __gnu_cxx::bitmap_allocator
#endif
#endif

View File

@@ -0,0 +1,65 @@
// Base to std::allocator -*- C++ -*-
// Copyright (C) 2004-2021 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++allocator.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _GLIBCXX_CXX_ALLOCATOR_H
#define _GLIBCXX_CXX_ALLOCATOR_H 1
#include <ext/malloc_allocator.h>
#if __cplusplus >= 201103L
namespace std
{
/**
* @brief An alias to the base class for std::allocator.
* @ingroup allocators
*
* Used to set the std::allocator base class to
* __gnu_cxx::malloc_allocator.
*
* @tparam _Tp Type of allocated object.
*/
template<typename _Tp>
using __allocator_base = __gnu_cxx::malloc_allocator<_Tp>;
}
#else
// Define malloc_allocator as the base class to std::allocator.
# define __allocator_base __gnu_cxx::malloc_allocator
#endif
#ifndef _GLIBCXX_SANITIZE_STD_ALLOCATOR
# if defined(__SANITIZE_ADDRESS__)
# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1
# elif defined __has_feature
# if __has_feature(address_sanitizer)
# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1
# endif
# endif
#endif
#endif

View File

@@ -0,0 +1,55 @@
// Base to std::allocator -*- C++ -*-
// Copyright (C) 2004-2021 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++allocator.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _GLIBCXX_CXX_ALLOCATOR_H
#define _GLIBCXX_CXX_ALLOCATOR_H 1
#include <ext/mt_allocator.h>
#if __cplusplus >= 201103L
namespace std
{
/**
* @brief An alias to the base class for std::allocator.
* @ingroup allocators
*
* Used to set the std::allocator base class to
* __gnu_cxx::__mt_alloc.
*
* @tparam _Tp Type of allocated object.
*/
template<typename _Tp>
using __allocator_base = __gnu_cxx::__mt_alloc<_Tp>;
}
#else
// Define __mt_alloc as the base class to std::allocator.
# define __allocator_base __gnu_cxx::__mt_alloc
#endif
#endif

View File

@@ -0,0 +1,65 @@
// Base to std::allocator -*- C++ -*-
// Copyright (C) 2004-2021 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++allocator.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _GLIBCXX_CXX_ALLOCATOR_H
#define _GLIBCXX_CXX_ALLOCATOR_H 1
#include <ext/new_allocator.h>
#if __cplusplus >= 201103L
namespace std
{
/**
* @brief An alias to the base class for std::allocator.
*
* Used to set the std::allocator base class to
* __gnu_cxx::new_allocator.
*
* @ingroup allocators
* @tparam _Tp Type of allocated object.
*/
template<typename _Tp>
using __allocator_base = __gnu_cxx::new_allocator<_Tp>;
}
#else
// Define new_allocator as the base class to std::allocator.
# define __allocator_base __gnu_cxx::new_allocator
#endif
#ifndef _GLIBCXX_SANITIZE_STD_ALLOCATOR
# if defined(__SANITIZE_ADDRESS__)
# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1
# elif defined __has_feature
# if __has_feature(address_sanitizer)
# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1
# endif
# endif
#endif
#endif

View File

@@ -0,0 +1,55 @@
// Base to std::allocator -*- C++ -*-
// Copyright (C) 2004-2021 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++allocator.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _GLIBCXX_CXX_ALLOCATOR_H
#define _GLIBCXX_CXX_ALLOCATOR_H 1
#include <ext/pool_allocator.h>
#if __cplusplus >= 201103L
namespace std
{
/**
* @brief An alias to the base class for std::allocator.
* @ingroup allocators
*
* Used to set the std::allocator base class to
* __gnu_cxx::__pool_alloc.
*
* @tparam _Tp Type of allocated object.
*/
template<typename _Tp>
using __allocator_base = __gnu_cxx::__pool_alloc<_Tp>;
}
#else
// Define __pool_alloc as the base class to std::allocator.
# define __allocator_base __gnu_cxx::__pool_alloc
#endif
#endif

View File

@@ -0,0 +1,47 @@
// Optimizations for random number functions, aarch64 version -*- C++ -*-
// Copyright (C) 2017-2021 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/opt_random.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{random}
*/
#ifndef _BITS_OPT_RANDOM_H
#define _BITS_OPT_RANDOM_H 1
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY (default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // _BITS_OPT_RANDOM_H

View File

@@ -0,0 +1,182 @@
// Optimizations for random number extensions, aarch64 version -*- C++ -*-
// Copyright (C) 2017-2021 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 ext/random.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ext/random}
*/
#ifndef _EXT_OPT_RANDOM_H
#define _EXT_OPT_RANDOM_H 1
#pragma GCC system_header
#ifdef __ARM_NEON
#ifdef __ARM_BIG_ENDIAN
# define __VEXT(_A,_B,_C) __builtin_shuffle (_A, _B, (__Uint8x16_t) \
{16-_C, 17-_C, 18-_C, 19-_C, 20-_C, 21-_C, 22-_C, 23-_C, \
24-_C, 25-_C, 26-_C, 27-_C, 28-_C, 29-_C, 30-_C, 31-_C})
#else
# define __VEXT(_A,_B,_C) __builtin_shuffle (_B, _A, (__Uint8x16_t) \
{_C, _C+1, _C+2, _C+3, _C+4, _C+5, _C+6, _C+7, \
_C+8, _C+9, _C+10, _C+11, _C+12, _C+13, _C+14, _C+15})
#endif
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
namespace __gnu_cxx _GLIBCXX_VISIBILITY (default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace {
// Logical Shift right 128-bits by c * 8 bits
__extension__ extern __inline __Uint32x4_t
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
__aarch64_lsr_128 (__Uint8x16_t __a, __const int __c)
{
const __Uint8x16_t __zero = {0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0};
return (__Uint32x4_t) __VEXT (__zero, __a, __c);
}
// Logical Shift left 128-bits by c * 8 bits
__extension__ extern __inline __Uint32x4_t
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
__aarch64_lsl_128 (__Uint8x16_t __a, __const int __c)
{
const __Uint8x16_t __zero = {0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0};
return (__Uint32x4_t) __VEXT (__a, __zero, 16 - __c);
}
template<size_t __sl1, size_t __sl2, size_t __sr1, size_t __sr2>
inline __Uint32x4_t __aarch64_recursion (__Uint32x4_t __a,
__Uint32x4_t __b,
__Uint32x4_t __c,
__Uint32x4_t __d,
__Uint32x4_t __e)
{
__Uint32x4_t __y = (__b >> __sr1);
__Uint32x4_t __z = __aarch64_lsr_128 ((__Uint8x16_t) __c, __sr2);
__Uint32x4_t __v = __d << __sl1;
__z = __z ^ __a;
__z = __z ^ __v;
__Uint32x4_t __x = __aarch64_lsl_128 ((__Uint8x16_t) __a, __sl2);
__y = __y & __e;
__z = __z ^ __x;
return __z ^ __y;
}
}
#define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_GEN_READ 1
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
void simd_fast_mersenne_twister_engine<_UIntType, __m,
__pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3,
__parity4>::
_M_gen_rand (void)
{
__Uint32x4_t __r1 = _M_state[_M_nstate - 2];
__Uint32x4_t __r2 = _M_state[_M_nstate - 1];
__Uint32x4_t __aData = {__msk1, __msk2, __msk3, __msk4};
size_t __i;
for (__i = 0; __i < _M_nstate - __pos1; ++__i)
{
__Uint32x4_t __r = __aarch64_recursion<__sl1, __sl2, __sr1, __sr2>
(_M_state[__i], _M_state[__i + __pos1], __r1, __r2, __aData);
_M_state[__i] = __r;
__r1 = __r2;
__r2 = __r;
}
for (; __i < _M_nstate; ++__i)
{
__Uint32x4_t __r = __aarch64_recursion<__sl1, __sl2, __sr1, __sr2>
(_M_state[__i], _M_state[__i + __pos1 - _M_nstate], __r1, __r2,
__aData);
_M_state[__i] = __r;
__r1 = __r2;
__r2 = __r;
}
_M_pos = 0;
}
#define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_OPERATOREQUAL 1
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
bool
operator==(const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3, __parity4>& __lhs,
const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3, __parity4>& __rhs)
{
if (__lhs._M_pos != __rhs._M_pos)
return false;
__Uint32x4_t __res = __lhs._M_state[0] ^ __rhs._M_state[0];
for (size_t __i = 1; __i < __lhs._M_nstate; ++__i)
__res |= __lhs._M_state[__i] ^ __rhs._M_state[__i];
return (__int128) __res == 0;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#endif // __ARM_NEON
#endif // _EXT_OPT_RANDOM_H

View File

@@ -0,0 +1,40 @@
// Specific definitions for generic platforms -*- C++ -*-
// Copyright (C) 2015-2021 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/cpu_defines.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iosfwd}
*/
#ifndef _GLIBCXX_CPU_DEFINES
#define _GLIBCXX_CPU_DEFINES 1
// Integer divide instructions don't trap on ARM.
#ifdef __ARM_ARCH_EXT_IDIV__
#define __glibcxx_integral_traps false
#else
#define __glibcxx_integral_traps true
#endif
#endif

View File

@@ -0,0 +1,87 @@
// Control various target specific ABI tweaks. ARM version.
// Copyright (C) 2004-2021 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/cxxabi_tweaks.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{cxxabi.h}
*/
#ifndef _CXXABI_TWEAKS_H
#define _CXXABI_TWEAKS_H 1
#ifdef __cplusplus
namespace __cxxabiv1
{
extern "C"
{
#endif
#ifdef __ARM_EABI__
// The ARM EABI uses the least significant bit of a 32-bit
// guard variable.
#define _GLIBCXX_GUARD_TEST(x) ((*(x) & 1) != 0)
#define _GLIBCXX_GUARD_SET(x) *(x) = 1
#define _GLIBCXX_GUARD_BIT 1
#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1)
#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1)
typedef int __guard;
#define _GLIBCXX_GUARD_TEST_AND_ACQUIRE(x) \
((__atomic_load_n(x, __ATOMIC_ACQUIRE) & 1) != 0)
#define _GLIBCXX_GUARD_SET_AND_RELEASE(x) \
__atomic_store_n(x, 1, __ATOMIC_RELEASE)
// We also want the element size in array cookies.
#define _GLIBCXX_ELTSIZE_IN_COOKIE 1
// __cxa_vec_ctor should return a pointer to the array.
typedef void * __cxa_vec_ctor_return_type;
#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return x
// Constructors and destructors return the "this" pointer.
typedef void * __cxa_cdtor_return_type;
#else // __ARM_EABI__
// The generic ABI uses the first byte of a 64-bit guard variable.
#define _GLIBCXX_GUARD_TEST(x) (*(char *) (x) != 0)
#define _GLIBCXX_GUARD_SET(x) *(char *) (x) = 1
#define _GLIBCXX_GUARD_BIT __guard_test_bit (0, 1)
#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1)
#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1)
__extension__ typedef int __guard __attribute__((mode (__DI__)));
// __cxa_vec_ctor has void return type.
typedef void __cxa_vec_ctor_return_type;
#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return
// Constructors and destructors do not return a value.
typedef void __cxa_cdtor_return_type;
#endif //!__ARM_EABI__
#ifdef __cplusplus
}
} // namespace __cxxabiv1
#endif
#endif

View File

@@ -0,0 +1,31 @@
// Low-level type for atomic operations -*- C++ -*-
// Copyright (C) 2004-2021 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/>.
#ifndef _GLIBCXX_ATOMIC_WORD_H
#define _GLIBCXX_ATOMIC_WORD_H 1
// This entity must not cross a page boundary.
typedef int _Atomic_word __attribute__ ((__aligned__ (4)));
#endif

View File

@@ -0,0 +1,89 @@
// Low-level functions for atomic operations: CRIS version -*- C++ -*-
// Copyright (C) 2001-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <ext/atomicity.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_Atomic_word
__exchange_and_add(volatile _Atomic_word* __mem, int __val) throw ()
{
int __tmp;
_Atomic_word __result;
#if (__CRIS_arch_version >= 32)
__asm__ __volatile__ (" clearf p \n"
"0: \n"
" move.d %4,%2 \n"
" move.d [%3],%0 \n"
" add.d %0,%2 \n"
" ax \n"
" move.d %2,[%3] \n"
" bcs 0b \n"
" clearf p \n"
: "=&r" (__result), "=Q" (*__mem), "=&r" (__tmp)
: "r" (__mem), "g" (__val), "Q" (*__mem)
: "memory");
#elif (__CRIS_arch_version >= 10)
__asm__ __volatile__ (" clearf \n"
"0: \n"
" move.d %4,%2 \n"
" move.d [%3],%0 \n"
" add.d %0,%2 \n"
" ax \n"
" move.d %2,[%3] \n"
" bwf 0b \n"
" clearf \n"
: "=&r" (__result), "=Q" (*__mem), "=&r" (__tmp)
: "r" (__mem), "g" (__val), "Q" (*__mem)
/* The memory clobber must stay, regardless of
current uses of this function. */
: "memory");
#else
__asm__ __volatile__ (" move $ccr,$r9 \n"
" di \n"
" move.d %4,%2 \n"
" move.d [%3],%0 \n"
" add.d %0,%2 \n"
" move.d %2,[%3] \n"
" move $r9,$ccr \n"
: "=&r" (__result), "=Q" (*__mem), "=&r" (__tmp)
: "r" (__mem), "g" (__val), "Q" (*__mem)
: "r9",
/* The memory clobber must stay, regardless of
current uses of this function. */
"memory");
#endif
return __result;
}
void
__atomic_add(volatile _Atomic_word* __mem, int __val) throw ()
{ __exchange_and_add(__mem, __val); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,40 @@
// Low-level type for atomic operations -*- C++ -*-
// Copyright (C) 2004-2021 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 atomic_word.h
* This file is a GNU extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_ATOMIC_WORD_H
#define _GLIBCXX_ATOMIC_WORD_H 1
typedef int _Atomic_word;
// This is a memory order acquire fence.
#define _GLIBCXX_READ_MEM_BARRIER __atomic_thread_fence (__ATOMIC_ACQUIRE)
// This is a memory order release fence.
#define _GLIBCXX_WRITE_MEM_BARRIER __atomic_thread_fence (__ATOMIC_RELEASE)
#endif

View File

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

View File

@@ -0,0 +1,59 @@
// Low-level functions for atomic operations: Generic version -*- C++ -*-
// Copyright (C) 1999-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <ext/atomicity.h>
#include <ext/concurrence.h>
namespace
{
__gnu_cxx::__mutex&
get_atomic_mutex()
{
static __gnu_cxx::__mutex atomic_mutex;
return atomic_mutex;
}
} // anonymous namespace
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_Atomic_word
__attribute__ ((__unused__))
__exchange_and_add(volatile _Atomic_word* __mem, int __val) throw ()
{
__gnu_cxx::__scoped_lock sentry(get_atomic_mutex());
_Atomic_word __result;
__result = *__mem;
*__mem += __val;
return __result;
}
void
__attribute__ ((__unused__))
__atomic_add(volatile _Atomic_word* __mem, int __val) throw ()
{ __exchange_and_add(__mem, __val); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,33 @@
// Specific definitions for generic platforms -*- C++ -*-
// Copyright (C) 2005-2021 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/cpu_defines.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iosfwd}
*/
#ifndef _GLIBCXX_CPU_DEFINES
#define _GLIBCXX_CPU_DEFINES 1
#endif

View File

@@ -0,0 +1,59 @@
// Control various target specific ABI tweaks. Generic version.
// Copyright (C) 2004-2021 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/cxxabi_tweaks.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{cxxabi.h}
*/
#ifndef _CXXABI_TWEAKS_H
#define _CXXABI_TWEAKS_H 1
#ifdef __cplusplus
namespace __cxxabiv1
{
extern "C"
{
#endif
// The generic ABI uses the first byte of a 64-bit guard variable.
#define _GLIBCXX_GUARD_TEST(x) (*(char *) (x) != 0)
#define _GLIBCXX_GUARD_SET(x) *(char *) (x) = 1
#define _GLIBCXX_GUARD_BIT __guard_test_bit (0, 1)
#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1)
#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1)
__extension__ typedef int __guard __attribute__((mode (__DI__)));
// __cxa_vec_ctor has void return type.
typedef void __cxa_vec_ctor_return_type;
#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return
// Constructors and destructors do not return a value.
typedef void __cxa_cdtor_return_type;
#ifdef __cplusplus
}
} // namespace __cxxabiv1
#endif
#endif

View File

@@ -0,0 +1,38 @@
// Optimizations for random number handling, generic version -*- C++ -*-
// Copyright (C) 2012-2021 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/opt_random.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{random}
*/
#ifndef _BITS_OPT_RANDOM_H
#define _BITS_OPT_RANDOM_H 1
#pragma GCC system_header
#endif // _BITS_OPT_RANDOM_H

View File

@@ -0,0 +1,38 @@
// Optimizations for random number extensions, generic version -*- C++ -*-
// Copyright (C) 2012-2021 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 ext/opt_random.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ext/random}
*/
#ifndef _EXT_OPT_RANDOM_H
#define _EXT_OPT_RANDOM_H 1
#pragma GCC system_header
#endif // _EXT_OPT_RANDOM_H

View File

@@ -0,0 +1,94 @@
// Low-level functions for atomic operations: PA-RISC version -*- C++ -*-
// Copyright (C) 2002-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <bits/c++config.h>
#include <ext/atomicity.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<int _Inst>
struct _Atomicity_lock
{
static volatile int _S_atomicity_lock;
};
template<int _Inst>
volatile int
_Atomicity_lock<_Inst>::_S_atomicity_lock __attribute__ ((aligned (16))) = 1;
// Because of the lack of weak support when using the hpux som
// linker, we explicitly instantiate the atomicity lock.
template volatile int _Atomicity_lock<0>::_S_atomicity_lock;
int
__attribute__ ((__unused__))
__exchange_and_add(volatile _Atomic_word* __mem, int __val) throw ()
{
_Atomic_word result;
int tmp;
volatile int& lock = _Atomicity_lock<0>::_S_atomicity_lock;
__asm__ __volatile__ ("ldcw 0(%1),%0\n\t"
"cmpib,<>,n 0,%0,.+20\n\t"
"ldw 0(%1),%0\n\t"
"cmpib,= 0,%0,.-4\n\t"
"nop\n\t"
"b,n .-20"
: "=&r" (tmp)
: "r" (&lock)
: "memory");
result = *__mem;
*__mem = result + __val;
__asm__ __volatile__ ("stw %1,0(%0)"
: : "r" (&lock), "r" (tmp) : "memory");
return result;
}
void
__attribute__ ((__unused__))
__atomic_add(volatile _Atomic_word* __mem, int __val) throw ()
{
int tmp;
volatile int& lock = _Atomicity_lock<0>::_S_atomicity_lock;
__asm__ __volatile__ ("ldcw 0(%1),%0\n\t"
"cmpib,<>,n 0,%0,.+20\n\t"
"ldw 0(%1),%0\n\t"
"cmpib,= 0,%0,.-4\n\t"
"nop\n\t"
"b,n .-20"
: "=&r" (tmp)
: "r" (&lock)
: "memory");
*__mem += __val;
__asm__ __volatile__ ("stw %1,0(%0)"
: : "r" (&lock), "r" (tmp) : "memory");
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,73 @@
// Low-level functions for atomic operations: x86, x >= 3 version -*- C++ -*-
// Copyright (C) 2003-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <ext/atomicity.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<int __inst>
struct _Atomicity_lock
{
static volatile _Atomic_word _S_atomicity_lock;
};
template<int __inst>
volatile _Atomic_word _Atomicity_lock<__inst>::_S_atomicity_lock = 0;
template volatile _Atomic_word _Atomicity_lock<0>::_S_atomicity_lock;
_Atomic_word
__attribute__ ((__unused__))
__exchange_and_add(volatile _Atomic_word* __mem, int __val) throw ()
{
register _Atomic_word __result, __tmp = 1;
// Obtain the atomic exchange/add spin lock.
do
{
__asm__ __volatile__ ("xchg{l} {%0,%1|%1,%0}"
: "=m" (_Atomicity_lock<0>::_S_atomicity_lock),
"+r" (__tmp)
: "m" (_Atomicity_lock<0>::_S_atomicity_lock));
}
while (__tmp);
__result = *__mem;
*__mem += __val;
// Release spin lock.
_Atomicity_lock<0>::_S_atomicity_lock = 0;
return __result;
}
void
__attribute__ ((__unused__))
__atomic_add(volatile _Atomic_word* __mem, int __val) throw ()
{ __exchange_and_add(__mem, __val); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,52 @@
// Low-level functions for atomic operations: x86, x >= 4 version -*- C++ -*-
// Copyright (C) 1999-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <ext/atomicity.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_Atomic_word
__attribute__ ((__unused__))
__exchange_and_add(volatile _Atomic_word* __mem, int __val) throw ()
{
register _Atomic_word __result;
__asm__ __volatile__ ("lock; xadd{l} {%0,%1|%1,%0}"
: "=r" (__result), "=m" (*__mem)
: "0" (__val), "m" (*__mem));
return __result;
}
void
__attribute__ ((__unused__))
__atomic_add(volatile _Atomic_word* __mem, int __val) throw ()
{
__asm__ __volatile__ ("lock; add{l} {%1,%0|%0,%1}"
: "=m" (*__mem) : "ir" (__val), "m" (*__mem));
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,221 @@
// Optimizations for random number functions, x86 version -*- C++ -*-
// Copyright (C) 2012-2021 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/opt_random.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{random}
*/
#ifndef _BITS_OPT_RANDOM_H
#define _BITS_OPT_RANDOM_H 1
#ifdef __SSE3__
#include <pmmintrin.h>
#endif
#pragma GCC system_header
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#ifdef __SSE3__
template<>
template<typename _UniformRandomNumberGenerator>
void
normal_distribution<double>::
__generate(typename normal_distribution<double>::result_type* __f,
typename normal_distribution<double>::result_type* __t,
_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
typedef uint64_t __uctype;
if (__f == __t)
return;
if (_M_saved_available)
{
_M_saved_available = false;
*__f++ = _M_saved * __param.stddev() + __param.mean();
if (__f == __t)
return;
}
constexpr uint64_t __maskval = 0xfffffffffffffull;
static const __m128i __mask = _mm_set1_epi64x(__maskval);
static const __m128i __two = _mm_set1_epi64x(0x4000000000000000ull);
static const __m128d __three = _mm_set1_pd(3.0);
const __m128d __av = _mm_set1_pd(__param.mean());
const __uctype __urngmin = __urng.min();
const __uctype __urngmax = __urng.max();
const __uctype __urngrange = __urngmax - __urngmin;
const __uctype __uerngrange = __urngrange + 1;
while (__f + 1 < __t)
{
double __le;
__m128d __x;
do
{
union
{
__m128i __i;
__m128d __d;
} __v;
if (__urngrange > __maskval)
{
if (__detail::_Power_of_2(__uerngrange))
__v.__i = _mm_and_si128(_mm_set_epi64x(__urng(),
__urng()),
__mask);
else
{
const __uctype __uerange = __maskval + 1;
const __uctype __scaling = __urngrange / __uerange;
const __uctype __past = __uerange * __scaling;
uint64_t __v1;
do
__v1 = __uctype(__urng()) - __urngmin;
while (__v1 >= __past);
__v1 /= __scaling;
uint64_t __v2;
do
__v2 = __uctype(__urng()) - __urngmin;
while (__v2 >= __past);
__v2 /= __scaling;
__v.__i = _mm_set_epi64x(__v1, __v2);
}
}
else if (__urngrange == __maskval)
__v.__i = _mm_set_epi64x(__urng(), __urng());
else if ((__urngrange + 2) * __urngrange >= __maskval
&& __detail::_Power_of_2(__uerngrange))
{
uint64_t __v1 = __urng() * __uerngrange + __urng();
uint64_t __v2 = __urng() * __uerngrange + __urng();
__v.__i = _mm_and_si128(_mm_set_epi64x(__v1, __v2),
__mask);
}
else
{
size_t __nrng = 2;
__uctype __high = __maskval / __uerngrange / __uerngrange;
while (__high > __uerngrange)
{
++__nrng;
__high /= __uerngrange;
}
const __uctype __highrange = __high + 1;
const __uctype __scaling = __urngrange / __highrange;
const __uctype __past = __highrange * __scaling;
__uctype __tmp;
uint64_t __v1;
do
{
do
__tmp = __uctype(__urng()) - __urngmin;
while (__tmp >= __past);
__v1 = __tmp / __scaling;
for (size_t __cnt = 0; __cnt < __nrng; ++__cnt)
{
__tmp = __v1;
__v1 *= __uerngrange;
__v1 += __uctype(__urng()) - __urngmin;
}
}
while (__v1 > __maskval || __v1 < __tmp);
uint64_t __v2;
do
{
do
__tmp = __uctype(__urng()) - __urngmin;
while (__tmp >= __past);
__v2 = __tmp / __scaling;
for (size_t __cnt = 0; __cnt < __nrng; ++__cnt)
{
__tmp = __v2;
__v2 *= __uerngrange;
__v2 += __uctype(__urng()) - __urngmin;
}
}
while (__v2 > __maskval || __v2 < __tmp);
__v.__i = _mm_set_epi64x(__v1, __v2);
}
__v.__i = _mm_or_si128(__v.__i, __two);
__x = _mm_sub_pd(__v.__d, __three);
__m128d __m = _mm_mul_pd(__x, __x);
__le = _mm_cvtsd_f64(_mm_hadd_pd (__m, __m));
}
while (__le == 0.0 || __le >= 1.0);
double __mult = (std::sqrt(-2.0 * std::log(__le) / __le)
* __param.stddev());
__x = _mm_add_pd(_mm_mul_pd(__x, _mm_set1_pd(__mult)), __av);
_mm_storeu_pd(__f, __x);
__f += 2;
}
if (__f != __t)
{
result_type __x, __y, __r2;
__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
__aurng(__urng);
do
{
__x = result_type(2.0) * __aurng() - 1.0;
__y = result_type(2.0) * __aurng() - 1.0;
__r2 = __x * __x + __y * __y;
}
while (__r2 > 1.0 || __r2 == 0.0);
const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2);
_M_saved = __x * __mult;
_M_saved_available = true;
*__f = __y * __mult * __param.stddev() + __param.mean();
}
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // _BITS_OPT_RANDOM_H

View File

@@ -0,0 +1,140 @@
// Optimizations for random number extensions, x86 version -*- C++ -*-
// Copyright (C) 2012-2021 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 ext/random.tcc
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ext/random}
*/
#ifndef _EXT_OPT_RANDOM_H
#define _EXT_OPT_RANDOM_H 1
#pragma GCC system_header
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#ifdef __SSE2__
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace {
template<size_t __sl1, size_t __sl2, size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2, uint32_t __msk3, uint32_t __msk4>
inline __m128i __sse2_recursion(__m128i __a, __m128i __b,
__m128i __c, __m128i __d)
{
__m128i __y = _mm_srli_epi32(__b, __sr1);
__m128i __z = _mm_srli_si128(__c, __sr2);
__m128i __v = _mm_slli_epi32(__d, __sl1);
__z = _mm_xor_si128(__z, __a);
__z = _mm_xor_si128(__z, __v);
__m128i __x = _mm_slli_si128(__a, __sl2);
__y = _mm_and_si128(__y, _mm_set_epi32(__msk4, __msk3, __msk2, __msk1));
__z = _mm_xor_si128(__z, __x);
return _mm_xor_si128(__z, __y);
}
}
#define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_GEN_READ 1
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
void simd_fast_mersenne_twister_engine<_UIntType, __m,
__pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3,
__parity4>::
_M_gen_rand(void)
{
__m128i __r1 = _mm_load_si128(&_M_state[_M_nstate - 2]);
__m128i __r2 = _mm_load_si128(&_M_state[_M_nstate - 1]);
size_t __i;
for (__i = 0; __i < _M_nstate - __pos1; ++__i)
{
__m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4>
(_M_state[__i], _M_state[__i + __pos1], __r1, __r2);
_mm_store_si128(&_M_state[__i], __r);
__r1 = __r2;
__r2 = __r;
}
for (; __i < _M_nstate; ++__i)
{
__m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4>
(_M_state[__i], _M_state[__i + __pos1 - _M_nstate], __r1, __r2);
_mm_store_si128(&_M_state[__i], __r);
__r1 = __r2;
__r2 = __r;
}
_M_pos = 0;
}
#define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_OPERATOREQUAL 1
template<typename _UIntType, size_t __m,
size_t __pos1, size_t __sl1, size_t __sl2,
size_t __sr1, size_t __sr2,
uint32_t __msk1, uint32_t __msk2,
uint32_t __msk3, uint32_t __msk4,
uint32_t __parity1, uint32_t __parity2,
uint32_t __parity3, uint32_t __parity4>
bool
operator==(const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3, __parity4>& __lhs,
const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
__m, __pos1, __sl1, __sl2, __sr1, __sr2,
__msk1, __msk2, __msk3, __msk4,
__parity1, __parity2, __parity3, __parity4>& __rhs)
{
__m128i __res = _mm_cmpeq_epi8(__lhs._M_state[0], __rhs._M_state[0]);
for (size_t __i = 1; __i < __lhs._M_nstate; ++__i)
__res = _mm_and_si128(__res, _mm_cmpeq_epi8(__lhs._M_state[__i],
__rhs._M_state[__i]));
return (_mm_movemask_epi8(__res) == 0xffff
&& __lhs._M_pos == __rhs._M_pos);
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // __SSE2__
#endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#endif // _EXT_OPT_RANDOM_H

View File

@@ -0,0 +1,135 @@
// Low-level functions for atomic operations: m68k version -*- C++ -*-
// Copyright (C) 2001-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <ext/atomicity.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#if ( defined(__mc68020__) || defined(__mc68030__) \
|| defined(__mc68040__) || defined(__mc68060__) ) \
&& !defined(__mcpu32__)
// These variants support compare-and-swap.
_Atomic_word
__attribute__ ((__unused__))
__exchange_and_add(volatile _Atomic_word* __mem, int __val) throw ()
{
register _Atomic_word __result = *__mem;
register _Atomic_word __temp;
__asm__ __volatile__ ("1: move%.l %0,%1\n\t"
"add%.l %3,%1\n\t"
"cas%.l %0,%1,%2\n\t"
"jne 1b"
: "=d" (__result), "=&d" (__temp), "=m" (*__mem)
: "d" (__val), "0" (__result), "m" (*__mem));
return __result;
}
#elif defined(__rtems__)
// This code is only provided for reference. RTEMS uses now the atomic
// builtins and libatomic. See configure.host.
//
// TAS/JBNE is unsafe on systems with strict priority-based scheduling.
// Disable interrupts, which we can do only from supervisor mode.
_Atomic_word
__attribute__ ((__unused__))
__exchange_and_add(volatile _Atomic_word* __mem, int __val) throw ()
{
_Atomic_word __result;
short __level, __tmpsr;
__asm__ __volatile__ ("move%.w %%sr,%0\n\tor%.l %0,%1\n\tmove%.w %1,%%sr"
: "=d"(__level), "=d"(__tmpsr) : "1"(0x700));
__result = *__mem;
*__mem = __result + __val;
__asm__ __volatile__ ("move%.w %0,%%sr" : : "d"(__level));
return __result;
}
#else
template<int __inst>
struct _Atomicity_lock
{
static volatile unsigned char _S_atomicity_lock;
};
template<int __inst>
volatile unsigned char _Atomicity_lock<__inst>::_S_atomicity_lock = 0;
template volatile unsigned char _Atomicity_lock<0>::_S_atomicity_lock;
_Atomic_word
__attribute__ ((__unused__))
__exchange_and_add(volatile _Atomic_word* __mem, int __val) throw ()
{
_Atomic_word __result;
// bset with no immediate addressing (not SMP-safe)
#if defined(__mcfisaa__) || defined(__mcfisaaplus__)
__asm__ __volatile__("1: bset.b #7,%0@\n\tjbne 1b"
: /* no outputs */
: "a"(&_Atomicity_lock<0>::_S_atomicity_lock)
: "cc", "memory");
// CPU32 and CF ISAs B & C support test-and-set (SMP-safe).
#elif defined(__mcpu32__) || defined(__mcfisab__) || defined (__mcfisac__)
__asm__ __volatile__("1: tas %0\n\tjbne 1b"
: "+m"(_Atomicity_lock<0>::_S_atomicity_lock)
: /* none */
: "cc");
// Use bset with immediate addressing for 68000/68010 (not SMP-safe)
// NOTE: TAS is available on the 68000, but unsupported by some Amiga
// memory controllers.
#else
__asm__ __volatile__("1: bset.b #7,%0\n\tjbne 1b"
: "+m"(_Atomicity_lock<0>::_S_atomicity_lock)
: /* none */
: "cc");
#endif
__result = *__mem;
*__mem = __result + __val;
_Atomicity_lock<0>::_S_atomicity_lock = 0;
return __result;
}
#endif /* TAS / BSET */
void
__attribute__ ((__unused__))
__atomic_add(volatile _Atomic_word* __mem, int __val) throw ()
{
// Careful: using add.l with a memory destination is not
// architecturally guaranteed to be atomic.
__exchange_and_add(__mem, __val);
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,39 @@
// Specific definitions for Xilinx MicroBlaze platforms -*- C++ -*-
// Copyright (C) 2009-2021 Free Software Foundation, Inc.
//
// Contributed by Michael Eager <eager@eagercon.com>.
//
// 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/cpu_defines.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iosfwd}
*/
#ifndef _GLIBCXX_CPU_DEFINES
#define _GLIBCXX_CPU_DEFINES 1
// Optimize memory size for embedded systems
// -- Use abort for eh terminate
#define _GLIBCXX_NO_VERBOSE_TERMINATE 1
#endif

View File

@@ -0,0 +1,36 @@
// Specific definitions for generic platforms -*- C++ -*-
// Copyright (C) 2005-2021 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/cpu_defines.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iosfwd}
*/
#ifndef _GLIBCXX_CPU_DEFINES
#define _GLIBCXX_CPU_DEFINES 1
// Integer divide instructions don't trap on PowerPC.
#define __glibcxx_integral_traps false
#endif

View File

@@ -0,0 +1,35 @@
// Low-level functions for atomic operations: sh version -*- C++ -*-
// Copyright (C) 1999-2021 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/>.
// Use the default atomicity stuff, which will use __atomic* builtins
// if threads are available, or the *_single functions on single-thread
// configurations.
// Actually we wouldn't need this header at all, but because of PR 53579
// libstdc++'s configury will not pickup the -matomic-model= option when
// set in the environment. This makes it impossible to enable the proper
// atomic model on SH without modifying GCC itself, because libstdc++ always
// thinks the target doesn't do any atomics and uses the default mutex based
// implementation from cpu/generic/atomicity_mutex.
#include <ext/atomicity.h>

View File

@@ -0,0 +1,48 @@
// Low-level type for atomic operations -*- C++ -*-
// Copyright (C) 2004-2021 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/>.
#ifndef _GLIBCXX_ATOMIC_WORD_H
#define _GLIBCXX_ATOMIC_WORD_H 1
#ifdef __arch64__
typedef long _Atomic_word;
#else
typedef int _Atomic_word;
#endif
#if defined(__sparc_v9__)
// These are necessary under the V9 RMO model, though it is almost never
// used in userspace.
#define _GLIBCXX_READ_MEM_BARRIER \
__asm __volatile ("membar #LoadLoad":::"memory")
#define _GLIBCXX_WRITE_MEM_BARRIER \
__asm __volatile ("membar #StoreStore":::"memory")
#elif defined(__sparc_v8__)
// This is necessary under the PSO model.
#define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("stbar":::"memory")
#endif
#endif

View File

@@ -0,0 +1,124 @@
// Low-level functions for atomic operations: Sparc version -*- C++ -*-
// Copyright (C) 1999-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <ext/atomicity.h>
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
#ifdef __arch64__
_Atomic_word
__attribute__ ((__unused__))
__exchange_and_add(volatile _Atomic_word* __mem, int __val) throw ()
{
_Atomic_word __tmp1, __tmp2;
_Atomic_word __val_extended = __val;
__asm__ __volatile__("1: ldx [%3], %0\n\t"
" add %0, %4, %1\n\t"
" casx [%3], %0, %1\n\t"
" sub %0, %1, %0\n\t"
" brnz,pn %0, 1b\n\t"
" nop"
: "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__mem)
: "r" (__mem), "r" (__val_extended), "m" (*__mem));
return __tmp2;
}
void
__attribute__ ((__unused__))
__atomic_add(volatile _Atomic_word* __mem, int __val) throw ()
{
_Atomic_word __tmp1, __tmp2;
_Atomic_word __val_extended = __val;
__asm__ __volatile__("1: ldx [%3], %0\n\t"
" add %0, %4, %1\n\t"
" casx [%3], %0, %1\n\t"
" sub %0, %1, %0\n\t"
" brnz,pn %0, 1b\n\t"
" nop"
: "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__mem)
: "r" (__mem), "r" (__val_extended), "m" (*__mem));
}
#else /* __arch32__ */
template<int __inst>
struct _Atomicity_lock
{
static unsigned char _S_atomicity_lock;
};
template<int __inst>
unsigned char _Atomicity_lock<__inst>::_S_atomicity_lock = 0;
template unsigned char _Atomicity_lock<0>::_S_atomicity_lock;
_Atomic_word
__attribute__ ((__unused__))
__exchange_and_add(volatile _Atomic_word* __mem, int __val) throw ()
{
_Atomic_word __result, __tmp;
__asm__ __volatile__("1: ldstub [%1], %0\n\t"
" cmp %0, 0\n\t"
" bne 1b\n\t"
" nop"
: "=&r" (__tmp)
: "r" (&_Atomicity_lock<0>::_S_atomicity_lock)
: "memory");
__result = *__mem;
*__mem += __val;
__asm__ __volatile__("stb %%g0, [%0]"
: /* no outputs */
: "r" (&_Atomicity_lock<0>::_S_atomicity_lock)
: "memory");
return __result;
}
void
__attribute__ ((__unused__))
__atomic_add(volatile _Atomic_word* __mem, int __val) throw ()
{
_Atomic_word __tmp;
__asm__ __volatile__("1: ldstub [%1], %0\n\t"
" cmp %0, 0\n\t"
" bne 1b\n\t"
" nop"
: "=&r" (__tmp)
: "r" (&_Atomicity_lock<0>::_S_atomicity_lock)
: "memory");
*__mem += __val;
__asm__ __volatile__("stb %%g0, [%0]"
: /* no outputs */
: "r" (&_Atomicity_lock<0>::_S_atomicity_lock)
: "memory");
}
#endif /* __arch32__ */
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

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

View File

@@ -0,0 +1,135 @@
// Wrapper of C-language FILE struct -*- C++ -*-
// Copyright (C) 2000-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 27.8 File-based streams
//
/** @file bits/basic_file.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ios}
*/
#ifndef _GLIBCXX_BASIC_FILE_STDIO_H
#define _GLIBCXX_BASIC_FILE_STDIO_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/c++io.h> // for __c_lock and __c_file
#include <bits/move.h> // for swap
#include <ios>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Generic declaration.
template<typename _CharT>
class __basic_file;
// Specialization.
template<>
class __basic_file<char>
{
// Underlying data source/sink.
__c_file* _M_cfile;
// True iff we opened _M_cfile, and thus must close it ourselves.
bool _M_cfile_created;
public:
__basic_file(__c_lock* __lock = 0) throw ();
#if __cplusplus >= 201103L
__basic_file(__basic_file&& __rv, __c_lock* = 0) noexcept
: _M_cfile(__rv._M_cfile), _M_cfile_created(__rv._M_cfile_created)
{
__rv._M_cfile = nullptr;
__rv._M_cfile_created = false;
}
__basic_file& operator=(const __basic_file&) = delete;
__basic_file& operator=(__basic_file&&) = delete;
void
swap(__basic_file& __f) noexcept
{
std::swap(_M_cfile, __f._M_cfile);
std::swap(_M_cfile_created, __f._M_cfile_created);
}
#endif
__basic_file*
open(const char* __name, ios_base::openmode __mode, int __prot = 0664);
#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
__basic_file*
open(const wchar_t* __name, ios_base::openmode __mode);
#endif
__basic_file*
sys_open(__c_file* __file, ios_base::openmode);
__basic_file*
sys_open(int __fd, ios_base::openmode __mode) throw ();
__basic_file*
close();
_GLIBCXX_PURE bool
is_open() const throw ();
_GLIBCXX_PURE int
fd() throw ();
_GLIBCXX_PURE __c_file*
file() throw ();
~__basic_file();
streamsize
xsputn(const char* __s, streamsize __n);
streamsize
xsputn_2(const char* __s1, streamsize __n1,
const char* __s2, streamsize __n2);
streamsize
xsgetn(char* __s, streamsize __n);
streamoff
seekoff(streamoff __off, ios_base::seekdir __way) throw ();
int
sync();
streamsize
showmanyc();
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif

View File

@@ -0,0 +1,50 @@
// Underlying io library details -*- C++ -*-
// Copyright (C) 2000-2021 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++io.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{ios}
*/
// c_io_stdio.h - Defines for using "C" stdio.h
#ifndef _GLIBCXX_CXX_IO_H
#define _GLIBCXX_CXX_IO_H 1
#include <cstdio>
#include <bits/gthr.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef __gthread_mutex_t __c_lock;
// for basic_file.h
typedef FILE __c_file;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif

View File

@@ -0,0 +1,172 @@
// std::ctype implementation details, GNU version -*- C++ -*-
// Copyright (C) 2001-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <bits/c++locale_internal.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
namespace std _GLIBCXX_VISIBILITY(default)
{
// NB: The other ctype<char> specializations are in src/locale.cc and
// various /config/os/* files.
ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
: ctype<char>(0, false, __refs)
{
if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_ctype);
this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
}
}
ctype_byname<char>::~ctype_byname()
{ }
#ifdef _GLIBCXX_USE_WCHAR_T
ctype<wchar_t>::__wmask_type
ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const throw()
{
// Darwin uses the same codes for 'char' as 'wchar_t', so this routine
// never gets called.
return __m;
};
wchar_t
ctype<wchar_t>::do_toupper(wchar_t __c) const
{ return towupper(__c); }
const wchar_t*
ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
{
while (__lo < __hi)
{
*__lo = towupper(*__lo);
++__lo;
}
return __hi;
}
wchar_t
ctype<wchar_t>::do_tolower(wchar_t __c) const
{ return towlower(__c); }
const wchar_t*
ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
{
while (__lo < __hi)
{
*__lo = towlower(*__lo);
++__lo;
}
return __hi;
}
wchar_t
ctype<wchar_t>::
do_widen(char __c) const
{ return _M_widen[static_cast<unsigned char>(__c)]; }
const char*
ctype<wchar_t>::
do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
{
while (__lo < __hi)
{
*__dest = _M_widen[static_cast<unsigned char>(*__lo)];
++__lo;
++__dest;
}
return __hi;
}
char
ctype<wchar_t>::
do_narrow(wchar_t __wc, char __dfault) const
{
if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
return _M_narrow[__wc];
const int __c = wctob(__wc);
return (__c == EOF ? __dfault : static_cast<char>(__c));
}
const wchar_t*
ctype<wchar_t>::
do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
char* __dest) const
{
if (_M_narrow_ok)
while (__lo < __hi)
{
if (*__lo >= 0 && *__lo < 128)
*__dest = _M_narrow[*__lo];
else
{
const int __c = wctob(*__lo);
*__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
}
++__lo;
++__dest;
}
else
while (__lo < __hi)
{
const int __c = wctob(*__lo);
*__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++__lo;
++__dest;
}
return __hi;
}
void
ctype<wchar_t>::_M_initialize_ctype() throw()
{
wint_t __i;
for (__i = 0; __i < 128; ++__i)
{
const int __c = wctob(__i);
if (__c == EOF)
break;
else
_M_narrow[__i] = static_cast<char>(__c);
}
if (__i == 128)
_M_narrow_ok = true;
else
_M_narrow_ok = false;
for (size_t __i = 0;
__i < sizeof(_M_widen) / sizeof(wint_t); ++__i)
_M_widen[__i] = btowc(__i);
}
#endif // _GLIBCXX_USE_WCHAR_T
}

View File

@@ -0,0 +1,200 @@
// localization implementation details, DragonFly version -*- C++ -*-
// Copyright (C) 2014-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.8 Standard locale categories.
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
// Modified for DragonFly by John Marino <gnugcc@marino.st>
#include <cstdlib>
#include <locale>
#include <stdexcept>
#include <limits>
#include <langinfo.h>
#include <xlocale.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<>
void
__convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
const __c_locale& __cloc) throw()
{
char* __sanity;
__v = strtof_l(__s, &__sanity, (locale_t)__cloc);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 23. Num_get overflow result.
if (__sanity == __s || *__sanity != '\0')
{
__v = 0.0f;
__err = ios_base::failbit;
}
else if (__v == numeric_limits<float>::infinity())
{
__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;
}
}
template<>
void
__convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
const __c_locale& __cloc) throw()
{
char* __sanity;
__v = strtod_l(__s, &__sanity, (locale_t)__cloc);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 23. Num_get overflow result.
if (__sanity == __s || *__sanity != '\0')
{
__v = 0.0;
__err = ios_base::failbit;
}
else if (__v == numeric_limits<double>::infinity())
{
__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;
}
}
template<>
void
__convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
const __c_locale& __cloc) throw()
{
char* __sanity;
__v = strtold_l(__s, &__sanity, (locale_t)__cloc);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 23. Num_get overflow result.
if (__sanity == __s || *__sanity != '\0')
{
__v = 0.0l;
__err = ios_base::failbit;
}
else if (__v == numeric_limits<long double>::infinity())
{
__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;
}
}
void
locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
__c_locale __old)
{
__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)
{
if (__cloc && _S_get_c_locale() != __cloc)
freelocale((locale_t)__cloc);
}
__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 __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
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
{
"LC_CTYPE",
"LC_NUMERIC",
"LC_TIME",
"LC_COLLATE",
"LC_MONETARY",
"LC_MESSAGES"
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
const char* const* const locale::_S_categories = __gnu_cxx::category_names;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
// XXX GLIBCXX_ABI Deprecated
#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
extern "C" void ldbl (void) __attribute__ ((alias (#dbl)))
_GLIBCXX_LDBL_COMPAT(_ZSt14__convert_to_vIdEvPKcRT_RSt12_Ios_IostateRKP15__locale_struct, _ZSt14__convert_to_vIeEvPKcRT_RSt12_Ios_IostateRKP15__locale_struct);
#endif // _GLIBCXX_LONG_DOUBLE_COMPAT

View File

@@ -0,0 +1,82 @@
// localization implementation details, DragonFly version -*- C++ -*-
// Copyright (C) 2001-2021 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);
#if _GLIBCXX_USE_C99_STDIO
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

View File

@@ -0,0 +1,288 @@
// std::codecvt implementation details, DragonFly version -*- C++ -*-
// Copyright (C) 2015-2021 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

View File

@@ -0,0 +1,74 @@
// std::collate implementation details, DragonFly version -*- C++ -*-
// Copyright (C) 2015-2021 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

View File

@@ -0,0 +1,230 @@
// std::ctype implementation details, DragonFly version -*- C++ -*-
// Copyright (C) 2014-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
// Modified for DragonFly by John Marino <gnugcc@marino.st>
#include <locale>
#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)
{
if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_ctype);
this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
}
}
ctype_byname<char>::~ctype_byname()
{ }
#ifdef _GLIBCXX_USE_WCHAR_T
ctype<wchar_t>::__wmask_type
ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const throw()
{
__wmask_type __ret;
switch (__m)
{
case space:
__ret = wctype_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_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_l(*__lo, (locale_t)_M_c_locale_ctype);
++__lo;
}
return __hi;
}
wchar_t
ctype<wchar_t>::do_tolower(wchar_t __c) const
{ 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_l(*__lo, (locale_t)_M_c_locale_ctype);
++__lo;
}
return __hi;
}
wchar_t
ctype<wchar_t>::
do_widen(char __c) const
{ return _M_widen[static_cast<unsigned char>(__c)]; }
const char*
ctype<wchar_t>::
do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
{
while (__lo < __hi)
{
*__dest = _M_widen[static_cast<unsigned char>(*__lo)];
++__lo;
++__dest;
}
return __hi;
}
char
ctype<wchar_t>::
do_narrow(wchar_t __wc, char __dfault) const
{
if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
return _M_narrow[__wc];
__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));
}
const wchar_t*
ctype<wchar_t>::
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)
{
if (*__lo >= 0 && *__lo < 128)
*__dest = _M_narrow[*__lo];
else
{
const int __c = wctob(*__lo);
*__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
}
++__lo;
++__dest;
}
else
while (__lo < __hi)
{
const int __c = wctob(*__lo);
*__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++__lo;
++__dest;
}
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)
{
const int __c = wctob(__i);
if (__c == EOF)
break;
else
_M_narrow[__i] = static_cast<char>(__c);
}
if (__i == 128)
_M_narrow_ok = true;
else
_M_narrow_ok = false;
for (size_t __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

View File

@@ -0,0 +1,903 @@
// std::moneypunct implementation details, DragonFly version -*- C++ -*-
// Copyright (C) 2015-2021 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

View File

@@ -0,0 +1,235 @@
// std::numpunct implementation details, DragonFly version -*- C++ -*-
// Copyright (C) 2015-2021 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

View File

@@ -0,0 +1,404 @@
// std::time_get, std::time_put implementation, DragonFly version -*- C++ -*-
// Copyright (C) 2001-2021 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

View File

@@ -0,0 +1,95 @@
// std::time_get, std::time_put implementation, DragonFly version -*- C++ -*-
// Copyright (C) 2015-2021 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

View File

@@ -0,0 +1,25 @@
// Locale internal implementation header -*- C++ -*-
// Copyright (C) 2002-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
// The generic locale code doesn't need to do anything here (yet)

View File

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

View File

@@ -0,0 +1,92 @@
// Wrapper for underlying C-language localization -*- C++ -*-
// Copyright (C) 2001-2021 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>
#ifndef _GLIBCXX_CXX_LOCALE_H
#define _GLIBCXX_CXX_LOCALE_H 1
#pragma GCC system_header
#include <clocale>
#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&, char* __out,
const int __size __attribute__((__unused__)),
const char* __fmt, ...)
{
char* __old = std::setlocale(LC_NUMERIC, 0);
char* __sav = 0;
if (__builtin_strcmp(__old, "C"))
{
const size_t __len = __builtin_strlen(__old) + 1;
__sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
std::setlocale(LC_NUMERIC, "C");
}
__builtin_va_list __args;
__builtin_va_start(__args, __fmt);
#if _GLIBCXX_USE_C99_STDIO && !_GLIBCXX_HAVE_BROKEN_VSNPRINTF
const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
#else
const int __ret = __builtin_vsprintf(__out, __fmt, __args);
#endif
__builtin_va_end(__args);
if (__sav)
{
std::setlocale(LC_NUMERIC, __sav);
delete [] __sav;
}
return __ret;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,92 @@
// std::messages implementation details, generic version -*- C++ -*-
// Copyright (C) 2001-2021 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/messages_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.7.1.2 messages virtual functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Non-virtual member functions.
template<typename _CharT>
messages<_CharT>::messages(size_t __refs)
: facet(__refs)
{ _M_c_locale_messages = _S_get_c_locale(); }
template<typename _CharT>
messages<_CharT>::messages(__c_locale, const char*, size_t __refs)
: facet(__refs)
{ _M_c_locale_messages = _S_get_c_locale(); }
template<typename _CharT>
typename messages<_CharT>::catalog
messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
const char*) const
{ return this->do_open(__s, __loc); }
// Virtual member functions.
template<typename _CharT>
messages<_CharT>::~messages()
{ _S_destroy_c_locale(_M_c_locale_messages); }
template<typename _CharT>
typename messages<_CharT>::catalog
messages<_CharT>::do_open(const basic_string<char>&, const locale&) const
{ return 0; }
template<typename _CharT>
typename messages<_CharT>::string_type
messages<_CharT>::do_get(catalog, int, int,
const string_type& __dfault) const
{ return __dfault; }
template<typename _CharT>
void
messages<_CharT>::do_close(catalog) const
{ }
// messages_byname
template<typename _CharT>
messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
: messages<_CharT>(__refs)
{
if (__builtin_strcmp(__s, "C") != 0
&& __builtin_strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_messages);
this->_S_create_c_locale(this->_M_c_locale_messages, __s);
}
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,92 @@
// std::time_get, std::time_put implementation, generic version -*- C++ -*-
// Copyright (C) 2001-2021 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>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT>
__timepunct<_CharT>::__timepunct(size_t __refs)
: facet(__refs), _M_data(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_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)
{
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);
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,120 @@
// Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*-
// Copyright (C) 2002-2021 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_internal.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{locale}
*/
// Written by Jakub Jelinek <jakub@redhat.com>
#include <bits/c++config.h>
#include <clocale>
#include <cstdlib>
#include <cstring>
#include <cstddef>
#include <langinfo.h>
#include <vector>
#include <string.h> // ::strdup
#include <ext/concurrence.h>
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
extern "C" __typeof(strcoll_l) __strcoll_l;
extern "C" __typeof(strftime_l) __strftime_l;
extern "C" __typeof(strtod_l) __strtod_l;
extern "C" __typeof(strtof_l) __strtof_l;
extern "C" __typeof(strtold_l) __strtold_l;
extern "C" __typeof(strxfrm_l) __strxfrm_l;
extern "C" __typeof(newlocale) __newlocale;
extern "C" __typeof(freelocale) __freelocale;
extern "C" __typeof(duplocale) __duplocale;
extern "C" __typeof(uselocale) __uselocale;
#ifdef _GLIBCXX_USE_WCHAR_T
extern "C" __typeof(iswctype_l) __iswctype_l;
extern "C" __typeof(towlower_l) __towlower_l;
extern "C" __typeof(towupper_l) __towupper_l;
extern "C" __typeof(wcscoll_l) __wcscoll_l;
extern "C" __typeof(wcsftime_l) __wcsftime_l;
extern "C" __typeof(wcsxfrm_l) __wcsxfrm_l;
extern "C" __typeof(wctype_l) __wctype_l;
#endif
#endif // GLIBC 2.3 and later
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
struct Catalog_info
{
Catalog_info(messages_base::catalog __id, const char* __domain,
locale __loc)
: _M_id(__id), _M_domain(strdup(__domain)), _M_locale(__loc)
{ }
~Catalog_info()
{ free(_M_domain); }
messages_base::catalog _M_id;
char* _M_domain;
locale _M_locale;
private:
Catalog_info(const Catalog_info&);
Catalog_info&
operator=(const Catalog_info&);
};
class Catalogs
{
public:
Catalogs() : _M_catalog_counter(0) { }
~Catalogs();
messages_base::catalog
_M_add(const char* __domain, locale __l);
void
_M_erase(messages_base::catalog __c);
const Catalog_info*
_M_get(messages_base::catalog __c) const;
private:
mutable __gnu_cxx::__mutex _M_mutex;
messages_base::catalog _M_catalog_counter;
vector<Catalog_info*> _M_infos;
};
Catalogs&
get_catalogs();
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,296 @@
// Wrapper for underlying C-language localization -*- C++ -*-
// Copyright (C) 2001-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.8 Standard locale categories.
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <stdexcept>
#include <limits>
#include <algorithm>
#include <langinfo.h>
#include <bits/c++locale_internal.h>
#include <backward/auto_ptr.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<>
void
__convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
const __c_locale& __cloc) throw()
{
char* __sanity;
__v = __strtof_l(__s, &__sanity, __cloc);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 23. Num_get overflow result.
if (__sanity == __s || *__sanity != '\0')
{
__v = 0.0f;
__err = ios_base::failbit;
}
else if (__v == numeric_limits<float>::infinity())
{
__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;
}
}
template<>
void
__convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
const __c_locale& __cloc) throw()
{
char* __sanity;
__v = __strtod_l(__s, &__sanity, __cloc);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 23. Num_get overflow result.
if (__sanity == __s || *__sanity != '\0')
{
__v = 0.0;
__err = ios_base::failbit;
}
else if (__v == numeric_limits<double>::infinity())
{
__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;
}
}
template<>
void
__convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
const __c_locale& __cloc) throw()
{
char* __sanity;
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
// Prefer strtold_l, as __strtold_l isn't prototyped in more recent
// glibc versions.
__v = strtold_l(__s, &__sanity, __cloc);
#else
__v = __strtold_l(__s, &__sanity, __cloc);
#endif
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 23. Num_get overflow result.
if (__sanity == __s || *__sanity != '\0')
{
__v = 0.0l;
__err = ios_base::failbit;
}
else if (__v == numeric_limits<long double>::infinity())
{
__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;
}
}
void
locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
__c_locale __old)
{
__cloc = __newlocale(1 << LC_ALL, __s, __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)
{
if (__cloc && _S_get_c_locale() != __cloc)
__freelocale(__cloc);
}
__c_locale
locale::facet::_S_clone_c_locale(__c_locale& __cloc) throw()
{ return __duplocale(__cloc); }
__c_locale
locale::facet::_S_lc_ctype_c_locale(__c_locale __cloc, const char* __s)
{
__c_locale __dup = __duplocale(__cloc);
if (__dup == __c_locale(0))
__throw_runtime_error(__N("locale::facet::_S_lc_ctype_c_locale "
"duplocale error"));
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __changed = __newlocale(LC_CTYPE_MASK, __s, __dup);
#else
__c_locale __changed = __newlocale(1 << LC_CTYPE, __s, __dup);
#endif
if (__changed == __c_locale(0))
{
__freelocale(__dup);
__throw_runtime_error(__N("locale::facet::_S_lc_ctype_c_locale "
"newlocale error"));
}
return __changed;
}
struct _CatalogIdComp
{
bool
operator()(messages_base::catalog __cat, const Catalog_info* __info) const
{ return __cat < __info->_M_id; }
bool
operator()(const Catalog_info* __info, messages_base::catalog __cat) const
{ return __info->_M_id < __cat; }
};
Catalogs::~Catalogs()
{
for (vector<Catalog_info*>::iterator __it = _M_infos.begin();
__it != _M_infos.end(); ++__it)
delete *__it;
}
messages_base::catalog
Catalogs::_M_add(const char* __domain, locale __l)
{
__gnu_cxx::__scoped_lock lock(_M_mutex);
// The counter is not likely to roll unless catalogs keep on being
// opened/closed which is consider as an application mistake for the
// moment.
if (_M_catalog_counter == numeric_limits<messages_base::catalog>::max())
return -1;
auto_ptr<Catalog_info> info(new Catalog_info(_M_catalog_counter++,
__domain, __l));
// Check if we managed to allocate memory for domain.
if (!info->_M_domain)
return -1;
_M_infos.push_back(info.get());
return info.release()->_M_id;
}
void
Catalogs::_M_erase(messages_base::catalog __c)
{
__gnu_cxx::__scoped_lock lock(_M_mutex);
vector<Catalog_info*>::iterator __res =
lower_bound(_M_infos.begin(), _M_infos.end(), __c, _CatalogIdComp());
if (__res == _M_infos.end() || (*__res)->_M_id != __c)
return;
delete *__res;
_M_infos.erase(__res);
// Just in case closed catalog was the last open.
if (__c == _M_catalog_counter - 1)
--_M_catalog_counter;
}
const Catalog_info*
Catalogs::_M_get(messages_base::catalog __c) const
{
__gnu_cxx::__scoped_lock lock(_M_mutex);
vector<Catalog_info*>::const_iterator __res =
lower_bound(_M_infos.begin(), _M_infos.end(), __c, _CatalogIdComp());
if (__res != _M_infos.end() && (*__res)->_M_id == __c)
return *__res;
return 0;
}
Catalogs&
get_catalogs()
{
static Catalogs __catalogs;
return __catalogs;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
{
"LC_CTYPE",
"LC_NUMERIC",
"LC_TIME",
"LC_COLLATE",
"LC_MONETARY",
"LC_MESSAGES",
"LC_PAPER",
"LC_NAME",
"LC_ADDRESS",
"LC_TELEPHONE",
"LC_MEASUREMENT",
"LC_IDENTIFICATION"
};
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
const char* const* const locale::_S_categories = __gnu_cxx::category_names;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
// XXX GLIBCXX_ABI Deprecated
#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
#pragma GCC diagnostic ignored "-Wattribute-alias"
#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
extern "C" void ldbl (void) __attribute__ ((alias (#dbl)))
_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

View File

@@ -0,0 +1,114 @@
// Wrapper for underlying C-language localization -*- C++ -*-
// Copyright (C) 2001-2021 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>
#ifndef _GLIBCXX_CXX_LOCALE_H
#define _GLIBCXX_CXX_LOCALE_H 1
#pragma GCC system_header
#include <clocale>
#define _GLIBCXX_C_LOCALE_GNU 1
#define _GLIBCXX_NUM_CATEGORIES 6
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
extern "C" __typeof(uselocale) __uselocale;
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef __locale_t __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 __attribute__ ((__unused__)),
char* __out,
const int __size __attribute__ ((__unused__)),
const char* __fmt, ...)
{
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __gnu_cxx::__uselocale(__cloc);
#else
char* __old = std::setlocale(LC_NUMERIC, 0);
char* __sav = 0;
if (__builtin_strcmp(__old, "C"))
{
const size_t __len = __builtin_strlen(__old) + 1;
__sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
std::setlocale(LC_NUMERIC, "C");
}
#endif
__builtin_va_list __args;
__builtin_va_start(__args, __fmt);
#if _GLIBCXX_USE_C99_STDIO
const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
#else
const int __ret = __builtin_vsprintf(__out, __fmt, __args);
#endif
__builtin_va_end(__args);
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__gnu_cxx::__uselocale(__old);
#else
if (__sav)
{
std::setlocale(LC_NUMERIC, __sav);
delete [] __sav;
}
#endif
return __ret;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif

View File

@@ -0,0 +1,307 @@
// std::codecvt implementation details, GNU version -*- C++ -*-
// Copyright (C) 2002-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.1.5 - Template class codecvt
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <cstdlib> // For MB_CUR_MAX
#include <climits> // For MB_LEN_MAX
#include <bits/c++locale_internal.h>
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);
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __uselocale(_M_c_locale_codecvt);
#endif
// 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;
}
}
}
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#endif
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);
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __uselocale(_M_c_locale_codecvt);
#endif
// 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;
}
}
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#endif
return __ret;
}
int
codecvt<wchar_t, char, mbstate_t>::
do_encoding() const throw()
{
// XXX This implementation assumes that the encoding is
// stateless and is either single-byte or variable-width.
int __ret = 0;
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __uselocale(_M_c_locale_codecvt);
#endif
if (MB_CUR_MAX == 1)
__ret = 1;
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#endif
return __ret;
}
int
codecvt<wchar_t, char, mbstate_t>::
do_max_length() const throw()
{
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __uselocale(_M_c_locale_codecvt);
#endif
// XXX Probably wrong for stateful encodings.
int __ret = MB_CUR_MAX;
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#endif
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);
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __uselocale(_M_c_locale_codecvt);
#endif
// 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;
}
}
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#endif
return __ret;
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,73 @@
// std::collate implementation details, GNU version -*- C++ -*-
// Copyright (C) 2001-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.4.1.2 collate virtual functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <bits/c++locale_internal.h>
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, _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, _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, _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, _M_c_locale_collate); }
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,306 @@
// std::ctype implementation details, GNU version -*- C++ -*-
// Copyright (C) 2001-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <cstdio>
#include <bits/c++locale_internal.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// NB: The other ctype<char> specializations are in src/locale.cc and
// various /config/os/* files.
ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
: ctype<char>(0, false, __refs)
{
if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_ctype);
this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
this->_M_toupper = this->_M_c_locale_ctype->__ctype_toupper;
this->_M_tolower = this->_M_c_locale_ctype->__ctype_tolower;
this->_M_table = this->_M_c_locale_ctype->__ctype_b;
}
}
ctype_byname<char>::~ctype_byname()
{ }
#ifdef _GLIBCXX_USE_WCHAR_T
ctype<wchar_t>::__wmask_type
ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const throw()
{
__wmask_type __ret;
switch (__m)
{
case space:
__ret = __wctype_l("space", _M_c_locale_ctype);
break;
case print:
__ret = __wctype_l("print", _M_c_locale_ctype);
break;
case cntrl:
__ret = __wctype_l("cntrl", _M_c_locale_ctype);
break;
case upper:
__ret = __wctype_l("upper", _M_c_locale_ctype);
break;
case lower:
__ret = __wctype_l("lower", _M_c_locale_ctype);
break;
case alpha:
__ret = __wctype_l("alpha", _M_c_locale_ctype);
break;
case digit:
__ret = __wctype_l("digit", _M_c_locale_ctype);
break;
case punct:
__ret = __wctype_l("punct", _M_c_locale_ctype);
break;
case xdigit:
__ret = __wctype_l("xdigit", _M_c_locale_ctype);
break;
case alnum:
__ret = __wctype_l("alnum", _M_c_locale_ctype);
break;
case graph:
__ret = __wctype_l("graph", _M_c_locale_ctype);
break;
case blank:
__ret = __wctype_l("blank", _M_c_locale_ctype);
break;
default:
__ret = __wmask_type();
}
return __ret;
}
wchar_t
ctype<wchar_t>::do_toupper(wchar_t __c) const
{ return __towupper_l(__c, _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_l(*__lo, _M_c_locale_ctype);
++__lo;
}
return __hi;
}
wchar_t
ctype<wchar_t>::do_tolower(wchar_t __c) const
{ return __towlower_l(__c, _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_l(*__lo, _M_c_locale_ctype);
++__lo;
}
return __hi;
}
bool
ctype<wchar_t>::
do_is(mask __m, wchar_t __c) const
{
// The case of __m == ctype_base::space is particularly important,
// due to its use in many istream functions. Therefore we deal with
// it first, exploiting the knowledge that on GNU systems _M_bit[5]
// is the mask corresponding to ctype_base::space. NB: an encoding
// change would not affect correctness!
bool __ret = false;
if (__m == _M_bit[5])
__ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype);
else
{
// Highest bitmask in ctype_base == 11
const size_t __bitmasksize = 11;
for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
if (__m & _M_bit[__bitcur])
{
if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
{
__ret = true;
break;
}
else if (__m == _M_bit[__bitcur])
break;
}
}
return __ret;
}
const wchar_t*
ctype<wchar_t>::
do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
{
for (; __lo < __hi; ++__vec, ++__lo)
{
// Highest bitmask in ctype_base == 11
const size_t __bitmasksize = 11;
mask __m = 0;
for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
if (__iswctype_l(*__lo, _M_wmask[__bitcur], _M_c_locale_ctype))
__m |= _M_bit[__bitcur];
*__vec = __m;
}
return __hi;
}
const wchar_t*
ctype<wchar_t>::
do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
{
while (__lo < __hi && !this->do_is(__m, *__lo))
++__lo;
return __lo;
}
const wchar_t*
ctype<wchar_t>::
do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
{
while (__lo < __hi && this->do_is(__m, *__lo) != 0)
++__lo;
return __lo;
}
wchar_t
ctype<wchar_t>::
do_widen(char __c) const
{ return _M_widen[static_cast<unsigned char>(__c)]; }
const char*
ctype<wchar_t>::
do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
{
while (__lo < __hi)
{
*__dest = _M_widen[static_cast<unsigned char>(*__lo)];
++__lo;
++__dest;
}
return __hi;
}
char
ctype<wchar_t>::
do_narrow(wchar_t __wc, char __dfault) const
{
if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
return _M_narrow[__wc];
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __uselocale(_M_c_locale_ctype);
#endif
const int __c = wctob(__wc);
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#endif
return (__c == EOF ? __dfault : static_cast<char>(__c));
}
const wchar_t*
ctype<wchar_t>::
do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
char* __dest) const
{
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __uselocale(_M_c_locale_ctype);
#endif
if (_M_narrow_ok)
while (__lo < __hi)
{
if (*__lo >= 0 && *__lo < 128)
*__dest = _M_narrow[*__lo];
else
{
const int __c = wctob(*__lo);
*__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
}
++__lo;
++__dest;
}
else
while (__lo < __hi)
{
const int __c = wctob(*__lo);
*__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
++__lo;
++__dest;
}
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#endif
return __hi;
}
void
ctype<wchar_t>::_M_initialize_ctype() throw()
{
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __uselocale(_M_c_locale_ctype);
#endif
wint_t __i;
for (__i = 0; __i < 128; ++__i)
{
const int __c = wctob(__i);
if (__c == EOF)
break;
else
_M_narrow[__i] = static_cast<char>(__c);
}
if (__i == 128)
_M_narrow_ok = true;
else
_M_narrow_ok = false;
for (size_t __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]);
}
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#endif
}
#endif // _GLIBCXX_USE_WCHAR_T
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,184 @@
// std::messages implementation details, GNU version -*- C++ -*-
// Copyright (C) 2001-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <bits/c++locale_internal.h>
#include <cstdlib> // std::free
#include <string.h> // ::strdup
namespace
{
using namespace std;
const char*
get_glibc_msg(__c_locale __locale_messages __attribute__((unused)),
const char* __name_messages __attribute__((unused)),
const char* __domainname,
const char* __dfault)
{
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
std::__c_locale __old = __uselocale(__locale_messages);
const char* __msg = dgettext(__domainname, __dfault);
__uselocale(__old);
return __msg;
#else
if (char* __sav = strdup(setlocale(LC_ALL, 0)))
{
setlocale(LC_ALL, __name_messages);
const char* __msg = dgettext(__domainname, __dfault);
setlocale(LC_ALL, __sav);
free(__sav);
return __msg;
}
return __dfault;
#endif
}
}
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Specializations.
template<>
typename messages<char>::catalog
messages<char>::do_open(const basic_string<char>& __s,
const locale& __l) const
{
typedef codecvt<char, char, mbstate_t> __codecvt_t;
const __codecvt_t& __codecvt = use_facet<__codecvt_t>(__l);
bind_textdomain_codeset(__s.c_str(),
__nl_langinfo_l(CODESET, __codecvt._M_c_locale_codecvt));
return get_catalogs()._M_add(__s.c_str(), __l);
}
template<>
void
messages<char>::do_close(catalog __c) const
{ get_catalogs()._M_erase(__c); }
template<>
string
messages<char>::do_get(catalog __c, int, int,
const string& __dfault) const
{
if (__c < 0 || __dfault.empty())
return __dfault;
const Catalog_info* __cat_info = get_catalogs()._M_get(__c);
if (!__cat_info)
return __dfault;
return get_glibc_msg(_M_c_locale_messages, _M_name_messages,
__cat_info->_M_domain,
__dfault.c_str());
}
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
typename messages<wchar_t>::catalog
messages<wchar_t>::do_open(const basic_string<char>& __s,
const locale& __l) const
{
typedef codecvt<wchar_t, char, mbstate_t> __codecvt_t;
const __codecvt_t& __codecvt = use_facet<__codecvt_t>(__l);
bind_textdomain_codeset(__s.c_str(),
__nl_langinfo_l(CODESET, __codecvt._M_c_locale_codecvt));
return get_catalogs()._M_add(__s.c_str(), __l);
}
template<>
void
messages<wchar_t>::do_close(catalog __c) const
{ get_catalogs()._M_erase(__c); }
template<>
wstring
messages<wchar_t>::do_get(catalog __c, int, int,
const wstring& __wdfault) const
{
if (__c < 0 || __wdfault.empty())
return __wdfault;
const Catalog_info* __cat_info = get_catalogs()._M_get(__c);
if (!__cat_info)
return __wdfault;
typedef codecvt<wchar_t, char, mbstate_t> __codecvt_t;
const __codecvt_t& __conv =
use_facet<__codecvt_t>(__cat_info->_M_locale);
const char* __translation;
mbstate_t __state;
__builtin_memset(&__state, 0, sizeof(mbstate_t));
{
const wchar_t* __wdfault_next;
size_t __mb_size = __wdfault.size() * __conv.max_length();
char* __dfault =
static_cast<char*>(__builtin_alloca(sizeof(char) * (__mb_size + 1)));
char* __dfault_next;
__conv.out(__state,
__wdfault.data(), __wdfault.data() + __wdfault.size(),
__wdfault_next,
__dfault, __dfault + __mb_size, __dfault_next);
// Make sure string passed to dgettext is \0 terminated.
*__dfault_next = '\0';
__translation = get_glibc_msg(_M_c_locale_messages, _M_name_messages,
__cat_info->_M_domain, __dfault);
// If we end up getting default value back we can simply return original
// default value.
if (__translation == __dfault)
return __wdfault;
}
__builtin_memset(&__state, 0, sizeof(mbstate_t));
size_t __size = __builtin_strlen(__translation);
const char* __translation_next;
wchar_t* __wtranslation =
static_cast<wchar_t*>(__builtin_alloca(sizeof(wchar_t) * (__size + 1)));
wchar_t* __wtranslation_next;
__conv.in(__state, __translation, __translation + __size,
__translation_next,
__wtranslation, __wtranslation + __size,
__wtranslation_next);
return wstring(__wtranslation, __wtranslation_next);
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,151 @@
// std::messages implementation details, GNU version -*- C++ -*-
// Copyright (C) 2001-2021 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/messages_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.7.1.2 messages functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <libintl.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Non-virtual member functions.
template<typename _CharT>
messages<_CharT>::messages(size_t __refs)
: facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
_M_name_messages(_S_get_c_name())
{ }
template<typename _CharT>
messages<_CharT>::messages(__c_locale __cloc, const char* __s,
size_t __refs)
: facet(__refs), _M_c_locale_messages(0), _M_name_messages(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_messages = __tmp;
}
else
_M_name_messages = _S_get_c_name();
// Last to avoid leaking memory if new throws.
_M_c_locale_messages = _S_clone_c_locale(__cloc);
}
template<typename _CharT>
typename messages<_CharT>::catalog
messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
const char* __dir) const
{
bindtextdomain(__s.c_str(), __dir);
return this->do_open(__s, __loc);
}
// Virtual member functions.
template<typename _CharT>
messages<_CharT>::~messages()
{
if (_M_name_messages != _S_get_c_name())
delete [] _M_name_messages;
_S_destroy_c_locale(_M_c_locale_messages);
}
template<typename _CharT>
typename messages<_CharT>::catalog
messages<_CharT>::do_open(const basic_string<char>& __s,
const locale&) const
{
// No error checking is done, assume the catalog exists and can
// be used.
textdomain(__s.c_str());
return 0;
}
template<typename _CharT>
void
messages<_CharT>::do_close(catalog) const
{ }
// messages_byname
template<typename _CharT>
messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
: messages<_CharT>(__refs)
{
if (this->_M_name_messages != locale::facet::_S_get_c_name())
{
delete [] this->_M_name_messages;
if (__builtin_strcmp(__s, locale::facet::_S_get_c_name()) != 0)
{
const size_t __len = __builtin_strlen(__s) + 1;
char* __tmp = new char[__len];
__builtin_memcpy(__tmp, __s, __len);
this->_M_name_messages = __tmp;
}
else
this->_M_name_messages = locale::facet::_S_get_c_name();
}
if (__builtin_strcmp(__s, "C") != 0
&& __builtin_strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_messages);
this->_S_create_c_locale(this->_M_c_locale_messages, __s);
}
}
//Specializations.
template<>
typename messages<char>::catalog
messages<char>::do_open(const basic_string<char>&,
const locale&) const;
template<>
void
messages<char>::do_close(catalog) const;
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
typename messages<wchar_t>::catalog
messages<wchar_t>::do_open(const basic_string<char>&,
const locale&) const;
template<>
void
messages<wchar_t>::do_close(catalog) const;
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,948 @@
// std::moneypunct implementation details, GNU version -*- C++ -*-
// Copyright (C) 2001-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <bits/c++locale_internal.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 monyepunct. 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
extern char __narrow_multibyte_chars(const char* s, __locale_t cloc);
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.
_M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
__cloc));
const char* thousands_sep = __nl_langinfo_l(__MON_THOUSANDS_SEP,
__cloc);
if (thousands_sep[0] != '\0' && thousands_sep[1] != '\0')
_M_data->_M_thousands_sep = __narrow_multibyte_chars(thousands_sep,
__cloc);
else
_M_data->_M_thousands_sep = *thousands_sep;
// Check for NULL, which implies no fractional digits.
if (_M_data->_M_decimal_point == '\0')
{
// Like in "C" locale.
_M_data->_M_frac_digits = 0;
_M_data->_M_decimal_point = '.';
}
else
_M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
__cloc));
const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
// _Intl == true
const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
char* __group = 0;
char* __ps = 0;
char* __ns = 0;
const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
__try
{
size_t __len;
// Check for NULL, which implies no grouping.
if (_M_data->_M_thousands_sep == '\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
{
__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 = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
_M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
__pposn);
char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
_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.
_M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
__cloc));
_M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
__cloc));
// Check for NULL, which implies no fractional digits.
if (_M_data->_M_decimal_point == '\0')
{
// Like in "C" locale.
_M_data->_M_frac_digits = 0;
_M_data->_M_decimal_point = '.';
}
else
_M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS,
__cloc));
const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
// _Intl == false
const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
char* __group = 0;
char* __ps = 0;
char* __ns = 0;
const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
__try
{
size_t __len;
// Check for NULL, which implies no grouping.
if (_M_data->_M_thousands_sep == '\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
{
__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 = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
_M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
__pposn);
char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
_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,
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
const char*)
#else
const char* __name)
#endif
{
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
{
// Named locale.
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __uselocale(__cloc);
#else
// Switch to named locale so that mbsrtowcs will work.
char* __old = setlocale(LC_ALL, 0);
const size_t __llen = strlen(__old) + 1;
char* __sav = new char[__llen];
memcpy(__sav, __old, __llen);
setlocale(LC_ALL, __name);
#endif
union { char *__s; wchar_t __w; } __u;
__u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
_M_data->_M_decimal_point = __u.__w;
__u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
_M_data->_M_thousands_sep = __u.__w;
// Check for NULL, which implies no fractional digits.
if (_M_data->_M_decimal_point == L'\0')
{
// Like in "C" locale.
_M_data->_M_frac_digits = 0;
_M_data->_M_decimal_point = L'.';
}
else
_M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
__cloc));
const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
char* __group = 0;
wchar_t* __wcs_ps = 0;
wchar_t* __wcs_ns = 0;
const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
__try
{
size_t __len;
// Check for NULL, which implies no grouping.
if (_M_data->_M_thousands_sep == L'\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
{
__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;
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#else
setlocale(LC_ALL, __sav);
delete [] __sav;
#endif
__throw_exception_again;
}
char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
_M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
__pposn);
char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
_M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
__nposn);
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#else
setlocale(LC_ALL, __sav);
delete [] __sav;
#endif
}
}
template<>
void
moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
const char*)
#else
const char* __name)
#endif
{
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
{
// Named locale.
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __uselocale(__cloc);
#else
// Switch to named locale so that mbsrtowcs will work.
char* __old = setlocale(LC_ALL, 0);
const size_t __llen = strlen(__old) + 1;
char* __sav = new char[__llen];
memcpy(__sav, __old, __llen);
setlocale(LC_ALL, __name);
#endif
union { char *__s; wchar_t __w; } __u;
__u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
_M_data->_M_decimal_point = __u.__w;
__u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
_M_data->_M_thousands_sep = __u.__w;
// Check for NULL, which implies no fractional digits.
if (_M_data->_M_decimal_point == L'\0')
{
// Like in "C" locale.
_M_data->_M_frac_digits = 0;
_M_data->_M_decimal_point = L'.';
}
else
_M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS,
__cloc));
const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc);
const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
char* __group = 0;
wchar_t* __wcs_ps = 0;
wchar_t* __wcs_ns = 0;
const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
__try
{
size_t __len;
// Check for NULL, which implies no grouping.
if (_M_data->_M_thousands_sep == L'\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
{
__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;
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#else
setlocale(LC_ALL, __sav);
delete [] __sav;
#endif
__throw_exception_again;
}
char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
_M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
__pposn);
char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
_M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
__nposn);
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#else
setlocale(LC_ALL, __sav);
delete [] __sav;
#endif
}
}
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

View File

@@ -0,0 +1,273 @@
// std::numpunct implementation details, GNU version -*- C++ -*-
// Copyright (C) 2001-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.3.1.2 numpunct virtual functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <bits/c++locale_internal.h>
#include <iconv.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
extern char __narrow_multibyte_chars(const char* s, __locale_t cloc);
// This file might be compiled twice, but we only want to define this once.
#if ! _GLIBCXX_USE_CXX11_ABI
char
__narrow_multibyte_chars(const char* s, __locale_t cloc)
{
const char* codeset = __nl_langinfo_l(CODESET, cloc);
if (!strcmp(codeset, "UTF-8"))
{
// optimize for some known cases
if (!strcmp(s, "\u202F")) // NARROW NO-BREAK SPACE
return ' ';
if (!strcmp(s, "\u2019")) // RIGHT SINGLE QUOTATION MARK
return '\'';
if (!strcmp(s, "\u066C")) // ARABIC THOUSANDS SEPARATOR
return '\'';
}
iconv_t cd = iconv_open("ASCII//TRANSLIT", codeset);
if (cd != (iconv_t)-1)
{
char c1;
size_t inbytesleft = strlen(s);
size_t outbytesleft = 1;
char* inbuf = const_cast<char*>(s);
char* outbuf = &c1;
size_t n = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
iconv_close(cd);
if (n != (size_t)-1)
{
cd = iconv_open(codeset, "ASCII");
if (cd != (iconv_t)-1)
{
char c2;
inbuf = &c1;
inbytesleft = 1;
outbuf = &c2;
outbytesleft = 1;
n = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
iconv_close(cd);
if (n != (size_t)-1)
return c2;
}
}
}
return '\0';
}
#endif
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.
_M_data->_M_decimal_point = *(__nl_langinfo_l(DECIMAL_POINT,
__cloc));
const char* thousands_sep = __nl_langinfo_l(THOUSANDS_SEP, __cloc);
if (thousands_sep[0] != '\0' && thousands_sep[1] != '\0')
_M_data->_M_thousands_sep = __narrow_multibyte_chars(thousands_sep,
__cloc);
else
_M_data->_M_thousands_sep = *thousands_sep;
// Check for NULL, which implies no grouping.
if (_M_data->_M_thousands_sep == '\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
{
const char* __src = __nl_langinfo_l(GROUPING, __cloc);
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 = "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.
// NB: In the GNU model wchar_t is always 32 bit wide.
union { char *__s; wchar_t __w; } __u;
__u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
_M_data->_M_decimal_point = __u.__w;
__u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
_M_data->_M_thousands_sep = __u.__w;
// Check for NULL, which implies no grouping.
if (_M_data->_M_thousands_sep == L'\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
{
const char* __src = __nl_langinfo_l(GROUPING, __cloc);
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

View File

@@ -0,0 +1,400 @@
// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
// Copyright (C) 2001-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include <bits/c++locale_internal.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()
{
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
_M_c_locale_timepunct);
#else
char* __old = setlocale(LC_ALL, 0);
const size_t __llen = strlen(__old) + 1;
char* __sav = new char[__llen];
memcpy(__sav, __old, __llen);
setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = strftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __sav);
delete [] __sav;
#endif
// 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, __cloc);
_M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc);
_M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc);
_M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc);
_M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc);
_M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT,
__cloc);
_M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc);
_M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc);
_M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc);
// Day names, starting with "C"'s Sunday.
_M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc);
_M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc);
_M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc);
_M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc);
_M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc);
_M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc);
_M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc);
// Abbreviated day names, starting with "C"'s Sun.
_M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc);
_M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc);
_M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc);
_M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc);
_M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc);
_M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc);
_M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc);
// Month names, starting with "C"'s January.
_M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc);
_M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc);
_M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc);
_M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc);
_M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc);
_M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc);
_M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc);
_M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc);
_M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc);
_M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc);
_M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc);
_M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc);
// Abbreviated month names, starting with "C"'s Jan.
_M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc);
_M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc);
_M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc);
_M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc);
_M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc);
_M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc);
_M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc);
_M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc);
_M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc);
_M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc);
_M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc);
_M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __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()
{
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
_M_c_locale_timepunct);
#else
char* __old = setlocale(LC_ALL, 0);
const size_t __llen = strlen(__old) + 1;
char* __sav = new char[__llen];
memcpy(__sav, __old, __llen);
setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __sav);
delete [] __sav;
#endif
// Make sure __s is null terminated.
if (__len == 0)
__s[0] = L'\0';
}
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
{
_M_c_locale_timepunct = _S_clone_c_locale(__cloc);
union { char *__s; wchar_t *__w; } __u;
__u.__s = __nl_langinfo_l(_NL_WD_FMT, __cloc);
_M_data->_M_date_format = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WERA_D_FMT, __cloc);
_M_data->_M_date_era_format = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WT_FMT, __cloc);
_M_data->_M_time_format = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WERA_T_FMT, __cloc);
_M_data->_M_time_era_format = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WD_T_FMT, __cloc);
_M_data->_M_date_time_format = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc);
_M_data->_M_date_time_era_format = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WAM_STR, __cloc);
_M_data->_M_am = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WPM_STR, __cloc);
_M_data->_M_pm = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc);
_M_data->_M_am_pm_format = __u.__w;
// Day names, starting with "C"'s Sunday.
__u.__s = __nl_langinfo_l(_NL_WDAY_1, __cloc);
_M_data->_M_day1 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WDAY_2, __cloc);
_M_data->_M_day2 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WDAY_3, __cloc);
_M_data->_M_day3 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WDAY_4, __cloc);
_M_data->_M_day4 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WDAY_5, __cloc);
_M_data->_M_day5 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WDAY_6, __cloc);
_M_data->_M_day6 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WDAY_7, __cloc);
_M_data->_M_day7 = __u.__w;
// Abbreviated day names, starting with "C"'s Sun.
__u.__s = __nl_langinfo_l(_NL_WABDAY_1, __cloc);
_M_data->_M_aday1 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABDAY_2, __cloc);
_M_data->_M_aday2 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABDAY_3, __cloc);
_M_data->_M_aday3 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABDAY_4, __cloc);
_M_data->_M_aday4 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABDAY_5, __cloc);
_M_data->_M_aday5 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABDAY_6, __cloc);
_M_data->_M_aday6 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABDAY_7, __cloc);
_M_data->_M_aday7 = __u.__w;
// Month names, starting with "C"'s January.
__u.__s = __nl_langinfo_l(_NL_WMON_1, __cloc);
_M_data->_M_month01 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WMON_2, __cloc);
_M_data->_M_month02 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WMON_3, __cloc);
_M_data->_M_month03 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WMON_4, __cloc);
_M_data->_M_month04 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WMON_5, __cloc);
_M_data->_M_month05 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WMON_6, __cloc);
_M_data->_M_month06 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WMON_7, __cloc);
_M_data->_M_month07 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WMON_8, __cloc);
_M_data->_M_month08 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WMON_9, __cloc);
_M_data->_M_month09 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WMON_10, __cloc);
_M_data->_M_month10 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WMON_11, __cloc);
_M_data->_M_month11 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WMON_12, __cloc);
_M_data->_M_month12 = __u.__w;
// Abbreviated month names, starting with "C"'s Jan.
__u.__s = __nl_langinfo_l(_NL_WABMON_1, __cloc);
_M_data->_M_amonth01 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABMON_2, __cloc);
_M_data->_M_amonth02 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABMON_3, __cloc);
_M_data->_M_amonth03 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABMON_4, __cloc);
_M_data->_M_amonth04 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABMON_5, __cloc);
_M_data->_M_amonth05 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABMON_6, __cloc);
_M_data->_M_amonth06 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABMON_7, __cloc);
_M_data->_M_amonth07 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABMON_8, __cloc);
_M_data->_M_amonth08 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABMON_9, __cloc);
_M_data->_M_amonth09 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABMON_10, __cloc);
_M_data->_M_amonth10 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABMON_11, __cloc);
_M_data->_M_amonth11 = __u.__w;
__u.__s = __nl_langinfo_l(_NL_WABMON_12, __cloc);
_M_data->_M_amonth12 = __u.__w;
}
}
#endif
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,89 @@
// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
// Copyright (C) 2001-2021 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>
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);
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@@ -0,0 +1,107 @@
// Wrapper for underlying C-language localization -*- C++ -*-
// Copyright (C) 2001-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 22.8 Standard locale categories.
//
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
namespace std _GLIBCXX_VISIBILITY(default)
{
void
locale::facet::_S_create_c_locale(__c_locale&, const char*, __c_locale*)
{ }
void
locale::facet::_S_destroy_c_locale(__c_locale&)
{ }
__c_locale
locale::facet::_S_clone_c_locale(__c_locale&) throw()
{ return __c_locale(); }
template<>
void
numpunct<char>::_M_initialize_numpunct(__c_locale)
{
// "C" locale
_M_decimal_point = '.';
_M_thousands_sep = ',';
_M_grouping = "";
_M_truename = "true";
_M_falsename = "false";
}
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
void
numpunct<wchar_t>::_M_initialize_numpunct(__c_locale)
{
// "C" locale
_M_decimal_point = L'.';
_M_thousands_sep = L',';
_M_grouping = "";
_M_truename = L"true";
_M_falsename = L"false";
}
#endif
template<>
void
moneypunct<char>::_M_initialize_moneypunct(__c_locale)
{
// "C" locale
_M_decimal_point = '.';
_M_thousands_sep = ',';
_M_grouping = "";
_M_curr_symbol = string_type();
_M_positive_sign = string_type();
_M_negative_sign = string_type();
_M_frac_digits = 0;
_M_pos_format = money_base::_S_default_pattern;
_M_neg_format = money_base::_S_default_pattern;
}
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
void
moneypunct<wchar_t>::_M_initialize_moneypunct(__c_locale)
{
// "C" locale
_M_decimal_point = L'.';
_M_thousands_sep = L',';
_M_grouping = "";
_M_curr_symbol = string_type();
_M_positive_sign = string_type();
_M_negative_sign = string_type();
_M_frac_digits = 0;
_M_pos_format = money_base::_S_default_pattern;
_M_neg_format = money_base::_S_default_pattern;
}
#endif
} // namespace std

Some files were not shown because too many files have changed in this diff Show More