1  /*
2  *
3  * Copyright (c) 1994
4  * Hewlett-Packard Company
5  *
6  * Copyright (c) 1996,1997
7  * Silicon Graphics Computer Systems, Inc.
8  *
9  * Copyright (c) 1997
10  * Moscow Center for SPARC Technology
11  *
12  * Copyright (c) 1999
13  * Boris Fomitchev
14  *
15  * This material is provided "as is", with absolutely no warranty expressed
16  * or implied. Any use is at your own risk.
17  *
18  * Permission to use or copy this software for any purpose is hereby granted
19  * without fee, provided the above notices are retained on all copies.
20  * Permission to modify the code and to distribute modified code is granted,
21  * provided the above notices are retained, and a notice that the code was
22  * modified is included with the above copyright notice.
23  *
24  */
25 
26 #include "stlport_prefix.h"
27 
28 #if !defined (_STLP_DEBUG) && ! defined (_STLP_ASSERTIONS)
29 #  if !defined (__APPLE__) || !defined (__GNUC__) || (__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 3))
30 /* dums: Please if the following code was being uncommented please explain why
31  * as for the moment it only looks like a source of inconsistency in the way
32  * STLport different translation units are compiled.
33  */
34 //#    define _STLP_ASSERTIONS 1
35 #  endif
36 #endif
37 
38 #include <utility>
39 #include <memory>
40 #include <vector>
41 #include <set>
42 #include <list>
43 #include <slist>
44 #include <deque>
45 #include <hash_map>
46 #include <limits>
47 #include <string>
48 #include <stdexcept>
49 #include <bitset>
50 #include <locale>
51 
52 #if defined (__DMC__)
53 // for rope static members
54 #  include <rope>
55 #endif
56 
57 #include <stl/_range_errors.c>
58 
59 _STLP_BEGIN_NAMESPACE
60 
61 #if defined (_STLP_NO_EXCEPTION_HEADER) || defined (_STLP_BROKEN_EXCEPTION_CLASS)
exception()62 exception::exception() _STLP_NOTHROW {}
~exception()63 exception::~exception() _STLP_NOTHROW {}
bad_exception()64 bad_exception::bad_exception() _STLP_NOTHROW {}
~bad_exception()65 bad_exception::~bad_exception() _STLP_NOTHROW {}
what() const66 const char* exception::what() const _STLP_NOTHROW { return "class exception"; }
what() const67 const char* bad_exception::what() const _STLP_NOTHROW { return "class bad_exception"; }
68 #endif
69 
70 #if defined (_STLP_OWN_STDEXCEPT)
71 #  include <stl/_stdexcept_base.c>
72 
73 // boris : those are needed to force typeinfo nodes to be created in here only
~logic_error()74 logic_error::~logic_error() _STLP_NOTHROW_INHERENTLY {}
~runtime_error()75 runtime_error::~runtime_error() _STLP_NOTHROW_INHERENTLY {}
~domain_error()76 domain_error::~domain_error() _STLP_NOTHROW_INHERENTLY {}
~invalid_argument()77 invalid_argument::~invalid_argument() _STLP_NOTHROW_INHERENTLY {}
~length_error()78 length_error::~length_error() _STLP_NOTHROW_INHERENTLY {}
~out_of_range()79 out_of_range::~out_of_range() _STLP_NOTHROW_INHERENTLY {}
~range_error()80 range_error::~range_error() _STLP_NOTHROW_INHERENTLY {}
~overflow_error()81 overflow_error::~overflow_error() _STLP_NOTHROW_INHERENTLY {}
~underflow_error()82 underflow_error::~underflow_error() _STLP_NOTHROW_INHERENTLY {}
83 
84 #endif
85 
86 #if !defined(_STLP_WCE_EVC3)
87 #  if defined (_STLP_NO_BAD_ALLOC)
88 const nothrow_t nothrow /* = {} */;
89 #  endif
90 #endif
91 
92 #if !defined (_STLP_NO_FORCE_INSTANTIATE)
93 
94 #  if defined (_STLP_DEBUG) || defined (_STLP_ASSERTIONS)
95 _STLP_MOVE_TO_PRIV_NAMESPACE
96 template class _STLP_CLASS_DECLSPEC __stl_debug_engine<bool>;
97 _STLP_MOVE_TO_STD_NAMESPACE
98 #  endif
99 
100 template class _STLP_CLASS_DECLSPEC __debug_alloc<__node_alloc>;
101 template class _STLP_CLASS_DECLSPEC __debug_alloc<__new_alloc>;
102 
103 //Export of the types used to represent buckets in the hashtable implementation.
104 /*
105  * For the vector class we do not use any MSVC6 workaround even if we export it from
106  * the STLport dynamic libraries because we know what methods are called and none is
107  * a template method. Moreover the exported class is an instanciation of vector with
108  * _Slist_node_base struct that is an internal STLport class that no user should ever
109  * use.
110  */
111 #  if !defined (_STLP_USE_PTR_SPECIALIZATIONS)
112 template class _STLP_CLASS_DECLSPEC allocator<_STLP_PRIV _Slist_node_base*>;
113 
114 _STLP_MOVE_TO_PRIV_NAMESPACE
115 template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_Slist_node_base**, _Slist_node_base*,
116                                                       allocator<_Slist_node_base*> >;
117 template class _STLP_CLASS_DECLSPEC _Vector_base<_Slist_node_base*,
118                                                  allocator<_Slist_node_base*> >;
119 _STLP_MOVE_TO_STD_NAMESPACE
120 #  endif
121 
122 #  if defined (_STLP_DEBUG)
123 _STLP_MOVE_TO_PRIV_NAMESPACE
124 template class _STLP_CLASS_DECLSPEC _STLP_NON_DBG_NAME(vector)<_Slist_node_base*,
125                                                                allocator<_Slist_node_base*> >;
126 _STLP_MOVE_TO_STD_NAMESPACE
127 #  endif
128 
129 template class _STLP_CLASS_DECLSPEC vector<_STLP_PRIV _Slist_node_base*,
130                                            allocator<_STLP_PRIV _Slist_node_base*> >;
131 //End of hashtable bucket types export.
132 
133 //Export of _Locale_impl facets container:
134 #  if !defined (_STLP_USE_PTR_SPECIALIZATIONS)
135 template class _STLP_CLASS_DECLSPEC allocator<locale::facet*>;
136 
137 _STLP_MOVE_TO_PRIV_NAMESPACE
138 template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<locale::facet**, locale::facet*, allocator<locale::facet*> >;
139 template class _STLP_CLASS_DECLSPEC _Vector_base<locale::facet*, allocator<locale::facet*> >;
140 _STLP_MOVE_TO_STD_NAMESPACE
141 
142 #  endif
143 #  if defined (_STLP_DEBUG)
144 _STLP_MOVE_TO_PRIV_NAMESPACE
145 #    define _STLP_NON_DBG_VECTOR _STLP_NON_DBG_NAME(vector)
146 template class _STLP_CLASS_DECLSPEC __construct_checker<_STLP_PRIV _STLP_NON_DBG_VECTOR<locale::facet*, allocator<locale::facet*> > >;
147 template class _STLP_CLASS_DECLSPEC _STLP_NON_DBG_VECTOR<locale::facet*, allocator<locale::facet*> >;
148 #    undef _STLP_NON_DBG_VECTOR
149 _STLP_MOVE_TO_STD_NAMESPACE
150 #  endif
151 
152 template class _STLP_CLASS_DECLSPEC vector<locale::facet*, allocator<locale::facet*> >;
153 //End of export of _Locale_impl facets container.
154 
155 #  if defined (_STLP_USE_PTR_SPECIALIZATIONS)
156 template class _STLP_CLASS_DECLSPEC allocator<void*>;
157 
158 typedef _STLP_PRIV _List_node<void*> _VoidPtr_Node;
159 template class _STLP_CLASS_DECLSPEC allocator<_VoidPtr_Node>;
160 
161 _STLP_MOVE_TO_PRIV_NAMESPACE
162 
163 template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<void**, void*, allocator<void*> >;
164 template class _STLP_CLASS_DECLSPEC _Vector_base<void*, allocator<void*> >;
165 template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(vector)<void*, allocator<void*> >;
166 
167 template class _STLP_CLASS_DECLSPEC _List_node<void*>;
168 template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_List_node_base, _VoidPtr_Node, allocator<_VoidPtr_Node> >;
169 template class _STLP_CLASS_DECLSPEC _List_base<void*, allocator<void*> >;
170 template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(list)<void*, allocator<void*> >;
171 
172 template class _STLP_CLASS_DECLSPEC _Slist_node<void*>;
173 template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_Slist_node_base, _Slist_node<void*>, allocator<_Slist_node<void*> > >;
174 template class _STLP_CLASS_DECLSPEC _Slist_base<void*, allocator<void*> >;
175 template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(slist)<void*, allocator<void*> >;
176 
177 template class  _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<size_t, void*, allocator<void*> >;
178 template class  _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<void***, void**, allocator<void**> >;
179 template struct _STLP_CLASS_DECLSPEC _Deque_iterator<void*, _Nonconst_traits<void*> >;
180 template class  _STLP_CLASS_DECLSPEC _Deque_base<void*, allocator<void*> >;
181 template class  _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(deque)<void*, allocator<void*> >;
182 
183 _STLP_MOVE_TO_STD_NAMESPACE
184 
185 #  endif /* _STLP_USE_PTR_SPECIALIZATIONS */
186 
187 _STLP_MOVE_TO_PRIV_NAMESPACE
188 
189 template class _STLP_CLASS_DECLSPEC _Rb_global<bool>;
190 template class _STLP_CLASS_DECLSPEC _List_global<bool>;
191 
192 template class _STLP_CLASS_DECLSPEC _Sl_global<bool>;
193 template class _STLP_CLASS_DECLSPEC _Stl_prime<bool>;
194 
195 template class _STLP_CLASS_DECLSPEC _LimG<bool>;
196 
197 _STLP_MOVE_TO_STD_NAMESPACE
198 
199 #endif /* _STLP_NO_FORCE_INSTANTIATE */
200 
201 _STLP_END_NAMESPACE
202 
203 #if defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY)
_STLP_SIGNAL_RUNTIME_COMPATIBILITY()204 extern "C" void _STLP_DECLSPEC _STLP_CALL _STLP_SIGNAL_RUNTIME_COMPATIBILITY() {}
205 #endif
206 
207 #define FORCE_SYMBOL extern
208 
209 #if defined (_WIN32) && defined (_STLP_USE_DECLSPEC) && !defined (_STLP_USE_STATIC_LIB)
210 // stlportmt.cpp : Defines the entry point for the DLL application.
211 //
212 #  undef FORCE_SYMBOL
213 #  define FORCE_SYMBOL APIENTRY
214 
215 extern "C" {
216 
DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID)217 BOOL APIENTRY DllMain( HANDLE hModule,
218                        DWORD  ul_reason_for_call,
219                        LPVOID) {
220   switch (ul_reason_for_call) {
221     case DLL_PROCESS_ATTACH:
222       DisableThreadLibraryCalls((HINSTANCE)hModule);
223     case DLL_THREAD_ATTACH:
224     case DLL_THREAD_DETACH:
225     case DLL_PROCESS_DETACH:
226       break;
227     }
228   return TRUE;
229 }
230 
231 } /* extern "C" */
232 
233 #if !defined (_STLP_MSVC) && !defined (__MINGW32__)
234 _STLP_BEGIN_NAMESPACE
235 
236 static void FORCE_SYMBOL
force_link()237 force_link() {
238   set<int>::iterator iter;
239   // _M_increment; _M_decrement instantiation
240   ++iter;
241   --iter;
242 }
243 
244 _STLP_END_NAMESPACE
245 #endif
246 
247 #endif /* _WIN32 */
248 
249 #if defined (__ICL) && (__ICL >= 900) && (_STLP_MSVC_LIB < 1300)
250 #  undef std
251 
252 namespace std
253 {
unexpected()254   void _STLP_CALL unexpected() {
255     unexpected_handler hdl;
256     set_unexpected(hdl = set_unexpected((unexpected_handler)0));
257     hdl();
258   }
259 }
260 #endif
261