You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

glibcxx_compat.cpp 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // Copyright (c) 2009-2014 The Bitcoin developers
  2. // Distributed under the MIT/X11 software license, see the accompanying
  3. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. #include <cstddef>
  5. #include <istream>
  6. #include <stdexcept>
  7. #include <typeinfo>
  8. #ifndef _GLIBCXX_USE_NOEXCEPT
  9. #define _GLIBCXX_USE_NOEXCEPT throw()
  10. #endif
  11. namespace std {
  12. const char* bad_exception::what() const throw()
  13. {
  14. return "std::bad_exception";
  15. }
  16. const char* bad_cast::what() const throw()
  17. {
  18. return "std::bad_cast";
  19. }
  20. const char* bad_alloc::what() const throw()
  21. {
  22. return "std::bad_alloc";
  23. }
  24. namespace __detail
  25. {
  26. struct _List_node_base
  27. {
  28. void _M_hook(std::__detail::_List_node_base* const __position) throw () __attribute__((used))
  29. {
  30. _M_next = __position;
  31. _M_prev = __position->_M_prev;
  32. __position->_M_prev->_M_next = this;
  33. __position->_M_prev = this;
  34. }
  35. void _M_unhook() __attribute__((used))
  36. {
  37. _List_node_base* const __next_node = _M_next;
  38. _List_node_base* const __prev_node = _M_prev;
  39. __prev_node->_M_next = __next_node;
  40. __next_node->_M_prev = __prev_node;
  41. }
  42. _List_node_base* _M_next;
  43. _List_node_base* _M_prev;
  44. };
  45. } // namespace detail
  46. template ostream& ostream::_M_insert(bool);
  47. template ostream& ostream::_M_insert(long);
  48. template ostream& ostream::_M_insert(double);
  49. template ostream& ostream::_M_insert(unsigned long);
  50. template ostream& ostream::_M_insert(const void*);
  51. template ostream& __ostream_insert(ostream&, const char*, streamsize);
  52. template istream& istream::_M_extract(long&);
  53. template istream& istream::_M_extract(unsigned short&);
  54. out_of_range::~out_of_range() _GLIBCXX_USE_NOEXCEPT { }
  55. length_error::~length_error() _GLIBCXX_USE_NOEXCEPT { }
  56. // Used with permission.
  57. // See: https://github.com/madlib/madlib/commit/c3db418c0d34d6813608f2137fef1012ce03043d
  58. void ctype<char>::_M_widen_init() const
  59. {
  60. char __tmp[sizeof(_M_widen)];
  61. for (unsigned __i = 0; __i < sizeof(_M_widen); ++__i)
  62. __tmp[__i] = __i;
  63. do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen);
  64. _M_widen_ok = 1;
  65. // Set _M_widen_ok to 2 if memcpy can't be used.
  66. for (unsigned __i = 0; __i < sizeof(_M_widen); ++__i)
  67. if (__tmp[__i] != _M_widen[__i]) {
  68. _M_widen_ok = 2;
  69. break;
  70. }
  71. }
  72. void __throw_out_of_range_fmt(const char*, ...) __attribute__((__noreturn__));
  73. void __throw_out_of_range_fmt(const char* err, ...)
  74. {
  75. // Safe and over-simplified version. Ignore the format and print it as-is.
  76. __throw_out_of_range(err);
  77. }
  78. }// namespace std