From: Piotr Caban Subject: [PATCH 7/7] msvcrt: Throw throw_scheduler_resource_allocation_error on Context tls index allocation error Message-Id: <5503545a-f509-be27-ce8c-be0ef6e6b213@codeweavers.com> Date: Thu, 23 Mar 2017 10:56:37 +0100 Signed-off-by: Piotr Caban --- dlls/msvcrt/cpp.c | 9 +++++++++ dlls/msvcrt/msvcrt.h | 3 +++ dlls/msvcrt/scheduler.c | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dlls/msvcrt/cpp.c b/dlls/msvcrt/cpp.c index 6963db7..46bf75f 100644 --- a/dlls/msvcrt/cpp.c +++ b/dlls/msvcrt/cpp.c @@ -843,6 +843,15 @@ void throw_bad_alloc(const char *str) } #endif +#if _MSVCR_VER >= 100 +void throw_scheduler_resource_allocation_error(const char *str, HRESULT hr) +{ + scheduler_resource_allocation_error e; + scheduler_resource_allocation_error_ctor_name(&e, str, hr); + _CxxThrowException(&e.e, &scheduler_resource_allocation_error_exception_type); +} +#endif + /****************************************************************** * ?set_terminate@@YAP6AXXZP6AXXZ@Z (MSVCRT.@) * diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index 659a3dc..dd957ef 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -285,6 +285,9 @@ void msvcrt_set_errno(int) DECLSPEC_HIDDEN; #if _MSVCR_VER >= 80 void throw_bad_alloc(const char*) DECLSPEC_HIDDEN; #endif +#if _MSVCR_VER >= 100 +void throw_scheduler_resource_allocation_error(const char*, HRESULT) DECLSPEC_HIDDEN; +#endif void __cdecl _purecall(void); void __cdecl _amsg_exit(int errnum); diff --git a/dlls/msvcrt/scheduler.c b/dlls/msvcrt/scheduler.c index eab9f77..ec2b06b 100644 --- a/dlls/msvcrt/scheduler.c +++ b/dlls/msvcrt/scheduler.c @@ -85,7 +85,8 @@ static Context* get_current_context(void) if (context_tls_index == TLS_OUT_OF_INDEXES) { int tls_index = TlsAlloc(); if (tls_index == TLS_OUT_OF_INDEXES) { - /* throw scheduler_resource_allocation_error */ + throw_scheduler_resource_allocation_error(NULL, + HRESULT_FROM_WIN32(GetLastError())); return NULL; }