static unsigned long WINAPI thread_start(void* const parameter) throw() { if (!parameter) { ExitThread(GetLastError()); } __acrt_thread_parameter* const context = static_cast<__acrt_thread_parameter*>(parameter); __acrt_getptd()->_beginthread_context = context; if (__acrt_is_packaged_app()) { context->_initialized_apartment = __acrt_RoInitialize(RO_INIT_MULTITHREADED) == S_OK; } __try { ThreadProcedure const procedure = reinterpret_cast<ThreadProcedure>(context->_procedure); _endthreadex(invoke_thread_procedure(procedure, context->_context)); } __except (_seh_filter_exe(GetExceptionCode(), GetExceptionInformation())) { // Execution should never reach here: _exit(GetExceptionCode()); } // This return statement will never be reached. All execution paths result // in the thread or process exiting. return 0; }
/*** * _configthreadlocale(int i) * * Purpose: * To set _own_locale flag on threadinfo sturct. If this flag is set, this thread * is going own it's threadlocinfo struct. Setlocale call on other thread will have * no effect on this thread's locale. If 0 is passed then nothing is changed, but * current status is returned. * Exit : * Returns the current status - i.e. per thread locale is enabled or not. * *******************************************************************************/ int __cdecl _configthreadlocale(int i) { /* * ownlocale flag struct: * bits: 000000000000000000000000000000P1 * P is set when _ENABLE_PER_THREAD_LOCALE is called for this thread * or _ENABLE_PER_THREAD_LOCALE_NEW was set when this thread was created. * * __globallocalestatus structure: * bits: 11111111111111111111111111111N1G * G is set if _ENABLE_PER_THREAD_LOCALE_GLOBAL is set. * G is 0 if _ENABLE_PER_THREAD_LOCALE_GLOBAL is not set. * N is set if _ENABLE_PER_THREAD_LOCALE_NEW is set. * N is 0 if _ENABLE_PER_THREAD_LOCALE_NEW is not set. */ __acrt_ptd* const ptd = __acrt_getptd(); int retval = (ptd->_own_locale & _PER_THREAD_LOCALE_BIT)==0 ? _DISABLE_PER_THREAD_LOCALE:_ENABLE_PER_THREAD_LOCALE; switch(i) { case _ENABLE_PER_THREAD_LOCALE : ptd->_own_locale = ptd->_own_locale | _PER_THREAD_LOCALE_BIT; break; case _DISABLE_PER_THREAD_LOCALE : ptd->_own_locale = ptd->_own_locale & ~_PER_THREAD_LOCALE_BIT; break; case 0 : break; /* used only during dll startup for linkopt */ case -1 : __globallocalestatus=-1; break; default : _VALIDATE_RETURN(("Invalid parameter for _configthreadlocale",0),EINVAL,-1); break; } return retval; }
extern "C" __crt_multibyte_data* __cdecl __acrt_update_thread_multibyte_data(void) { __crt_multibyte_data* ptmbci = nullptr; __acrt_ptd* const ptd = __acrt_getptd(); if ((ptd->_own_locale & __globallocalestatus) == 0 || ptd->_locale_info == nullptr) { __acrt_lock(__acrt_multibyte_cp_lock); __try { ptmbci = ptd->_multibyte_info; if (ptmbci != __acrt_current_multibyte_data) { /* * Decrement the reference count in the old mbc info structure * and free it, if necessary */ if (ptmbci != nullptr && InterlockedDecrement(&ptmbci->refcount) == 0 && ptmbci != &__acrt_initial_multibyte_data) { /* * Free it */ _free_crt(ptmbci); } /* * Point to the current mbc info structure and increment its * reference count. */ ptmbci = ptd->_multibyte_info = __acrt_current_multibyte_data; InterlockedIncrement(&ptmbci->refcount); } } __finally { __acrt_unlock(__acrt_multibyte_cp_lock); } }
extern "C" char* __cdecl strtok(char* const string, char const* const control) { return __acrt_strtok_s_novalidation(string, control, &__acrt_getptd()->_strtok_token); }
extern "C" unexpected_handler __cdecl _get_unexpected() { return get_unexpected_or_default(__acrt_getptd()); }