epoc32/include/tools/stlport/stl/debug/_debug.c
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
     1.1 --- a/epoc32/include/tools/stlport/stl/debug/_debug.c	Wed Mar 31 12:27:01 2010 +0100
     1.2 +++ b/epoc32/include/tools/stlport/stl/debug/_debug.c	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -1,496 +1,639 @@
     1.4 -/*
     1.5 - * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     1.6 - *
     1.7 - * Copyright (c) 1997
     1.8 - * Moscow Center for SPARC Technology
     1.9 - *
    1.10 - * Copyright (c) 1999 
    1.11 - * Boris Fomitchev
    1.12 - *
    1.13 - * This material is provided "as is", with absolutely no warranty expressed
    1.14 - * or implied. Any use is at your own risk.
    1.15 - *
    1.16 - * Permission to use or copy this software for any purpose is hereby granted 
    1.17 - * without fee, provided the above notices are retained on all copies.
    1.18 - * Permission to modify the code and to distribute modified code is granted,
    1.19 - * provided the above notices are retained, and a notice that the code was
    1.20 - * modified is included with the above copyright notice.
    1.21 - *
    1.22 - */
    1.23 -
    1.24 -# ifndef _STLP_DEBUG_C
    1.25 -#  define  _STLP_DEBUG_C
    1.26 -
    1.27 -#if defined ( _STLP_DEBUG )
    1.28 -
    1.29 -# ifdef _STLP_THREADS
    1.30 -#  ifndef _STLP_NEED_MUTABLE 
    1.31 -#   define _STLP_ACQUIRE_LOCK(_Lock) _Lock._M_acquire_lock();
    1.32 -#   define _STLP_RELEASE_LOCK(_Lock) _Lock._M_release_lock();
    1.33 -#  else
    1.34 -#   define _STLP_ACQUIRE_LOCK(_Lock) ((_STLP_mutex&)_Lock)._M_acquire_lock();
    1.35 -#   define _STLP_RELEASE_LOCK(_Lock) ((_STLP_mutex&)_Lock)._M_release_lock();
    1.36 -#  endif /* _STLP_NEED_MUTABLE */
    1.37 -# else
    1.38 -#  define _STLP_ACQUIRE_LOCK(_Lock)
    1.39 -#  define _STLP_RELEASE_LOCK(_Lock)
    1.40 -# endif /* _STLP_THREADS */
    1.41 -
    1.42 -_STLP_BEGIN_NAMESPACE
    1.43 -
    1.44 -//==========================================================
    1.45 -//  global non-inline functions
    1.46 -//==========================================================
    1.47 -
    1.48 -// [ i1, i2)
    1.49 -template <class _Iterator>
    1.50 -inline bool  _STLP_CALL
    1.51 -__in_range_aux(const _Iterator& __it, const _Iterator& __first,
    1.52 -               const _Iterator& __last, const random_access_iterator_tag &) {
    1.53 -    return ( __it >= __first && 
    1.54 -             __it < __last);
    1.55 -}
    1.56 -
    1.57 -template <class _Iterator1, class _Iterator>
    1.58 -# if defined (_STLP_MSVC) && (_STLP_MSVC >= 1100)
    1.59 -inline bool _STLP_CALL  __in_range_aux(_Iterator1 __it, const _Iterator& __first,
    1.60 -# else
    1.61 -inline bool _STLP_CALL  __in_range_aux(const _Iterator1& __it, const _Iterator& __first,
    1.62 -# endif
    1.63 -                                       const _Iterator& __last, const forward_iterator_tag &) {
    1.64 -    _Iterator1 __i(__first);
    1.65 -    for (;  __i != __last && __i != __it; ++__i);
    1.66 -    return (__i!=__last);
    1.67 -}
    1.68 -
    1.69 -# if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
    1.70 -template <class _Iterator1, class _Iterator>
    1.71 -inline bool  _STLP_CALL
    1.72 -__in_range_aux(const _Iterator1& __it, const _Iterator& __first,
    1.73 -               const _Iterator& __last, const bidirectional_iterator_tag &) {
    1.74 -    _Iterator1 __i(__first);
    1.75 -    for (;  __i != __last && __i != __it; ++__i);
    1.76 -    return (__i !=__last);
    1.77 -}
    1.78 -# endif
    1.79 -
    1.80 -template <class _Iterator>
    1.81 -bool _STLP_CALL  __check_range(const _Iterator& __first, const _Iterator& __last) {
    1.82 -    _STLP_VERBOSE_RETURN(__valid_range(__first,__last), _StlMsg_INVALID_RANGE )
    1.83 -    return true;
    1.84 -}
    1.85 -
    1.86 -template <class _Iterator>
    1.87 -bool _STLP_CALL  __check_range(const _Iterator& __it, 
    1.88 -                               const _Iterator& __start, const _Iterator& __finish) {
    1.89 -    _STLP_VERBOSE_RETURN(__in_range(__it,__start, __finish), 
    1.90 -                         _StlMsg_NOT_IN_RANGE_1)
    1.91 -    return true;
    1.92 -}
    1.93 -
    1.94 -template <class _Iterator>
    1.95 -bool _STLP_CALL  __check_range(const _Iterator& __first, const _Iterator& __last, 
    1.96 -                               const _Iterator& __start, const _Iterator& __finish) {
    1.97 -    _STLP_VERBOSE_RETURN(__in_range(__first, __last, __start, __finish), 
    1.98 -                         _StlMsg_NOT_IN_RANGE_2)
    1.99 -    return true;
   1.100 -}
   1.101 -
   1.102 -//===============================================================
   1.103 -
   1.104 -template <class _Iterator>
   1.105 -void  _STLP_CALL __invalidate_range(const __owned_list* __base, 
   1.106 -                                    const _Iterator& __first,
   1.107 -                                    const _Iterator& __last)
   1.108 -{
   1.109 -    typedef _Iterator* _Safe_iterator_ptr;
   1.110 -    typedef __owned_link _L_type;
   1.111 -    _STLP_ACQUIRE_LOCK(__base->_M_lock)
   1.112 -    _L_type* __pos;
   1.113 -    _L_type* __prev;
   1.114 -
   1.115 -    for (__prev = (_L_type*)&__base->_M_node, __pos= (_L_type*)__prev->_M_next; 
   1.116 -         __pos!=0;) {	    
   1.117 -        if ((!(&__first == (_Iterator*)__pos || &__last == (_Iterator*)__pos))
   1.118 -            &&  __in_range_aux(
   1.119 -			       ((_Iterator*)__pos)->_M_iterator,
   1.120 -			       __first._M_iterator,
   1.121 -			       __last._M_iterator,
   1.122 -			       _STLP_ITERATOR_CATEGORY(__first, _Iterator))) {
   1.123 -	  __pos->_M_owner = 0;
   1.124 -	  __pos = (_L_type*) (__prev->_M_next = __pos->_M_next);
   1.125 -	}
   1.126 -	else {
   1.127 -	  __prev = __pos;
   1.128 -	  __pos=(_L_type*)__pos->_M_next;
   1.129 -	}
   1.130 -    }
   1.131 -    _STLP_RELEASE_LOCK(__base->_M_lock)    
   1.132 -}
   1.133 -
   1.134 -template <class _Iterator>
   1.135 -void  _STLP_CALL __invalidate_iterator(const __owned_list* __base, 
   1.136 -                                       const _Iterator& __it)
   1.137 -{
   1.138 -    typedef __owned_link   _L_type;
   1.139 -    _L_type*  __position, *__prev;
   1.140 -    _STLP_ACQUIRE_LOCK(__base->_M_lock)
   1.141 -    for (__prev = (_L_type*)&__base->_M_node, __position = (_L_type*)__prev->_M_next; 
   1.142 -         __position!= 0;) {
   1.143 -      // this requires safe iterators to be derived from __owned_link
   1.144 -       if ((__position != (_L_type*)&__it) && ((_Iterator*)__position)->_M_iterator ==__it._M_iterator) {
   1.145 -	    __position->_M_owner = 0;
   1.146 -	    __position = (_L_type*) (__prev->_M_next = __position->_M_next);
   1.147 -        }
   1.148 -       else {
   1.149 -	 __prev = __position;
   1.150 -	 __position=(_L_type*)__position->_M_next;
   1.151 -       }
   1.152 -    }
   1.153 -    _STLP_RELEASE_LOCK(__base->_M_lock)
   1.154 -}
   1.155 -
   1.156 -_STLP_END_NAMESPACE
   1.157 -
   1.158 -# endif /* _STLP_DEBUG */
   1.159 -
   1.160 -# if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION)
   1.161 -
   1.162 -// dwa 12/26/99 -- for abort
   1.163 -#  if defined (_STLP_USE_NEW_C_HEADERS)
   1.164 -#   include <cstdlib>
   1.165 -#  else
   1.166 -#   include <stdlib.h>
   1.167 -#  endif
   1.168 -
   1.169 -# if defined (_STLP_WIN32)
   1.170 -#  include <stl/_threads.h>
   1.171 -# endif
   1.172 -
   1.173 -//==========================================================
   1.174 -// .c section
   1.175 -//  owned_list non-inline methods and global functions 
   1.176 -//==========================================================
   1.177 -
   1.178 -#if defined ( _STLP_ASSERTIONS )
   1.179 -
   1.180 -_STLP_BEGIN_NAMESPACE
   1.181 -
   1.182 -# ifndef _STLP_STRING_LITERAL
   1.183 -# define _STLP_STRING_LITERAL(__x) __x
   1.184 -# endif
   1.185 -
   1.186 -# ifdef _STLP_WINCE
   1.187 -#  define _STLP_PERCENT_S "%hs" 
   1.188 -# else
   1.189 -#  define _STLP_PERCENT_S "%s" 
   1.190 -# endif
   1.191 -
   1.192 -# define _STLP_MESSAGE_TABLE_BODY = { \
   1.193 -_STLP_STRING_LITERAL("\n" _STLP_PERCENT_S "(%d): STL error: %s\n"), \
   1.194 -_STLP_STRING_LITERAL(_STLP_PERCENT_S "(%d): STL assertion failure : " _STLP_PERCENT_S "\n" _STLP_ASSERT_MSG_TRAILER), \
   1.195 -_STLP_STRING_LITERAL("\n" _STLP_PERCENT_S "(%d): STL error : " _STLP_PERCENT_S "\n" _STLP_PERCENT_S "(%d): STL assertion failure:     " _STLP_PERCENT_S " \n" _STLP_ASSERT_MSG_TRAILER), \
   1.196 -_STLP_STRING_LITERAL("Invalid argument to operation (see operation documentation)"),                  \
   1.197 -_STLP_STRING_LITERAL("Taking an iterator out of destroyed (or otherwise corrupted) container"),       \
   1.198 -_STLP_STRING_LITERAL("Trying to extract an object out from empty container"),\
   1.199 -_STLP_STRING_LITERAL("Past-the-end iterator could not be erased"),  \
   1.200 -_STLP_STRING_LITERAL("Index out of bounds"),  \
   1.201 -_STLP_STRING_LITERAL("Container doesn't own the iterator"),  \
   1.202 -_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) iterator used"),  \
   1.203 -_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) lefthand iterator in expression"),  \
   1.204 -_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) righthand iterator in expression"),  \
   1.205 -_STLP_STRING_LITERAL("Iterators used in expression are from different owners"),  \
   1.206 -_STLP_STRING_LITERAL("Iterator could not be dereferenced (past-the-end ?)"),  \
   1.207 -_STLP_STRING_LITERAL("Range [first,last) is invalid"),  \
   1.208 -_STLP_STRING_LITERAL("Iterator is not in range [first,last)"),  \
   1.209 -_STLP_STRING_LITERAL("Range [first,last) is not in range [start,finish)"),  \
   1.210 -_STLP_STRING_LITERAL("The advance would produce invalid iterator"),  \
   1.211 -_STLP_STRING_LITERAL("Iterator is singular (advanced beyond the bounds ?)"),  \
   1.212 -_STLP_STRING_LITERAL("Memory block deallocated twice"),  \
   1.213 -_STLP_STRING_LITERAL("Deallocating a block that was never allocated"),  \
   1.214 -_STLP_STRING_LITERAL("Deallocating a memory block allocated for another type"),  \
   1.215 -_STLP_STRING_LITERAL("Size of block passed to deallocate() doesn't match block size"),  \
   1.216 -_STLP_STRING_LITERAL("Pointer underrun - safety margin at front of memory block overwritten"),  \
   1.217 -_STLP_STRING_LITERAL("Pointer overrrun - safety margin at back of memory block overwritten"),   \
   1.218 -_STLP_STRING_LITERAL("Attempt to dereference null pointer returned by auto_ptr::get()"),   \
   1.219 -_STLP_STRING_LITERAL("Unknown problem") \
   1.220 -  }
   1.221 -
   1.222 -# if ( _STLP_STATIC_TEMPLATE_DATA > 0 )
   1.223 -#ifdef __SYMBIAN32__
   1.224 -template <class _Dummy>
   1.225 -const char* __stl_debug_engine<_Dummy>::_Message_table[_StlMsg_MAX];//  _STLP_MESSAGE_TABLE_BODY;
   1.226 -#else
   1.227 -template <class _Dummy>
   1.228 -const char* __stl_debug_engine<_Dummy>::_Message_table[_StlMsg_MAX]  _STLP_MESSAGE_TABLE_BODY;
   1.229 -#endif
   1.230 -
   1.231 -# else
   1.232 -__DECLARE_INSTANCE(const char*, __stl_debug_engine<bool>::_Message_table[_StlMsg_MAX],
   1.233 -		   _STLP_MESSAGE_TABLE_BODY);
   1.234 -
   1.235 -# endif
   1.236 -
   1.237 -# undef _STLP_STRING_LITERAL
   1.238 -# undef _STLP_PERCENT_S
   1.239 -_STLP_END_NAMESPACE
   1.240 -
   1.241 -// abort()
   1.242 -#    include <cstdlib>
   1.243 -
   1.244 -#  if !defined( _STLP_DEBUG_MESSAGE )
   1.245 -
   1.246 -#    include <cstdarg>
   1.247 -#    include <cstdio>
   1.248 -
   1.249 -_STLP_BEGIN_NAMESPACE
   1.250 -
   1.251 -template <class _Dummy>
   1.252 -void _STLP_CALL  
   1.253 -__stl_debug_engine<_Dummy>::_Message(const char * __format_str, ...)
   1.254 -{
   1.255 -	STLPORT_CSTD::va_list __args;
   1.256 -	va_start( __args, __format_str );
   1.257 -
   1.258 -# if defined (_STLP_WINCE)
   1.259 -	TCHAR __buffer[512];
   1.260 -	int _convert = strlen(__format_str) + 1;
   1.261 -	LPWSTR _lpw = (LPWSTR)alloca(_convert*sizeof(wchar_t));
   1.262 -	_lpw[0] = '\0';
   1.263 -	MultiByteToWideChar(GetACP(), 0, __format_str, -1, _lpw, _convert);
   1.264 -	wvsprintf(__buffer, _lpw, __args);
   1.265 -	//	wvsprintf(__buffer, __format_str, __args);
   1.266 -	_STLP_WINCE_TRACE(__buffer);
   1.267 -# elif defined (_STLP_WIN32) && ( defined(_STLP_MSVC) || defined (__ICL) || defined (__BORLANDC__)) && ! defined (__WINS__)
   1.268 -    char __buffer [4096];
   1.269 -    _vsnprintf(__buffer, sizeof(__buffer) / sizeof(char),
   1.270 -               __format_str, __args);
   1.271 -    OutputDebugStringA(__buffer);
   1.272 -# elif defined (__amigaos__)
   1.273 -    STLPORT_CSTD::vfprintf(stderr, __format_str, (char *)__args);
   1.274 -# else
   1.275 -    STLPORT_CSTD::vfprintf(stderr, __format_str, __args);
   1.276 -# endif /* WINCE */
   1.277 -
   1.278 -# ifdef _STLP_DEBUG_MESSAGE_POST
   1.279 -	_STLP_DEBUG_MESSAGE_POST
   1.280 -# endif
   1.281 -
   1.282 -    va_end(__args);
   1.283 -
   1.284 -}
   1.285 -
   1.286 -_STLP_END_NAMESPACE
   1.287 -
   1.288 -#  endif /* _STLP_DEBUG_MESSAGE */
   1.289 -
   1.290 -
   1.291 -_STLP_BEGIN_NAMESPACE
   1.292 -
   1.293 -
   1.294 -template <class _Dummy>
   1.295 -void _STLP_CALL  
   1.296 -__stl_debug_engine<_Dummy>::_IndexedError(int __error_ind, const char* __f, int __l)
   1.297 -{
   1.298 -  __stl_debug_message(_Message_table[_StlFormat_ERROR_RETURN], 
   1.299 -		      __f, __l, _Message_table[__error_ind]);
   1.300 -}
   1.301 -
   1.302 -template <class _Dummy>
   1.303 -void _STLP_CALL  
   1.304 -__stl_debug_engine<_Dummy>::_VerboseAssert(const char* __expr, int __error_ind, const char* __f, int __l)
   1.305 -{
   1.306 -  __stl_debug_message(_Message_table[_StlFormat_VERBOSE_ASSERTION_FAILURE],
   1.307 -		      __f, __l, _Message_table[__error_ind], __f, __l, __expr);
   1.308 -  __stl_debug_terminate();
   1.309 -}
   1.310 -
   1.311 -template <class _Dummy>
   1.312 -void _STLP_CALL 
   1.313 -__stl_debug_engine<_Dummy>::_Assert(const char* __expr, const char* __f, int __l)
   1.314 -{
   1.315 -  __stl_debug_message(_Message_table[_StlFormat_ASSERTION_FAILURE],__f, __l, __expr);
   1.316 -  __stl_debug_terminate();
   1.317 -}
   1.318 -
   1.319 -// if exceptions are present, sends unique exception
   1.320 -// if not, calls abort() to terminate
   1.321 -template <class _Dummy>
   1.322 -void _STLP_CALL 
   1.323 -__stl_debug_engine<_Dummy>::_Terminate()
   1.324 -{
   1.325 -# ifdef _STLP_USE_NAMESPACES
   1.326 -  using namespace _STLP_STD;
   1.327 -# endif
   1.328 -# if defined (_STLP_USE_EXCEPTIONS) && ! defined (_STLP_NO_DEBUG_EXCEPTIONS)
   1.329 -  throw __stl_debug_exception();
   1.330 -# else
   1.331 -  _STLP_ABORT();
   1.332 -# endif
   1.333 -}
   1.334 -
   1.335 -_STLP_END_NAMESPACE
   1.336 -
   1.337 -# endif /* _STLP_ASSERTIONS */
   1.338 -
   1.339 -#ifdef _STLP_DEBUG
   1.340 -
   1.341 -_STLP_BEGIN_NAMESPACE
   1.342 -
   1.343 -//==========================================================
   1.344 -//  owned_list non-inline methods 
   1.345 -//==========================================================
   1.346 -
   1.347 -template <class _Dummy>
   1.348 -void  _STLP_CALL
   1.349 -__stl_debug_engine<_Dummy>::_Invalidate_all(__owned_list* __l) {
   1.350 -  _STLP_ACQUIRE_LOCK(__l->_M_lock);
   1.351 -  _Stamp_all(__l, 0);
   1.352 -  __l->_M_node._M_next =0;
   1.353 -  _STLP_RELEASE_LOCK(__l->_M_lock);
   1.354 -}
   1.355 -
   1.356 -// boris : this is unasafe routine; should be used from within critical section only !
   1.357 -template <class _Dummy>
   1.358 -void  _STLP_CALL
   1.359 -__stl_debug_engine<_Dummy>::_Stamp_all(__owned_list* __l, __owned_list* __o) {
   1.360 -  // crucial
   1.361 -  if (__l->_M_node._M_owner) {
   1.362 -    for (__owned_link*  __position = (__owned_link*)__l->_M_node._M_next; 
   1.363 -	 __position != 0; __position= (__owned_link*)__position->_M_next) {
   1.364 -      _STLP_ASSERT(__position->_Owner()== __l)
   1.365 -      __position->_M_owner=__o;
   1.366 -    }
   1.367 -  }
   1.368 -}
   1.369 -
   1.370 -template <class _Dummy>
   1.371 -void  _STLP_CALL
   1.372 -__stl_debug_engine<_Dummy>::_Verify(const __owned_list* __l) {
   1.373 -  _STLP_ACQUIRE_LOCK(__l->_M_lock);
   1.374 -  if (__l) {
   1.375 -    _STLP_ASSERT(__l->_M_node._Owner() != 0)
   1.376 -    for (__owned_link* __position = (__owned_link*)__l->_M_node._M_next; 
   1.377 -         __position != 0; __position= (__owned_link*)__position->_M_next) {
   1.378 -      _STLP_ASSERT(__position->_Owner()== __l)
   1.379 -    }
   1.380 -  }
   1.381 -  _STLP_RELEASE_LOCK(__l->_M_lock);
   1.382 -}
   1.383 -
   1.384 -template <class _Dummy>
   1.385 -void _STLP_CALL  
   1.386 -__stl_debug_engine<_Dummy>::_Swap_owners(__owned_list& __x, __owned_list& __y) {
   1.387 -
   1.388 -  //  according to the standard : --no swap() function invalidates any references, 
   1.389 -  //  pointers,  or  iterators referring to the elements of the containers being swapped.
   1.390 -
   1.391 -  __owned_link* __tmp;
   1.392 -
   1.393 -  // boris : there is a deadlock potential situation here if we lock two containers sequentially.
   1.394 -  // As user is supposed to provide its own synchronization around swap() ( it is unsafe to do any container/iterator access
   1.395 -  // in parallel with swap()), we just do not use any locking at all -- that behaviour is closer to non-debug version
   1.396 -
   1.397 -  __tmp = __x._M_node._M_next;
   1.398 -
   1.399 -  _Stamp_all(&__x, &__y);
   1.400 -  _Stamp_all(&__y, &__x);
   1.401 -
   1.402 -  __x._M_node._M_next = __y._M_node._M_next;
   1.403 -  __y._M_node._M_next = __tmp;  
   1.404 -
   1.405 -}
   1.406 -
   1.407 -template <class _Dummy>
   1.408 -void _STLP_CALL 
   1.409 -__stl_debug_engine<_Dummy>::_M_detach(__owned_list* __l, __owned_link* __c_node) {
   1.410 -  if (__l  != 0) {
   1.411 -
   1.412 -    _STLP_VERBOSE_ASSERT(__l->_Owner()!=0, _StlMsg_INVALID_CONTAINER)
   1.413 -
   1.414 -    _STLP_ACQUIRE_LOCK(__l->_M_lock)
   1.415 -      // boris : re-test the condition in case someone else already deleted us
   1.416 -      if(__c_node->_M_owner != 0) {
   1.417 -        __owned_link* __prev, *__next;
   1.418 -        
   1.419 -        for (__prev = &__l->_M_node; (__next = __prev->_M_next) != __c_node; 
   1.420 -             __prev = __next) {
   1.421 -          _STLP_ASSERT(__next && __next->_Owner() == __l)
   1.422 -            }
   1.423 -        
   1.424 -        __prev->_M_next = __c_node->_M_next;
   1.425 -        __c_node->_M_owner=0;
   1.426 -      }
   1.427 -    _STLP_RELEASE_LOCK(__l->_M_lock)
   1.428 -  }
   1.429 -}
   1.430 -
   1.431 -template <class _Dummy>
   1.432 -void _STLP_CALL 
   1.433 -__stl_debug_engine<_Dummy>::_M_attach(__owned_list* __l, __owned_link* __c_node) {
   1.434 -  if (__l ==0) {
   1.435 -    (__c_node)->_M_owner = 0;    
   1.436 -  } else {
   1.437 -    _STLP_VERBOSE_ASSERT(__l->_Owner()!=0, _StlMsg_INVALID_CONTAINER)
   1.438 -    _STLP_ACQUIRE_LOCK(__l->_M_lock)
   1.439 -    __c_node->_M_owner = __l;
   1.440 -    __c_node->_M_next = __l->_M_node._M_next;
   1.441 -    __l->_M_node._M_next = __c_node;
   1.442 -    _STLP_RELEASE_LOCK(__l->_M_lock)
   1.443 -  }
   1.444 -}
   1.445 -
   1.446 -
   1.447 -template <class _Dummy>
   1.448 -void* _STLP_CALL
   1.449 -__stl_debug_engine<_Dummy>::_Get_container_ptr(const __owned_link* __l) {
   1.450 -  const __owned_list* __owner    = __l->_Owner();
   1.451 -  _STLP_VERBOSE_RETURN_0(__owner != 0, _StlMsg_INVALID_ITERATOR)
   1.452 -  void* __ret = __CONST_CAST(void*,__owner->_Owner());
   1.453 -  _STLP_VERBOSE_RETURN_0(__ret !=0, _StlMsg_INVALID_CONTAINER)
   1.454 -  return __ret;
   1.455 -}
   1.456 -
   1.457 -template <class _Dummy>
   1.458 -bool _STLP_CALL
   1.459 -__stl_debug_engine<_Dummy>::_Check_same_owner( const __owned_link& __i1, 
   1.460 -                                               const __owned_link& __i2)
   1.461 -{
   1.462 -  _STLP_VERBOSE_RETURN(__i1._Valid(), _StlMsg_INVALID_LEFTHAND_ITERATOR)
   1.463 -  _STLP_VERBOSE_RETURN(__i2._Valid(), _StlMsg_INVALID_RIGHTHAND_ITERATOR)
   1.464 -  _STLP_VERBOSE_RETURN((__i1._Owner()==__i2._Owner()), _StlMsg_DIFFERENT_OWNERS)
   1.465 -  return true;
   1.466 -}
   1.467 -
   1.468 -template <class _Dummy>
   1.469 -bool  _STLP_CALL
   1.470 -__stl_debug_engine<_Dummy>::_Check_same_owner_or_null( const __owned_link& __i1, 
   1.471 -						       const __owned_link& __i2)
   1.472 -{
   1.473 -  _STLP_VERBOSE_RETURN(__i1._Owner()==__i2._Owner(), _StlMsg_DIFFERENT_OWNERS)
   1.474 -  return true;
   1.475 -}
   1.476 -
   1.477 -template <class _Dummy>
   1.478 -bool _STLP_CALL
   1.479 -__stl_debug_engine<_Dummy>::_Check_if_owner( const __owned_list * __l, const __owned_link& __it)
   1.480 -{
   1.481 -  const __owned_list* __owner_ptr = __it._Owner();
   1.482 -  _STLP_VERBOSE_RETURN(__owner_ptr!=0, _StlMsg_INVALID_ITERATOR)
   1.483 -  _STLP_VERBOSE_RETURN(__l==__owner_ptr, _StlMsg_NOT_OWNER)
   1.484 -  return true;
   1.485 -}
   1.486 -
   1.487 -
   1.488 -_STLP_END_NAMESPACE
   1.489 -
   1.490 -#endif /* _STLP_DEBUG */
   1.491 -
   1.492 -#endif /* if defined (EXPOSE_GLOBALS_IMPLEMENTATION) */
   1.493 -
   1.494 -#endif /* header guard */
   1.495 -
   1.496 -// Local Variables:
   1.497 -// mode:C++
   1.498 -// End:
   1.499 -
   1.500 +/*
   1.501 + *
   1.502 + * Copyright (c) 1997
   1.503 + * Moscow Center for SPARC Technology
   1.504 + *
   1.505 + * Copyright (c) 1999
   1.506 + * Boris Fomitchev
   1.507 + *
   1.508 + * This material is provided "as is", with absolutely no warranty expressed
   1.509 + * or implied. Any use is at your own risk.
   1.510 + *
   1.511 + * Permission to use or copy this software for any purpose is hereby granted
   1.512 + * without fee, provided the above notices are retained on all copies.
   1.513 + * Permission to modify the code and to distribute modified code is granted,
   1.514 + * provided the above notices are retained, and a notice that the code was
   1.515 + * modified is included with the above copyright notice.
   1.516 + *
   1.517 + */
   1.518 +
   1.519 +#ifndef _STLP_DEBUG_C
   1.520 +#define _STLP_DEBUG_C
   1.521 +
   1.522 +#if defined (_STLP_DEBUG)
   1.523 +#if defined (_STLP_THREADS)
   1.524 +#  if !defined (_STLP_NEED_MUTABLE)
   1.525 +#    define _STLP_ACQUIRE_LOCK(_Lock) _Lock._M_acquire_lock();
   1.526 +#    define _STLP_RELEASE_LOCK(_Lock) _Lock._M_release_lock();
   1.527 +#  else
   1.528 +#    define _STLP_ACQUIRE_LOCK(_Lock) ((_STLP_mutex&)_Lock)._M_acquire_lock();
   1.529 +#    define _STLP_RELEASE_LOCK(_Lock) ((_STLP_mutex&)_Lock)._M_release_lock();
   1.530 +#  endif /* _STLP_NEED_MUTABLE */
   1.531 +#else
   1.532 +#  define _STLP_ACQUIRE_LOCK(_Lock)
   1.533 +#  define _STLP_RELEASE_LOCK(_Lock)
   1.534 +#endif /* _STLP_THREADS */
   1.535 +
   1.536 +_STLP_BEGIN_NAMESPACE
   1.537 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.538 +
   1.539 +//==========================================================
   1.540 +//  global non-inline functions
   1.541 +//==========================================================
   1.542 +// [ i1, i2)
   1.543 +#if !defined (__DMC__)
   1.544 +template <class _Iterator>
   1.545 +inline bool  _STLP_CALL
   1.546 +__in_range_aux(const _Iterator& __it, const _Iterator& __first,
   1.547 +               const _Iterator& __last, const random_access_iterator_tag &) {
   1.548 +    return ( __it >= __first &&
   1.549 +             __it < __last);
   1.550 +}
   1.551 +#endif
   1.552 +
   1.553 +template <class _Iterator1, class _Iterator>
   1.554 +#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1100)
   1.555 +inline bool _STLP_CALL  __in_range_aux(_Iterator1 __it, const _Iterator& __first,
   1.556 +#else
   1.557 +inline bool _STLP_CALL  __in_range_aux(const _Iterator1& __it, const _Iterator& __first,
   1.558 +#endif
   1.559 +                                       const _Iterator& __last, const forward_iterator_tag &) {
   1.560 +  _Iterator1 __i(__first);
   1.561 +  for (;  __i != __last && __i != __it; ++__i);
   1.562 +  return (__i != __last);
   1.563 +}
   1.564 +
   1.565 +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
   1.566 +template <class _Iterator1, class _Iterator>
   1.567 +inline bool  _STLP_CALL
   1.568 +__in_range_aux(const _Iterator1& __it, const _Iterator& __first,
   1.569 +               const _Iterator& __last, const bidirectional_iterator_tag &) {
   1.570 +  _Iterator1 __i(__first);
   1.571 +  for (;  __i != __last && __i != __it; ++__i);
   1.572 +  return (__i != __last);
   1.573 +}
   1.574 +#endif
   1.575 +
   1.576 +template <class _Iterator>
   1.577 +bool _STLP_CALL __check_range_aux(const _Iterator& __first, const _Iterator& __last,
   1.578 +                                  const __false_type& /*_IsIntegral*/) {
   1.579 +  _STLP_VERBOSE_RETURN(__valid_range(__first,__last), _StlMsg_INVALID_RANGE )
   1.580 +  return true;
   1.581 +}
   1.582 +
   1.583 +template <class _Integral>
   1.584 +bool _STLP_CALL __check_range_aux(_Integral /*__first*/, _Integral /*__last*/,
   1.585 +                                  const __true_type& /*_IsIntegral*/)
   1.586 +{ return true; }
   1.587 +
   1.588 +template <class _Iterator>
   1.589 +bool _STLP_CALL  __check_range(const _Iterator& __first, const _Iterator& __last) {
   1.590 +  typedef typename _IsIntegral<_Iterator>::_Ret _Integral;
   1.591 +  return __check_range_aux(__first, __last, _Integral());
   1.592 +}
   1.593 +
   1.594 +template <class _Iterator>
   1.595 +bool _STLP_CALL  __check_range(const _Iterator& __it,
   1.596 +                               const _Iterator& __start, const _Iterator& __finish) {
   1.597 +  _STLP_VERBOSE_RETURN(__in_range(__it, __start, __finish),
   1.598 +                       _StlMsg_NOT_IN_RANGE_1)
   1.599 +  return true;
   1.600 +}
   1.601 +
   1.602 +template <class _Iterator>
   1.603 +bool _STLP_CALL  __check_range(const _Iterator& __first, const _Iterator& __last,
   1.604 +                               const _Iterator& __start, const _Iterator& __finish) {
   1.605 +  _STLP_VERBOSE_RETURN(__in_range(__first, __last, __start, __finish),
   1.606 +                       _StlMsg_NOT_IN_RANGE_2)
   1.607 +  return true;
   1.608 +}
   1.609 +
   1.610 +template <class _Tp>
   1.611 +bool _STLP_CALL __check_ptr_range(const _Tp* __first, const _Tp* __last) {
   1.612 +  _STLP_VERBOSE_RETURN((__first != 0 || __last == 0), _StlMsg_INVALID_ARGUMENT)
   1.613 +  _STLP_VERBOSE_RETURN(__valid_range(__first, __last, random_access_iterator_tag()),
   1.614 +                       _StlMsg_INVALID_RANGE)
   1.615 +  return true;
   1.616 +}
   1.617 +
   1.618 +//===============================================================
   1.619 +template <class _Iterator>
   1.620 +void _STLP_CALL __invalidate_range(const __owned_list* __base,
   1.621 +                                   const _Iterator& __first,
   1.622 +                                   const _Iterator& __last) {
   1.623 +  typedef __owned_link _L_type;
   1.624 +  _STLP_ACQUIRE_LOCK(__base->_M_lock)
   1.625 +  _L_type* __prev = __CONST_CAST(_L_type*, &__base->_M_node);
   1.626 +  _L_type* __pos = __prev->_M_next;
   1.627 +
   1.628 +  while (__pos != 0) {
   1.629 +    if (!(&__first == __STATIC_CAST(_Iterator*, __pos) || &__last == __STATIC_CAST(_Iterator*, __pos)) &&
   1.630 +        __in_range_aux(__STATIC_CAST(_Iterator*, __pos)->_M_iterator,
   1.631 +                       __first._M_iterator, __last._M_iterator,
   1.632 +                       _STLP_ITERATOR_CATEGORY(__first, _Iterator))) {
   1.633 +      __pos->_M_owner = 0;
   1.634 +      __prev->_M_next = __pos->_M_next;
   1.635 +    }
   1.636 +    else {
   1.637 +      __prev = __pos;
   1.638 +    }
   1.639 +    __pos = __prev->_M_next;
   1.640 +  }
   1.641 +  _STLP_RELEASE_LOCK(__base->_M_lock)
   1.642 +}
   1.643 +
   1.644 +template <class _Iterator>
   1.645 +void _STLP_CALL __invalidate_iterator(const __owned_list* __base,
   1.646 +                                      const _Iterator& __it) {
   1.647 +  typedef __owned_link   _L_type;
   1.648 +  _STLP_ACQUIRE_LOCK(__base->_M_lock)
   1.649 +  _L_type* __prev = __CONST_CAST(_L_type*, &__base->_M_node);
   1.650 +  _L_type* __pos = __prev->_M_next;
   1.651 +  while (__pos != 0) {
   1.652 +    // this requires safe iterators to be derived from __owned_link
   1.653 +    if ((__pos != __STATIC_CAST(const _L_type*, &__it)) &&
   1.654 +        (__STATIC_CAST(_Iterator*, __pos)->_M_iterator == __it._M_iterator)) {
   1.655 +      __pos->_M_owner = 0;
   1.656 +      __prev->_M_next = __pos->_M_next;
   1.657 +    }
   1.658 +    else {
   1.659 +      __prev = __pos;
   1.660 +    }
   1.661 +    __pos = __prev->_M_next;
   1.662 +  }
   1.663 +  _STLP_RELEASE_LOCK(__base->_M_lock)
   1.664 +}
   1.665 +
   1.666 +template <class _Iterator>
   1.667 +void _STLP_CALL  __change_range_owner(const _Iterator& __first,
   1.668 +                                      const _Iterator& __last,
   1.669 +                                      const __owned_list* __dst) {
   1.670 +  if (__first._Owner() == __dst)
   1.671 +    return;
   1.672 +
   1.673 +  typedef __owned_link _L_type;
   1.674 +  // Check __stl_debug_engine<_Dummy>::_Swap_owners comments to see why there is no lock here
   1.675 +  //_STLP_ACQUIRE_LOCK(__base->_M_lock)
   1.676 +  __owned_list *__base = __CONST_CAST(__owned_list*, __first._Owner());
   1.677 +  _L_type* __src_prev = &__base->_M_node;
   1.678 +  _L_type* __pos = __src_prev->_M_next;
   1.679 +  _L_type* __dst_prev = __CONST_CAST(_L_type*, &__dst->_M_node);
   1.680 +
   1.681 +  while (__pos != 0) {
   1.682 +    if (!(&__first == __STATIC_CAST(_Iterator*, __pos) || &__last == __STATIC_CAST(_Iterator*, __pos)) &&
   1.683 +        __in_range_aux(__STATIC_CAST(_Iterator*, __pos)->_M_iterator,
   1.684 +                       __first._M_iterator, __last._M_iterator,
   1.685 +                       _STLP_ITERATOR_CATEGORY(__first, _Iterator))) {
   1.686 +      __pos->_M_owner = __CONST_CAST(__owned_list*, __dst);
   1.687 +      //remove __pos from __base:
   1.688 +      __src_prev->_M_next = __pos->_M_next;
   1.689 +      //add __pos to __dst:
   1.690 +      __pos->_M_next = __dst_prev->_M_next;
   1.691 +      __dst_prev->_M_next = __pos;
   1.692 +    }
   1.693 +    else {
   1.694 +      __src_prev = __pos;
   1.695 +    }
   1.696 +    __pos = __src_prev->_M_next;
   1.697 +  }
   1.698 +  //_STLP_RELEASE_LOCK(__base->_M_lock)
   1.699 +}
   1.700 +
   1.701 +template <class _Iterator>
   1.702 +void _STLP_CALL __change_ite_owner(const _Iterator& __it,
   1.703 +                                   const __owned_list* __dst) {
   1.704 +  if (__it._Owner() == __dst)
   1.705 +    return;
   1.706 +
   1.707 +  typedef __owned_link _L_type;
   1.708 +  // Check __stl_debug_engine<_Dummy>::_Swap_owners comments to see why there is no lock here
   1.709 +  //_STLP_ACQUIRE_LOCK(__base->_M_lock)
   1.710 +  __owned_list *__base = __CONST_CAST(__owned_list*, __it._Owner());
   1.711 +  _L_type* __prev = &__base->_M_node;
   1.712 +  _L_type* __pos = __prev->_M_next;
   1.713 +  _L_type* __dst_prev = __CONST_CAST(_L_type*, &__dst->_M_node);
   1.714 +
   1.715 +  while (__pos != 0) {
   1.716 +    // this requires safe iterators to be derived from __owned_link
   1.717 +    if ((__pos != __STATIC_CAST(const _L_type*, &__it)) &&
   1.718 +        (__STATIC_CAST(_Iterator*, __pos)->_M_iterator == __it._M_iterator)) {
   1.719 +      __pos->_M_owner = __CONST_CAST(__owned_list*, __dst);
   1.720 +      //remove __pos from __base:
   1.721 +      __prev->_M_next = __pos->_M_next;
   1.722 +      //add __pos to __dst:
   1.723 +      __pos->_M_next = __dst_prev->_M_next;
   1.724 +      __dst_prev->_M_next = __pos;
   1.725 +    }
   1.726 +    else {
   1.727 +      __prev = __pos;
   1.728 +    }
   1.729 +    __pos = __prev->_M_next;
   1.730 +  }
   1.731 +  //_STLP_RELEASE_LOCK(__base->_M_lock)
   1.732 +}
   1.733 +
   1.734 +_STLP_MOVE_TO_STD_NAMESPACE
   1.735 +_STLP_END_NAMESPACE
   1.736 +
   1.737 +#endif /* _STLP_DEBUG */
   1.738 +
   1.739 +#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION)
   1.740 +
   1.741 +#  ifndef _STLP_INTERNAL_CSTDLIB
   1.742 +#    include <stl/_cstdlib.h>
   1.743 +#  endif
   1.744 +
   1.745 +//==========================================================
   1.746 +// .c section
   1.747 +//  owned_list non-inline methods and global functions
   1.748 +//==========================================================
   1.749 +
   1.750 +#  if defined (_STLP_ASSERTIONS)
   1.751 +
   1.752 +_STLP_BEGIN_NAMESPACE
   1.753 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.754 +
   1.755 +#    if !defined (_STLP_STRING_LITERAL)
   1.756 +#      define _STLP_STRING_LITERAL(__x) __x
   1.757 +#    endif
   1.758 +
   1.759 +#    if defined (_STLP_USE_WIDE_INTERFACE)
   1.760 +// note: WinCE needs this to format single-byte strings in __stl_debug_engine::_Message
   1.761 +#      define _STLP_PERCENT_S "%hs"
   1.762 +#    else
   1.763 +#      define _STLP_PERCENT_S "%s"
   1.764 +#    endif /* _STLP_USE_WIDE_INTERFACE */
   1.765 +
   1.766 +#    define _STLP_MESSAGE_TABLE_BODY = { \
   1.767 +_STLP_STRING_LITERAL("\n" _STLP_PERCENT_S "(%d): STL error: " _STLP_PERCENT_S "\n"), \
   1.768 +_STLP_STRING_LITERAL(_STLP_PERCENT_S "(%d): STL assertion failure : " _STLP_PERCENT_S "\n" _STLP_ASSERT_MSG_TRAILER), \
   1.769 +_STLP_STRING_LITERAL("\n" _STLP_PERCENT_S "(%d): STL error : " _STLP_PERCENT_S "\n" _STLP_PERCENT_S "(%d): STL assertion failure:     " _STLP_PERCENT_S " \n" _STLP_ASSERT_MSG_TRAILER), \
   1.770 +_STLP_STRING_LITERAL("Invalid argument to operation (see operation documentation)"),                  \
   1.771 +_STLP_STRING_LITERAL("Taking an iterator out of destroyed (or otherwise corrupted) container"),       \
   1.772 +_STLP_STRING_LITERAL("Trying to extract an object out from empty container"),\
   1.773 +_STLP_STRING_LITERAL("Past-the-end iterator could not be erased"),  \
   1.774 +_STLP_STRING_LITERAL("Index out of bounds"),  \
   1.775 +_STLP_STRING_LITERAL("Container doesn't own the iterator"),  \
   1.776 +_STLP_STRING_LITERAL("Container is owner of the iterator, but should not"),  \
   1.777 +_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) iterator used"),  \
   1.778 +_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) lefthand iterator in expression"),  \
   1.779 +_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) righthand iterator in expression"),  \
   1.780 +_STLP_STRING_LITERAL("Iterators used in expression are from different owners"),  \
   1.781 +_STLP_STRING_LITERAL("Iterator could not be dereferenced (past-the-end ?)"),  \
   1.782 +_STLP_STRING_LITERAL("Range [first,last) is invalid"),  \
   1.783 +_STLP_STRING_LITERAL("Iterator is not in range [first,last)"),  \
   1.784 +_STLP_STRING_LITERAL("Range [first,last) is not in range [start,finish)"),  \
   1.785 +_STLP_STRING_LITERAL("The advance would produce invalid iterator"),  \
   1.786 +_STLP_STRING_LITERAL("Iterator is singular (advanced beyond the bounds ?)"),  \
   1.787 +_STLP_STRING_LITERAL("Invalid strict weak ordering predicate, if pred(a, b) then we should have !pred(b, a)"), \
   1.788 +_STLP_STRING_LITERAL("Invalid equivalent predicate, if pred(a, b) then we should have pred(b, a)"), \
   1.789 +_STLP_STRING_LITERAL("Memory block deallocated twice"),  \
   1.790 +_STLP_STRING_LITERAL("Deallocating a block that was never allocated"),  \
   1.791 +_STLP_STRING_LITERAL("Deallocating a memory block allocated for another type"),  \
   1.792 +_STLP_STRING_LITERAL("Size of block passed to deallocate() doesn't match block size"),  \
   1.793 +_STLP_STRING_LITERAL("Pointer underrun - safety margin at front of memory block overwritten"),  \
   1.794 +_STLP_STRING_LITERAL("Pointer overrrun - safety margin at back of memory block overwritten"),   \
   1.795 +_STLP_STRING_LITERAL("Attempt to dereference null pointer returned by auto_ptr::get()"),   \
   1.796 +_STLP_STRING_LITERAL("Memory allocation function returned a wrongly align memory block"),   \
   1.797 +_STLP_STRING_LITERAL("Unknown problem") \
   1.798 +  }
   1.799 +
   1.800 +#    if (_STLP_STATIC_TEMPLATE_DATA > 0)
   1.801 +template <class _Dummy>
   1.802 +const char* __stl_debug_engine<_Dummy>::_Message_table[_StlMsg_MAX]  _STLP_MESSAGE_TABLE_BODY;
   1.803 +
   1.804 +#      if (defined (__CYGWIN__) || defined (__MINGW32__)) && \
   1.805 +           defined (_STLP_USE_DYNAMIC_LIB) && !defined (__BUILDING_STLPORT)
   1.806 +/*
   1.807 + * Under cygwin, when STLport is used as a shared library, the id needs
   1.808 + * to be specified as imported otherwise they will be duplicated in the
   1.809 + * calling executable.
   1.810 + */
   1.811 +_STLP_TEMPLATE_NULL
   1.812 +_STLP_DECLSPEC const char* __stl_debug_engine<bool>::_Message_table[_StlMsg_MAX];
   1.813 +#      endif
   1.814 +
   1.815 +#    else
   1.816 +__DECLARE_INSTANCE(const char*, __stl_debug_engine<bool>::_Message_table[_StlMsg_MAX],
   1.817 +                   _STLP_MESSAGE_TABLE_BODY);
   1.818 +#    endif
   1.819 +
   1.820 +#    undef _STLP_STRING_LITERAL
   1.821 +#    undef _STLP_PERCENT_S
   1.822 +
   1.823 +_STLP_MOVE_TO_STD_NAMESPACE
   1.824 +_STLP_END_NAMESPACE
   1.825 +
   1.826 +// abort()
   1.827 +#  ifndef _STLP_INTERNAL_CSTDLIB
   1.828 +#    include <stl/_cstdlib.h>
   1.829 +#  endif
   1.830 +
   1.831 +#  if !defined (_STLP_DEBUG_MESSAGE)
   1.832 +#    ifndef _STLP_INTERNAL_CSTDARG
   1.833 +#      include <stl/_cstdarg.h>
   1.834 +#    endif
   1.835 +#    ifndef _STLP_INTERNAL_CSTDIO
   1.836 +#      include <stl/_cstdio.h>
   1.837 +#    endif
   1.838 +#    if defined (_STLP_DEBUG_MODE_THROWS) && !defined (_STLP_RANGE_ERRORS_H)
   1.839 +#      include <stl/_range_errors.h>
   1.840 +#    endif
   1.841 +
   1.842 +_STLP_BEGIN_NAMESPACE
   1.843 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.844 +
   1.845 +template <class _Dummy>
   1.846 +void _STLP_CALL
   1.847 +__stl_debug_engine<_Dummy>::_Message(const char * __format_str, ...) {
   1.848 +  STLPORT_CSTD::va_list __args;
   1.849 +  va_start( __args, __format_str );
   1.850 +
   1.851 +#      if !defined (_STLP_DEBUG_MODE_THROWS)
   1.852 +#        if defined (_STLP_USE_WIDE_INTERFACE)
   1.853 +  TCHAR __buffer[512];
   1.854 +  int _convert = strlen(__format_str) + 1;
   1.855 +  LPWSTR _lpw = (LPWSTR)alloca(_convert * sizeof(wchar_t));
   1.856 +  _lpw[0] = '\0';
   1.857 +  MultiByteToWideChar(GetACP(), 0, __format_str, -1, _lpw, _convert);
   1.858 +  wvsprintf(__buffer, _lpw, __args);
   1.859 +  _STLP_WINCE_TRACE(__buffer);
   1.860 +#        elif defined (_STLP_WIN32) && (defined(_STLP_MSVC) || defined (__ICL))
   1.861 +  char __buffer [4096];
   1.862 +
   1.863 +#          if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
   1.864 +  vsnprintf(__buffer, _STLP_ARRAY_SIZE(__buffer), __format_str, __args);
   1.865 +#          else
   1.866 +  vsnprintf_s(__buffer, _STLP_ARRAY_SIZE(__buffer), _TRUNCATE, __format_str, __args);
   1.867 +#          endif
   1.868 +
   1.869 +  OutputDebugStringA(__buffer);
   1.870 +
   1.871 +#        elif defined (__amigaos__)
   1.872 +  STLPORT_CSTD::vfprintf(stderr, __format_str, (char *)__args);
   1.873 +#        else
   1.874 +  STLPORT_CSTD::vfprintf(stderr, __format_str, __args);
   1.875 +#        endif
   1.876 +#      else
   1.877 +  char __buffer[4096];
   1.878 +
   1.879 +#        if defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
   1.880 +  vsnprintf_s(__buffer, _STLP_ARRAY_SIZE(__buffer), _TRUNCATE, __format_str, __args);
   1.881 +#        elif defined (_STLP_WIN32) && (defined(_STLP_MSVC) || defined (__ICL))
   1.882 +  vsnprintf(__buffer, _STLP_ARRAY_SIZE(__buffer), __format_str, __args);
   1.883 +#        else
   1.884 +  vsprintf(__buffer, __format_str, __args);
   1.885 +#        endif
   1.886 +#      endif
   1.887 +
   1.888 +#      ifdef _STLP_DEBUG_MESSAGE_POST
   1.889 +  _STLP_DEBUG_MESSAGE_POST
   1.890 +#      endif
   1.891 +
   1.892 +  va_end(__args);
   1.893 +
   1.894 +#      if defined (_STLP_DEBUG_MODE_THROWS)
   1.895 +  __stl_throw_runtime_error(__buffer);
   1.896 +#      endif
   1.897 +}
   1.898 +
   1.899 +_STLP_MOVE_TO_STD_NAMESPACE
   1.900 +_STLP_END_NAMESPACE
   1.901 +
   1.902 +#    else
   1.903 +_STLP_BEGIN_NAMESPACE
   1.904 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.905 +template <class _Dummy>
   1.906 +void _STLP_CALL
   1.907 +__stl_debug_engine<_Dummy>::_Message(const char * __format_str, ...)
   1.908 +{}
   1.909 +_STLP_MOVE_TO_STD_NAMESPACE
   1.910 +_STLP_END_NAMESPACE
   1.911 +#    endif /* _STLP_DEBUG_MESSAGE */
   1.912 +
   1.913 +_STLP_BEGIN_NAMESPACE
   1.914 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.915 +
   1.916 +template <class _Dummy>
   1.917 +void _STLP_CALL
   1.918 +__stl_debug_engine<_Dummy>::_IndexedError(int __error_ind, const char* __f, int __l) {
   1.919 +  __stl_debug_message(_Message_table[_StlFormat_ERROR_RETURN],
   1.920 +                      __f, __l, _Message_table[__error_ind]);
   1.921 +}
   1.922 +
   1.923 +template <class _Dummy>
   1.924 +void _STLP_CALL
   1.925 +__stl_debug_engine<_Dummy>::_VerboseAssert(const char* __expr, int __error_ind, const char* __f, int __l) {
   1.926 +  __stl_debug_message(_Message_table[_StlFormat_VERBOSE_ASSERTION_FAILURE],
   1.927 +                      __f, __l, _Message_table[__error_ind], __f, __l, __expr);
   1.928 +  __stl_debug_terminate();
   1.929 +}
   1.930 +
   1.931 +template <class _Dummy>
   1.932 +void _STLP_CALL
   1.933 +__stl_debug_engine<_Dummy>::_Assert(const char* __expr, const char* __f, int __l) {
   1.934 +  __stl_debug_message(_Message_table[_StlFormat_ASSERTION_FAILURE],__f, __l, __expr);
   1.935 +  __stl_debug_terminate();
   1.936 +}
   1.937 +
   1.938 +// if exceptions are present, sends unique exception
   1.939 +// if not, calls abort() to terminate
   1.940 +template <class _Dummy>
   1.941 +void _STLP_CALL
   1.942 +__stl_debug_engine<_Dummy>::_Terminate()
   1.943 +{ _STLP_ABORT(); }
   1.944 +
   1.945 +_STLP_MOVE_TO_STD_NAMESPACE
   1.946 +_STLP_END_NAMESPACE
   1.947 +
   1.948 +#  endif /* _STLP_ASSERTIONS */
   1.949 +
   1.950 +#  if defined (_STLP_DEBUG)
   1.951 +
   1.952 +_STLP_BEGIN_NAMESPACE
   1.953 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.954 +
   1.955 +//==========================================================
   1.956 +//  owned_list non-inline methods
   1.957 +//==========================================================
   1.958 +
   1.959 +template <class _Dummy>
   1.960 +void  _STLP_CALL
   1.961 +__stl_debug_engine<_Dummy>::_Invalidate_all(__owned_list* __l) {
   1.962 +  _STLP_ACQUIRE_LOCK(__l->_M_lock);
   1.963 +  _Stamp_all(__l, 0);
   1.964 +  __l->_M_node._M_next =0;
   1.965 +  _STLP_RELEASE_LOCK(__l->_M_lock);
   1.966 +}
   1.967 +
   1.968 +// boris : this is unasafe routine; should be used from within critical section only !
   1.969 +template <class _Dummy>
   1.970 +void  _STLP_CALL
   1.971 +__stl_debug_engine<_Dummy>::_Stamp_all(__owned_list* __l, __owned_list* __o) {
   1.972 +  // crucial
   1.973 +  if (__l->_M_node._M_owner) {
   1.974 +    for (__owned_link*  __pos = (__owned_link*)__l->_M_node._M_next;
   1.975 +      __pos != 0; __pos = (__owned_link*)__pos->_M_next) {
   1.976 +      _STLP_ASSERT(__pos->_Owner()== __l)
   1.977 +      __pos->_M_owner=__o;
   1.978 +    }
   1.979 +  }
   1.980 +}
   1.981 +
   1.982 +template <class _Dummy>
   1.983 +void  _STLP_CALL
   1.984 +__stl_debug_engine<_Dummy>::_Verify(const __owned_list* __l) {
   1.985 +  _STLP_ACQUIRE_LOCK(__l->_M_lock);
   1.986 +  if (__l) {
   1.987 +    _STLP_ASSERT(__l->_M_node._Owner() != 0)
   1.988 +    for (__owned_link* __pos = (__owned_link*)__l->_M_node._M_next;
   1.989 +         __pos != 0; __pos = (__owned_link*)__pos->_M_next) {
   1.990 +      _STLP_ASSERT(__pos->_Owner()== __l)
   1.991 +    }
   1.992 +  }
   1.993 +  _STLP_RELEASE_LOCK(__l->_M_lock);
   1.994 +}
   1.995 +
   1.996 +template <class _Dummy>
   1.997 +void _STLP_CALL
   1.998 +__stl_debug_engine<_Dummy>::_Swap_owners(__owned_list& __x, __owned_list& __y) {
   1.999 +  /*
  1.1000 +   *  according to the standard : --no swap() function invalidates any references,
  1.1001 +   *  pointers,  or  iterators referring to the elements of the containers being swapped.
  1.1002 +   */
  1.1003 +
  1.1004 +  __owned_link* __tmp;
  1.1005 +
  1.1006 +  /*
  1.1007 +   * boris : there is a deadlock potential situation here if we lock two containers sequentially.
  1.1008 +   * As user is supposed to provide its own synchronization around swap() ( it is unsafe to do any container/iterator access
  1.1009 +   * in parallel with swap()), we just do not use any locking at all -- that behaviour is closer to non-debug version
  1.1010 +   */
  1.1011 +
  1.1012 +  __tmp = __x._M_node._M_next;
  1.1013 +
  1.1014 +  _Stamp_all(&__x, &__y);
  1.1015 +  _Stamp_all(&__y, &__x);
  1.1016 +
  1.1017 +  __x._M_node._M_next = __y._M_node._M_next;
  1.1018 +  __y._M_node._M_next = __tmp;
  1.1019 +}
  1.1020 +
  1.1021 +template <class _Dummy>
  1.1022 +void _STLP_CALL
  1.1023 +__stl_debug_engine<_Dummy>::_Set_owner(__owned_list& __src, __owned_list& __dst) {
  1.1024 +  if (&__src == &__dst)
  1.1025 +    return;
  1.1026 +
  1.1027 +  // Check __stl_debug_engine<_Dummy>::_Swap_owners comments to see why there is no lock here
  1.1028 +  typedef __owned_link _L_type;
  1.1029 +  _L_type* __prev = &__src._M_node;
  1.1030 +  _L_type* __pos = __prev->_M_next;
  1.1031 +
  1.1032 +  while (__pos != 0) {
  1.1033 +    __pos->_M_owner = &__dst;
  1.1034 +    __prev = __pos;
  1.1035 +    __pos = __prev->_M_next;
  1.1036 +  }
  1.1037 +  __prev->_M_next = __dst._M_node._M_next;
  1.1038 +  __dst._M_node._M_next = __src._M_node._M_next;
  1.1039 +  __src._M_node._M_next = 0;
  1.1040 +}
  1.1041 +
  1.1042 +template <class _Dummy>
  1.1043 +void _STLP_CALL
  1.1044 +__stl_debug_engine<_Dummy>::_M_detach(__owned_list* __l, __owned_link* __c_node) {
  1.1045 +  if (__l  != 0) {
  1.1046 +
  1.1047 +    _STLP_VERBOSE_ASSERT(__l->_Owner()!=0, _StlMsg_INVALID_CONTAINER)
  1.1048 +
  1.1049 +    _STLP_ACQUIRE_LOCK(__l->_M_lock)
  1.1050 +      // boris : re-test the condition in case someone else already deleted us
  1.1051 +      if(__c_node->_M_owner != 0) {
  1.1052 +        __owned_link* __prev, *__next;
  1.1053 +
  1.1054 +        for (__prev = &__l->_M_node; (__next = __prev->_M_next) != __c_node;
  1.1055 +             __prev = __next) {
  1.1056 +          _STLP_ASSERT(__next && __next->_Owner() == __l)
  1.1057 +            }
  1.1058 +
  1.1059 +        __prev->_M_next = __c_node->_M_next;
  1.1060 +        __c_node->_M_owner=0;
  1.1061 +      }
  1.1062 +    _STLP_RELEASE_LOCK(__l->_M_lock)
  1.1063 +  }
  1.1064 +}
  1.1065 +
  1.1066 +template <class _Dummy>
  1.1067 +void _STLP_CALL
  1.1068 +__stl_debug_engine<_Dummy>::_M_attach(__owned_list* __l, __owned_link* __c_node) {
  1.1069 +  if (__l ==0) {
  1.1070 +    (__c_node)->_M_owner = 0;
  1.1071 +  } else {
  1.1072 +    _STLP_VERBOSE_ASSERT(__l->_Owner()!=0, _StlMsg_INVALID_CONTAINER)
  1.1073 +    _STLP_ACQUIRE_LOCK(__l->_M_lock)
  1.1074 +    __c_node->_M_owner = __l;
  1.1075 +    __c_node->_M_next = __l->_M_node._M_next;
  1.1076 +    __l->_M_node._M_next = __c_node;
  1.1077 +    _STLP_RELEASE_LOCK(__l->_M_lock)
  1.1078 +  }
  1.1079 +}
  1.1080 +
  1.1081 +template <class _Dummy>
  1.1082 +void* _STLP_CALL
  1.1083 +__stl_debug_engine<_Dummy>::_Get_container_ptr(const __owned_link* __l) {
  1.1084 +  const __owned_list* __owner    = __l->_Owner();
  1.1085 +  _STLP_VERBOSE_RETURN_0(__owner != 0, _StlMsg_INVALID_ITERATOR)
  1.1086 +  void* __ret = __CONST_CAST(void*,__owner->_Owner());
  1.1087 +  _STLP_VERBOSE_RETURN_0(__ret !=0, _StlMsg_INVALID_CONTAINER)
  1.1088 +  return __ret;
  1.1089 +}
  1.1090 +
  1.1091 +template <class _Dummy>
  1.1092 +bool _STLP_CALL
  1.1093 +__stl_debug_engine<_Dummy>::_Check_same_owner(const __owned_link& __i1,
  1.1094 +                                              const __owned_link& __i2) {
  1.1095 +  _STLP_VERBOSE_RETURN(__i1._Valid(), _StlMsg_INVALID_LEFTHAND_ITERATOR)
  1.1096 +  _STLP_VERBOSE_RETURN(__i2._Valid(), _StlMsg_INVALID_RIGHTHAND_ITERATOR)
  1.1097 +  _STLP_VERBOSE_RETURN((__i1._Owner() == __i2._Owner()), _StlMsg_DIFFERENT_OWNERS)
  1.1098 +  return true;
  1.1099 +}
  1.1100 +
  1.1101 +template <class _Dummy>
  1.1102 +bool _STLP_CALL
  1.1103 +__stl_debug_engine<_Dummy>::_Check_same_or_null_owner(const __owned_link& __i1,
  1.1104 +                                                      const __owned_link& __i2) {
  1.1105 +  _STLP_VERBOSE_RETURN(__i1._Owner() == __i2._Owner(), _StlMsg_DIFFERENT_OWNERS)
  1.1106 +  return true;
  1.1107 +}
  1.1108 +
  1.1109 +template <class _Dummy>
  1.1110 +bool _STLP_CALL
  1.1111 +__stl_debug_engine<_Dummy>::_Check_if_owner( const __owned_list * __l, const __owned_link& __it) {
  1.1112 +  const __owned_list* __owner_ptr = __it._Owner();
  1.1113 +  _STLP_VERBOSE_RETURN(__owner_ptr != 0, _StlMsg_INVALID_ITERATOR)
  1.1114 +  _STLP_VERBOSE_RETURN(__l == __owner_ptr, _StlMsg_NOT_OWNER)
  1.1115 +  return true;
  1.1116 +}
  1.1117 +
  1.1118 +template <class _Dummy>
  1.1119 +bool _STLP_CALL
  1.1120 +__stl_debug_engine<_Dummy>::_Check_if_not_owner( const __owned_list * __l, const __owned_link& __it) {
  1.1121 +  const __owned_list* __owner_ptr = __it._Owner();
  1.1122 +  _STLP_VERBOSE_RETURN(__owner_ptr != 0, _StlMsg_INVALID_ITERATOR)
  1.1123 +  _STLP_VERBOSE_RETURN(__l != __owner_ptr, _StlMsg_SHOULD_NOT_OWNER)
  1.1124 +  return true;
  1.1125 +}
  1.1126 +
  1.1127 +_STLP_MOVE_TO_STD_NAMESPACE
  1.1128 +_STLP_END_NAMESPACE
  1.1129 +
  1.1130 +#  endif /* _STLP_DEBUG */
  1.1131 +
  1.1132 +#endif /* if defined (EXPOSE_GLOBALS_IMPLEMENTATION) */
  1.1133 +
  1.1134 +#endif /* header guard */
  1.1135 +
  1.1136 +// Local Variables:
  1.1137 +// mode:C++
  1.1138 +// End: