]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/src/compatibility.cc
Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
[thirdparty/gcc.git] / libstdc++-v3 / src / compatibility.cc
CommitLineData
bb2b2a24
BK
1// Compatibility symbols for previous versions -*- C++ -*-
2
bc2631e0 3// Copyright (C) 2005, 2006, 2007, 2008, 2009
bb2b2a24
BK
4// Free Software Foundation, Inc.
5//
6// This file is part of the GNU ISO C++ Library. This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
748086b7 9// Free Software Foundation; either version 3, or (at your option)
bb2b2a24
BK
10// any later version.
11
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16
748086b7
JJ
17// Under Section 7 of GPL version 3, you are granted additional
18// permissions described in the GCC Runtime Library Exception, version
19// 3.1, as published by the Free Software Foundation.
bb2b2a24 20
748086b7
JJ
21// You should have received a copy of the GNU General Public License and
22// a copy of the GCC Runtime Library Exception along with this program;
23// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24// <http://www.gnu.org/licenses/>.
bb2b2a24
BK
25
26#include <bits/c++config.h>
27
1f93f687
JJ
28#if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC) \
29 && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE)
462ec415
JJ
30#define istreambuf_iterator istreambuf_iteratorXX
31#define basic_fstream basic_fstreamXX
32#define basic_ifstream basic_ifstreamXX
33#define basic_ofstream basic_ofstreamXX
34#define _M_copy(a, b, c) _M_copyXX(a, b, c)
35#define _M_move(a, b, c) _M_moveXX(a, b, c)
36#define _M_assign(a, b, c) _M_assignXX(a, b, c)
37#define _M_disjunct(a) _M_disjunctXX(a)
38#define _M_check_length(a, b, c) _M_check_lengthXX(a, b, c)
39#define _M_set_length_and_sharable(a) _M_set_length_and_sharableXX(a)
40#define ignore ignoreXX
41#define eq eqXX
3cbc7af0 42#define _List_node_base _List_node_baseXX
bb2b2a24
BK
43#endif
44
45#include <string>
46#include <istream>
47#include <fstream>
48#include <sstream>
6defecc2 49#include <cmath>
6725add5 50#include <ext/numeric_traits.h>
bb2b2a24 51
3cbc7af0 52_GLIBCXX_BEGIN_NAMESPACE(std)
bb2b2a24 53
3cbc7af0 54 // std::istream ignore explicit specializations.
bb2b2a24
BK
55 template<>
56 basic_istream<char>&
57 basic_istream<char>::
58 ignore(streamsize __n)
59 {
60 if (__n == 1)
61 return ignore();
62
63 _M_gcount = 0;
64 sentry __cerb(*this, true);
65 if (__cerb && __n > 0)
66 {
67 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
bc2631e0 68 __try
bb2b2a24
BK
69 {
70 const int_type __eof = traits_type::eof();
71 __streambuf_type* __sb = this->rdbuf();
72 int_type __c = __sb->sgetc();
73
74 // See comment in istream.tcc.
75 bool __large_ignore = false;
76 while (true)
77 {
78 while (_M_gcount < __n
79 && !traits_type::eq_int_type(__c, __eof))
80 {
81 streamsize __size = std::min(streamsize(__sb->egptr()
82 - __sb->gptr()),
3cbc7af0 83 streamsize(__n - _M_gcount));
bb2b2a24
BK
84 if (__size > 1)
85 {
86 __sb->gbump(__size);
87 _M_gcount += __size;
88 __c = __sb->sgetc();
89 }
90 else
91 {
92 ++_M_gcount;
93 __c = __sb->snextc();
94 }
95 }
6725add5 96 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
bb2b2a24
BK
97 && !traits_type::eq_int_type(__c, __eof))
98 {
6725add5
PC
99 _M_gcount =
100 __gnu_cxx::__numeric_traits<streamsize>::__min;
bb2b2a24
BK
101 __large_ignore = true;
102 }
103 else
104 break;
105 }
106
107 if (__large_ignore)
6725add5 108 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
bb2b2a24
BK
109
110 if (traits_type::eq_int_type(__c, __eof))
111 __err |= ios_base::eofbit;
112 }
bc2631e0 113 __catch(__cxxabiv1::__forced_unwind&)
d05f74f1
JM
114 {
115 this->_M_setstate(ios_base::badbit);
116 __throw_exception_again;
117 }
bc2631e0 118 __catch(...)
bb2b2a24
BK
119 { this->_M_setstate(ios_base::badbit); }
120 if (__err)
121 this->setstate(__err);
122 }
123 return *this;
124 }
125
126#ifdef _GLIBCXX_USE_WCHAR_T
127 template<>
128 basic_istream<wchar_t>&
129 basic_istream<wchar_t>::
130 ignore(streamsize __n)
131 {
132 if (__n == 1)
133 return ignore();
134
135 _M_gcount = 0;
136 sentry __cerb(*this, true);
137 if (__cerb && __n > 0)
138 {
139 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
bc2631e0 140 __try
bb2b2a24
BK
141 {
142 const int_type __eof = traits_type::eof();
143 __streambuf_type* __sb = this->rdbuf();
144 int_type __c = __sb->sgetc();
145
146 bool __large_ignore = false;
147 while (true)
148 {
149 while (_M_gcount < __n
150 && !traits_type::eq_int_type(__c, __eof))
151 {
152 streamsize __size = std::min(streamsize(__sb->egptr()
153 - __sb->gptr()),
3cbc7af0 154 streamsize(__n - _M_gcount));
bb2b2a24
BK
155 if (__size > 1)
156 {
157 __sb->gbump(__size);
158 _M_gcount += __size;
159 __c = __sb->sgetc();
160 }
161 else
162 {
163 ++_M_gcount;
164 __c = __sb->snextc();
165 }
166 }
6725add5 167 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
bb2b2a24
BK
168 && !traits_type::eq_int_type(__c, __eof))
169 {
6725add5
PC
170 _M_gcount =
171 __gnu_cxx::__numeric_traits<streamsize>::__min;
bb2b2a24
BK
172 __large_ignore = true;
173 }
174 else
175 break;
176 }
177
178 if (__large_ignore)
6725add5 179 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
bb2b2a24
BK
180
181 if (traits_type::eq_int_type(__c, __eof))
182 __err |= ios_base::eofbit;
183 }
bc2631e0 184 __catch(__cxxabiv1::__forced_unwind&)
d05f74f1
JM
185 {
186 this->_M_setstate(ios_base::badbit);
187 __throw_exception_again;
188 }
bc2631e0 189 __catch(...)
bb2b2a24
BK
190 { this->_M_setstate(ios_base::badbit); }
191 if (__err)
192 this->setstate(__err);
193 }
194 return *this;
195 }
196#endif
3cbc7af0
BK
197
198_GLIBCXX_END_NAMESPACE
199
bb2b2a24
BK
200
201// NB: These symbols renames should go into the shared library only,
202// and only those shared libraries that support versioning.
1f93f687
JJ
203#if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC) \
204 && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE)
bb2b2a24
BK
205
206/* gcc-3.4.4
207_ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv
208_ZNSt19istreambuf_iteratorIwSt11char_traitsIwEEppEv
209 */
3cbc7af0
BK
210
211_GLIBCXX_BEGIN_NAMESPACE(std)
212
bb2b2a24
BK
213 template
214 istreambuf_iterator<char>&
215 istreambuf_iterator<char>::operator++();
216
217#ifdef _GLIBCXX_USE_WCHAR_T
218 template
219 istreambuf_iterator<wchar_t>&
220 istreambuf_iterator<wchar_t>::operator++();
221#endif
3cbc7af0
BK
222
223_GLIBCXX_END_NAMESPACE
224
bb2b2a24
BK
225
226/* gcc-4.0.0
227_ZNSs4_Rep26_M_set_length_and_sharableEj
228_ZNSs7_M_copyEPcPKcj
229_ZNSs7_M_moveEPcPKcj
230_ZNSs9_M_assignEPcjc
231_ZNKSs11_M_disjunctEPKc
232_ZNKSs15_M_check_lengthEjjPKc
233_ZNSbIwSt11char_traitsIwESaIwEE4_Rep26_M_set_length_and_sharableEj
234_ZNSbIwSt11char_traitsIwESaIwEE7_M_copyEPwPKwj
235_ZNSbIwSt11char_traitsIwESaIwEE7_M_moveEPwPKwj
236_ZNSbIwSt11char_traitsIwESaIwEE9_M_assignEPwjw
237_ZNKSbIwSt11char_traitsIwESaIwEE11_M_disjunctEPKw
238_ZNKSbIwSt11char_traitsIwESaIwEE15_M_check_lengthEjjPKc
239
240_ZNKSt13basic_fstreamIcSt11char_traitsIcEE7is_openEv
241_ZNKSt13basic_fstreamIwSt11char_traitsIwEE7is_openEv
242_ZNKSt14basic_ifstreamIcSt11char_traitsIcEE7is_openEv
243_ZNKSt14basic_ifstreamIwSt11char_traitsIwEE7is_openEv
244_ZNKSt14basic_ofstreamIcSt11char_traitsIcEE7is_openEv
245_ZNKSt14basic_ofstreamIwSt11char_traitsIwEE7is_openEv
246
247_ZNSi6ignoreEi
248_ZNSi6ignoreEv
249_ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEi
250_ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEv
251
252_ZNSt11char_traitsIcE2eqERKcS2_
253_ZNSt11char_traitsIwE2eqERKwS2_
254 */
3cbc7af0
BK
255_GLIBCXX_BEGIN_NAMESPACE(std)
256
bb2b2a24
BK
257 // std::char_traits is explicitly specialized
258 bool (* __p1)(const char&, const char&) = &char_traits<char>::eq;
259
260 // std::string
261 template
262 void
263 basic_string<char>::_M_copy(char*, const char*, size_t);
264
265 template
266 void
267 basic_string<char>::_M_move(char*, const char*, size_t);
268
269 template
270 void
271 basic_string<char>::_M_assign(char*, size_t, char);
272
273 template
274 bool
275 basic_string<char>::_M_disjunct(const char*) const;
276
277 template
278 void
279 basic_string<char>::_M_check_length(size_t, size_t, const char*) const;
280
281 template
282 void
283 basic_string<char>::_Rep::_M_set_length_and_sharable(size_t);
284
285
286 // std::istream
287 template
288 basic_istream<char>&
289 basic_istream<char>::ignore();
290
291 template
292 bool
293 basic_fstream<char>::is_open() const;
294
295 template
296 bool
297 basic_ifstream<char>::is_open() const;
298
299 template
300 bool
301 basic_ofstream<char>::is_open() const;
302
303#ifdef _GLIBCXX_USE_WCHAR_T
304 bool (* __p2)(const wchar_t&, const wchar_t&) = &char_traits<wchar_t>::eq;
305
306 // std::wstring
307 template
308 void
309 basic_string<wchar_t>::_M_copy(wchar_t*, const wchar_t*, size_t);
310
311 template
312 void
313 basic_string<wchar_t>::_M_move(wchar_t*, const wchar_t*, size_t);
314
315 template
316 void
317 basic_string<wchar_t>::_M_assign(wchar_t*, size_t, wchar_t);
318
319 template
320 bool
321 basic_string<wchar_t>::_M_disjunct(const wchar_t*) const;
322
323 template
324 void
325 basic_string<wchar_t>::_M_check_length(size_t, size_t,
326 const char*) const;
327
328 template
329 void
330 basic_string<wchar_t>::_Rep::_M_set_length_and_sharable(size_t);
331
332 template
333 basic_istream<wchar_t>&
334 basic_istream<wchar_t>::ignore();
335
336 template
337 bool
338 basic_fstream<wchar_t>::is_open() const;
339
340 template
341 bool
342 basic_ifstream<wchar_t>::is_open() const;
343
344 template
345 bool
346 basic_ofstream<wchar_t>::is_open() const;
347#endif
3cbc7af0
BK
348
349_GLIBCXX_END_NAMESPACE
bb2b2a24
BK
350
351// The rename syntax for default exported names is
352// asm (".symver name1,exportedname@GLIBCXX_3.4")
353// asm (".symver name2,exportedname@@GLIBCXX_3.4.5")
354// In the future, GLIBCXX_ABI > 6 should remove all uses of
355// _GLIBCXX_*_SYMVER macros in this file.
356
462ec415 357#define _GLIBCXX_3_4_SYMVER(XXname, name) \
bb2b2a24
BK
358 extern "C" void \
359 _X##name() \
462ec415 360 __attribute__ ((alias(#XXname))); \
bb2b2a24
BK
361 asm (".symver " "_X" #name "," #name "@GLIBCXX_3.4");
362
462ec415 363#define _GLIBCXX_3_4_5_SYMVER(XXname, name) \
bb2b2a24
BK
364 extern "C" void \
365 _Y##name() \
462ec415 366 __attribute__ ((alias(#XXname))); \
bb2b2a24
BK
367 asm (".symver " "_Y" #name "," #name "@@GLIBCXX_3.4.5");
368
369#define _GLIBCXX_ASM_SYMVER(cur, old, version) \
370 asm (".symver " #cur "," #old "@@" #version);
371
372#define _GLIBCXX_APPLY_SYMVER _GLIBCXX_3_4_SYMVER
bb2b2a24
BK
373#include <bits/compatibility.h>
374#undef _GLIBCXX_APPLY_SYMVER
bb2b2a24
BK
375
376#define _GLIBCXX_APPLY_SYMVER _GLIBCXX_3_4_5_SYMVER
bb2b2a24
BK
377#include <bits/compatibility.h>
378#undef _GLIBCXX_APPLY_SYMVER
bb2b2a24 379
45f388bb 380
3cbc7af0
BK
381/* gcc-3.4.0
382_ZN10__gnu_norm15_List_node_base4hookEPS0_;
383_ZN10__gnu_norm15_List_node_base4swapERS0_S1_;
384_ZN10__gnu_norm15_List_node_base6unhookEv;
385_ZN10__gnu_norm15_List_node_base7reverseEv;
386_ZN10__gnu_norm15_List_node_base8transferEPS0_S1_;
3cbc7af0 387*/
45f388bb 388#include "list.cc"
3cbc7af0
BK
389_GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX4hookEPS_, \
390_ZN10__gnu_norm15_List_node_base4hookEPS0_, \
391GLIBCXX_3.4)
392
393_GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX4swapERS_S0_, \
394_ZN10__gnu_norm15_List_node_base4swapERS0_S1_, \
395GLIBCXX_3.4)
396
397_GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX6unhookEv, \
398_ZN10__gnu_norm15_List_node_base6unhookEv, \
399GLIBCXX_3.4)
400
401_GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX7reverseEv, \
402_ZN10__gnu_norm15_List_node_base7reverseEv, \
403GLIBCXX_3.4)
404
405_GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX8transferEPS_S0_, \
406_ZN10__gnu_norm15_List_node_base8transferEPS0_S1_, \
407GLIBCXX_3.4)
45f388bb 408#undef _List_node_base
3cbc7af0 409
6defecc2 410// gcc-4.1.0
adc8a1e3
BK
411// Long double versions of "C" math functions.
412#if defined (_GLIBCXX_LONG_DOUBLE_COMPAT) \
413 || (defined (__hppa__) && defined (__linux__))
414
6defecc2
JJ
415#define _GLIBCXX_MATHL_WRAPPER(name, argdecl, args, ver) \
416extern "C" double \
417__ ## name ## l_wrapper argdecl \
418{ \
419 return name args; \
420} \
421asm (".symver __" #name "l_wrapper, " #name "l@" #ver)
3cbc7af0 422
6defecc2
JJ
423#define _GLIBCXX_MATHL_WRAPPER1(name, ver) \
424 _GLIBCXX_MATHL_WRAPPER (name, (double x), (x), ver)
425
426#define _GLIBCXX_MATHL_WRAPPER2(name, ver) \
427 _GLIBCXX_MATHL_WRAPPER (name, (double x, double y), (x, y), ver)
428
429#ifdef _GLIBCXX_HAVE_ACOSL
430_GLIBCXX_MATHL_WRAPPER1 (acos, GLIBCXX_3.4.3);
431#endif
432#ifdef _GLIBCXX_HAVE_ASINL
433_GLIBCXX_MATHL_WRAPPER1 (asin, GLIBCXX_3.4.3);
434#endif
435#ifdef _GLIBCXX_HAVE_ATAN2L
436_GLIBCXX_MATHL_WRAPPER2 (atan2, GLIBCXX_3.4);
437#endif
438#ifdef _GLIBCXX_HAVE_ATANL
439_GLIBCXX_MATHL_WRAPPER1 (atan, GLIBCXX_3.4.3);
440#endif
441#ifdef _GLIBCXX_HAVE_CEILL
442_GLIBCXX_MATHL_WRAPPER1 (ceil, GLIBCXX_3.4.3);
443#endif
444#ifdef _GLIBCXX_HAVE_COSHL
445_GLIBCXX_MATHL_WRAPPER1 (cosh, GLIBCXX_3.4);
446#endif
447#ifdef _GLIBCXX_HAVE_COSL
448_GLIBCXX_MATHL_WRAPPER1 (cos, GLIBCXX_3.4);
449#endif
450#ifdef _GLIBCXX_HAVE_EXPL
451_GLIBCXX_MATHL_WRAPPER1 (exp, GLIBCXX_3.4);
452#endif
453#ifdef _GLIBCXX_HAVE_FLOORL
454_GLIBCXX_MATHL_WRAPPER1 (floor, GLIBCXX_3.4.3);
455#endif
456#ifdef _GLIBCXX_HAVE_FMODL
457_GLIBCXX_MATHL_WRAPPER2 (fmod, GLIBCXX_3.4.3);
458#endif
459#ifdef _GLIBCXX_HAVE_FREXPL
460_GLIBCXX_MATHL_WRAPPER (frexp, (double x, int *y), (x, y), GLIBCXX_3.4.3);
461#endif
462#ifdef _GLIBCXX_HAVE_HYPOTL
463_GLIBCXX_MATHL_WRAPPER2 (hypot, GLIBCXX_3.4);
464#endif
465#ifdef _GLIBCXX_HAVE_LDEXPL
466_GLIBCXX_MATHL_WRAPPER (ldexp, (double x, int y), (x, y), GLIBCXX_3.4.3);
bb2b2a24 467#endif
6defecc2
JJ
468#ifdef _GLIBCXX_HAVE_LOG10L
469_GLIBCXX_MATHL_WRAPPER1 (log10, GLIBCXX_3.4);
470#endif
471#ifdef _GLIBCXX_HAVE_LOGL
472_GLIBCXX_MATHL_WRAPPER1 (log, GLIBCXX_3.4);
473#endif
474#ifdef _GLIBCXX_HAVE_MODFL
475_GLIBCXX_MATHL_WRAPPER (modf, (double x, double *y), (x, y), GLIBCXX_3.4.3);
476#endif
477#ifdef _GLIBCXX_HAVE_POWL
478_GLIBCXX_MATHL_WRAPPER2 (pow, GLIBCXX_3.4);
479#endif
480#ifdef _GLIBCXX_HAVE_SINHL
481_GLIBCXX_MATHL_WRAPPER1 (sinh, GLIBCXX_3.4);
482#endif
483#ifdef _GLIBCXX_HAVE_SINL
484_GLIBCXX_MATHL_WRAPPER1 (sin, GLIBCXX_3.4);
485#endif
486#ifdef _GLIBCXX_HAVE_SQRTL
487_GLIBCXX_MATHL_WRAPPER1 (sqrt, GLIBCXX_3.4);
488#endif
489#ifdef _GLIBCXX_HAVE_TANHL
490_GLIBCXX_MATHL_WRAPPER1 (tanh, GLIBCXX_3.4);
491#endif
492#ifdef _GLIBCXX_HAVE_TANL
493_GLIBCXX_MATHL_WRAPPER1 (tan, GLIBCXX_3.4);
494#endif
495#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
496
497#endif
498
499#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
500extern void *_ZTVN10__cxxabiv123__fundamental_type_infoE[];
501extern void *_ZTVN10__cxxabiv119__pointer_type_infoE[];
502extern __attribute__((used, weak)) const char _ZTSe[2] = "e";
503extern __attribute__((used, weak)) const char _ZTSPe[3] = "Pe";
504extern __attribute__((used, weak)) const char _ZTSPKe[4] = "PKe";
505extern __attribute__((used, weak)) const void *_ZTIe[2]
506 = { (void *) &_ZTVN10__cxxabiv123__fundamental_type_infoE[2],
507 (void *) _ZTSe };
508extern __attribute__((used, weak)) const void *_ZTIPe[4]
509 = { (void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2],
510 (void *) _ZTSPe, (void *) 0L, (void *) _ZTIe };
511extern __attribute__((used, weak)) const void *_ZTIPKe[4]
512 = { (void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2],
513 (void *) _ZTSPKe, (void *) 1L, (void *) _ZTIe };
514#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
515
516
f9314d01 517
fb5c309d 518#ifdef _GLIBCXX_SYMVER_DARWIN
6defecc2 519#if (defined(__ppc__) || defined(__ppc64__)) && defined(PIC)
f9314d01
GK
520/* __eprintf shouldn't have been made visible from libstdc++, or
521 anywhere, but on Mac OS X 10.4 it was defined in
522 libstdc++.6.0.3.dylib; so on that platform we have to keep defining
523 it to keep binary compatibility. We can't just put the libgcc
524 version in the export list, because that doesn't work; once a
525 symbol is marked as hidden, it stays that way. */
526
527#include <cstdio>
528#include <cstdlib>
529
530using namespace std;
531
532extern "C" void
3cbc7af0
BK
533__eprintf(const char *string, const char *expression,
534 unsigned int line, const char *filename)
f9314d01 535{
3cbc7af0
BK
536 fprintf(stderr, string, expression, line, filename);
537 fflush(stderr);
538 abort();
f9314d01
GK
539}
540#endif
fb5c309d 541#endif