* config/xtensa/lib1funcs.asm (__umodsi3, __modsi3): Rearrange so that
[official-gcc.git] / libstdc++-v3 / src / compatibility.cc
blob83b20b967063769cfdb1b37f518b36f431193c43
1 // Compatibility symbols for previous versions -*- C++ -*-
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.
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.
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.
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.
31 #include <bits/c++config.h>
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
49 #include <string>
50 #include <istream>
51 #include <fstream>
52 #include <sstream>
53 #include <cmath>
54 #include <ext/numeric_traits.h>
56 _GLIBCXX_BEGIN_NAMESPACE(std)
58 // std::istream ignore explicit specializations.
59 template<>
60 basic_istream<char>&
61 basic_istream<char>::
62 ignore(streamsize __n)
64 if (__n == 1)
65 return ignore();
67 _M_gcount = 0;
68 sentry __cerb(*this, true);
69 if (__cerb && __n > 0)
71 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
72 try
74 const int_type __eof = traits_type::eof();
75 __streambuf_type* __sb = this->rdbuf();
76 int_type __c = __sb->sgetc();
78 // See comment in istream.tcc.
79 bool __large_ignore = false;
80 while (true)
82 while (_M_gcount < __n
83 && !traits_type::eq_int_type(__c, __eof))
85 streamsize __size = std::min(streamsize(__sb->egptr()
86 - __sb->gptr()),
87 streamsize(__n - _M_gcount));
88 if (__size > 1)
90 __sb->gbump(__size);
91 _M_gcount += __size;
92 __c = __sb->sgetc();
94 else
96 ++_M_gcount;
97 __c = __sb->snextc();
100 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
101 && !traits_type::eq_int_type(__c, __eof))
103 _M_gcount =
104 __gnu_cxx::__numeric_traits<streamsize>::__min;
105 __large_ignore = true;
107 else
108 break;
111 if (__large_ignore)
112 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
114 if (traits_type::eq_int_type(__c, __eof))
115 __err |= ios_base::eofbit;
117 catch(...)
118 { this->_M_setstate(ios_base::badbit); }
119 if (__err)
120 this->setstate(__err);
122 return *this;
125 #ifdef _GLIBCXX_USE_WCHAR_T
126 template<>
127 basic_istream<wchar_t>&
128 basic_istream<wchar_t>::
129 ignore(streamsize __n)
131 if (__n == 1)
132 return ignore();
134 _M_gcount = 0;
135 sentry __cerb(*this, true);
136 if (__cerb && __n > 0)
138 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
141 const int_type __eof = traits_type::eof();
142 __streambuf_type* __sb = this->rdbuf();
143 int_type __c = __sb->sgetc();
145 bool __large_ignore = false;
146 while (true)
148 while (_M_gcount < __n
149 && !traits_type::eq_int_type(__c, __eof))
151 streamsize __size = std::min(streamsize(__sb->egptr()
152 - __sb->gptr()),
153 streamsize(__n - _M_gcount));
154 if (__size > 1)
156 __sb->gbump(__size);
157 _M_gcount += __size;
158 __c = __sb->sgetc();
160 else
162 ++_M_gcount;
163 __c = __sb->snextc();
166 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
167 && !traits_type::eq_int_type(__c, __eof))
169 _M_gcount =
170 __gnu_cxx::__numeric_traits<streamsize>::__min;
171 __large_ignore = true;
173 else
174 break;
177 if (__large_ignore)
178 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
180 if (traits_type::eq_int_type(__c, __eof))
181 __err |= ios_base::eofbit;
183 catch(...)
184 { this->_M_setstate(ios_base::badbit); }
185 if (__err)
186 this->setstate(__err);
188 return *this;
190 #endif
192 _GLIBCXX_END_NAMESPACE
195 // NB: These symbols renames should go into the shared library only,
196 // and only those shared libraries that support versioning.
197 #if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC)
199 /* gcc-3.4.4
200 _ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv
201 _ZNSt19istreambuf_iteratorIwSt11char_traitsIwEEppEv
204 _GLIBCXX_BEGIN_NAMESPACE(std)
206 template
207 istreambuf_iterator<char>&
208 istreambuf_iterator<char>::operator++();
210 #ifdef _GLIBCXX_USE_WCHAR_T
211 template
212 istreambuf_iterator<wchar_t>&
213 istreambuf_iterator<wchar_t>::operator++();
214 #endif
216 _GLIBCXX_END_NAMESPACE
219 /* gcc-4.0.0
220 _ZNSs4_Rep26_M_set_length_and_sharableEj
221 _ZNSs7_M_copyEPcPKcj
222 _ZNSs7_M_moveEPcPKcj
223 _ZNSs9_M_assignEPcjc
224 _ZNKSs11_M_disjunctEPKc
225 _ZNKSs15_M_check_lengthEjjPKc
226 _ZNSbIwSt11char_traitsIwESaIwEE4_Rep26_M_set_length_and_sharableEj
227 _ZNSbIwSt11char_traitsIwESaIwEE7_M_copyEPwPKwj
228 _ZNSbIwSt11char_traitsIwESaIwEE7_M_moveEPwPKwj
229 _ZNSbIwSt11char_traitsIwESaIwEE9_M_assignEPwjw
230 _ZNKSbIwSt11char_traitsIwESaIwEE11_M_disjunctEPKw
231 _ZNKSbIwSt11char_traitsIwESaIwEE15_M_check_lengthEjjPKc
233 _ZNKSt13basic_fstreamIcSt11char_traitsIcEE7is_openEv
234 _ZNKSt13basic_fstreamIwSt11char_traitsIwEE7is_openEv
235 _ZNKSt14basic_ifstreamIcSt11char_traitsIcEE7is_openEv
236 _ZNKSt14basic_ifstreamIwSt11char_traitsIwEE7is_openEv
237 _ZNKSt14basic_ofstreamIcSt11char_traitsIcEE7is_openEv
238 _ZNKSt14basic_ofstreamIwSt11char_traitsIwEE7is_openEv
240 _ZNSi6ignoreEi
241 _ZNSi6ignoreEv
242 _ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEi
243 _ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEv
245 _ZNSt11char_traitsIcE2eqERKcS2_
246 _ZNSt11char_traitsIwE2eqERKwS2_
248 _GLIBCXX_BEGIN_NAMESPACE(std)
250 // std::char_traits is explicitly specialized
251 bool (* __p1)(const char&, const char&) = &char_traits<char>::eq;
253 // std::string
254 template
255 void
256 basic_string<char>::_M_copy(char*, const char*, size_t);
258 template
259 void
260 basic_string<char>::_M_move(char*, const char*, size_t);
262 template
263 void
264 basic_string<char>::_M_assign(char*, size_t, char);
266 template
267 bool
268 basic_string<char>::_M_disjunct(const char*) const;
270 template
271 void
272 basic_string<char>::_M_check_length(size_t, size_t, const char*) const;
274 template
275 void
276 basic_string<char>::_Rep::_M_set_length_and_sharable(size_t);
279 // std::istream
280 template
281 basic_istream<char>&
282 basic_istream<char>::ignore();
284 template
285 bool
286 basic_fstream<char>::is_open() const;
288 template
289 bool
290 basic_ifstream<char>::is_open() const;
292 template
293 bool
294 basic_ofstream<char>::is_open() const;
296 #ifdef _GLIBCXX_USE_WCHAR_T
297 bool (* __p2)(const wchar_t&, const wchar_t&) = &char_traits<wchar_t>::eq;
299 // std::wstring
300 template
301 void
302 basic_string<wchar_t>::_M_copy(wchar_t*, const wchar_t*, size_t);
304 template
305 void
306 basic_string<wchar_t>::_M_move(wchar_t*, const wchar_t*, size_t);
308 template
309 void
310 basic_string<wchar_t>::_M_assign(wchar_t*, size_t, wchar_t);
312 template
313 bool
314 basic_string<wchar_t>::_M_disjunct(const wchar_t*) const;
316 template
317 void
318 basic_string<wchar_t>::_M_check_length(size_t, size_t,
319 const char*) const;
321 template
322 void
323 basic_string<wchar_t>::_Rep::_M_set_length_and_sharable(size_t);
325 template
326 basic_istream<wchar_t>&
327 basic_istream<wchar_t>::ignore();
329 template
330 bool
331 basic_fstream<wchar_t>::is_open() const;
333 template
334 bool
335 basic_ifstream<wchar_t>::is_open() const;
337 template
338 bool
339 basic_ofstream<wchar_t>::is_open() const;
340 #endif
342 _GLIBCXX_END_NAMESPACE
344 // The rename syntax for default exported names is
345 // asm (".symver name1,exportedname@GLIBCXX_3.4")
346 // asm (".symver name2,exportedname@@GLIBCXX_3.4.5")
347 // In the future, GLIBCXX_ABI > 6 should remove all uses of
348 // _GLIBCXX_*_SYMVER macros in this file.
350 #define _GLIBCXX_3_4_SYMVER(XXname, name) \
351 extern "C" void \
352 _X##name() \
353 __attribute__ ((alias(#XXname))); \
354 asm (".symver " "_X" #name "," #name "@GLIBCXX_3.4");
356 #define _GLIBCXX_3_4_5_SYMVER(XXname, name) \
357 extern "C" void \
358 _Y##name() \
359 __attribute__ ((alias(#XXname))); \
360 asm (".symver " "_Y" #name "," #name "@@GLIBCXX_3.4.5");
362 #define _GLIBCXX_ASM_SYMVER(cur, old, version) \
363 asm (".symver " #cur "," #old "@@" #version);
365 #define _GLIBCXX_APPLY_SYMVER _GLIBCXX_3_4_SYMVER
366 #include <bits/compatibility.h>
367 #undef _GLIBCXX_APPLY_SYMVER
369 #define _GLIBCXX_APPLY_SYMVER _GLIBCXX_3_4_5_SYMVER
370 #include <bits/compatibility.h>
371 #undef _GLIBCXX_APPLY_SYMVER
374 /* gcc-3.4.0
375 _ZN10__gnu_norm15_List_node_base4hookEPS0_;
376 _ZN10__gnu_norm15_List_node_base4swapERS0_S1_;
377 _ZN10__gnu_norm15_List_node_base6unhookEv;
378 _ZN10__gnu_norm15_List_node_base7reverseEv;
379 _ZN10__gnu_norm15_List_node_base8transferEPS0_S1_;
381 #include "list.cc"
382 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX4hookEPS_, \
383 _ZN10__gnu_norm15_List_node_base4hookEPS0_, \
384 GLIBCXX_3.4)
386 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX4swapERS_S0_, \
387 _ZN10__gnu_norm15_List_node_base4swapERS0_S1_, \
388 GLIBCXX_3.4)
390 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX6unhookEv, \
391 _ZN10__gnu_norm15_List_node_base6unhookEv, \
392 GLIBCXX_3.4)
394 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX7reverseEv, \
395 _ZN10__gnu_norm15_List_node_base7reverseEv, \
396 GLIBCXX_3.4)
398 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX8transferEPS_S0_, \
399 _ZN10__gnu_norm15_List_node_base8transferEPS0_S1_, \
400 GLIBCXX_3.4)
401 #undef _List_node_base
403 // gcc-4.1.0
404 #ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
405 #define _GLIBCXX_MATHL_WRAPPER(name, argdecl, args, ver) \
406 extern "C" double \
407 __ ## name ## l_wrapper argdecl \
409 return name args; \
411 asm (".symver __" #name "l_wrapper, " #name "l@" #ver)
413 #define _GLIBCXX_MATHL_WRAPPER1(name, ver) \
414 _GLIBCXX_MATHL_WRAPPER (name, (double x), (x), ver)
416 #define _GLIBCXX_MATHL_WRAPPER2(name, ver) \
417 _GLIBCXX_MATHL_WRAPPER (name, (double x, double y), (x, y), ver)
419 #ifdef _GLIBCXX_HAVE_ACOSL
420 _GLIBCXX_MATHL_WRAPPER1 (acos, GLIBCXX_3.4.3);
421 #endif
422 #ifdef _GLIBCXX_HAVE_ASINL
423 _GLIBCXX_MATHL_WRAPPER1 (asin, GLIBCXX_3.4.3);
424 #endif
425 #ifdef _GLIBCXX_HAVE_ATAN2L
426 _GLIBCXX_MATHL_WRAPPER2 (atan2, GLIBCXX_3.4);
427 #endif
428 #ifdef _GLIBCXX_HAVE_ATANL
429 _GLIBCXX_MATHL_WRAPPER1 (atan, GLIBCXX_3.4.3);
430 #endif
431 #ifdef _GLIBCXX_HAVE_CEILL
432 _GLIBCXX_MATHL_WRAPPER1 (ceil, GLIBCXX_3.4.3);
433 #endif
434 #ifdef _GLIBCXX_HAVE_COSHL
435 _GLIBCXX_MATHL_WRAPPER1 (cosh, GLIBCXX_3.4);
436 #endif
437 #ifdef _GLIBCXX_HAVE_COSL
438 _GLIBCXX_MATHL_WRAPPER1 (cos, GLIBCXX_3.4);
439 #endif
440 #ifdef _GLIBCXX_HAVE_EXPL
441 _GLIBCXX_MATHL_WRAPPER1 (exp, GLIBCXX_3.4);
442 #endif
443 #ifdef _GLIBCXX_HAVE_FLOORL
444 _GLIBCXX_MATHL_WRAPPER1 (floor, GLIBCXX_3.4.3);
445 #endif
446 #ifdef _GLIBCXX_HAVE_FMODL
447 _GLIBCXX_MATHL_WRAPPER2 (fmod, GLIBCXX_3.4.3);
448 #endif
449 #ifdef _GLIBCXX_HAVE_FREXPL
450 _GLIBCXX_MATHL_WRAPPER (frexp, (double x, int *y), (x, y), GLIBCXX_3.4.3);
451 #endif
452 #ifdef _GLIBCXX_HAVE_HYPOTL
453 _GLIBCXX_MATHL_WRAPPER2 (hypot, GLIBCXX_3.4);
454 #endif
455 #ifdef _GLIBCXX_HAVE_LDEXPL
456 _GLIBCXX_MATHL_WRAPPER (ldexp, (double x, int y), (x, y), GLIBCXX_3.4.3);
457 #endif
458 #ifdef _GLIBCXX_HAVE_LOG10L
459 _GLIBCXX_MATHL_WRAPPER1 (log10, GLIBCXX_3.4);
460 #endif
461 #ifdef _GLIBCXX_HAVE_LOGL
462 _GLIBCXX_MATHL_WRAPPER1 (log, GLIBCXX_3.4);
463 #endif
464 #ifdef _GLIBCXX_HAVE_MODFL
465 _GLIBCXX_MATHL_WRAPPER (modf, (double x, double *y), (x, y), GLIBCXX_3.4.3);
466 #endif
467 #ifdef _GLIBCXX_HAVE_POWL
468 _GLIBCXX_MATHL_WRAPPER2 (pow, GLIBCXX_3.4);
469 #endif
470 #ifdef _GLIBCXX_HAVE_SINHL
471 _GLIBCXX_MATHL_WRAPPER1 (sinh, GLIBCXX_3.4);
472 #endif
473 #ifdef _GLIBCXX_HAVE_SINL
474 _GLIBCXX_MATHL_WRAPPER1 (sin, GLIBCXX_3.4);
475 #endif
476 #ifdef _GLIBCXX_HAVE_SQRTL
477 _GLIBCXX_MATHL_WRAPPER1 (sqrt, GLIBCXX_3.4);
478 #endif
479 #ifdef _GLIBCXX_HAVE_TANHL
480 _GLIBCXX_MATHL_WRAPPER1 (tanh, GLIBCXX_3.4);
481 #endif
482 #ifdef _GLIBCXX_HAVE_TANL
483 _GLIBCXX_MATHL_WRAPPER1 (tan, GLIBCXX_3.4);
484 #endif
485 #endif // _GLIBCXX_LONG_DOUBLE_COMPAT
487 #endif
489 #ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
490 extern void *_ZTVN10__cxxabiv123__fundamental_type_infoE[];
491 extern void *_ZTVN10__cxxabiv119__pointer_type_infoE[];
492 extern __attribute__((used, weak)) const char _ZTSe[2] = "e";
493 extern __attribute__((used, weak)) const char _ZTSPe[3] = "Pe";
494 extern __attribute__((used, weak)) const char _ZTSPKe[4] = "PKe";
495 extern __attribute__((used, weak)) const void *_ZTIe[2]
496 = { (void *) &_ZTVN10__cxxabiv123__fundamental_type_infoE[2],
497 (void *) _ZTSe };
498 extern __attribute__((used, weak)) const void *_ZTIPe[4]
499 = { (void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2],
500 (void *) _ZTSPe, (void *) 0L, (void *) _ZTIe };
501 extern __attribute__((used, weak)) const void *_ZTIPKe[4]
502 = { (void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2],
503 (void *) _ZTSPKe, (void *) 1L, (void *) _ZTIe };
504 #endif // _GLIBCXX_LONG_DOUBLE_COMPAT
508 #ifdef _GLIBCXX_SYMVER_DARWIN
509 #if (defined(__ppc__) || defined(__ppc64__)) && defined(PIC)
510 /* __eprintf shouldn't have been made visible from libstdc++, or
511 anywhere, but on Mac OS X 10.4 it was defined in
512 libstdc++.6.0.3.dylib; so on that platform we have to keep defining
513 it to keep binary compatibility. We can't just put the libgcc
514 version in the export list, because that doesn't work; once a
515 symbol is marked as hidden, it stays that way. */
517 #include <cstdio>
518 #include <cstdlib>
520 using namespace std;
522 extern "C" void
523 __eprintf(const char *string, const char *expression,
524 unsigned int line, const char *filename)
526 fprintf(stderr, string, expression, line, filename);
527 fflush(stderr);
528 abort();
530 #endif
531 #endif