Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11534 from Pokechu22/warning-fixes-feb-2023
Resolve various compiler warnings
  • Loading branch information
phire committed Feb 10, 2023
2 parents a88e5ef + 3024ca2 commit dad7a32
Show file tree
Hide file tree
Showing 34 changed files with 418 additions and 348 deletions.
30 changes: 15 additions & 15 deletions Source/Core/Common/Debug/CodeTrace.cpp
Expand Up @@ -48,6 +48,21 @@ u32 GetMemoryTargetSize(std::string_view instr)

return 4;
}

bool CompareMemoryTargetToTracked(const std::string& instr, const u32 mem_target,
const std::set<u32>& mem_tracked)
{
// This function is hit often and should be optimized.
auto it_lower = std::lower_bound(mem_tracked.begin(), mem_tracked.end(), mem_target);

if (it_lower == mem_tracked.end())
return false;
else if (*it_lower == mem_target)
return true;

// If the base value doesn't hit, still need to check if longer values overlap.
return *it_lower < mem_target + GetMemoryTargetSize(instr);
}
} // namespace

void CodeTrace::SetRegTracked(const std::string& reg)
Expand Down Expand Up @@ -124,21 +139,6 @@ TraceOutput CodeTrace::SaveCurrentInstruction() const
return output;
}

bool CompareMemoryTargetToTracked(const std::string& instr, const u32 mem_target,
const std::set<u32>& mem_tracked)
{
// This function is hit often and should be optimized.
auto it_lower = std::lower_bound(mem_tracked.begin(), mem_tracked.end(), mem_target);

if (it_lower == mem_tracked.end())
return false;
else if (*it_lower == mem_target)
return true;

// If the base value doesn't hit, still need to check if longer values overlap.
return *it_lower < mem_target + GetMemoryTargetSize(instr);
}

AutoStepResults CodeTrace::AutoStepping(bool continue_previous, AutoStop stop_on)
{
AutoStepResults results;
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/Common/FatFsUtil.cpp
Expand Up @@ -195,6 +195,7 @@ extern "C" DWORD get_fattime(void)
return static_cast<DWORD>(s_callbacks->GetCurrentTimeFAT());
}

#if FF_USE_LFN == 3 // match ff.h; currently unused by Dolphin
extern "C" void* ff_memalloc(UINT msize)
{
return std::malloc(msize);
Expand All @@ -204,7 +205,9 @@ extern "C" void ff_memfree(void* mblock)
{
return std::free(mblock);
}
#endif

#if FF_FS_REENTRANT
extern "C" int ff_cre_syncobj(BYTE vol, FF_SYNC_t* sobj)
{
*sobj = new std::recursive_mutex();
Expand All @@ -229,6 +232,7 @@ extern "C" int ff_del_syncobj(FF_SYNC_t sobj)
delete reinterpret_cast<std::recursive_mutex*>(sobj);
return 1;
}
#endif

static const char* FatFsErrorToString(FRESULT error_code)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/Boot/Boot.cpp
Expand Up @@ -502,8 +502,8 @@ bool CBoot::BootUp(Core::System& system, std::unique_ptr<BootParameters> boot)

struct BootTitle
{
BootTitle(Core::System& system, const std::vector<DiscIO::Riivolution::Patch>& patches)
: system(system), config(SConfig::GetInstance()), riivolution_patches(patches)
BootTitle(Core::System& system_, const std::vector<DiscIO::Riivolution::Patch>& patches)
: system(system_), config(SConfig::GetInstance()), riivolution_patches(patches)
{
}
bool operator()(BootParameters::Disc& disc) const
Expand Down
7 changes: 7 additions & 0 deletions Source/Core/Core/FifoPlayer/FifoPlayer.cpp
Expand Up @@ -101,7 +101,14 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file,
part_start = offset;
// Copy cpmem now, because end_of_primitives isn't triggered until the first opcode after
// primitive data, and the first opcode might update cpmem
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
std::memcpy(&cpmem, &analyzer.m_cpmem, sizeof(CPState));
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
}
if (analyzer.m_end_of_primitives)
{
Expand Down
66 changes: 33 additions & 33 deletions Source/Core/Core/HW/AudioInterface.cpp
Expand Up @@ -292,21 +292,21 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
const AICR tmp_ai_ctrl(val);

auto& core_timing = system.GetCoreTiming();
auto& state = system.GetAudioInterfaceState().GetData();
if (state.control.AIINTMSK != tmp_ai_ctrl.AIINTMSK)
auto& state_ = system.GetAudioInterfaceState().GetData();
if (state_.control.AIINTMSK != tmp_ai_ctrl.AIINTMSK)
{
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Change AIINTMSK to {}", tmp_ai_ctrl.AIINTMSK);
state.control.AIINTMSK = tmp_ai_ctrl.AIINTMSK;
state_.control.AIINTMSK = tmp_ai_ctrl.AIINTMSK;
}

if (state.control.AIINTVLD != tmp_ai_ctrl.AIINTVLD)
if (state_.control.AIINTVLD != tmp_ai_ctrl.AIINTVLD)
{
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Change AIINTVLD to {}", tmp_ai_ctrl.AIINTVLD);
state.control.AIINTVLD = tmp_ai_ctrl.AIINTVLD;
state_.control.AIINTVLD = tmp_ai_ctrl.AIINTVLD;
}

// Set frequency of streaming audio
if (tmp_ai_ctrl.AISFR != state.control.AISFR)
if (tmp_ai_ctrl.AISFR != state_.control.AISFR)
{
// AISFR rates below are intentionally inverted wrt yagcd
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Change AISFR to {}",
Expand All @@ -315,79 +315,79 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
}

// Set frequency of DMA
if (tmp_ai_ctrl.AIDFR != state.control.AIDFR)
if (tmp_ai_ctrl.AIDFR != state_.control.AIDFR)
{
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Change AIDFR to {}",
tmp_ai_ctrl.AIDFR ? "32khz" : "48khz");
SetAIDSampleRate(tmp_ai_ctrl.AIDFR ? SampleRate::AI32KHz : SampleRate::AI48KHz);
}

// Streaming counter
if (tmp_ai_ctrl.PSTAT != state.control.PSTAT)
if (tmp_ai_ctrl.PSTAT != state_.control.PSTAT)
{
DEBUG_LOG_FMT(AUDIO_INTERFACE, "{} streaming audio",
tmp_ai_ctrl.PSTAT ? "start" : "stop");
state.control.PSTAT = tmp_ai_ctrl.PSTAT;
state.last_cpu_time = core_timing.GetTicks();
state_.control.PSTAT = tmp_ai_ctrl.PSTAT;
state_.last_cpu_time = core_timing.GetTicks();

core_timing.RemoveEvent(state.event_type_ai);
core_timing.ScheduleEvent(GetAIPeriod(), state.event_type_ai);
core_timing.RemoveEvent(state_.event_type_ai);
core_timing.ScheduleEvent(GetAIPeriod(), state_.event_type_ai);
}

// AI Interrupt
if (tmp_ai_ctrl.AIINT)
{
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Clear AIS Interrupt");
state.control.AIINT = 0;
state_.control.AIINT = 0;
}

// Sample Count Reset
if (tmp_ai_ctrl.SCRESET)
{
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Reset AIS sample counter");
state.sample_counter = 0;
state_.sample_counter = 0;

state.last_cpu_time = core_timing.GetTicks();
state_.last_cpu_time = core_timing.GetTicks();
}

UpdateInterrupts();
}));

