Common: reformat (#4720)

* common: format AlignedMalloc.cpp

* common: format AppTrait.h

* common: format Assertions.h

* common: format CheckedStaticBox

* common: format Console

* common: format Dependencies.h

* common: format EmbeddedImage

* common: format EventSource

* common: format Exceptions

* common: format FastFormatString.cpp

* common: format General.h

* common: format InitInterface

* common: format MathUtils.h

* common: format MemsetFast/MemcpyFast

* common: format Mutex.cpp

* common: format PageFaultSource.h

* common: format Path.h

* common: format PathUtils.cpp

* common: format Pcsx2Types.h

* common: format Perf

* common: format PersistentThread.h

* common: format RwMutex

* common: format SafeArray

* common: format ScopedAlloc.h

* common: format ScopedPtrMT.h

* common: format Semaphore.cpp

* common: format StringHelpers

* common: format ThreadTools.cpp

* common: format Threading.h

* common: format ThreadingDialogs

* common: format ThreadingInternal.h

* common: format TraceLog.h

* common: format VirtualMemory.cpp

* common: format pxCheckBox

* common: format pxEvents.h

* common: format pxForwardDefs.h

* common: format pxRadioPanel

* common: format pxStaticText

* common: format pxStreams

* common: format pxTranslate.cpp

* common: format pxWindowTextWriter.cpp

* common: format wxAppWithHelpers

* common: format wxBaseTools.h

* common: format wxGuiTools

* common: format wxHelpers.cpp

* common: format Darwin directory

* common: format Linux directory

* common: format Windows directory

* common: format LnxCpuDetect.cpp

* common: format WinCpuDetect.cpp

* common: format bmi.cpp

* common: format cpudetect.cpp

* common: format cpu_detect_internal.h

* common: format fpu.cpp

* common: format groups.cpp

* common: format instructions.h

* common: format internal.h

* common: format jmp.cpp

* common: format legacy.cpp

* common: format legacy_instructions.h

* common: format legacy_internal.h

* common: format movs.cpp

* common: format simd.cpp

* common: format tools.h

* common: format x86emitter.cpp

* common: format x86types.h

* common: format bmi.h

* common: format dwshift.h

* common: format group1.h group2.h group3.h

* common: format incdec.h

* common: format jmpcall.h

* common: format movs.h

* common: format simd_arithmetic.h

* common: format simd_comparisons.h

* common: format simd_helpers.h

* common: format simd_moremovs.h

* common: format simd_shufflepack.h

* common: format simd_templated_helpers.h

* common: format test.h
This commit is contained in:
Kojin authored and GitHub committed 2021-09-06 14:28:26 -04:00
1 parent f9bf87f50d
commit 13dfceff48
102 files changed
+13189 -12692

No files matched your search

+181 -175
View File
@@ -42,28 +42,28 @@ Fnptr_OutOfMemory pxDoOutOfMemory = NULL;
// That's ok. What we don't want is the *same* thread recurse-asserting.
static DeclareTls(int) s_assert_guard(0);
pxDoAssertFnType *pxDoAssert = pxAssertImpl_LogIt;
pxDoAssertFnType* pxDoAssert = pxAssertImpl_LogIt;
// make life easier for people using VC++ IDE by using this format, which allows double-click
// response times from the Output window...
wxString DiagnosticOrigin::ToString(const wxChar *msg) const
wxString DiagnosticOrigin::ToString(const wxChar* msg) const
{
FastFormatUnicode message;
FastFormatUnicode message;
message.Write(L"%ls(%d) : assertion failed:\n", srcfile, line);
message.Write(L"%ls(%d) : assertion failed:\n", srcfile, line);
if (function != NULL)
message.Write(" Function: %s\n", function);
if (function != NULL)
message.Write(" Function: %s\n", function);
message.Write(L" Thread: %s\n", WX_STR(Threading::pxGetCurrentThreadName()));
message.Write(L" Thread: %s\n", WX_STR(Threading::pxGetCurrentThreadName()));
if (condition != NULL)
message.Write(L" Condition: %ls\n", condition);
if (condition != NULL)
message.Write(L" Condition: %ls\n", condition);
if (msg != NULL)
message.Write(L" Message: %ls\n", msg);
if (msg != NULL)
message.Write(L" Message: %ls\n", msg);
return message;
return message;
}
@@ -71,191 +71,196 @@ wxString DiagnosticOrigin::ToString(const wxChar *msg) const
void pxTrap()
{
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
__debugbreak();
__debugbreak();
#elif defined(__WXMAC__) && !defined(__DARWIN__)
#if __powerc
Debugger();
Debugger();
#else
SysBreak();
SysBreak();
#endif
#elif defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
Debugger();
Debugger();
#elif defined(__UNIX__)
raise(SIGTRAP);
raise(SIGTRAP);
#else
// TODO
#endif // Win/Unix
}
bool pxAssertImpl_LogIt(const DiagnosticOrigin &origin, const wxChar *msg)
bool pxAssertImpl_LogIt(const DiagnosticOrigin& origin, const wxChar* msg)
{
//wxLogError( L"%s", origin.ToString( msg ).c_str() );
wxMessageOutputDebug().Printf(L"%s", origin.ToString(msg).c_str());
pxTrap();
return false;
//wxLogError( L"%s", origin.ToString( msg ).c_str() );
wxMessageOutputDebug().Printf(L"%s", origin.ToString(msg).c_str());
pxTrap();
return false;
}
DEVASSERT_INLINE void pxOnAssert(const DiagnosticOrigin &origin, const wxString &msg)
DEVASSERT_INLINE void pxOnAssert(const DiagnosticOrigin& origin, const wxString& msg)
{
// Recursion guard: Allow at least one recursive call. This is useful because sometimes
// we get meaningless assertions while unwinding stack traces after exceptions have occurred.
// Recursion guard: Allow at least one recursive call. This is useful because sometimes
// we get meaningless assertions while unwinding stack traces after exceptions have occurred.
RecursionGuard guard(s_assert_guard);
if (guard.Counter > 2) {
return pxTrap();
}
RecursionGuard guard(s_assert_guard);
if (guard.Counter > 2)
{
return pxTrap();
}
// wxWidgets doesn't come with debug builds on some Linux distros, and other distros make
// it difficult to use the debug build (compilation failures). To handle these I've had to
// bypass the internal wxWidgets assertion handler entirely, since it may not exist even if
// PCSX2 itself is compiled in debug mode (assertions enabled).
// wxWidgets doesn't come with debug builds on some Linux distros, and other distros make
// it difficult to use the debug build (compilation failures). To handle these I've had to
// bypass the internal wxWidgets assertion handler entirely, since it may not exist even if
// PCSX2 itself is compiled in debug mode (assertions enabled).
bool trapit;
bool trapit;
if (pxDoAssert == NULL) {
// Note: Format uses MSVC's syntax for output window hotlinking.
trapit = pxAssertImpl_LogIt(origin, msg.wc_str());
} else {
trapit = pxDoAssert(origin, msg.wc_str());
}
if (pxDoAssert == NULL)
{
// Note: Format uses MSVC's syntax for output window hotlinking.
trapit = pxAssertImpl_LogIt(origin, msg.wc_str());
}
else
{
trapit = pxDoAssert(origin, msg.wc_str());
}
if (trapit) {
pxTrap();
}
if (trapit)
{
pxTrap();
}
}
// --------------------------------------------------------------------------------------
// BaseException (implementations)
// --------------------------------------------------------------------------------------
BaseException &BaseException::SetBothMsgs(const wxChar *msg_diag)
BaseException& BaseException::SetBothMsgs(const wxChar* msg_diag)
{
m_message_user = msg_diag ? wxString(wxGetTranslation(msg_diag)) : wxString("");
return SetDiagMsg(msg_diag);
m_message_user = msg_diag ? wxString(wxGetTranslation(msg_diag)) : wxString("");
return SetDiagMsg(msg_diag);
}
BaseException &BaseException::SetDiagMsg(const wxString &msg_diag)
BaseException& BaseException::SetDiagMsg(const wxString& msg_diag)
{
m_message_diag = msg_diag;
return *this;
m_message_diag = msg_diag;
return *this;
}
BaseException &BaseException::SetUserMsg(const wxString &msg_user)
BaseException& BaseException::SetUserMsg(const wxString& msg_user)
{
m_message_user = msg_user;
return *this;
m_message_user = msg_user;
return *this;
}
wxString BaseException::FormatDiagnosticMessage() const
{
return m_message_diag;
return m_message_diag;
}
wxString BaseException::FormatDisplayMessage() const
{
return m_message_user.IsEmpty() ? m_message_diag : m_message_user;
return m_message_user.IsEmpty() ? m_message_diag : m_message_user;
}
// --------------------------------------------------------------------------------------
// Exception::RuntimeError (implementations)
// --------------------------------------------------------------------------------------
Exception::RuntimeError::RuntimeError(const std::runtime_error &ex, const wxString &prefix)
Exception::RuntimeError::RuntimeError(const std::runtime_error& ex, const wxString& prefix)
{
IsSilent = false;
IsSilent = false;
SetDiagMsg(pxsFmt(L"STL Runtime Error%s: %s",
(prefix.IsEmpty() ? L"" : pxsFmt(L" (%s)", WX_STR(prefix)).c_str()),
WX_STR(fromUTF8(ex.what()))));
SetDiagMsg(pxsFmt(L"STL Runtime Error%s: %s",
(prefix.IsEmpty() ? L"" : pxsFmt(L" (%s)", WX_STR(prefix)).c_str()),
WX_STR(fromUTF8(ex.what()))));
}
Exception::RuntimeError::RuntimeError(const std::exception &ex, const wxString &prefix)
Exception::RuntimeError::RuntimeError(const std::exception& ex, const wxString& prefix)
{
IsSilent = false;
IsSilent = false;
SetDiagMsg(pxsFmt(L"STL Exception%s: %s",
(prefix.IsEmpty() ? L"" : pxsFmt(L" (%s)", WX_STR(prefix)).c_str()),
WX_STR(fromUTF8(ex.what()))));
SetDiagMsg(pxsFmt(L"STL Exception%s: %s",
(prefix.IsEmpty() ? L"" : pxsFmt(L" (%s)", WX_STR(prefix)).c_str()),
WX_STR(fromUTF8(ex.what()))));
}
// --------------------------------------------------------------------------------------
// Exception::OutOfMemory (implementations)
// --------------------------------------------------------------------------------------
Exception::OutOfMemory::OutOfMemory(const wxString &allocdesc)
Exception::OutOfMemory::OutOfMemory(const wxString& allocdesc)
{
AllocDescription = allocdesc;
AllocDescription = allocdesc;
}
wxString Exception::OutOfMemory::FormatDiagnosticMessage() const
{
FastFormatUnicode retmsg;
retmsg.Write(L"Out of memory");
if (!AllocDescription.IsEmpty())
retmsg.Write(L" while allocating '%s'", WX_STR(AllocDescription));
FastFormatUnicode retmsg;
retmsg.Write(L"Out of memory");
if (!AllocDescription.IsEmpty())
retmsg.Write(L" while allocating '%s'", WX_STR(AllocDescription));
if (!m_message_diag.IsEmpty())
retmsg.Write(L":\n%s", WX_STR(m_message_diag));
if (!m_message_diag.IsEmpty())
retmsg.Write(L":\n%s", WX_STR(m_message_diag));
return retmsg;
return retmsg;
}
wxString Exception::OutOfMemory::FormatDisplayMessage() const
{
FastFormatUnicode retmsg;
retmsg.Write(L"%s", _("Oh noes! Out of memory!"));
FastFormatUnicode retmsg;
retmsg.Write(L"%s", _("Oh noes! Out of memory!"));
if (!m_message_user.IsEmpty())
retmsg.Write(L"\n\n%s", WX_STR(m_message_user));
if (!m_message_user.IsEmpty())
retmsg.Write(L"\n\n%s", WX_STR(m_message_user));
return retmsg;
return retmsg;
}
// --------------------------------------------------------------------------------------
// Exception::VirtualMemoryMapConflict (implementations)
// --------------------------------------------------------------------------------------
Exception::VirtualMemoryMapConflict::VirtualMemoryMapConflict(const wxString &allocdesc)
Exception::VirtualMemoryMapConflict::VirtualMemoryMapConflict(const wxString& allocdesc)
{
AllocDescription = allocdesc;
m_message_user = _("Virtual memory mapping failure! Your system may have conflicting device drivers, services, or may simply have insufficient memory or resources to meet PCSX2's lofty needs.");
AllocDescription = allocdesc;
m_message_user = _("Virtual memory mapping failure! Your system may have conflicting device drivers, services, or may simply have insufficient memory or resources to meet PCSX2's lofty needs.");
}
wxString Exception::VirtualMemoryMapConflict::FormatDiagnosticMessage() const
{
FastFormatUnicode retmsg;
retmsg.Write(L"Virtual memory map failed");
if (!AllocDescription.IsEmpty())
retmsg.Write(L" while reserving '%s'", WX_STR(AllocDescription));
FastFormatUnicode retmsg;
retmsg.Write(L"Virtual memory map failed");
if (!AllocDescription.IsEmpty())
retmsg.Write(L" while reserving '%s'", WX_STR(AllocDescription));
if (!m_message_diag.IsEmpty())
retmsg.Write(L":\n%s", WX_STR(m_message_diag));
if (!m_message_diag.IsEmpty())
retmsg.Write(L":\n%s", WX_STR(m_message_diag));
return retmsg;
return retmsg;
}
wxString Exception::VirtualMemoryMapConflict::FormatDisplayMessage() const
{
FastFormatUnicode retmsg;
retmsg.Write(L"%s",
pxE(L"There is not enough virtual memory available, or necessary virtual memory mappings have already been reserved by other processes, services, or DLLs."));
FastFormatUnicode retmsg;
retmsg.Write(L"%s",
pxE(L"There is not enough virtual memory available, or necessary virtual memory mappings have already been reserved by other processes, services, or DLLs."));
if (!m_message_diag.IsEmpty())
retmsg.Write(L"\n\n%s", WX_STR(m_message_diag));
if (!m_message_diag.IsEmpty())
retmsg.Write(L"\n\n%s", WX_STR(m_message_diag));
return retmsg;
return retmsg;
}
// ------------------------------------------------------------------------
wxString Exception::CancelEvent::FormatDiagnosticMessage() const
{
return L"Action canceled: " + m_message_diag;
return L"Action canceled: " + m_message_diag;
}
wxString Exception::CancelEvent::FormatDisplayMessage() const
{
return L"Action canceled: " + m_message_diag;
return L"Action canceled: " + m_message_diag;
}
// --------------------------------------------------------------------------------------
@@ -263,40 +268,40 @@ wxString Exception::CancelEvent::FormatDisplayMessage() const
// --------------------------------------------------------------------------------------
wxString Exception::BadStream::FormatDiagnosticMessage() const
{
FastFormatUnicode retval;
_formatDiagMsg(retval);
return retval;
FastFormatUnicode retval;
_formatDiagMsg(retval);
return retval;
}
wxString Exception::BadStream::FormatDisplayMessage() const
{
FastFormatUnicode retval;
_formatUserMsg(retval);
return retval;
FastFormatUnicode retval;
_formatUserMsg(retval);
return retval;
}
void Exception::BadStream::_formatDiagMsg(FastFormatUnicode &dest) const
void Exception::BadStream::_formatDiagMsg(FastFormatUnicode& dest) const
{
dest.Write(L"Path: ");
if (!StreamName.IsEmpty())
dest.Write(L"%s", WX_STR(StreamName));
else
dest.Write(L"[Unnamed or unknown]");
dest.Write(L"Path: ");
if (!StreamName.IsEmpty())
dest.Write(L"%s", WX_STR(StreamName));
else
dest.Write(L"[Unnamed or unknown]");
if (!m_message_diag.IsEmpty())
dest.Write(L"\n%s", WX_STR(m_message_diag));
if (!m_message_diag.IsEmpty())
dest.Write(L"\n%s", WX_STR(m_message_diag));
}
void Exception::BadStream::_formatUserMsg(FastFormatUnicode &dest) const
void Exception::BadStream::_formatUserMsg(FastFormatUnicode& dest) const
{
dest.Write(_("Path: "));
if (!StreamName.IsEmpty())
dest.Write(L"%s", WX_STR(StreamName));
else
dest.Write(_("[Unnamed or unknown]"));
dest.Write(_("Path: "));
if (!StreamName.IsEmpty())
dest.Write(L"%s", WX_STR(StreamName));
else
dest.Write(_("[Unnamed or unknown]"));
if (!m_message_user.IsEmpty())
dest.Write(L"\n%s", WX_STR(m_message_user));
if (!m_message_user.IsEmpty())
dest.Write(L"\n%s", WX_STR(m_message_user));
}
// --------------------------------------------------------------------------------------
@@ -304,19 +309,19 @@ void Exception::BadStream::_formatUserMsg(FastFormatUnicode &dest) const
// --------------------------------------------------------------------------------------
wxString Exception::CannotCreateStream::FormatDiagnosticMessage() const
{
FastFormatUnicode retval;
retval.Write("File could not be created.");
_formatDiagMsg(retval);
return retval;
FastFormatUnicode retval;
retval.Write("File could not be created.");
_formatDiagMsg(retval);
return retval;
}
wxString Exception::CannotCreateStream::FormatDisplayMessage() const
{
FastFormatUnicode retval;
retval.Write(_("A file could not be created."));
retval.Write("\n");
_formatUserMsg(retval);
return retval;
FastFormatUnicode retval;
retval.Write(_("A file could not be created."));
retval.Write("\n");
_formatUserMsg(retval);
return retval;
}
// --------------------------------------------------------------------------------------
@@ -324,19 +329,19 @@ wxString Exception::CannotCreateStream::FormatDisplayMessage() const
// --------------------------------------------------------------------------------------
wxString Exception::FileNotFound::FormatDiagnosticMessage() const
{
FastFormatUnicode retval;
retval.Write("File not found.\n");
_formatDiagMsg(retval);
return retval;
FastFormatUnicode retval;
retval.Write("File not found.\n");
_formatDiagMsg(retval);
return retval;
}
wxString Exception::FileNotFound::FormatDisplayMessage() const
{
FastFormatUnicode retval;
retval.Write(_("File not found."));
retval.Write("\n");
_formatUserMsg(retval);
return retval;
FastFormatUnicode retval;
retval.Write(_("File not found."));
retval.Write("\n");
_formatUserMsg(retval);
return retval;
}
// --------------------------------------------------------------------------------------
@@ -344,19 +349,19 @@ wxString Exception::FileNotFound::FormatDisplayMessage() const
// --------------------------------------------------------------------------------------
wxString Exception::AccessDenied::FormatDiagnosticMessage() const
{
FastFormatUnicode retval;
retval.Write("Permission denied to file.\n");
_formatDiagMsg(retval);
return retval;
FastFormatUnicode retval;
retval.Write("Permission denied to file.\n");
_formatDiagMsg(retval);
return retval;
}
wxString Exception::AccessDenied::FormatDisplayMessage() const
{
FastFormatUnicode retval;
retval.Write(_("Permission denied while trying to open file, likely due to insufficient user account rights."));
retval.Write("\n");
_formatUserMsg(retval);
return retval;
FastFormatUnicode retval;
retval.Write(_("Permission denied while trying to open file, likely due to insufficient user account rights."));
retval.Write("\n");
_formatUserMsg(retval);
return retval;
}
// --------------------------------------------------------------------------------------
@@ -364,19 +369,19 @@ wxString Exception::AccessDenied::FormatDisplayMessage() const
// --------------------------------------------------------------------------------------
wxString Exception::EndOfStream::FormatDiagnosticMessage() const
{
FastFormatUnicode retval;
retval.Write("Unexpected end of file or stream.\n");
_formatDiagMsg(retval);
return retval;
FastFormatUnicode retval;
retval.Write("Unexpected end of file or stream.\n");
_formatDiagMsg(retval);
return retval;
}
wxString Exception::EndOfStream::FormatDisplayMessage() const
{
FastFormatUnicode retval;
retval.Write(_("Unexpected end of file or stream encountered. File is probably truncated or corrupted."));
retval.Write("\n");
_formatUserMsg(retval);
return retval;
FastFormatUnicode retval;
retval.Write(_("Unexpected end of file or stream encountered. File is probably truncated or corrupted."));
retval.Write("\n");
_formatUserMsg(retval);
return retval;
}
// --------------------------------------------------------------------------------------
@@ -385,34 +390,35 @@ wxString Exception::EndOfStream::FormatDisplayMessage() const
// Translates an Errno code into an exception.
// Throws an exception based on the given error code (usually taken from ANSI C's errno)
BaseException *Exception::FromErrno(const wxString &streamname, int errcode)
BaseException* Exception::FromErrno(const wxString& streamname, int errcode)
{
pxAssumeDev(errcode != 0, "Invalid NULL error code? (errno)");
pxAssumeDev(errcode != 0, "Invalid NULL error code? (errno)");
switch (errcode) {
case EINVAL:
pxFailDev(L"Invalid argument");
return &(new Exception::BadStream(streamname))->SetDiagMsg(L"Invalid argument? (likely caused by an unforgivable programmer error!)");
switch (errcode)
{
case EINVAL:
pxFailDev(L"Invalid argument");
return &(new Exception::BadStream(streamname))->SetDiagMsg(L"Invalid argument? (likely caused by an unforgivable programmer error!)");
case EACCES: // Access denied!
return new Exception::AccessDenied(streamname);
case EACCES: // Access denied!
return new Exception::AccessDenied(streamname);
case EMFILE: // Too many open files!
return &(new Exception::CannotCreateStream(streamname))->SetDiagMsg(L"Too many open files"); // File handle allocation failure
case EMFILE: // Too many open files!
return &(new Exception::CannotCreateStream(streamname))->SetDiagMsg(L"Too many open files"); // File handle allocation failure
case EEXIST:
return &(new Exception::CannotCreateStream(streamname))->SetDiagMsg(L"File already exists");
case EEXIST:
return &(new Exception::CannotCreateStream(streamname))->SetDiagMsg(L"File already exists");
case ENOENT: // File not found!
return new Exception::FileNotFound(streamname);
case ENOENT: // File not found!
return new Exception::FileNotFound(streamname);
case EPIPE:
return &(new Exception::BadStream(streamname))->SetDiagMsg(L"Broken pipe");
case EPIPE:
return &(new Exception::BadStream(streamname))->SetDiagMsg(L"Broken pipe");
case EBADF:
return &(new Exception::BadStream(streamname))->SetDiagMsg(L"Bad file number");
case EBADF:
return &(new Exception::BadStream(streamname))->SetDiagMsg(L"Bad file number");
default:
return &(new Exception::BadStream(streamname))->SetDiagMsg(pxsFmt(L"General file/stream error [errno: %d]", errcode));
}
default:
return &(new Exception::BadStream(streamname))->SetDiagMsg(pxsFmt(L"General file/stream error [errno: %d]", errcode));
}
}