]> git.buserror.net Git - polintos/scott/priv.git/blob - lib/c++/stlport/dll_main.cpp
Add STLport 5.1.4
[polintos/scott/priv.git] / lib / c++ / stlport / dll_main.cpp
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 #define __PUT_STATIC_DATA_MEMBERS_HERE
27 #define _STLP_EXPOSE_GLOBALS_IMPLEMENTATION
28
29 #include "stlport_prefix.h"
30
31 #if !defined (_STLP_DEBUG) && ! defined (_STLP_ASSERTIONS)
32 #  if !defined (__APPLE__) || !defined (__GNUC__) || (__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 3))
33 /* dums: Please if the following code was being uncommented please explain why
34  * as for the moment it only looks like a source of inconsistency in the way
35  * STLport different translation units are compiled.
36  */
37 //#    define _STLP_ASSERTIONS 1
38 #  endif
39 #endif
40
41 #include <utility>
42 #include <memory>
43 #include <vector>
44 #include <set>
45 #include <list>
46 #include <slist>
47 #include <deque>
48 #include <hash_map>
49 #include <limits>
50 #include <string>
51 #include <stdexcept>
52 #include <bitset>
53 #include <locale>
54
55 #if (_STLP_STATIC_TEMPLATE_DATA < 1) || defined (__DMC__)
56 // for rope static members
57 #  include <rope>
58 #endif
59
60 // boris : this piece of code duplicated from _range_errors.h
61 #undef _STLP_THROW_MSG
62 #if defined(_STLP_THROW_RANGE_ERRORS)
63 #  ifndef _STLP_STDEXCEPT
64 #    include <stdexcept>
65 #  endif
66 #  ifndef _STLP_STRING
67 #    include <string>
68 #  endif
69 #  define _STLP_THROW_MSG(ex,msg)  throw ex(string(msg))
70 #else
71 #  if defined (_STLP_RTTI_BUG)
72 #    define _STLP_THROW_MSG(ex,msg)  TerminateProcess(GetCurrentProcess(), 0)
73 #  else
74 #    include <cstdlib>
75 #    include <cstdio>
76 #    define _STLP_THROW_MSG(ex,msg)  puts(msg),_STLP_ABORT()
77 #  endif
78 #endif
79
80 #if defined (_STLP_MSVC) && (_STLP_MSVC < 1310)
81 #  pragma optimize("g", off)
82 #endif
83
84 _STLP_BEGIN_NAMESPACE
85
86 void _STLP_DECLSPEC _STLP_CALL __stl_throw_runtime_error(const char* __msg)
87 { _STLP_THROW_MSG(runtime_error, __msg); }
88
89 void _STLP_DECLSPEC _STLP_CALL __stl_throw_range_error(const char* __msg)
90 { _STLP_THROW_MSG(range_error, __msg); }
91
92 void _STLP_DECLSPEC _STLP_CALL __stl_throw_out_of_range(const char* __msg)
93 { _STLP_THROW_MSG(out_of_range, __msg); }
94
95 void _STLP_DECLSPEC _STLP_CALL __stl_throw_length_error(const char* __msg)
96 { _STLP_THROW_MSG(length_error, __msg); }
97
98 void _STLP_DECLSPEC _STLP_CALL __stl_throw_invalid_argument(const char* __msg)
99 { _STLP_THROW_MSG(invalid_argument, __msg); }
100
101 void _STLP_DECLSPEC _STLP_CALL __stl_throw_overflow_error(const char* __msg)
102 { _STLP_THROW_MSG(overflow_error, __msg); }
103
104 #if defined (_STLP_NO_EXCEPTION_HEADER) || defined (_STLP_BROKEN_EXCEPTION_CLASS)
105 exception::exception() _STLP_NOTHROW {}
106 exception::~exception() _STLP_NOTHROW {}
107 bad_exception::bad_exception() _STLP_NOTHROW {}
108 bad_exception::~bad_exception() _STLP_NOTHROW {}
109 const char* exception::what() const _STLP_NOTHROW { return "class exception"; }
110 const char* bad_exception::what() const _STLP_NOTHROW { return "class bad_exception"; }
111 #endif
112
113 #if defined (_STLP_OWN_STDEXCEPT)
114 __Named_exception::__Named_exception(const string& __str) {
115 #if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
116   strncpy(_M_name, __str.c_str(), _S_bufsize);
117   _M_name[_S_bufsize - 1] = '\0';
118 #else
119   strncpy_s(_STLP_ARRAY_AND_SIZE(_M_name), __str.c_str(), _TRUNCATE);
120 #endif
121 }
122
123 const char* __Named_exception::what() const _STLP_NOTHROW_INHERENTLY { return _M_name; }
124
125 // boris : those are needed to force typeinfo nodes to be created in here only
126 __Named_exception::~__Named_exception() _STLP_NOTHROW_INHERENTLY {}
127
128 logic_error::~logic_error() _STLP_NOTHROW_INHERENTLY {}
129 runtime_error::~runtime_error() _STLP_NOTHROW_INHERENTLY {}
130 domain_error::~domain_error() _STLP_NOTHROW_INHERENTLY {}
131 invalid_argument::~invalid_argument() _STLP_NOTHROW_INHERENTLY {}
132 length_error::~length_error() _STLP_NOTHROW_INHERENTLY {}
133 out_of_range::~out_of_range() _STLP_NOTHROW_INHERENTLY {}
134 range_error::~range_error() _STLP_NOTHROW_INHERENTLY {}
135 overflow_error::~overflow_error() _STLP_NOTHROW_INHERENTLY {}
136 underflow_error::~underflow_error() _STLP_NOTHROW_INHERENTLY {}
137
138 #endif /* _STLP_OWN_STDEXCEPT */
139
140 #if !defined(_STLP_WCE_EVC3)
141 #  if defined (_STLP_NO_BAD_ALLOC)
142 const nothrow_t nothrow /* = {} */;
143 #  endif
144 #endif
145
146 #if !defined (_STLP_NO_FORCE_INSTANTIATE)
147
148 #  if defined (_STLP_DEBUG) || defined (_STLP_ASSERTIONS)
149 _STLP_MOVE_TO_PRIV_NAMESPACE
150 template struct _STLP_CLASS_DECLSPEC __stl_debug_engine<bool>;
151 _STLP_MOVE_TO_STD_NAMESPACE
152 #  endif
153
154 template class _STLP_CLASS_DECLSPEC __debug_alloc<__node_alloc>;
155 template class _STLP_CLASS_DECLSPEC __debug_alloc<__new_alloc>;
156
157 //Export of the types used to represent buckets in the hashtable implementation.
158 /*
159  * For the vector class we do not use any MSVC6 workaround even if we export it from
160  * the STLport dynamic libraries because we know what methods are called and none is
161  * a template method. Moreover the exported class is an instanciation of vector with
162  * _Slist_node_base struct that is an internal STLport class that no user should ever
163  * use.
164  */
165 #  if !defined (_STLP_USE_PTR_SPECIALIZATIONS)
166 template class _STLP_CLASS_DECLSPEC allocator<_STLP_PRIV _Slist_node_base*>;
167
168 _STLP_MOVE_TO_PRIV_NAMESPACE
169 template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_Slist_node_base**, _Slist_node_base*,
170                                                       allocator<_Slist_node_base*> >;
171 template class _STLP_CLASS_DECLSPEC _Vector_base<_Slist_node_base*,
172                                                  allocator<_Slist_node_base*> >;
173 _STLP_MOVE_TO_STD_NAMESPACE
174 #  endif
175
176 #  if defined (_STLP_DEBUG)
177 _STLP_MOVE_TO_PRIV_NAMESPACE
178 template class _STLP_CLASS_DECLSPEC _STLP_NON_DBG_NAME(vector)<_Slist_node_base*,
179                                                                allocator<_Slist_node_base*> >;
180 _STLP_MOVE_TO_STD_NAMESPACE
181 #  endif
182
183 template class _STLP_CLASS_DECLSPEC vector<_STLP_PRIV _Slist_node_base*,
184                                            allocator<_STLP_PRIV _Slist_node_base*> >;
185 //End of hashtable bucket types export.
186
187 //Export of _Locale_impl facets container:
188 #  if !defined (_STLP_USE_PTR_SPECIALIZATIONS)
189 template class _STLP_CLASS_DECLSPEC allocator<locale::facet*>;
190
191 _STLP_MOVE_TO_PRIV_NAMESPACE
192 template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<locale::facet**, locale::facet*, allocator<locale::facet*> >;
193 template class _STLP_CLASS_DECLSPEC _Vector_base<locale::facet*, allocator<locale::facet*> >;
194 _STLP_MOVE_TO_STD_NAMESPACE
195
196 #  endif
197 #  if defined (_STLP_DEBUG)
198 _STLP_MOVE_TO_PRIV_NAMESPACE
199 #    define _STLP_NON_DBG_VECTOR _STLP_NON_DBG_NAME(vector)
200 template class _STLP_CLASS_DECLSPEC __construct_checker<_STLP_PRIV _STLP_NON_DBG_VECTOR<locale::facet*, allocator<locale::facet*> > >;
201 template class _STLP_CLASS_DECLSPEC _STLP_NON_DBG_VECTOR<locale::facet*, allocator<locale::facet*> >;
202 #    undef _STLP_NON_DBG_VECTOR
203 _STLP_MOVE_TO_STD_NAMESPACE
204 #  endif
205
206 template class _STLP_CLASS_DECLSPEC vector<locale::facet*, allocator<locale::facet*> >;
207 //End of export of _Locale_impl facets container.
208
209 #  if defined (_STLP_USE_PTR_SPECIALIZATIONS)
210 template class _STLP_CLASS_DECLSPEC allocator<void*>;
211
212 typedef _STLP_PRIV _List_node<void*> _VoidPtr_Node;
213 template class _STLP_CLASS_DECLSPEC allocator<_VoidPtr_Node>;
214
215 _STLP_MOVE_TO_PRIV_NAMESPACE
216
217 template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<void**, void*, allocator<void*> >;
218 template class _STLP_CLASS_DECLSPEC _Vector_base<void*, allocator<void*> >;
219 template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(vector)<void*, allocator<void*> >;
220
221 template class _STLP_CLASS_DECLSPEC _List_node<void*>;
222 template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_List_node_base, _VoidPtr_Node, allocator<_VoidPtr_Node> >;
223 template class _STLP_CLASS_DECLSPEC _List_base<void*, allocator<void*> >;
224 template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(list)<void*, allocator<void*> >;
225
226 template class _STLP_CLASS_DECLSPEC _Slist_node<void*>;
227 template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_Slist_node_base, _Slist_node<void*>, allocator<_Slist_node<void*> > >;
228 template class _STLP_CLASS_DECLSPEC _Slist_base<void*, allocator<void*> >;
229 template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(slist)<void*, allocator<void*> >;
230
231 template class  _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<size_t, void*, allocator<void*> >;
232 template class  _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<void***, void**, allocator<void**> >;
233 template struct _STLP_CLASS_DECLSPEC _Deque_iterator<void*, _Nonconst_traits<void*> >;
234 template class  _STLP_CLASS_DECLSPEC _Deque_base<void*, allocator<void*> >;
235 template class  _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(deque)<void*, allocator<void*> >;
236
237 _STLP_MOVE_TO_STD_NAMESPACE
238
239 #  endif /* _STLP_USE_PTR_SPECIALIZATIONS */
240
241 _STLP_MOVE_TO_PRIV_NAMESPACE
242
243 template class _STLP_CLASS_DECLSPEC _Rb_global<bool>;
244 template class _STLP_CLASS_DECLSPEC _List_global<bool>;
245
246 template class _STLP_CLASS_DECLSPEC _Sl_global<bool>;
247 template class _STLP_CLASS_DECLSPEC _Stl_prime<bool>;
248
249 template class _STLP_CLASS_DECLSPEC _LimG<bool>;
250
251 _STLP_MOVE_TO_STD_NAMESPACE
252
253 #endif /* _STLP_NO_FORCE_INSTANTIATE */
254
255 _STLP_END_NAMESPACE
256
257 #define FORCE_SYMBOL extern
258
259 #if defined (_WIN32) && defined (_STLP_USE_DECLSPEC) && !defined (_STLP_USE_STATIC_LIB)
260 // stlportmt.cpp : Defines the entry point for the DLL application.
261 //
262 #  define WIN32_LEAN_AND_MEAN
263 #  include <windows.h>
264
265 #  undef FORCE_SYMBOL
266 #  define FORCE_SYMBOL APIENTRY
267
268 extern "C" {
269
270 BOOL APIENTRY DllMain( HANDLE hModule,
271                        DWORD  ul_reason_for_call,
272                        LPVOID) {
273   switch (ul_reason_for_call) {
274     case DLL_PROCESS_ATTACH:
275       DisableThreadLibraryCalls((HINSTANCE)hModule);
276     case DLL_THREAD_ATTACH:
277     case DLL_THREAD_DETACH:
278     case DLL_PROCESS_DETACH:
279       break;
280     }
281   return TRUE;
282 }
283
284 } /* extern "C" */
285
286 #if !defined (_STLP_MSVC) && !defined (__MINGW32__)
287 _STLP_BEGIN_NAMESPACE
288
289 static void FORCE_SYMBOL
290 force_link() {
291   set<int>::iterator iter;
292   // _M_increment; _M_decrement instantiation
293   ++iter;
294   --iter;
295 }
296
297 _STLP_END_NAMESPACE
298 #endif
299
300 #endif /* _WIN32 */
301
302 #if defined (__ICL) && (__ICL >= 900) && (_STLP_MSVC_LIB < 1300)
303 #  undef std
304
305 namespace std
306 {
307   void _STLP_CALL unexpected() {
308     unexpected_handler hdl;
309     set_unexpected(hdl = set_unexpected((unexpected_handler)0));
310     hdl();
311   }
312 }
313 #endif