mmio->Register(base | AI_VOLUME_REGISTER, MMIO::DirectRead<u32>(&state.volume.hex),
MMIO::ComplexWrite<u32>([](Core::System& system, u32, u32 val) {
auto& state = system.GetAudioInterfaceState().GetData();
state.volume.hex = val;
auto& state_ = system.GetAudioInterfaceState().GetData();
state_.volume.hex = val;
SoundStream* sound_stream = system.GetSoundStream();
sound_stream->GetMixer()->SetStreamingVolume(state.volume.left,
state.volume.right);
sound_stream->GetMixer()->SetStreamingVolume(state_.volume.left,
state_.volume.right);
}));

mmio->Register(base | AI_SAMPLE_COUNTER, MMIO::ComplexRead<u32>([](Core::System& system, u32) {
auto& state = system.GetAudioInterfaceState().GetData();
auto& state_ = system.GetAudioInterfaceState().GetData();
const u64 cycles_streamed =
IsPlaying() ? (system.GetCoreTiming().GetTicks() - state.last_cpu_time) :
state.last_cpu_time;
return state.sample_counter +
static_cast<u32>(cycles_streamed / state.cpu_cycles_per_sample);
IsPlaying() ? (system.GetCoreTiming().GetTicks() - state_.last_cpu_time) :
state_.last_cpu_time;
return state_.sample_counter +
static_cast<u32>(cycles_streamed / state_.cpu_cycles_per_sample);
}),
MMIO::ComplexWrite<u32>([](Core::System& system, u32, u32 val) {
auto& core_timing = system.GetCoreTiming();
auto& state = system.GetAudioInterfaceState().GetData();
state.sample_counter = val;
state.last_cpu_time = core_timing.GetTicks();
core_timing.RemoveEvent(state.event_type_ai);
core_timing.ScheduleEvent(GetAIPeriod(), state.event_type_ai);
auto& state_ = system.GetAudioInterfaceState().GetData();
state_.sample_counter = val;
state_.last_cpu_time = core_timing.GetTicks();
core_timing.RemoveEvent(state_.event_type_ai);
core_timing.ScheduleEvent(GetAIPeriod(), state_.event_type_ai);
}));

mmio->Register(base | AI_INTERRUPT_TIMING, MMIO::DirectRead<u32>(&state.interrupt_timing),
MMIO::ComplexWrite<u32>([](Core::System& system, u32, u32 val) {
auto& core_timing = system.GetCoreTiming();
auto& state = system.GetAudioInterfaceState().GetData();
auto& state_ = system.GetAudioInterfaceState().GetData();
DEBUG_LOG_FMT(AUDIO_INTERFACE, "AI_INTERRUPT_TIMING={:08x} at PC: {:08x}", val,
system.GetPPCState().pc);
state.interrupt_timing = val;
core_timing.RemoveEvent(state.event_type_ai);
core_timing.ScheduleEvent(GetAIPeriod(), state.event_type_ai);
state_.interrupt_timing = val;
core_timing.RemoveEvent(state_.event_type_ai);
core_timing.ScheduleEvent(GetAIPeriod(), state_.event_type_ai);
}));
}

Expand Down

0 comments on commit dad7a32

Please sign in to comment.