home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / src / dll_main.cpp < prev    next >
C/C++ Source or Header  |  2002-02-02  |  8KB  |  256 lines

  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. # define _STLP_ASSERTIONS 1
  33. # endif
  34.  
  35. #include <utility>
  36.  
  37. #include <stl/debug/_debug.h>
  38. #include <memory>
  39. #include <vector>
  40. #include <set>
  41. #include <list>
  42. #include <slist>
  43. #include <stl/_hashtable.h>
  44. #include <limits>
  45. #include <string>
  46. #include <stdexcept>
  47. #include <bitset>
  48.  
  49. # if ( _STLP_STATIC_TEMPLATE_DATA < 1 )
  50. // for rope, locale static members
  51. #  include <rope>
  52. #  include <locale>
  53. # endif
  54.  
  55. # if defined (_STLP_UNIX)
  56. #  define _STLP_HAS_PERTHREAD_ALLOCATOR
  57. # include <stl/_pthread_alloc.h>
  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_WINCE)
  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. #ifdef _STLP_MSVC
  81. #pragma optimize("g",off)
  82. #endif 
  83.  
  84. _STLP_BEGIN_NAMESPACE
  85.  
  86. void _STLP_DECLSPEC _STLP_CALL __stl_throw_range_error(const char* __msg) { 
  87.   _STLP_THROW_MSG(range_error, __msg); 
  88. }
  89.  
  90. void _STLP_DECLSPEC _STLP_CALL __stl_throw_out_of_range(const char* __msg) { 
  91.   _STLP_THROW_MSG(out_of_range, __msg); 
  92. }
  93.  
  94. void _STLP_DECLSPEC _STLP_CALL __stl_throw_length_error(const char* __msg) { 
  95.   _STLP_THROW_MSG(length_error, __msg); 
  96. }
  97.  
  98. void _STLP_DECLSPEC _STLP_CALL __stl_throw_invalid_argument(const char* __msg) { 
  99.   _STLP_THROW_MSG(invalid_argument, __msg); 
  100. }
  101.  
  102. void _STLP_DECLSPEC _STLP_CALL __stl_throw_overflow_error(const char* __msg) { 
  103.   _STLP_THROW_MSG(overflow_error, __msg); 
  104. }
  105.  
  106. _STLP_DECLSPEC const char*  _STLP_CALL
  107. __get_c_string(const string& __str) { 
  108.   return __str.c_str(); 
  109. }
  110.  
  111.  
  112. # if defined (_STLP_NO_EXCEPTION_HEADER) || defined(_STLP_BROKEN_EXCEPTION_CLASS)
  113. exception::exception() _STLP_NOTHROW {}
  114. exception::~exception() _STLP_NOTHROW {}
  115. bad_exception::bad_exception() _STLP_NOTHROW {}
  116. bad_exception::~bad_exception() _STLP_NOTHROW {}
  117. const char* exception::what() const _STLP_NOTHROW {return "class exception";}
  118. const char* bad_exception::what() const _STLP_NOTHROW {return "class bad_exception";}
  119. # endif
  120.  
  121. # ifdef _STLP_OWN_STDEXCEPT
  122. __Named_exception::__Named_exception(const string& __str) {
  123.   strncpy(_M_name, __get_c_string(__str), _S_bufsize);
  124.   _M_name[_S_bufsize - 1] = '\0';
  125. }
  126.  
  127. const char* __Named_exception::what() const _STLP_NOTHROW_INHERENTLY { return _M_name; }
  128.  
  129. // boris : those are needed to force typeinfo nodes to be created in here only
  130. __Named_exception::~__Named_exception() _STLP_NOTHROW_INHERENTLY {}
  131.  
  132. logic_error::~logic_error() _STLP_NOTHROW_INHERENTLY {}
  133. runtime_error::~runtime_error() _STLP_NOTHROW_INHERENTLY {}
  134. domain_error::~domain_error() _STLP_NOTHROW_INHERENTLY {}
  135. invalid_argument::~invalid_argument() _STLP_NOTHROW_INHERENTLY {}
  136. length_error::~length_error() _STLP_NOTHROW_INHERENTLY {}
  137. out_of_range::~out_of_range() _STLP_NOTHROW_INHERENTLY {}
  138. range_error::~range_error() _STLP_NOTHROW_INHERENTLY {}
  139. overflow_error::~overflow_error() _STLP_NOTHROW_INHERENTLY {}
  140. underflow_error::~underflow_error() _STLP_NOTHROW_INHERENTLY {}
  141.  
  142. # endif
  143.  
  144. # ifdef  _STLP_NO_BAD_ALLOC
  145. const nothrow_t nothrow /* = {} */;
  146. # endif
  147.  
  148. # ifndef _STLP_NO_FORCE_INSTANTIATE
  149.  
  150. # if defined (_STLP_DEBUG) || defined (_STLP_ASSERTIONS)
  151. template struct _STLP_CLASS_DECLSPEC __stl_debug_engine<bool>;
  152. # endif
  153.  
  154. template class _STLP_CLASS_DECLSPEC __node_alloc<false,0>;
  155. template class _STLP_CLASS_DECLSPEC __node_alloc<true,0>;
  156. template class _STLP_CLASS_DECLSPEC __debug_alloc< __node_alloc<true,0> >;
  157. template class _STLP_CLASS_DECLSPEC __debug_alloc< __node_alloc<false,0> >;
  158. template class _STLP_CLASS_DECLSPEC __debug_alloc<__new_alloc>;
  159. #ifdef _STLP_HAS_PERTHREAD_ALLOCATOR
  160. template class _STLP_CLASS_DECLSPEC _Pthread_alloc<_MAX_BYTES>;
  161. template class _STLP_CLASS_DECLSPEC __debug_alloc<__pthread_alloc>;
  162. #endif
  163. template class _STLP_CLASS_DECLSPEC __malloc_alloc<0>;
  164.  
  165. # if defined (_STLP_THREADS) && ! defined ( _STLP_ATOMIC_EXCHANGE ) && (defined(_STLP_PTHREADS) || defined (_STLP_UITHREADS)  || defined (_STLP_OS2THREADS))
  166. template class _STLP_CLASS_DECLSPEC _Swap_lock_struct<0>;
  167. # endif
  168.  
  169. template class allocator<void*>;
  170. template class _STLP_alloc_proxy<void**, void*, allocator<void*> >;
  171. template class _Vector_base<void*,allocator<void*> >;
  172. # if defined (_STLP_DEBUG) && ! defined (__SUNPRO_CC)
  173. template class __WORKAROUND_DBG_RENAME(vector) <void*,allocator<void*> >;
  174. # endif
  175. template class __vector__<void*,allocator<void*> >;
  176.  
  177. template class _Rb_global<bool>;
  178. template class _List_global<bool>;
  179. template class _Sl_global<bool>;
  180. template class _Stl_prime<bool>;
  181. template class _LimG<bool>;
  182. template class _Bs_G<bool>;
  183.  
  184. template class _STLP_CLASS_DECLSPEC allocator<char>;
  185. template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<char *,char, allocator<char> >;
  186. template class _STLP_CLASS_DECLSPEC _String_base<char, allocator<char> >;
  187.  
  188. # if defined (_STLP_DEBUG) && ! defined (__SUNPRO_CC)
  189. template class _STLP_CLASS_DECLSPEC _Nondebug_string<char, char_traits<char>, allocator<char> >;
  190. # endif
  191.  
  192. template class basic_string<char, char_traits<char>, allocator<char> >;
  193. # endif
  194.  
  195. _STLP_END_NAMESPACE
  196.  
  197. # if defined (_WIN32) && defined (_STLP_USE_DECLSPEC) && ! defined (_STLP_USE_STATIC_LIB) && ! defined (_STLP_USE_STATICX_LIB)
  198. // stlportmt.cpp : Defines the entry point for the DLL application.
  199. //
  200. #define WIN32_LEAN_AND_MEAN
  201. #include <windows.h>
  202.  
  203. extern "C" {
  204.  
  205. BOOL APIENTRY DllMain( HANDLE hModule, 
  206.                        DWORD  ul_reason_for_call, 
  207.                        LPVOID lpReserved
  208.                      )
  209. {
  210.     switch (ul_reason_for_call)
  211.     {
  212.         case DLL_PROCESS_ATTACH:
  213.           DisableThreadLibraryCalls((HINSTANCE)hModule);
  214.         case DLL_THREAD_ATTACH:
  215.         case DLL_THREAD_DETACH:
  216.         case DLL_PROCESS_DETACH:
  217.             break;
  218.     }
  219.     return TRUE;
  220. }
  221.  
  222. } /* extern "C" */
  223.  
  224. _STLP_BEGIN_NAMESPACE
  225.  
  226. void force_link()
  227. {
  228.   float f;
  229.   f = numeric_limits<float>::infinity();
  230.   f = numeric_limits<float>::quiet_NaN();
  231.   f = numeric_limits<float>::signaling_NaN();
  232.   double d;
  233.   d = numeric_limits<double>::infinity();
  234.   d = numeric_limits<double>::quiet_NaN();
  235.   d = numeric_limits<double>::signaling_NaN();
  236. #ifndef _STLP_NO_LONG_DOUBLE
  237.   long double ld;
  238.   ld = numeric_limits<long double>::infinity();
  239.   ld = numeric_limits<long double>::quiet_NaN();
  240.   ld = numeric_limits<long double>::signaling_NaN();
  241. #endif
  242.   
  243.   set<int>::iterator iter;
  244.   // _M_increment; _M_decrement instantiation
  245.   ++iter;
  246.   --iter;
  247.   
  248.   // force bitset globals to be instantiated
  249.   unsigned char uc = _Bs_G<bool>::_S_bit_count[0];
  250.   uc += _Bs_G<bool>::_S_first_one[0];
  251. }
  252.  
  253. _STLP_END_NAMESPACE
  254.  
  255. # endif
  256.