]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/src/compatibility.cc
re PR other/28145 (C++ (throw() and catch(...) {/* fall through */ } ) and pthread...
[thirdparty/gcc.git] / libstdc++-v3 / src / compatibility.cc
1 // Compatibility symbols for previous versions -*- C++ -*-
2
3 // Copyright (C) 2005, 2006
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
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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
33 #if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC)
34 #define istreambuf_iterator istreambuf_iteratorXX
35 #define basic_fstream basic_fstreamXX
36 #define basic_ifstream basic_ifstreamXX
37 #define basic_ofstream basic_ofstreamXX
38 #define _M_copy(a, b, c) _M_copyXX(a, b, c)
39 #define _M_move(a, b, c) _M_moveXX(a, b, c)
40 #define _M_assign(a, b, c) _M_assignXX(a, b, c)
41 #define _M_disjunct(a) _M_disjunctXX(a)
42 #define _M_check_length(a, b, c) _M_check_lengthXX(a, b, c)
43 #define _M_set_length_and_sharable(a) _M_set_length_and_sharableXX(a)
44 #define ignore ignoreXX
45 #define eq eqXX
46 #define _List_node_base _List_node_baseXX
47 #endif
48
49 #include <string>
50 #include <istream>
51 #include <fstream>
52 #include <sstream>
53 #include <cmath>
54 #include <ext/numeric_traits.h>
55
56 _GLIBCXX_BEGIN_NAMESPACE(std)
57
58 // std::istream ignore explicit specializations.
59 template<>
60 basic_istream<char>&
61 basic_istream<char>::
62 ignore(streamsize __n)
63 {
64 if (__n == 1)
65 return ignore();
66
67 _M_gcount = 0;
68 sentry __cerb(*this, true);
69 if (__cerb && __n > 0)
70 {
71 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
72 try
73 {
74 const int_type __eof = traits_type::eof();
75 __streambuf_type* __sb = this->rdbuf();
76 int_type __c = __sb->sgetc();
77
78 // See comment in istream.tcc.
79 bool __large_ignore = false;
80 while (true)
81 {
82 while (_M_gcount < __n
83 && !traits_type::eq_int_type(__c, __eof))
84 {
85 streamsize __size = std::min(streamsize(__sb->egptr()
86 - __sb->gptr()),
87 streamsize(__n - _M_gcount));
88 if (__size > 1)
89 {
90 __sb->gbump(__size);
91 _M_gcount += __size;
92 __c = __sb->sgetc();
93 }
94 else
95 {
96 ++_M_gcount;
97 __c = __sb->snextc();
98 }
99 }
100 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
101 && !traits_type::eq_int_type(__c, __eof))
102 {
103 _M_gcount =
104 __gnu_cxx::__numeric_traits<streamsize>::__min;
105 __large_ignore = true;
106 }
107 else
108 break;
109 }
110
111 if (__large_ignore)
112 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
113
114 if (traits_type::eq_int_type(__c, __eof))
115 __err |= ios_base::eofbit;
116 }
117 catch(__cxxabiv1::__forced_unwind&)
118 {
119 this->_M_setstate(ios_base::badbit);
120 __throw_exception_again;
121 }
122 catch(...)
123 { this->_M_setstate(ios_base::badbit); }
124 if (__err)
125 this->setstate(__err);
126 }
127 return *this;
128 }
129
130 #ifdef _GLIBCXX_USE_WCHAR_T
131 template<>
132 basic_istream<wchar_t>&
133 basic_istream<wchar_t>::
134 ignore(streamsize __n)
135 {
136 if (__n == 1)
137 return ignore();
138
139 _M_gcount = 0;
140 sentry __cerb(*this, true);
141 if (__cerb && __n > 0)
142 {
143 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
144 try
145 {
146 const int_type __eof = traits_type::eof();
147 __streambuf_type* __sb = this->rdbuf();
148 int_type __c = __sb->sgetc();
149
150 bool __large_ignore = false;
151 while (true)
152 {
153 while (_M_gcount < __n
154 && !traits_type::eq_int_type(__c, __eof))
155 {
156 streamsize __size = std::min(streamsize(__sb->egptr()
157 - __sb->gptr()),
158 streamsize(__n - _M_gcount));
159 if (__size > 1)
160 {
161 __sb->gbump(__size);
162 _M_gcount += __size;
163 __c = __sb->sgetc();
164 }
165 else
166 {
167 ++_M_gcount;
168 __c = __sb->snextc();
169 }
170 }
171 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
172 && !traits_type::eq_int_type(__c, __eof))
173 {
174 _M_gcount =
175 __gnu_cxx::__numeric_traits<streamsize>::__min;
176 __large_ignore = true;
177 }
178 else
179 break;
180 }
181
182 if (__large_ignore)
183 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
184
185 if (traits_type::eq_int_type(__c, __eof))
186 __err |= ios_base::eofbit;
187 }
188 catch(__cxxabiv1::__forced_unwind&)
189 {
190 this->_M_setstate(ios_base::badbit);
191 __throw_exception_again;
192 }
193 catch(...)
194 { this->_M_setstate(ios_base::badbit); }
195 if (__err)
196 this->setstate(__err);
197 }
198 return *this;
199 }
200 #endif
201
202 _GLIBCXX_END_NAMESPACE
203
204
205 // NB: These symbols renames should go into the shared library only,
206 // and only those shared libraries that support versioning.
207 #if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC)
208
209 /* gcc-3.4.4
210 _ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv
211 _ZNSt19istreambuf_iteratorIwSt11char_traitsIwEEppEv
212 */
213
214 _GLIBCXX_BEGIN_NAMESPACE(std)
215
216 template
217 istreambuf_iterator<char>&
218 istreambuf_iterator<char>::operator++();
219
220 #ifdef _GLIBCXX_USE_WCHAR_T
221 template
222 istreambuf_iterator<wchar_t>&
223 istreambuf_iterator<wchar_t>::operator++();
224 #endif
225
226 _GLIBCXX_END_NAMESPACE
227
228
229 /* gcc-4.0.0
230 _ZNSs4_Rep26_M_set_length_and_sharableEj
231 _ZNSs7_M_copyEPcPKcj
232 _ZNSs7_M_moveEPcPKcj
233 _ZNSs9_M_assignEPcjc
234 _ZNKSs11_M_disjunctEPKc
235 _ZNKSs15_M_check_lengthEjjPKc
236 _ZNSbIwSt11char_traitsIwESaIwEE4_Rep26_M_set_length_and_sharableEj
237 _ZNSbIwSt11char_traitsIwESaIwEE7_M_copyEPwPKwj
238 _ZNSbIwSt11char_traitsIwESaIwEE7_M_moveEPwPKwj
239 _ZNSbIwSt11char_traitsIwESaIwEE9_M_assignEPwjw
240 _ZNKSbIwSt11char_traitsIwESaIwEE11_M_disjunctEPKw
241 _ZNKSbIwSt11char_traitsIwESaIwEE15_M_check_lengthEjjPKc
242
243 _ZNKSt13basic_fstreamIcSt11char_traitsIcEE7is_openEv
244 _ZNKSt13basic_fstreamIwSt11char_traitsIwEE7is_openEv
245 _ZNKSt14basic_ifstreamIcSt11char_traitsIcEE7is_openEv
246 _ZNKSt14basic_ifstreamIwSt11char_traitsIwEE7is_openEv
247 _ZNKSt14basic_ofstreamIcSt11char_traitsIcEE7is_openEv
248 _ZNKSt14basic_ofstreamIwSt11char_traitsIwEE7is_openEv
249
250 _ZNSi6ignoreEi
251 _ZNSi6ignoreEv
252 _ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEi
253 _ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEv
254
255 _ZNSt11char_traitsIcE2eqERKcS2_
256 _ZNSt11char_traitsIwE2eqERKwS2_
257 */
258 _GLIBCXX_BEGIN_NAMESPACE(std)
259
260 // std::char_traits is explicitly specialized
261 bool (* __p1)(const char&, const char&) = &char_traits<char>::eq;
262
263 // std::string
264 template
265 void
266 basic_string<char>::_M_copy(char*, const char*, size_t);
267
268 template
269 void
270 basic_string<char>::_M_move(char*, const char*, size_t);
271
272 template
273 void
274 basic_string<char>::_M_assign(char*, size_t, char);
275
276 template
277 bool
278 basic_string<char>::_M_disjunct(const char*) const;
279
280 template
281 void
282 basic_string<char>::_M_check_length(size_t, size_t, const char*) const;
283
284 template
285 void
286 basic_string<char>::_Rep::_M_set_length_and_sharable(size_t);
287
288
289 // std::istream
290 template
291 basic_istream<char>&
292 basic_istream<char>::ignore();
293
294 template
295 bool
296 basic_fstream<char>::is_open() const;
297
298 template
299 bool
300 basic_ifstream<char>::is_open() const;
301
302 template
303 bool
304 basic_ofstream<char>::is_open() const;
305
306 #ifdef _GLIBCXX_USE_WCHAR_T
307 bool (* __p2)(const wchar_t&, const wchar_t&) = &char_traits<wchar_t>::eq;
308
309 // std::wstring
310 template
311 void
312 basic_string<wchar_t>::_M_copy(wchar_t*, const wchar_t*, size_t);
313
314 template
315 void
316 basic_string<wchar_t>::_M_move(wchar_t*, const wchar_t*, size_t);
317
318 template
319 void
320 basic_string<wchar_t>::_M_assign(wchar_t*, size_t, wchar_t);
321
322 template
323 bool
324 basic_string<wchar_t>::_M_disjunct(const wchar_t*) const;
325
326 template
327 void
328 basic_string<wchar_t>::_M_check_length(size_t, size_t,
329 const char*) const;
330
331 template
332 void
333 basic_string<wchar_t>::_Rep::_M_set_length_and_sharable(size_t);
334
335 template
336 basic_istream<wchar_t>&
337 basic_istream<wchar_t>::ignore();
338
339 template
340 bool
341 basic_fstream<wchar_t>::is_open() const;
342
343 template
344 bool
345 basic_ifstream<wchar_t>::is_open() const;
346
347 template
348 bool
349 basic_ofstream<wchar_t>::is_open() const;
350 #endif
351
352 _GLIBCXX_END_NAMESPACE
353
354 // The rename syntax for default exported names is
355 // asm (".symver name1,exportedname@GLIBCXX_3.4")
356 // asm (".symver name2,exportedname@@GLIBCXX_3.4.5")
357 // In the future, GLIBCXX_ABI > 6 should remove all uses of
358 // _GLIBCXX_*_SYMVER macros in this file.
359
360 #define _GLIBCXX_3_4_SYMVER(XXname, name) \
361 extern "C" void \
362 _X##name() \
363 __attribute__ ((alias(#XXname))); \
364 asm (".symver " "_X" #name "," #name "@GLIBCXX_3.4");
365
366 #define _GLIBCXX_3_4_5_SYMVER(XXname, name) \
367 extern "C" void \
368 _Y##name() \
369 __attribute__ ((alias(#XXname))); \
370 asm (".symver " "_Y" #name "," #name "@@GLIBCXX_3.4.5");
371
372 #define _GLIBCXX_ASM_SYMVER(cur, old, version) \
373 asm (".symver " #cur "," #old "@@" #version);
374
375 #define _GLIBCXX_APPLY_SYMVER _GLIBCXX_3_4_SYMVER
376 #include <bits/compatibility.h>
377 #undef _GLIBCXX_APPLY_SYMVER
378
379 #define _GLIBCXX_APPLY_SYMVER _GLIBCXX_3_4_5_SYMVER
380 #include <bits/compatibility.h>
381 #undef _GLIBCXX_APPLY_SYMVER
382
383
384 /* gcc-3.4.0
385 _ZN10__gnu_norm15_List_node_base4hookEPS0_;
386 _ZN10__gnu_norm15_List_node_base4swapERS0_S1_;
387 _ZN10__gnu_norm15_List_node_base6unhookEv;
388 _ZN10__gnu_norm15_List_node_base7reverseEv;
389 _ZN10__gnu_norm15_List_node_base8transferEPS0_S1_;
390 */
391 #include "list.cc"
392 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX4hookEPS_, \
393 _ZN10__gnu_norm15_List_node_base4hookEPS0_, \
394 GLIBCXX_3.4)
395
396 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX4swapERS_S0_, \
397 _ZN10__gnu_norm15_List_node_base4swapERS0_S1_, \
398 GLIBCXX_3.4)
399
400 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX6unhookEv, \
401 _ZN10__gnu_norm15_List_node_base6unhookEv, \
402 GLIBCXX_3.4)
403
404 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX7reverseEv, \
405 _ZN10__gnu_norm15_List_node_base7reverseEv, \
406 GLIBCXX_3.4)
407
408 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX8transferEPS_S0_, \
409 _ZN10__gnu_norm15_List_node_base8transferEPS0_S1_, \
410 GLIBCXX_3.4)
411 #undef _List_node_base
412
413 // gcc-4.1.0
414 #ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
415 #define _GLIBCXX_MATHL_WRAPPER(name, argdecl, args, ver) \
416 extern "C" double \
417 __ ## name ## l_wrapper argdecl \
418 { \
419 return name args; \
420 } \
421 asm (".symver __" #name "l_wrapper, " #name "l@" #ver)
422
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);
467 #endif
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
500 extern void *_ZTVN10__cxxabiv123__fundamental_type_infoE[];
501 extern void *_ZTVN10__cxxabiv119__pointer_type_infoE[];
502 extern __attribute__((used, weak)) const char _ZTSe[2] = "e";
503 extern __attribute__((used, weak)) const char _ZTSPe[3] = "Pe";
504 extern __attribute__((used, weak)) const char _ZTSPKe[4] = "PKe";
505 extern __attribute__((used, weak)) const void *_ZTIe[2]
506 = { (void *) &_ZTVN10__cxxabiv123__fundamental_type_infoE[2],
507 (void *) _ZTSe };
508 extern __attribute__((used, weak)) const void *_ZTIPe[4]
509 = { (void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2],
510 (void *) _ZTSPe, (void *) 0L, (void *) _ZTIe };
511 extern __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
517
518 #ifdef _GLIBCXX_SYMVER_DARWIN
519 #if (defined(__ppc__) || defined(__ppc64__)) && defined(PIC)
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
530 using namespace std;
531
532 extern "C" void
533 __eprintf(const char *string, const char *expression,
534 unsigned int line, const char *filename)
535 {
536 fprintf(stderr, string, expression, line, filename);
537 fflush(stderr);
538 abort();
539 }
540 #endif
541 #endif