diff --git a/common/BitCast.h b/common/BitCast.h deleted file mode 100644 index d4c79bf2f0..0000000000 --- a/common/BitCast.h +++ /dev/null @@ -1,29 +0,0 @@ -/* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2021 PCSX2 Dev Team - * - * PCSX2 is free software: you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with PCSX2. - * If not, see . - */ - -#pragma once - -// An implementation of bit_cast until we get c++20 - -template -T2 bit_cast(const T1& src) -{ - static_assert(sizeof(T2) == sizeof(T1), "bit_cast: types must be equal size"); - static_assert(std::is_pod::value, "bit_cast: source must be POD"); - static_assert(std::is_pod::value, "bit_cast: destination must be POD"); - T2 dst; - memcpy(&dst, &src, sizeof(T2)); - return dst; -} diff --git a/common/common.vcxproj b/common/common.vcxproj index 29dca1956d..d3ac561dec 100644 --- a/common/common.vcxproj +++ b/common/common.vcxproj @@ -105,7 +105,6 @@ - diff --git a/common/common.vcxproj.filters b/common/common.vcxproj.filters index 000faa1024..b866f5a12f 100644 --- a/common/common.vcxproj.filters +++ b/common/common.vcxproj.filters @@ -276,9 +276,6 @@ Header Files - - Header Files - Header Files diff --git a/pcsx2-qt/Debugger/CpuWidget.cpp b/pcsx2-qt/Debugger/CpuWidget.cpp index db68e712b5..e7794a8042 100644 --- a/pcsx2-qt/Debugger/CpuWidget.cpp +++ b/pcsx2-qt/Debugger/CpuWidget.cpp @@ -26,7 +26,6 @@ #include "DebugTools/Breakpoints.h" #include "DebugTools/BiosDebugData.h" #include "DebugTools/MipsStackWalk.h" -#include "common/BitCast.h" #include "QtUtils.h" #include @@ -539,7 +538,7 @@ static std::vector searchWorker(DebugInterface* cpu, u32 start, u32 end, T { const float fTop = value + 0.00001f; const float fBottom = value - 0.00001f; - const float memValue = bit_cast(cpu->read32(addr)); + const float memValue = std::bit_cast(cpu->read32(addr)); if (fBottom < memValue && memValue < fTop) { hitAddresses.emplace_back(addr); @@ -556,7 +555,7 @@ static std::vector searchWorker(DebugInterface* cpu, u32 start, u32 end, T { const double dTop = value + 0.00001f; const double dBottom = value - 0.00001f; - const double memValue = bit_cast(cpu->read64(addr)); + const double memValue = std::bit_cast(cpu->read64(addr)); if (dBottom < memValue && memValue < dTop) { hitAddresses.emplace_back(addr); @@ -588,7 +587,7 @@ static std::vector searchWorkerByteArray(DebugInterface* cpu, u32 start, u3 for (u32 addr = start; addr < end; addr += 1) { bool hit = true; - for (size_t i = 0; i < value.length(); i++) + for (qsizetype i = 0; i < value.length(); i++) { if (cpu->read8(addr + i) != value[i]) { diff --git a/pcsx2-qt/Debugger/MemoryViewWidget.cpp b/pcsx2-qt/Debugger/MemoryViewWidget.cpp index aca700e870..4e6cc5a5c8 100644 --- a/pcsx2-qt/Debugger/MemoryViewWidget.cpp +++ b/pcsx2-qt/Debugger/MemoryViewWidget.cpp @@ -17,8 +17,6 @@ #include "MemoryViewWidget.h" -#include "common/BitCast.h" - #include "QtHost.h" #include "QtUtils.h" #include diff --git a/pcsx2-qt/Debugger/RegisterWidget.cpp b/pcsx2-qt/Debugger/RegisterWidget.cpp index f53eb84e24..0aa236df19 100644 --- a/pcsx2-qt/Debugger/RegisterWidget.cpp +++ b/pcsx2-qt/Debugger/RegisterWidget.cpp @@ -17,8 +17,6 @@ #include "RegisterWidget.h" -#include "common/BitCast.h" - #include "QtUtils.h" #include #include @@ -30,6 +28,7 @@ #include #include +#include #define CAT_SHOW_FLOAT (categoryIndex == EECAT_FPR && m_showFPRFloat) || (categoryIndex == EECAT_VU0F && m_showVU0FFloat) @@ -151,7 +150,7 @@ void RegisterWidget::paintEvent(QPaintEvent* event) if (categoryIndex == EECAT_VU0F && m_showVU0FFloat) painter.drawText(m_fieldStartX[j], yStart, m_fieldWidth, m_rowHeight, Qt::AlignLeft, - painter.fontMetrics().elidedText(QString::number(bit_cast(m_cpu->getRegister(categoryIndex, registerIndex)._u32[regIndex])), Qt::ElideRight, m_fieldWidth - painter.fontMetrics().averageCharWidth())); + painter.fontMetrics().elidedText(QString::number(std::bit_cast(m_cpu->getRegister(categoryIndex, registerIndex)._u32[regIndex])), Qt::ElideRight, m_fieldWidth - painter.fontMetrics().averageCharWidth())); else painter.drawText(m_fieldStartX[j], yStart, m_fieldWidth, m_rowHeight, Qt::AlignLeft, FilledQStringFromValue(curRegister._u32[regIndex], 16)); @@ -168,7 +167,7 @@ void RegisterWidget::paintEvent(QPaintEvent* event) if (categoryIndex == EECAT_FPR && m_showFPRFloat) painter.drawText(safeValueStartX, yStart, renderSize.width(), m_rowHeight, Qt::AlignLeft, - QString("%1").arg(QString::number(bit_cast(m_cpu->getRegister(categoryIndex, registerIndex)._u32[0]))).toUpper()); + QString("%1").arg(QString::number(std::bit_cast(m_cpu->getRegister(categoryIndex, registerIndex)._u32[0]))).toUpper()); else if (m_cpu->getRegisterSize(categoryIndex) == 64) painter.drawText(safeValueStartX, yStart, renderSize.width(), m_rowHeight, Qt::AlignLeft, FilledQStringFromValue(m_cpu->getRegister(categoryIndex, registerIndex).lo, 16)); @@ -299,7 +298,7 @@ void RegisterWidget::contextCopyValue() const int categoryIndex = ui.registerTabs->currentIndex(); const u128 val = m_cpu->getRegister(categoryIndex, m_selectedRow); if (CAT_SHOW_FLOAT) - QApplication::clipboard()->setText(QString("%1").arg(QString::number(bit_cast(val._u32[0])).toUpper(), 16)); + QApplication::clipboard()->setText(QString("%1").arg(QString::number(std::bit_cast(val._u32[0])).toUpper(), 16)); else QApplication::clipboard()->setText(QString("%1").arg(QString::number(val._u64[0], 16).toUpper(), 16)); } @@ -323,7 +322,7 @@ void RegisterWidget::contextCopySegment() const int categoryIndex = ui.registerTabs->currentIndex(); const u128 val = m_cpu->getRegister(categoryIndex, m_selectedRow); if (CAT_SHOW_FLOAT) - QApplication::clipboard()->setText(FilledQStringFromValue(bit_cast(val._u32[3 - m_selected128Field]), 10)); + QApplication::clipboard()->setText(FilledQStringFromValue(std::bit_cast(val._u32[3 - m_selected128Field]), 10)); else QApplication::clipboard()->setText(FilledQStringFromValue(val._u32[3 - m_selected128Field], 16)); } @@ -340,7 +339,7 @@ bool RegisterWidget::contextFetchNewValue(u64& out, u64 currentValue, bool segme if (!floatingPoint) existingValue = existingValue.arg(currentValue, regSize == 64 ? 16 : 8, 16, QChar('0')); else - existingValue = existingValue.arg(bit_cast((u32)currentValue)); + existingValue = existingValue.arg(std::bit_cast((u32)currentValue)); //: Changing the value in a CPU register (e.g. "Change t0") QString input = QInputDialog::getText(this, tr("Change %1").arg(m_cpu->getRegisterName(categoryIndex, m_selectedRow)), "", @@ -360,7 +359,7 @@ bool RegisterWidget::contextFetchNewValue(u64& out, u64 currentValue, bool segme } else { - out = bit_cast(input.toFloat(&ok)); + out = std::bit_cast(input.toFloat(&ok)); if (!ok) { QMessageBox::warning(this, tr("Invalid register value"), tr("Invalid floating-point register value."));