Add patch from 9.3.5 to 9.3.5-P1. This is for adding randomization
[dragonfly.git] / contrib / gcc-4.1 / libstdc++-v3 / src / compatibility.cc
blob613e8fbb8c621968fdc9b09a9d20e4f8bb7ead8f
1 // Compatibility symbols for previous versions -*- C++ -*-
3 // Copyright (C) 2005
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) && 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 #endif
48 #include <string>
49 #include <istream>
50 #include <fstream>
51 #include <sstream>
53 namespace std
55 // std::istream ignore explicit specializations.
57 template<>
58 basic_istream<char>&
59 basic_istream<char>::
60 ignore(streamsize __n)
62 if (__n == 1)
63 return ignore();
65 _M_gcount = 0;
66 sentry __cerb(*this, true);
67 if (__cerb && __n > 0)
69 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
70 try
72 const int_type __eof = traits_type::eof();
73 __streambuf_type* __sb = this->rdbuf();
74 int_type __c = __sb->sgetc();
76 // See comment in istream.tcc.
77 bool __large_ignore = false;
78 while (true)
80 while (_M_gcount < __n
81 && !traits_type::eq_int_type(__c, __eof))
83 streamsize __size = std::min(streamsize(__sb->egptr()
84 - __sb->gptr()),
85 streamsize(__n - _M_gcount));
86 if (__size > 1)
88 __sb->gbump(__size);
89 _M_gcount += __size;
90 __c = __sb->sgetc();
92 else
94 ++_M_gcount;
95 __c = __sb->snextc();
98 if (__n == numeric_limits<streamsize>::max()
99 && !traits_type::eq_int_type(__c, __eof))
101 _M_gcount = numeric_limits<streamsize>::min();
102 __large_ignore = true;
104 else
105 break;
108 if (__large_ignore)
109 _M_gcount = numeric_limits<streamsize>::max();
111 if (traits_type::eq_int_type(__c, __eof))
112 __err |= ios_base::eofbit;
114 catch(...)
115 { this->_M_setstate(ios_base::badbit); }
116 if (__err)
117 this->setstate(__err);
119 return *this;
122 #ifdef _GLIBCXX_USE_WCHAR_T
123 template<>
124 basic_istream<wchar_t>&
125 basic_istream<wchar_t>::
126 ignore(streamsize __n)
128 if (__n == 1)
129 return ignore();
131 _M_gcount = 0;
132 sentry __cerb(*this, true);
133 if (__cerb && __n > 0)
135 ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
138 const int_type __eof = traits_type::eof();
139 __streambuf_type* __sb = this->rdbuf();
140 int_type __c = __sb->sgetc();
142 bool __large_ignore = false;
143 while (true)
145 while (_M_gcount < __n
146 && !traits_type::eq_int_type(__c, __eof))
148 streamsize __size = std::min(streamsize(__sb->egptr()
149 - __sb->gptr()),
150 streamsize(__n - _M_gcount));
151 if (__size > 1)
153 __sb->gbump(__size);
154 _M_gcount += __size;
155 __c = __sb->sgetc();
157 else
159 ++_M_gcount;
160 __c = __sb->snextc();
163 if (__n == numeric_limits<streamsize>::max()
164 && !traits_type::eq_int_type(__c, __eof))
166 _M_gcount = numeric_limits<streamsize>::min();
167 __large_ignore = true;
169 else
170 break;
173 if (__large_ignore)
174 _M_gcount = numeric_limits<streamsize>::max();
176 if (traits_type::eq_int_type(__c, __eof))
177 __err |= ios_base::eofbit;
179 catch(...)
180 { this->_M_setstate(ios_base::badbit); }
181 if (__err)
182 this->setstate(__err);
184 return *this;
186 #endif
189 // NB: These symbols renames should go into the shared library only,
190 // and only those shared libraries that support versioning.
191 #if defined(_GLIBCXX_SYMVER) && defined(PIC)
193 /* gcc-3.4.4
194 _ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv
195 _ZNSt19istreambuf_iteratorIwSt11char_traitsIwEEppEv
197 namespace std
199 template
200 istreambuf_iterator<char>&
201 istreambuf_iterator<char>::operator++();
203 #ifdef _GLIBCXX_USE_WCHAR_T
204 template
205 istreambuf_iterator<wchar_t>&
206 istreambuf_iterator<wchar_t>::operator++();
207 #endif
208 } // namespace std
210 /* gcc-4.0.0
211 _ZNSs4_Rep26_M_set_length_and_sharableEj
212 _ZNSs7_M_copyEPcPKcj
213 _ZNSs7_M_moveEPcPKcj
214 _ZNSs9_M_assignEPcjc
215 _ZNKSs11_M_disjunctEPKc
216 _ZNKSs15_M_check_lengthEjjPKc
217 _ZNSbIwSt11char_traitsIwESaIwEE4_Rep26_M_set_length_and_sharableEj
218 _ZNSbIwSt11char_traitsIwESaIwEE7_M_copyEPwPKwj
219 _ZNSbIwSt11char_traitsIwESaIwEE7_M_moveEPwPKwj
220 _ZNSbIwSt11char_traitsIwESaIwEE9_M_assignEPwjw
221 _ZNKSbIwSt11char_traitsIwESaIwEE11_M_disjunctEPKw
222 _ZNKSbIwSt11char_traitsIwESaIwEE15_M_check_lengthEjjPKc
224 _ZNKSt13basic_fstreamIcSt11char_traitsIcEE7is_openEv
225 _ZNKSt13basic_fstreamIwSt11char_traitsIwEE7is_openEv
226 _ZNKSt14basic_ifstreamIcSt11char_traitsIcEE7is_openEv
227 _ZNKSt14basic_ifstreamIwSt11char_traitsIwEE7is_openEv
228 _ZNKSt14basic_ofstreamIcSt11char_traitsIcEE7is_openEv
229 _ZNKSt14basic_ofstreamIwSt11char_traitsIwEE7is_openEv
231 _ZNSi6ignoreEi
232 _ZNSi6ignoreEv
233 _ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEi
234 _ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEv
236 _ZNSt11char_traitsIcE2eqERKcS2_
237 _ZNSt11char_traitsIwE2eqERKwS2_
239 namespace std
241 // std::char_traits is explicitly specialized
242 bool (* __p1)(const char&, const char&) = &char_traits<char>::eq;
244 // std::string
245 template
246 void
247 basic_string<char>::_M_copy(char*, const char*, size_t);
249 template
250 void
251 basic_string<char>::_M_move(char*, const char*, size_t);
253 template
254 void
255 basic_string<char>::_M_assign(char*, size_t, char);
257 template
258 bool
259 basic_string<char>::_M_disjunct(const char*) const;
261 template
262 void
263 basic_string<char>::_M_check_length(size_t, size_t, const char*) const;
265 template
266 void
267 basic_string<char>::_Rep::_M_set_length_and_sharable(size_t);
270 // std::istream
271 template
272 basic_istream<char>&
273 basic_istream<char>::ignore();
275 template
276 bool
277 basic_fstream<char>::is_open() const;
279 template
280 bool
281 basic_ifstream<char>::is_open() const;
283 template
284 bool
285 basic_ofstream<char>::is_open() const;
287 #ifdef _GLIBCXX_USE_WCHAR_T
288 bool (* __p2)(const wchar_t&, const wchar_t&) = &char_traits<wchar_t>::eq;
290 // std::wstring
291 template
292 void
293 basic_string<wchar_t>::_M_copy(wchar_t*, const wchar_t*, size_t);
295 template
296 void
297 basic_string<wchar_t>::_M_move(wchar_t*, const wchar_t*, size_t);
299 template
300 void
301 basic_string<wchar_t>::_M_assign(wchar_t*, size_t, wchar_t);
303 template
304 bool
305 basic_string<wchar_t>::_M_disjunct(const wchar_t*) const;
307 template
308 void
309 basic_string<wchar_t>::_M_check_length(size_t, size_t,
310 const char*) const;
312 template
313 void
314 basic_string<wchar_t>::_Rep::_M_set_length_and_sharable(size_t);
316 template
317 basic_istream<wchar_t>&
318 basic_istream<wchar_t>::ignore();
320 template
321 bool
322 basic_fstream<wchar_t>::is_open() const;
324 template
325 bool
326 basic_ifstream<wchar_t>::is_open() const;
328 template
329 bool
330 basic_ofstream<wchar_t>::is_open() const;
331 #endif
334 // The rename syntax for default exported names is
335 // asm (".symver name1,exportedname@GLIBCXX_3.4")
336 // asm (".symver name2,exportedname@@GLIBCXX_3.4.5")
337 // In the future, GLIBCXX_ABI > 6 should remove all uses of
338 // _GLIBCXX_*_SYMVER macros in this file.
340 #define _GLIBCXX_3_4_SYMVER(XXname, name) \
341 extern "C" void \
342 _X##name() \
343 __attribute__ ((alias(#XXname))); \
344 asm (".symver " "_X" #name "," #name "@GLIBCXX_3.4");
346 #define _GLIBCXX_3_4_5_SYMVER(XXname, name) \
347 extern "C" void \
348 _Y##name() \
349 __attribute__ ((alias(#XXname))); \
350 asm (".symver " "_Y" #name "," #name "@@GLIBCXX_3.4.5");
352 #define _GLIBCXX_ASM_SYMVER(cur, old, version) \
353 asm (".symver " #cur "," #old "@@" #version);
355 #define _GLIBCXX_APPLY_SYMVER _GLIBCXX_3_4_SYMVER
356 #include <bits/compatibility.h>
357 #undef _GLIBCXX_APPLY_SYMVER
359 #define _GLIBCXX_APPLY_SYMVER _GLIBCXX_3_4_5_SYMVER
360 #include <bits/compatibility.h>
361 #undef _GLIBCXX_APPLY_SYMVER
363 #endif
365 #ifdef __APPLE__
366 #if (defined(__ppc__) || defined (__ppc64__)) && defined (PIC)
367 /* __eprintf shouldn't have been made visible from libstdc++, or
368 anywhere, but on Mac OS X 10.4 it was defined in
369 libstdc++.6.0.3.dylib; so on that platform we have to keep defining
370 it to keep binary compatibility. We can't just put the libgcc
371 version in the export list, because that doesn't work; once a
372 symbol is marked as hidden, it stays that way. */
374 #include <cstdio>
375 #include <cstdlib>
377 using namespace std;
379 extern "C" void
380 __eprintf (const char *string, const char *expression,
381 unsigned int line, const char *filename)
383 fprintf (stderr, string, expression, line, filename);
384 fflush (stderr);
385 abort ();
387 #endif
388 #endif /* __APPLE__ */