]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/src/c++11/compatibility-ldbl-alt128-cxx11.cc
888eb112125578be1d284e8263c232d927e23606
[thirdparty/gcc.git] / libstdc++-v3 / src / c++11 / compatibility-ldbl-alt128-cxx11.cc
1 // Compatibility symbols for alternate 128-bit long-double format -*- C++ -*-
2
3 // Copyright (C) 2018-2023 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24
25 #define _GLIBCXX_USE_CXX11_ABI 1
26 #include <locale>
27
28 #ifdef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
29
30 #if !defined(_GLIBCXX_USE_DUAL_ABI)
31 #error "compatibility-ldbl-alt128-cxx11.cc must only be compiled when dual ABI is enabled"
32 #endif
33
34 #if ! defined __LONG_DOUBLE_IBM128__ && ! defined __LONG_DOUBLE_IEEE128__
35 #error "compatibility-ldbl-alt128.cc must only be compiled for 128-bit long double"
36 #endif
37
38 #define C char
39 #define C_is_char
40 #include "locale-inst-monetary.h"
41
42 #ifdef _GLIBCXX_USE_WCHAR_T
43 # undef C
44 # undef C_is_char
45 # define C wchar_t
46 # include "locale-inst-monetary.h"
47 #endif
48
49 #include <functional>
50 namespace std _GLIBCXX_VISIBILITY(default)
51 {
52 _GLIBCXX_BEGIN_NAMESPACE_VERSION
53
54 namespace
55 {
56 alignas(money_get<char>) char money_get_c[sizeof(money_get<char>)];
57 alignas(money_put<char>) char money_put_c[sizeof(money_put<char>)];
58 #ifdef _GLIBCXX_USE_WCHAR_T
59 alignas(money_get<wchar_t>) char money_get_w[sizeof(money_get<wchar_t>)];
60 alignas(money_put<wchar_t>) char money_put_w[sizeof(money_put<wchar_t>)];
61 #endif
62
63 template<typename Facet>
64 void
65 init_facet(function<void(const locale::id*, const locale::facet*)>& func,
66 Facet* facet)
67 {
68 func(&Facet::id, facet);
69 }
70
71 } // namespace
72
73 template class function<void(const locale::id*, const locale::facet*)>;
74
75 void
76 __locale_Impl_init_extra_ldbl128(
77 function<void(const locale::id*, const locale::facet*)> f,
78 bool classic)
79 {
80 if (classic)
81 {
82 init_facet(f, new (&money_get_c) money_get<char>(1));
83 init_facet(f, new (&money_put_c) money_put<char>(1));
84 #ifdef _GLIBCXX_USE_WCHAR_T
85 init_facet(f, new (&money_get_w) money_get<wchar_t>(1));
86 init_facet(f, new (&money_put_w) money_put<wchar_t>(1));
87 #endif
88 }
89 else
90 {
91 init_facet(f, new money_get<char>);
92 init_facet(f, new money_put<char>);
93 #ifdef _GLIBCXX_USE_WCHAR_T
94 init_facet(f, new money_get<wchar_t>);
95 init_facet(f, new money_put<wchar_t>);
96 #endif
97 }
98 }
99
100 _GLIBCXX_END_NAMESPACE_VERSION
101 } // namespace
102 #endif