Remove outermost loop parameter.
[official-gcc/graphite-test-results.git] / libstdc++-v3 / src / compatibility.cc
blobdceebe1174ca540cfbb79824b98bf790db9378c5
1 // Compatibility symbols for previous versions -*- C++ -*-
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
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 3, 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 // 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.
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/>.
26 #include <bits/c++config.h>
28 #if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC) \
29 && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE)
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
42 #define _List_node_base _List_node_baseXX
43 #endif
45 #include <string>
46 #include <istream>
47 #include <fstream>
48 #include <sstream>
49 #include <cmath>
50 #include <ext/numeric_traits.h>
52 _GLIBCXX_BEGIN_NAMESPACE(std)
54 // std::istream ignore explicit specializations.
55 template<>
56 basic_istream<char>&
57 basic_istream<char>::
58 ignore(streamsize __n)
60 if (__n == 1)
61 return ignore();
63 _M_gcount = 0;
64 sentry __cerb(*this, true);
65 if ( __n > 0 && __cerb)
67 ios_base::iostate __err = ios_base::goodbit;
68 __try
70 const int_type __eof = traits_type::eof();
71 __streambuf_type* __sb = this->rdbuf();
72 int_type __c = __sb->sgetc();
74 // See comment in istream.tcc.
75 bool __large_ignore = false;
76 while (true)
78 while (_M_gcount < __n
79 && !traits_type::eq_int_type(__c, __eof))
81 streamsize __size = std::min(streamsize(__sb->egptr()
82 - __sb->gptr()),
83 streamsize(__n - _M_gcount));
84 if (__size > 1)
86 __sb->gbump(__size);
87 _M_gcount += __size;
88 __c = __sb->sgetc();
90 else
92 ++_M_gcount;
93 __c = __sb->snextc();
96 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
97 && !traits_type::eq_int_type(__c, __eof))
99 _M_gcount =
100 __gnu_cxx::__numeric_traits<streamsize>::__min;
101 __large_ignore = true;
103 else
104 break;
107 if (__large_ignore)
108 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
110 if (traits_type::eq_int_type(__c, __eof))
111 __err |= ios_base::eofbit;
113 __catch(__cxxabiv1::__forced_unwind&)
115 this->_M_setstate(ios_base::badbit);
116 __throw_exception_again;
118 __catch(...)
119 { this->_M_setstate(ios_base::badbit); }
120 if (__err)
121 this->setstate(__err);
123 return *this;
126 #ifdef _GLIBCXX_USE_WCHAR_T
127 template<>
128 basic_istream<wchar_t>&
129 basic_istream<wchar_t>::
130 ignore(streamsize __n)
132 if (__n == 1)
133 return ignore();
135 _M_gcount = 0;
136 sentry __cerb(*this, true);
137 if (__n > 0 && __cerb)
139 ios_base::iostate __err = ios_base::goodbit;
140 __try
142 const int_type __eof = traits_type::eof();
143 __streambuf_type* __sb = this->rdbuf();
144 int_type __c = __sb->sgetc();
146 bool __large_ignore = false;
147 while (true)
149 while (_M_gcount < __n
150 && !traits_type::eq_int_type(__c, __eof))
152 streamsize __size = std::min(streamsize(__sb->egptr()
153 - __sb->gptr()),
154 streamsize(__n - _M_gcount));
155 if (__size > 1)
157 __sb->gbump(__size);
158 _M_gcount += __size;
159 __c = __sb->sgetc();
161 else
163 ++_M_gcount;
164 __c = __sb->snextc();
167 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
168 && !traits_type::eq_int_type(__c, __eof))
170 _M_gcount =
171 __gnu_cxx::__numeric_traits<streamsize>::__min;
172 __large_ignore = true;
174 else
175 break;
178 if (__large_ignore)
179 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
181 if (traits_type::eq_int_type(__c, __eof))
182 __err |= ios_base::eofbit;
184 __catch(__cxxabiv1::__forced_unwind&)
186 this->_M_setstate(ios_base::badbit);
187 __throw_exception_again;
189 __catch(...)
190 { this->_M_setstate(ios_base::badbit); }
191 if (__err)
192 this->setstate(__err);
194 return *this;
196 #endif
198 _GLIBCXX_END_NAMESPACE
201 // NB: These symbols renames should go into the shared library only,
202 // and only those shared libraries that support versioning.
203 #if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC) \
204 && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE)
206 /* gcc-3.4.4
207 _ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv
208 _ZNSt19istreambuf_iteratorIwSt11char_traitsIwEEppEv
211 _GLIBCXX_BEGIN_NAMESPACE(std)
213 template
214 istreambuf_iterator<char>&
215 istreambuf_iterator<char>::operator++();
217 #ifdef _GLIBCXX_USE_WCHAR_T
218 template
219 istreambuf_iterator<wchar_t>&
220 istreambuf_iterator<wchar_t>::operator++();
221 #endif
223 _GLIBCXX_END_NAMESPACE
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
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
247 _ZNSi6ignoreEi
248 _ZNSi6ignoreEv
249 _ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEi
250 _ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEv
252 _ZNSt11char_traitsIcE2eqERKcS2_
253 _ZNSt11char_traitsIwE2eqERKwS2_
255 _GLIBCXX_BEGIN_NAMESPACE(std)
257 // std::char_traits is explicitly specialized
258 bool (* __p1)(const char&, const char&) = &char_traits<char>::eq;
260 // std::string
261 template
262 void
263 basic_string<char>::_M_copy(char*, const char*, size_t);
265 template
266 void
267 basic_string<char>::_M_move(char*, const char*, size_t);
269 template
270 void
271 basic_string<char>::_M_assign(char*, size_t, char);
273 template
274 bool
275 basic_string<char>::_M_disjunct(const char*) const;
277 template
278 void
279 basic_string<char>::_M_check_length(size_t, size_t, const char*) const;
281 template
282 void
283 basic_string<char>::_Rep::_M_set_length_and_sharable(size_t);
286 // std::istream
287 template
288 basic_istream<char>&
289 basic_istream<char>::ignore();
291 template
292 bool
293 basic_fstream<char>::is_open() const;
295 template
296 bool
297 basic_ifstream<char>::is_open() const;
299 template
300 bool
301 basic_ofstream<char>::is_open() const;
303 #ifdef _GLIBCXX_USE_WCHAR_T
304 bool (* __p2)(const wchar_t&, const wchar_t&) = &char_traits<wchar_t>::eq;
306 // std::wstring
307 template
308 void
309 basic_string<wchar_t>::_M_copy(wchar_t*, const wchar_t*, size_t);
311 template
312 void
313 basic_string<wchar_t>::_M_move(wchar_t*, const wchar_t*, size_t);
315 template
316 void
317 basic_string<wchar_t>::_M_assign(wchar_t*, size_t, wchar_t);
319 template
320 bool
321 basic_string<wchar_t>::_M_disjunct(const wchar_t*) const;
323 template
324 void
325 basic_string<wchar_t>::_M_check_length(size_t, size_t,
326 const char*) const;
328 template
329 void
330 basic_string<wchar_t>::_Rep::_M_set_length_and_sharable(size_t);
332 template
333 basic_istream<wchar_t>&
334 basic_istream<wchar_t>::ignore();
336 template
337 bool
338 basic_fstream<wchar_t>::is_open() const;
340 template
341 bool
342 basic_ifstream<wchar_t>::is_open() const;
344 template
345 bool
346 basic_ofstream<wchar_t>::is_open() const;
347 #endif
349 _GLIBCXX_END_NAMESPACE
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.
357 #define _GLIBCXX_3_4_SYMVER(XXname, name) \
358 extern "C" void \
359 _X##name() \
360 __attribute__ ((alias(#XXname))); \
361 asm (".symver " "_X" #name "," #name "@GLIBCXX_3.4");
363 #define _GLIBCXX_3_4_5_SYMVER(XXname, name) \
364 extern "C" void \
365 _Y##name() \
366 __attribute__ ((alias(#XXname))); \
367 asm (".symver " "_Y" #name "," #name "@@GLIBCXX_3.4.5");
369 #define _GLIBCXX_ASM_SYMVER(cur, old, version) \
370 asm (".symver " #cur "," #old "@@" #version);
372 #define _GLIBCXX_APPLY_SYMVER _GLIBCXX_3_4_SYMVER
373 #include <bits/compatibility.h>
374 #undef _GLIBCXX_APPLY_SYMVER
376 #define _GLIBCXX_APPLY_SYMVER _GLIBCXX_3_4_5_SYMVER
377 #include <bits/compatibility.h>
378 #undef _GLIBCXX_APPLY_SYMVER
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_;
388 #include "list.cc"
389 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX7_M_hookEPS_, \
390 _ZN10__gnu_norm15_List_node_base4hookEPS0_, \
391 GLIBCXX_3.4)
393 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX4swapERS_S0_, \
394 _ZN10__gnu_norm15_List_node_base4swapERS0_S1_, \
395 GLIBCXX_3.4)
397 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX9_M_unhookEv, \
398 _ZN10__gnu_norm15_List_node_base6unhookEv, \
399 GLIBCXX_3.4)
401 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX10_M_reverseEv, \
402 _ZN10__gnu_norm15_List_node_base7reverseEv, \
403 GLIBCXX_3.4)
405 _GLIBCXX_ASM_SYMVER(_ZNSt17_List_node_baseXX11_M_transferEPS_S0_, \
406 _ZN10__gnu_norm15_List_node_base8transferEPS0_S1_, \
407 GLIBCXX_3.4)
408 #undef _List_node_base
410 // gcc-4.1.0
411 // Long double versions of "C" math functions.
412 #if defined (_GLIBCXX_LONG_DOUBLE_COMPAT) \
413 || (defined (__hppa__) && defined (__linux__))
415 #define _GLIBCXX_MATHL_WRAPPER(name, argdecl, args, ver) \
416 extern "C" double \
417 __ ## name ## l_wrapper argdecl \
419 return name args; \
421 asm (".symver __" #name "l_wrapper, " #name "l@" #ver)
423 #define _GLIBCXX_MATHL_WRAPPER1(name, ver) \
424 _GLIBCXX_MATHL_WRAPPER (name, (double x), (x), ver)
426 #define _GLIBCXX_MATHL_WRAPPER2(name, ver) \
427 _GLIBCXX_MATHL_WRAPPER (name, (double x, double y), (x, y), ver)
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
497 #endif
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 * const _ZTIe[2]
506 = { (void *) &_ZTVN10__cxxabiv123__fundamental_type_infoE[2],
507 (void *) _ZTSe };
508 extern __attribute__((used, weak)) const void * const _ZTIPe[4]
509 = { (void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2],
510 (void *) _ZTSPe, (void *) 0L, (void *) _ZTIe };
511 extern __attribute__((used, weak)) const void * const _ZTIPKe[4]
512 = { (void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2],
513 (void *) _ZTSPKe, (void *) 1L, (void *) _ZTIe };
514 #endif // _GLIBCXX_LONG_DOUBLE_COMPAT
516 #ifdef _GLIBCXX_SYMVER_DARWIN
517 #if (defined(__ppc__) || defined(__ppc64__)) && defined(PIC)
518 /* __eprintf shouldn't have been made visible from libstdc++, or
519 anywhere, but on Mac OS X 10.4 it was defined in
520 libstdc++.6.0.3.dylib; so on that platform we have to keep defining
521 it to keep binary compatibility. We can't just put the libgcc
522 version in the export list, because that doesn't work; once a
523 symbol is marked as hidden, it stays that way. */
525 #include <cstdio>
526 #include <cstdlib>
528 using namespace std;
530 extern "C" void
531 __eprintf(const char *string, const char *expression,
532 unsigned int line, const char *filename)
534 fprintf(stderr, string, expression, line, filename);
535 fflush(stderr);
536 abort();
538 #endif
539 #endif