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