1.1 --- a/epoc32/include/tools/stlport/stl/debug/_debug.h Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/tools/stlport/stl/debug/_debug.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -1,426 +1,460 @@
1.4 -/*
1.5 - *
1.6 - * Copyright (c) 1997
1.7 - * Moscow Center for SPARC Technology
1.8 - *
1.9 - * Copyright (c) 1999
1.10 - * Boris Fomitchev
1.11 - *
1.12 - * This material is provided "as is", with absolutely no warranty expressed
1.13 - * or implied. Any use is at your own risk.
1.14 - *
1.15 - * Permission to use or copy this software for any purpose is hereby granted
1.16 - * without fee, provided the above notices are retained on all copies.
1.17 - * Permission to modify the code and to distribute modified code is granted,
1.18 - * provided the above notices are retained, and a notice that the code was
1.19 - * modified is included with the above copyright notice.
1.20 - *
1.21 - */
1.22 -
1.23 -#ifndef _STLP_DEBUG_H
1.24 -# define _STLP_DEBUG_H
1.25 -
1.26 -# if defined (_STLP_ASSERTIONS) || defined (_STLP_DEBUG)
1.27 -
1.28 -#ifndef _STLP_CONFIG_H
1.29 -# include <stl/_config.h>
1.30 -#endif
1.31 -
1.32 -# if !defined (_STLP_EXTRA_OPERATORS_FOR_DEBUG) && \
1.33 - ( defined (_STLP_BASE_MATCH_BUG) || (defined (_STLP_MSVC) && _STLP_MSVC < 1100 ) )
1.34 -# define _STLP_EXTRA_OPERATORS_FOR_DEBUG
1.35 -# endif
1.36 -
1.37 -# if !defined(_STLP_FILE__)
1.38 -# define _STLP_FILE__ __FILE__
1.39 -# endif
1.40 -
1.41 -enum {
1.42 - _StlFormat_ERROR_RETURN,
1.43 - _StlFormat_ASSERTION_FAILURE,
1.44 - _StlFormat_VERBOSE_ASSERTION_FAILURE,
1.45 - _StlMsg_INVALID_ARGUMENT,
1.46 - _StlMsg_INVALID_CONTAINER,
1.47 - _StlMsg_EMPTY_CONTAINER,
1.48 - _StlMsg_ERASE_PAST_THE_END,
1.49 - _StlMsg_OUT_OF_BOUNDS,
1.50 - _StlMsg_NOT_OWNER,
1.51 - _StlMsg_INVALID_ITERATOR,
1.52 - _StlMsg_INVALID_LEFTHAND_ITERATOR,
1.53 - _StlMsg_INVALID_RIGHTHAND_ITERATOR,
1.54 - _StlMsg_DIFFERENT_OWNERS ,
1.55 - _StlMsg_NOT_DEREFERENCEABLE ,
1.56 - _StlMsg_INVALID_RANGE ,
1.57 - _StlMsg_NOT_IN_RANGE_1 ,
1.58 - _StlMsg_NOT_IN_RANGE_2 ,
1.59 - _StlMsg_INVALID_ADVANCE ,
1.60 - _StlMsg_SINGULAR_ITERATOR ,
1.61 - // debug alloc messages
1.62 - _StlMsg_DBA_DELETED_TWICE ,
1.63 - _StlMsg_DBA_NEVER_ALLOCATED ,
1.64 - _StlMsg_DBA_TYPE_MISMATCH ,
1.65 - _StlMsg_DBA_SIZE_MISMATCH ,
1.66 - _StlMsg_DBA_UNDERRUN ,
1.67 - _StlMsg_DBA_OVERRUN ,
1.68 - // auto_ptr messages
1.69 - _StlMsg_AUTO_PTR_NULL ,
1.70 - _StlMsg_UNKNOWN
1.71 - /* _StlMsg_MAX */
1.72 -};
1.73 -
1.74 -/* have to hardcode that ;() */
1.75 -# define _StlMsg_MAX 27
1.76 -
1.77 -_STLP_BEGIN_NAMESPACE
1.78 -
1.79 -// This class is unique (not inherited from exception),
1.80 -// to disallow catch in anything but (...)
1.81 -struct __stl_debug_exception {
1.82 - // no members
1.83 -};
1.84 -
1.85 -class _STLP_CLASS_DECLSPEC __owned_link;
1.86 -class _STLP_CLASS_DECLSPEC __owned_list;
1.87 -
1.88 -template <class _Dummy>
1.89 -struct __stl_debug_engine {
1.90 -
1.91 - // Basic routine to report any debug message
1.92 - // Use _STLP_DEBUG_MESSAGE to override
1.93 - static void _STLP_CALL _Message(const char * format_str, ...);
1.94 -
1.95 - // Micsellanous function to report indexed error message
1.96 - static void _STLP_CALL _IndexedError(int __ind, const char* __f, int __l);
1.97 -
1.98 - // Basic assertion report mechanism.
1.99 - // Reports failed assertion via __stl_debug_message and calls _Terminate
1.100 - // if _STLP_DEBUG_TERMINATE is specified, calls __stl_debug_terminate instead
1.101 - static void _STLP_CALL _Assert(const char* __expr, const char* __f, int __l);
1.102 -
1.103 - // The same, with additional diagnostics
1.104 - static void _STLP_CALL _VerboseAssert(const char* __expr, int __error_ind, const char* __f, int __l);
1.105 -
1.106 - // If exceptions are present, sends unique exception
1.107 - // If not, calls _STLP_ABORT() to terminate
1.108 - // Use _STLP_DEBUG_TERMINATE to override
1.109 - static void _STLP_CALL _Terminate();
1.110 -
1.111 -# ifdef _STLP_DEBUG
1.112 -
1.113 - // owned_list/link delegate non-inline functions here
1.114 -
1.115 - static bool _STLP_CALL _Check_same_owner( const __owned_link& __i1,
1.116 - const __owned_link& __i2);
1.117 - static bool _STLP_CALL _Check_same_owner_or_null( const __owned_link& __i1,
1.118 - const __owned_link& __i2);
1.119 - static bool _STLP_CALL _Check_if_owner( const __owned_list*, const __owned_link&);
1.120 -
1.121 - static void _STLP_CALL _Verify(const __owned_list*);
1.122 -
1.123 - static void _STLP_CALL _Swap_owners(__owned_list&, __owned_list& /*, bool __swap_roots */ );
1.124 -
1.125 - static void _STLP_CALL _Invalidate_all(__owned_list*);
1.126 -
1.127 - static void _STLP_CALL _Stamp_all(__owned_list*, __owned_list*);
1.128 -
1.129 - static void _STLP_CALL _M_detach(__owned_list*, __owned_link*);
1.130 -
1.131 - static void _STLP_CALL _M_attach(__owned_list*, __owned_link*);
1.132 -
1.133 - // accessor : check and get pointer to the container
1.134 - static void* _STLP_CALL _Get_container_ptr(const __owned_link*);
1.135 -# endif /* _STLP_DEBUG */
1.136 -
1.137 - // debug messages and formats
1.138 - _STLP_STATIC_MEMBER_DECLSPEC static const char* _Message_table[_StlMsg_MAX];
1.139 -};
1.140 -
1.141 -
1.142 -# if defined (_STLP_USE_TEMPLATE_EXPORT)
1.143 -_STLP_EXPORT_TEMPLATE struct _STLP_CLASS_DECLSPEC __stl_debug_engine<bool>;
1.144 -# endif /* _STLP_USE_TEMPLATE_EXPORT */
1.145 -
1.146 -typedef __stl_debug_engine<bool> __stl_debugger;
1.147 -
1.148 -_STLP_END_NAMESPACE
1.149 -
1.150 -# ifndef _STLP_ASSERT
1.151 -# define _STLP_ASSERT(expr) \
1.152 - if (!(expr)) {STLPORT::__stl_debugger::_Assert( # expr, _STLP_FILE__, __LINE__);}
1.153 -# endif
1.154 -
1.155 -# endif /* _STLP_ASSERTIONS || _STLP_DEBUG */
1.156 -
1.157 -
1.158 -// this section is for _STLP_DEBUG only
1.159 -#if defined ( _STLP_DEBUG )
1.160 -
1.161 -# ifndef _STLP_VERBOSE_ASSERT
1.162 -// fbp : new form not requiring ";"
1.163 -# define _STLP_VERBOSE_ASSERT(expr,__diag_num) \
1.164 - if (!(expr)) { STLPORT::__stl_debugger::_VerboseAssert\
1.165 - ( # expr, __diag_num, _STLP_FILE__, __LINE__ ); \
1.166 - }
1.167 -# endif
1.168 -
1.169 -# define _STLP_DEBUG_CHECK(expr) _STLP_ASSERT(expr)
1.170 -# define _STLP_DEBUG_DO(expr) expr;
1.171 -
1.172 -# ifndef _STLP_VERBOSE_RETURN
1.173 -# define _STLP_VERBOSE_RETURN(__expr,__diag_num) if (!(__expr)) { \
1.174 - __stl_debugger::_IndexedError(__diag_num, __FILE__ , __LINE__); \
1.175 - return false; }
1.176 -# endif
1.177 -
1.178 -# ifndef _STLP_VERBOSE_RETURN_0
1.179 -# define _STLP_VERBOSE_RETURN_0(__expr,__diag_num) if (!(__expr)) { \
1.180 - __stl_debugger::_IndexedError(__diag_num, __FILE__ , __LINE__); \
1.181 - return 0; }
1.182 -# endif
1.183 -
1.184 -#if ! defined (_STLP_INTERNAL_THREADS_H)
1.185 -# include <stl/_threads.h>
1.186 -#endif
1.187 -
1.188 -#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
1.189 -# include <stl/_iterator_base.h>
1.190 -#endif
1.191 -
1.192 -_STLP_BEGIN_NAMESPACE
1.193 -
1.194 -//=============================================================
1.195 -template <class _Iterator>
1.196 -inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2,
1.197 - const random_access_iterator_tag&) {
1.198 - return (__i1< __i2) || (__i1 == __i2);
1.199 -}
1.200 -
1.201 -template <class _Iterator>
1.202 -inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2,
1.203 - const bidirectional_iterator_tag&) {
1.204 - // check if comparable
1.205 - bool __dummy(__i1==__i2);
1.206 - return (__dummy==__dummy);
1.207 -}
1.208 -
1.209 -template <class _Iterator>
1.210 -inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2, const forward_iterator_tag&) {
1.211 - // check if comparable
1.212 - bool __dummy(__i1==__i2);
1.213 - return (__dummy==__dummy);
1.214 -}
1.215 -
1.216 -template <class _Iterator>
1.217 -inline bool _STLP_CALL __valid_range(const _Iterator&,const _Iterator&, const input_iterator_tag&) {
1.218 - return true;
1.219 -}
1.220 -
1.221 -template <class _Iterator>
1.222 -inline bool _STLP_CALL __valid_range(const _Iterator&,const _Iterator&, const output_iterator_tag&) {
1.223 - return true;
1.224 -}
1.225 -
1.226 -template <class _Iterator>
1.227 -inline bool _STLP_CALL __valid_range(const _Iterator& __i1, const _Iterator& __i2) {
1.228 - return __valid_range(__i1,__i2,_STLP_ITERATOR_CATEGORY(__i1, _Iterator));
1.229 -}
1.230 -
1.231 -// Note : that means in range [i1, i2].
1.232 -template <class _Iterator>
1.233 -inline bool _STLP_CALL __in_range(const _Iterator& _It, const _Iterator& __i1,
1.234 - const _Iterator& __i2) {
1.235 - return __valid_range(__i1,_It,_STLP_ITERATOR_CATEGORY(__i1, _Iterator)) &&
1.236 - __valid_range(_It,__i2,_STLP_ITERATOR_CATEGORY(_It, _Iterator));
1.237 -}
1.238 -
1.239 -template <class _Iterator>
1.240 -inline bool _STLP_CALL __in_range(const _Iterator& __first, const _Iterator& __last,
1.241 - const _Iterator& __start, const _Iterator& __finish) {
1.242 - return __valid_range(__first,__last,_STLP_ITERATOR_CATEGORY(__first, _Iterator)) &&
1.243 - __valid_range(__start,__first,_STLP_ITERATOR_CATEGORY(__first, _Iterator)) &&
1.244 - __valid_range(__last,__finish,_STLP_ITERATOR_CATEGORY(__last, _Iterator));
1.245 -}
1.246 -
1.247 -//==========================================================
1.248 -
1.249 -
1.250 -class _STLP_CLASS_DECLSPEC __owned_link {
1.251 -public:
1.252 -
1.253 - __owned_link() : _M_owner(0) {}
1.254 - __owned_link(const __owned_list* __c) : _M_owner(0), _M_next(0) {
1.255 - __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__c), this);
1.256 - }
1.257 - __owned_link(const __owned_link& __rhs): _M_owner(0) {
1.258 - __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__rhs._M_owner), this);
1.259 - }
1.260 - __owned_link& operator=(const __owned_link& __rhs) {
1.261 - __owned_list* __new_owner = __CONST_CAST(__owned_list*,__rhs._M_owner);
1.262 - __owned_list* __old_owner = _M_owner;
1.263 - if ( __old_owner != __new_owner ) {
1.264 - __stl_debugger::_M_detach(__old_owner, this);
1.265 - __stl_debugger::_M_attach(__new_owner, this);
1.266 - }
1.267 - return *this;
1.268 - }
1.269 - ~__owned_link() {
1.270 - __stl_debugger::_M_detach(_M_owner, this);
1.271 - _Invalidate();
1.272 - }
1.273 -
1.274 - const __owned_list* _Owner() const {
1.275 - return _M_owner;
1.276 - }
1.277 - __owned_list* _Owner() {
1.278 - return _M_owner;
1.279 - }
1.280 - void _Set_owner(const __owned_list* __o) {
1.281 - _M_owner= __CONST_CAST(__owned_list*,__o);
1.282 - }
1.283 - bool _Valid() const {
1.284 - return _M_owner !=0;
1.285 - }
1.286 -
1.287 - void _Invalidate() { _M_owner=0; _M_next = 0; }
1.288 - void _Link_to_self() { _M_next= 0; }
1.289 -
1.290 - __owned_link* _Next() { return _M_next; }
1.291 - const __owned_link* _Next() const { return _M_next; }
1.292 -
1.293 -public:
1.294 - __owned_list* _M_owner;
1.295 - __owned_link* _M_next;
1.296 -};
1.297 -
1.298 -
1.299 -class _STLP_CLASS_DECLSPEC __owned_list {
1.300 -public:
1.301 - __owned_list(const void* __o) {
1.302 - // fprintf(stderr, "__owned_list(): %p\n",(void*)this);
1.303 - _M_node._M_owner = __CONST_CAST(__owned_list*, __REINTERPRET_CAST(const __owned_list*,__o));
1.304 - _M_node._M_next=0;
1.305 - }
1.306 - ~__owned_list() {
1.307 - // fprintf(stderr, "~__owned_list(): %p\n",(void*)this);
1.308 - _Invalidate_all();
1.309 - // that prevents detach
1.310 - _M_node._Invalidate();
1.311 - }
1.312 - const void* _Owner() const {
1.313 - return (const void*)_M_node._M_owner;
1.314 - }
1.315 - void* _Owner() {
1.316 - return (void*)_M_node._M_owner;
1.317 - }
1.318 - bool _Valid() const {
1.319 - return _M_node._M_owner!=0;
1.320 - }
1.321 - void _Invalidate() { _M_node._M_owner=0; }
1.322 -
1.323 - __owned_link* _First() { return _M_node._Next(); }
1.324 - __owned_link* _Last() { return 0 ; }
1.325 -
1.326 - const __owned_link* _First() const { return (__owned_link*)_M_node._M_next; }
1.327 - const __owned_link* _Last() const { return 0 ;}
1.328 -
1.329 - void _Verify() const {
1.330 - __stl_debugger::_Verify(this);
1.331 - }
1.332 -
1.333 - void _Swap_owners(__owned_list& __y) {
1.334 - __stl_debugger::_Swap_owners(*this, __y);
1.335 - }
1.336 -
1.337 - void _Invalidate_all() {
1.338 - __stl_debugger::_Invalidate_all(this);
1.339 - }
1.340 -
1.341 - mutable __owned_link _M_node;
1.342 - mutable _STLP_mutex _M_lock;
1.343 -
1.344 -private:
1.345 - // should never be called, should be left undefined,
1.346 - // but some compilers complain about it ;(
1.347 - __owned_list(const __owned_list&){}
1.348 - void operator=(const __owned_list&) {}
1.349 -
1.350 - friend class __owned_link;
1.351 - friend struct __stl_debug_engine<bool>;
1.352 -};
1.353 -
1.354 -
1.355 -//==========================================================
1.356 -
1.357 -// forward declaratioins
1.358 -
1.359 -template <class _Iterator>
1.360 -bool _STLP_CALL __check_range(const _Iterator&, const _Iterator&);
1.361 -template <class _Iterator>
1.362 -bool _STLP_CALL __check_range(const _Iterator&,
1.363 - const _Iterator&, const _Iterator&);
1.364 -template <class _Iterator>
1.365 -bool _STLP_CALL __check_range(const _Iterator&, const _Iterator& ,
1.366 - const _Iterator&, const _Iterator& );
1.367 -
1.368 -template <class _Iterator>
1.369 -void _STLP_CALL __invalidate_range(const __owned_list* __base,
1.370 - const _Iterator& __first,
1.371 - const _Iterator& __last);
1.372 -
1.373 -template <class _Iterator>
1.374 -void _STLP_CALL __invalidate_iterator(const __owned_list* __base,
1.375 - const _Iterator& __it);
1.376 -
1.377 -//============================================================
1.378 -
1.379 -inline bool _STLP_CALL
1.380 -__check_same_owner( const __owned_link& __i1, const __owned_link& __i2) {
1.381 - return __stl_debugger::_Check_same_owner(__i1,__i2);
1.382 -}
1.383 -inline bool _STLP_CALL
1.384 -__check_same_owner_or_null( const __owned_link& __i1, const __owned_link& __i2) {
1.385 - return __stl_debugger::_Check_same_owner_or_null(__i1,__i2);
1.386 -}
1.387 -
1.388 -template <class _Iterator>
1.389 -inline bool _STLP_CALL __check_if_owner( const __owned_list* __owner,
1.390 - const _Iterator& __it) {
1.391 - return __stl_debugger::_Check_if_owner(__owner, (const __owned_link&)__it);
1.392 -}
1.393 -
1.394 -_STLP_END_NAMESPACE
1.395 -
1.396 -# endif /* _STLP_DEBUG */
1.397 -
1.398 -#if defined ( _STLP_ASSERTIONS )
1.399 -
1.400 -# ifndef _STLP_ASSERT_MSG_TRAILER
1.401 -# define _STLP_ASSERT_MSG_TRAILER
1.402 -# endif
1.403 -
1.404 -// dwa 12/30/98 - if _STLP_DEBUG_MESSAGE is defined, the user can supply own definition.
1.405 -# if !defined( _STLP_DEBUG_MESSAGE )
1.406 -# define __stl_debug_message __stl_debugger::_Message
1.407 -# else
1.408 - extern void __stl_debug_message(const char * format_str, ...);
1.409 -# endif
1.410 -
1.411 -// fbp: if _STLP_DEBUG_TERMINATE is defined, the user can supply own definition.
1.412 -# if !defined( _STLP_DEBUG_TERMINATE )
1.413 -# define __stl_debug_terminate __stl_debugger::_Terminate
1.414 -# else
1.415 - extern void __stl_debug_terminate(void);
1.416 -# endif
1.417 -
1.418 -#endif
1.419 -
1.420 -# if !defined (_STLP_LINK_TIME_INSTANTIATION)
1.421 -# include <stl/debug/_debug.c>
1.422 -# endif
1.423 -
1.424 -#endif /* DEBUG_H */
1.425 -
1.426 -// Local Variables:
1.427 -// mode:C++
1.428 -// End:
1.429 -
1.430 +/*
1.431 + *
1.432 + * Copyright (c) 1997
1.433 + * Moscow Center for SPARC Technology
1.434 + *
1.435 + * Copyright (c) 1999
1.436 + * Boris Fomitchev
1.437 + *
1.438 + * This material is provided "as is", with absolutely no warranty expressed
1.439 + * or implied. Any use is at your own risk.
1.440 + *
1.441 + * Permission to use or copy this software for any purpose is hereby granted
1.442 + * without fee, provided the above notices are retained on all copies.
1.443 + * Permission to modify the code and to distribute modified code is granted,
1.444 + * provided the above notices are retained, and a notice that the code was
1.445 + * modified is included with the above copyright notice.
1.446 + *
1.447 + */
1.448 +
1.449 +#ifndef _STLP_DEBUG_H
1.450 +#define _STLP_DEBUG_H
1.451 +
1.452 +#if defined (_STLP_ASSERTIONS) || defined (_STLP_DEBUG)
1.453 +
1.454 +# ifndef _STLP_TYPE_TRAITS_H
1.455 +# include <stl/type_traits.h>
1.456 +# endif
1.457 +
1.458 +# if !defined (_STLP_EXTRA_OPERATORS_FOR_DEBUG) && \
1.459 + (defined (_STLP_BASE_MATCH_BUG) || (defined (_STLP_MSVC) && _STLP_MSVC < 1100))
1.460 +# define _STLP_EXTRA_OPERATORS_FOR_DEBUG
1.461 +# endif
1.462 +
1.463 +# if !defined (_STLP_FILE__)
1.464 +# define _STLP_FILE__ __FILE__
1.465 +# endif
1.466 +
1.467 +_STLP_BEGIN_NAMESPACE
1.468 +
1.469 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.470 +
1.471 +enum {
1.472 + //General errors
1.473 + _StlFormat_ERROR_RETURN,
1.474 + _StlFormat_ASSERTION_FAILURE,
1.475 + _StlFormat_VERBOSE_ASSERTION_FAILURE,
1.476 + _StlMsg_INVALID_ARGUMENT,
1.477 + //Container/Iterator related errors
1.478 + _StlMsg_INVALID_CONTAINER,
1.479 + _StlMsg_EMPTY_CONTAINER,
1.480 + _StlMsg_ERASE_PAST_THE_END,
1.481 + _StlMsg_OUT_OF_BOUNDS,
1.482 + _StlMsg_NOT_OWNER,
1.483 + _StlMsg_SHOULD_NOT_OWNER,
1.484 + _StlMsg_INVALID_ITERATOR,
1.485 + _StlMsg_INVALID_LEFTHAND_ITERATOR,
1.486 + _StlMsg_INVALID_RIGHTHAND_ITERATOR,
1.487 + _StlMsg_DIFFERENT_OWNERS ,
1.488 + _StlMsg_NOT_DEREFERENCEABLE ,
1.489 + _StlMsg_INVALID_RANGE ,
1.490 + _StlMsg_NOT_IN_RANGE_1 ,
1.491 + _StlMsg_NOT_IN_RANGE_2 ,
1.492 + _StlMsg_INVALID_ADVANCE ,
1.493 + _StlMsg_SINGULAR_ITERATOR ,
1.494 + //Bad predicate for sorting
1.495 + _StlMsg_INVALID_STRICT_WEAK_PREDICATE,
1.496 + _StlMsg_INVALID_EQUIVALENT_PREDICATE,
1.497 + // debug alloc messages
1.498 + _StlMsg_DBA_DELETED_TWICE ,
1.499 + _StlMsg_DBA_NEVER_ALLOCATED ,
1.500 + _StlMsg_DBA_TYPE_MISMATCH ,
1.501 + _StlMsg_DBA_SIZE_MISMATCH ,
1.502 + _StlMsg_DBA_UNDERRUN ,
1.503 + _StlMsg_DBA_OVERRUN ,
1.504 + // auto_ptr messages
1.505 + _StlMsg_AUTO_PTR_NULL ,
1.506 + //Memory alignent message
1.507 + _StlMsg_WRONG_MEMORY_ALIGNMENT,
1.508 + _StlMsg_UNKNOWN
1.509 + /* _StlMsg_MAX */
1.510 +};
1.511 +
1.512 +/* have to hardcode that ;() */
1.513 +# define _StlMsg_MAX 31
1.514 +
1.515 +// This class is unique (not inherited from exception),
1.516 +// to disallow catch in anything but (...)
1.517 +struct __stl_debug_exception {
1.518 + // no members
1.519 +};
1.520 +
1.521 +class _STLP_CLASS_DECLSPEC __owned_link;
1.522 +class _STLP_CLASS_DECLSPEC __owned_list;
1.523 +
1.524 +#if defined (_STLP_DEBUG_MODE_THROWS)
1.525 +# define _STLP_MESSAGE_NORETURN _STLP_FUNCTION_THROWS
1.526 +#else
1.527 +# define _STLP_MESSAGE_NORETURN
1.528 +#endif
1.529 +
1.530 +template <class _Dummy>
1.531 +struct __stl_debug_engine {
1.532 +
1.533 + // Basic routine to report any debug message
1.534 + // Use _STLP_DEBUG_MESSAGE to override
1.535 + static void _STLP_MESSAGE_NORETURN _STLP_CALL _Message(const char * format_str, ...);
1.536 +
1.537 + // Micsellanous function to report indexed error message
1.538 + static void _STLP_CALL _IndexedError(int __ind, const char* __f, int __l);
1.539 +
1.540 + // Basic assertion report mechanism.
1.541 + // Reports failed assertion via __stl_debug_message and calls _Terminate
1.542 + // if _STLP_DEBUG_TERMINATE is specified, calls __stl_debug_terminate instead
1.543 + static void _STLP_CALL _Assert(const char* __expr, const char* __f, int __l);
1.544 +
1.545 + // The same, with additional diagnostics
1.546 + static void _STLP_CALL _VerboseAssert(const char* __expr, int __error_ind, const char* __f, int __l);
1.547 +
1.548 + // If exceptions are present, sends unique exception
1.549 + // If not, calls _STLP_ABORT() to terminate
1.550 + // Use _STLP_DEBUG_TERMINATE to override
1.551 + static void _STLP_CALL _Terminate();
1.552 +
1.553 +# if defined (_STLP_DEBUG)
1.554 + // owned_list/link delegate non-inline functions here
1.555 +
1.556 + static bool _STLP_CALL _Check_same_owner( const __owned_link& __i1,
1.557 + const __owned_link& __i2);
1.558 + static bool _STLP_CALL _Check_same_or_null_owner( const __owned_link& __i1,
1.559 + const __owned_link& __i2);
1.560 + static bool _STLP_CALL _Check_if_owner( const __owned_list*, const __owned_link&);
1.561 +
1.562 + static bool _STLP_CALL _Check_if_not_owner( const __owned_list*, const __owned_link&);
1.563 +
1.564 + static void _STLP_CALL _Verify(const __owned_list*);
1.565 +
1.566 + static void _STLP_CALL _Swap_owners(__owned_list&, __owned_list&);
1.567 +
1.568 + static void _STLP_CALL _Invalidate_all(__owned_list*);
1.569 +
1.570 + static void _STLP_CALL _Set_owner(__owned_list& /*src*/, __owned_list& /*dst*/);
1.571 +
1.572 + static void _STLP_CALL _Stamp_all(__owned_list*, __owned_list*);
1.573 +
1.574 + static void _STLP_CALL _M_detach(__owned_list*, __owned_link*);
1.575 +
1.576 + static void _STLP_CALL _M_attach(__owned_list*, __owned_link*);
1.577 +
1.578 + // accessor : check and get pointer to the container
1.579 + static void* _STLP_CALL _Get_container_ptr(const __owned_link*);
1.580 +# endif
1.581 +
1.582 + // debug messages and formats
1.583 + static _STLP_STATIC_MEMBER_DECLSPEC const char* _Message_table[_StlMsg_MAX];
1.584 +};
1.585 +
1.586 +#undef _STLP_MESSAGE_NORETURN
1.587 +
1.588 +# if defined (_STLP_USE_TEMPLATE_EXPORT)
1.589 +_STLP_EXPORT_TEMPLATE struct _STLP_CLASS_DECLSPEC __stl_debug_engine<bool>;
1.590 +# endif /* _STLP_USE_TEMPLATE_EXPORT */
1.591 +
1.592 +typedef __stl_debug_engine<bool> __stl_debugger;
1.593 +
1.594 +_STLP_MOVE_TO_STD_NAMESPACE
1.595 +
1.596 +_STLP_END_NAMESPACE
1.597 +
1.598 +# if !defined (_STLP_ASSERT)
1.599 +# define _STLP_ASSERT(expr) \
1.600 + if (!(expr)) { _STLP_PRIV __stl_debugger::_Assert( # expr, _STLP_FILE__, __LINE__); }
1.601 +# endif
1.602 +
1.603 +#endif /* _STLP_ASSERTIONS || _STLP_DEBUG */
1.604 +
1.605 +// this section is for _STLP_DEBUG only
1.606 +#if defined (_STLP_DEBUG)
1.607 +
1.608 +# if !defined (_STLP_VERBOSE_ASSERT)
1.609 +// fbp : new form not requiring ";"
1.610 +# define _STLP_VERBOSE_ASSERT(expr, __diag_num) \
1.611 + if (!(expr)) { _STLP_PRIV __stl_debugger::_VerboseAssert\
1.612 + ( # expr, _STLP_PRIV __diag_num, _STLP_FILE__, __LINE__ ); \
1.613 + }
1.614 +# endif
1.615 +
1.616 +# define _STLP_DEBUG_CHECK(expr) _STLP_ASSERT(expr)
1.617 +# define _STLP_DEBUG_DO(expr) expr;
1.618 +
1.619 +# if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
1.620 +# define _STLP_STD_DEBUG_CHECK(expr) _STLP_DEBUG_CHECK(expr)
1.621 +# define _STLP_STD_DEBUG_DO(expr) _STLP_DEBUG_DO(expr)
1.622 +# else
1.623 +# define _STLP_STD_DEBUG_CHECK(expr)
1.624 +# define _STLP_STD_DEBUG_DO(expr)
1.625 +# endif
1.626 +
1.627 +# if !defined (_STLP_VERBOSE_RETURN)
1.628 +# define _STLP_VERBOSE_RETURN(__expr,__diag_num) if (!(__expr)) { \
1.629 + _STLP_PRIV __stl_debugger::_IndexedError(__diag_num, _STLP_FILE__ , __LINE__); \
1.630 + return false; }
1.631 +# endif
1.632 +
1.633 +# if !defined (_STLP_VERBOSE_RETURN_0)
1.634 +# define _STLP_VERBOSE_RETURN_0(__expr,__diag_num) if (!(__expr)) { \
1.635 + _STLP_PRIV __stl_debugger::_IndexedError(__diag_num, _STLP_FILE__, __LINE__); \
1.636 + return 0; }
1.637 +# endif
1.638 +
1.639 +# ifndef _STLP_INTERNAL_THREADS_H
1.640 +# include <stl/_threads.h>
1.641 +# endif
1.642 +
1.643 +# ifndef _STLP_INTERNAL_ITERATOR_BASE_H
1.644 +# include <stl/_iterator_base.h>
1.645 +# endif
1.646 +
1.647 +_STLP_BEGIN_NAMESPACE
1.648 +
1.649 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.650 +
1.651 +/*
1.652 + * Special debug iterator traits having an additionnal static member
1.653 + * method _Check. It is used by the slit debug implementation to check
1.654 + * the special before_begin iterator.
1.655 + */
1.656 +template <class _Traits>
1.657 +struct _DbgTraits : _Traits {
1.658 + typedef _DbgTraits<typename _Traits::_ConstTraits> _ConstTraits;
1.659 + typedef _DbgTraits<typename _Traits::_NonConstTraits> _NonConstTraits;
1.660 +
1.661 + template <class _Iterator>
1.662 + static bool _Check(const _Iterator&) {return true;}
1.663 +};
1.664 +
1.665 +//=============================================================
1.666 +template <class _Iterator>
1.667 +inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2,
1.668 + const random_access_iterator_tag&)
1.669 +{ return (__i1 < __i2) || (__i1 == __i2); }
1.670 +
1.671 +template <class _Iterator>
1.672 +inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2,
1.673 + const bidirectional_iterator_tag&) {
1.674 + // check if comparable
1.675 + bool __dummy(__i1==__i2);
1.676 + return (__dummy==__dummy);
1.677 +}
1.678 +
1.679 +template <class _Iterator>
1.680 +inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2,
1.681 + const forward_iterator_tag&) {
1.682 + // check if comparable
1.683 + bool __dummy(__i1==__i2);
1.684 + return (__dummy==__dummy);
1.685 +}
1.686 +
1.687 +template <class _Iterator>
1.688 +inline bool _STLP_CALL __valid_range(const _Iterator&,const _Iterator&,
1.689 + const input_iterator_tag&)
1.690 +{ return true; }
1.691 +
1.692 +template <class _Iterator>
1.693 +inline bool _STLP_CALL __valid_range(const _Iterator&,const _Iterator&,
1.694 + const output_iterator_tag&)
1.695 +{ return true; }
1.696 +
1.697 +template <class _Iterator>
1.698 +inline bool _STLP_CALL __valid_range(const _Iterator& __i1, const _Iterator& __i2)
1.699 +{ return __valid_range(__i1,__i2,_STLP_ITERATOR_CATEGORY(__i1, _Iterator)); }
1.700 +
1.701 +// Note : that means in range [i1, i2].
1.702 +template <class _Iterator>
1.703 +inline bool _STLP_CALL __in_range(const _Iterator& _It,
1.704 + const _Iterator& __i1, const _Iterator& __i2)
1.705 +{ return __valid_range(__i1,_It) && __valid_range(_It,__i2); }
1.706 +
1.707 +template <class _Iterator>
1.708 +inline bool _STLP_CALL __in_range(const _Iterator& __first, const _Iterator& __last,
1.709 + const _Iterator& __start, const _Iterator& __finish)
1.710 +{ return __valid_range(__first,__last) && __valid_range(__start,__first) && __valid_range(__last,__finish); }
1.711 +
1.712 +//==========================================================
1.713 +class _STLP_CLASS_DECLSPEC __owned_link {
1.714 +public:
1.715 + __owned_link() : _M_owner(0) {}
1.716 + __owned_link(const __owned_list* __c) : _M_owner(0), _M_next(0)
1.717 + { __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__c), this); }
1.718 + __owned_link(const __owned_link& __rhs): _M_owner(0)
1.719 + { __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__rhs._M_owner), this); }
1.720 + __owned_link& operator=(const __owned_link& __rhs) {
1.721 + __owned_list* __new_owner = __CONST_CAST(__owned_list*,__rhs._M_owner);
1.722 + __owned_list* __old_owner = _M_owner;
1.723 + if ( __old_owner != __new_owner ) {
1.724 + __stl_debugger::_M_detach(__old_owner, this);
1.725 + __stl_debugger::_M_attach(__new_owner, this);
1.726 + }
1.727 + return *this;
1.728 + }
1.729 + ~__owned_link() {
1.730 + __stl_debugger::_M_detach(_M_owner, this);
1.731 + _Invalidate();
1.732 + }
1.733 +
1.734 + const __owned_list* _Owner() const { return _M_owner; }
1.735 + __owned_list* _Owner() { return _M_owner; }
1.736 + void _Set_owner(const __owned_list* __o) { _M_owner= __CONST_CAST(__owned_list*,__o); }
1.737 + bool _Valid() const { return _M_owner != 0; }
1.738 + void _Invalidate() { _M_owner = 0; _M_next = 0; }
1.739 + void _Link_to_self() { _M_next = 0; }
1.740 +
1.741 + __owned_link* _Next() { return _M_next; }
1.742 + const __owned_link* _Next() const { return _M_next; }
1.743 +
1.744 +public:
1.745 + __owned_list* _M_owner;
1.746 + __owned_link* _M_next;
1.747 +};
1.748 +
1.749 +
1.750 +class _STLP_CLASS_DECLSPEC __owned_list {
1.751 +public:
1.752 + __owned_list(void* __o) {
1.753 + // fprintf(stderr, "__owned_list(): %p\n",(void*)this);
1.754 + _M_node._M_owner = __REINTERPRET_CAST(__owned_list*,__o);
1.755 + _M_node._M_next = 0;
1.756 + }
1.757 + ~__owned_list() {
1.758 + // fprintf(stderr, "~__owned_list(): %p\n",(void*)this);
1.759 + _Invalidate_all();
1.760 + // that prevents detach
1.761 + _M_node._Invalidate();
1.762 + }
1.763 + const void* _Owner() const { return (const void*)_M_node._M_owner; }
1.764 + void* _Owner() { return (void*)_M_node._M_owner; }
1.765 + bool _Valid() const { return _M_node._M_owner != 0; }
1.766 + void _Invalidate() { _M_node._M_owner = 0; }
1.767 +
1.768 + __owned_link* _First() { return _M_node._Next(); }
1.769 + __owned_link* _Last() { return 0 ; }
1.770 +
1.771 + const __owned_link* _First() const { return (__owned_link*)_M_node._M_next; }
1.772 + const __owned_link* _Last() const { return 0 ;}
1.773 +
1.774 + void _Verify() const { __stl_debugger::_Verify(this); }
1.775 + void _Swap_owners(__owned_list& __y) { __stl_debugger::_Swap_owners(*this, __y); }
1.776 + void _Invalidate_all() { __stl_debugger::_Invalidate_all(this); }
1.777 + void _Set_owner(__owned_list& __y) { __stl_debugger::_Set_owner(*this, __y); }
1.778 +
1.779 + mutable __owned_link _M_node;
1.780 + mutable _STLP_mutex _M_lock;
1.781 +
1.782 +private:
1.783 + // should never be called, should be left not implemented,
1.784 + // but some compilers complain about it ;(
1.785 + __owned_list(const __owned_list&){}
1.786 + __owned_list& operator = (const __owned_list&) { return *this; }
1.787 +
1.788 + friend class __owned_link;
1.789 + friend struct __stl_debug_engine<bool>;
1.790 +};
1.791 +
1.792 +
1.793 +//==========================================================
1.794 +
1.795 +// forward declaratioins
1.796 +
1.797 +template <class _Iterator>
1.798 +bool _STLP_CALL __check_range(const _Iterator&, const _Iterator&);
1.799 +template <class _Iterator>
1.800 +bool _STLP_CALL __check_range(const _Iterator&,
1.801 + const _Iterator&, const _Iterator&);
1.802 +template <class _Iterator>
1.803 +bool _STLP_CALL __check_range(const _Iterator&, const _Iterator& ,
1.804 + const _Iterator&, const _Iterator& );
1.805 +template <class _Tp>
1.806 +bool _STLP_CALL __check_ptr_range(const _Tp*, const _Tp*);
1.807 +
1.808 +
1.809 +template <class _Iterator>
1.810 +void _STLP_CALL __invalidate_range(const __owned_list* __base,
1.811 + const _Iterator& __first,
1.812 + const _Iterator& __last);
1.813 +
1.814 +template <class _Iterator>
1.815 +void _STLP_CALL __invalidate_iterator(const __owned_list* __base,
1.816 + const _Iterator& __it);
1.817 +
1.818 +template <class _Iterator>
1.819 +void _STLP_CALL __change_range_owner(const _Iterator& __first,
1.820 + const _Iterator& __last,
1.821 + const __owned_list* __dst);
1.822 +
1.823 +template <class _Iterator>
1.824 +void _STLP_CALL __change_ite_owner(const _Iterator& __it,
1.825 + const __owned_list* __dst);
1.826 +
1.827 +//============================================================
1.828 +inline bool _STLP_CALL
1.829 +__check_same_owner(const __owned_link& __i1, const __owned_link& __i2)
1.830 +{ return __stl_debugger::_Check_same_owner(__i1,__i2); }
1.831 +
1.832 +inline bool _STLP_CALL
1.833 +__check_same_or_null_owner(const __owned_link& __i1, const __owned_link& __i2)
1.834 +{ return __stl_debugger::_Check_same_or_null_owner(__i1,__i2); }
1.835 +
1.836 +template <class _Iterator>
1.837 +inline bool _STLP_CALL __check_if_owner( const __owned_list* __owner,
1.838 + const _Iterator& __it)
1.839 +{ return __stl_debugger::_Check_if_owner(__owner, (const __owned_link&)__it); }
1.840 +
1.841 +template <class _Iterator>
1.842 +inline bool _STLP_CALL __check_if_not_owner( const __owned_list* /*__owner*/,
1.843 + const _Iterator& /*__it*/,
1.844 + const __false_type&)
1.845 +{ return true; }
1.846 +
1.847 +template <class _Iterator>
1.848 +inline bool _STLP_CALL __check_if_not_owner( const __owned_list* __owner,
1.849 + const _Iterator& __it,
1.850 + const __true_type&)
1.851 +{ return __stl_debugger::_Check_if_not_owner(__owner, (const __owned_link&)__it); }
1.852 +
1.853 +_STLP_MOVE_TO_STD_NAMESPACE
1.854 +
1.855 +_STLP_END_NAMESPACE
1.856 +
1.857 +#endif /* _STLP_DEBUG */
1.858 +
1.859 +#if defined (_STLP_ASSERTIONS)
1.860 +
1.861 +# if !defined (_STLP_ASSERT_MSG_TRAILER)
1.862 +# define _STLP_ASSERT_MSG_TRAILER
1.863 +# endif
1.864 +
1.865 +// dwa 12/30/98 - if _STLP_DEBUG_MESSAGE is defined, the user can supply own definition.
1.866 +# if !defined (_STLP_DEBUG_MESSAGE)
1.867 +# define __stl_debug_message __stl_debugger::_Message
1.868 +# else
1.869 +extern void __stl_debug_message(const char * format_str, ...);
1.870 +# endif
1.871 +
1.872 +// fbp: if _STLP_DEBUG_TERMINATE is defined, the user can supply own definition.
1.873 +# if !defined (_STLP_DEBUG_TERMINATE)
1.874 +# define __stl_debug_terminate __stl_debugger::_Terminate
1.875 +# else
1.876 +extern void __stl_debug_terminate();
1.877 +# endif
1.878 +
1.879 +#endif
1.880 +
1.881 +#if !defined (_STLP_LINK_TIME_INSTANTIATION)
1.882 +# include <stl/debug/_debug.c>
1.883 +#endif
1.884 +
1.885 +#endif /* DEBUG_H */
1.886 +
1.887 +// Local Variables:
1.888 +// mode:C++
1.889 +// End: