|
|
|
|
|
|
|
|
|
|
|
|
|
|
| #include <corecrt_internal.h>
|
|
|
|
|
|
|
|
|
|
|
| static CRITICAL_SECTION __acrt_lock_table[__acrt_lock_count];
|
|
|
|
|
|
|
|
|
|
|
|
|
| static unsigned __acrt_locks_initialized;
|
|
|
|
|
|
|
| extern "C" bool __cdecl __acrt_initialize_locks()
|
| {
|
| for (unsigned i = 0; i < __acrt_lock_count; ++i)
|
| {
|
| if (!__acrt_InitializeCriticalSectionEx(&__acrt_lock_table[i], _CORECRT_SPINCOUNT, 0))
|
| {
|
| __acrt_uninitialize_locks(false);
|
| return false;
|
| }
|
|
|
| ++__acrt_locks_initialized;
|
| }
|
|
|
| return true;
|
| }
|
|
|
| extern "C" bool __cdecl __acrt_uninitialize_locks(bool const )
|
| {
|
| for (unsigned i = __acrt_locks_initialized; i > 0; --i)
|
| {
|
| DeleteCriticalSection(&__acrt_lock_table[i - 1]);
|
| --__acrt_locks_initialized;
|
| }
|
|
|
| return true;
|
| }
|
|
|
| extern "C" void __cdecl __acrt_lock(_In_ __acrt_lock_id _Lock)
|
| {
|
| EnterCriticalSection(&__acrt_lock_table[_Lock]);
|
| }
|
|
|
| extern "C" void __cdecl __acrt_unlock(_In_ __acrt_lock_id _Lock)
|
| {
|
| LeaveCriticalSection(&__acrt_lock_table[_Lock]);
|
| }
|
|
|
| extern "C" void __cdecl _lock_locales()
|
| {
|
| __acrt_eagerly_load_locale_apis();
|
| __acrt_lock(__acrt_locale_lock);
|
| }
|
|
|
| extern "C" void __cdecl _unlock_locales()
|
| {
|
| __acrt_unlock(__acrt_locale_lock);
|
| }
|
|
|