// Takes a reference to a locale::id, and returns its numeric index. // If no numeric index has yet been assigned, assigns one. The return // value is always positive. static size_t _Stl_loc_get_index(locale::id& id) { if (id._M_index == 0) { #if defined (_STLP_ATOMIC_INCREMENT) id._M_index = _STLP_ATOMIC_INCREMENT(&(locale::id::_S_max)); #else static _STLP_STATIC_MUTEX _Index_lock _STLP_MUTEX_INITIALIZER; _STLP_auto_lock sentry(_Index_lock); size_t new_index = locale::id::_S_max++; id._M_index = new_index; #endif } return id._M_index; }
// Takes a reference to a locale::id, assign a numeric index if not already // affected and returns it. The returned index is always positive. static const locale::id& _Stl_loc_get_index(locale::id& id) { if (id._M_index == 0) { #if defined (_STLP_ATOMIC_INCREMENT) && !defined (_STLP_WIN95_LIKE) static _STLP_VOLATILE __stl_atomic_t _S_index = __STATIC_CAST(__stl_atomic_t, locale::id::_S_max); id._M_index = _STLP_ATOMIC_INCREMENT(&_S_index); #else static _STLP_STATIC_MUTEX _Index_lock _STLP_MUTEX_INITIALIZER; _STLP_auto_lock sentry(_Index_lock); size_t new_index = locale::id::_S_max++; id._M_index = new_index; #endif } return id; }