Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cmake-init generated CMake files #4

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
9 changes: 5 additions & 4 deletions asio/include/asio/detail/impl/win_mutex.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int win_mutex::do_init()
# endif
return 0;
#else
__try
try
{
# if defined(UNDER_CE)
::InitializeCriticalSection(&crit_section_);
Expand All @@ -64,10 +64,11 @@ int win_mutex::do_init()
return ::GetLastError();
# endif
}
__except(GetExceptionCode() == STATUS_NO_MEMORY
? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
catch (const std::bad_alloc&)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anarthal This was my quick solution for ths MSVC inline problem

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like GitHub had an issue yesterday, I got some 500 errors when trying to post my comments.

This doesn't do what you'd expect. SEH __catch clauses do catch C++ exceptions, but C++ catch doesn't catch SEH exceptions AFAIK. There's no std::bad_alloc exception in SEH to begin with.

If I'm not mistaken, the SEH handler there is only relevant for Windows XP/Windows Server 2003 and previous versions (see the InitializeCriticalSection docs). I don't think you can target these systems with a C++20 compiler, so you can likely remove the SEH try/catch in your prototype without loss of functionality.

{
return ERROR_OUTOFMEMORY;
if(GetExceptionCode() == STATUS_NO_MEMORY
? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
return ERROR_OUTOFMEMORY;
}

return 0;
Expand Down
15 changes: 9 additions & 6 deletions asio/include/asio/detail/impl/win_static_mutex.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int win_static_mutex::do_init()
}
# endif
#else
__try
try
{
# if defined(UNDER_CE)
::InitializeCriticalSection(&crit_section_);
Expand All @@ -111,12 +111,15 @@ int win_static_mutex::do_init()
}
# endif
}
__except(GetExceptionCode() == STATUS_NO_MEMORY
? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
catch (const std::bad_alloc&)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anarthal This was my quick solution for ths MSVC inline problem

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same applies here.

{
::ReleaseMutex(mutex);
::CloseHandle(mutex);
return ERROR_OUTOFMEMORY;
if(GetExceptionCode() == STATUS_NO_MEMORY
? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
{
::ReleaseMutex(mutex);
::CloseHandle(mutex);
return ERROR_OUTOFMEMORY;
}
}
#endif

Expand Down
Loading