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