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