Master Core  v0.0.9 - 49a5c0d97abf09ef2911ddfe8d9551df59f9efd3-dirty
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
glibcxx_compat.cpp
Go to the documentation of this file.
1 #include <cstddef>
2 #include <istream>
3 #include <stdexcept>
4 #include <typeinfo>
5 
6 #ifndef _GLIBCXX_USE_NOEXCEPT
7  #define _GLIBCXX_USE_NOEXCEPT throw()
8 #endif
9 
10 namespace std {
11 
12 const char* bad_exception::what() const throw()
13 {
14  return "std::bad_exception";
15 }
16 
17 const char* bad_cast::what() const throw()
18 {
19  return "std::bad_cast";
20 }
21 
22 const char* bad_alloc::what() const throw()
23 {
24  return "std::bad_alloc";
25 }
26 
27 namespace __detail
28 {
30 {
31  void _M_hook(std::__detail::_List_node_base* const __position) throw () __attribute__((used))
32  {
33  _M_next = __position;
34  _M_prev = __position->_M_prev;
35  __position->_M_prev->_M_next = this;
36  __position->_M_prev = this;
37  }
38  void _M_unhook() __attribute__((used))
39  {
40  _List_node_base* const __next_node = _M_next;
41  _List_node_base* const __prev_node = _M_prev;
42  __prev_node->_M_next = __next_node;
43  __next_node->_M_prev = __prev_node;
44  }
47 };
48 } // namespace detail
49 
50 template ostream& ostream::_M_insert(bool);
51 template ostream& ostream::_M_insert(long);
52 template ostream& ostream::_M_insert(double);
53 template ostream& ostream::_M_insert(unsigned long);
54 template ostream& ostream::_M_insert(const void*);
55 template ostream& __ostream_insert(ostream&, const char*, streamsize);
56 template istream& istream::_M_extract(long&);
57 template istream& istream::_M_extract(unsigned short&);
58 
59 out_of_range::~out_of_range() _GLIBCXX_USE_NOEXCEPT { }
60 
61 length_error::~length_error() _GLIBCXX_USE_NOEXCEPT { }
62 
63 // Used with permission.
64 // See: https://github.com/madlib/madlib/commit/c3db418c0d34d6813608f2137fef1012ce03043d
65 
66 void
67 ctype<char>::_M_widen_init() const {
68  char __tmp[sizeof(_M_widen)];
69  for (unsigned __i = 0; __i < sizeof(_M_widen); ++__i)
70  __tmp[__i] = __i;
71  do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen);
72 
73  _M_widen_ok = 1;
74  // Set _M_widen_ok to 2 if memcpy can't be used.
75  for (unsigned __i = 0; __i < sizeof(_M_widen); ++__i)
76  if (__tmp[__i] != _M_widen[__i]) {
77  _M_widen_ok = 2;
78  break;
79  }
80 }
81 
82 void __throw_out_of_range_fmt(const char*, ...) __attribute__((__noreturn__));
83 void __throw_out_of_range_fmt(const char* err, ...)
84 {
85  // Safe and over-simplified version. Ignore the format and print it as-is.
86  __throw_out_of_range(err);
87 }
88 
89 }// namespace std
void _M_unhook() __attribute__((used))
STL namespace.
void _M_hook(std::__detail::_List_node_base *const __position) __attribute__((used))
#define _GLIBCXX_USE_NOEXCEPT