From 3d592972dc3fd61cc88771b889eff237e4e03e0f Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 20 Oct 2020 19:07:39 -0700 Subject: Revert "core: Fix clang build" --- src/core/hle/kernel/address_arbiter.cpp | 4 +- src/core/hle/kernel/handle_table.cpp | 2 +- src/core/hle/kernel/hle_ipc.cpp | 2 +- src/core/hle/kernel/kernel.cpp | 2 +- src/core/hle/kernel/memory/address_space_info.cpp | 2 - src/core/hle/kernel/memory/memory_manager.cpp | 4 +- src/core/hle/kernel/memory/page_heap.cpp | 17 +++--- src/core/hle/kernel/memory/page_heap.h | 18 +++--- src/core/hle/kernel/memory/page_table.cpp | 6 +- src/core/hle/kernel/physical_core.h | 2 +- src/core/hle/kernel/process.cpp | 17 +++--- src/core/hle/kernel/resource_limit.cpp | 4 +- src/core/hle/kernel/scheduler.cpp | 72 +++++++---------------- src/core/hle/kernel/svc.cpp | 7 +-- src/core/hle/kernel/svc_wrap.h | 17 +++--- src/core/hle/kernel/synchronization.cpp | 4 +- src/core/hle/kernel/thread.cpp | 2 +- src/core/hle/kernel/thread.h | 6 +- 18 files changed, 74 insertions(+), 114 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index b6ebc5329..b882eaa0f 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp @@ -108,7 +108,7 @@ ResultCode AddressArbiter::ModifyByWaitingCountAndSignalToAddressIfEqual(VAddr a auto& monitor = system.Monitor(); s32 updated_value; do { - updated_value = static_cast(monitor.ExclusiveRead32(current_core, address)); + updated_value = monitor.ExclusiveRead32(current_core, address); if (updated_value != value) { return ERR_INVALID_STATE; @@ -129,7 +129,7 @@ ResultCode AddressArbiter::ModifyByWaitingCountAndSignalToAddressIfEqual(VAddr a updated_value = value; } } - } while (!monitor.ExclusiveWrite32(current_core, address, static_cast(updated_value))); + } while (!monitor.ExclusiveWrite32(current_core, address, updated_value)); WakeThreads(waiting_threads, num_to_wake); return RESULT_SUCCESS; diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index fe4988f84..3e745c18b 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp @@ -68,7 +68,7 @@ ResultVal HandleTable::Create(std::shared_ptr obj) { generations[slot] = generation; objects[slot] = std::move(obj); - const auto handle = static_cast(generation | static_cast(slot << 15)); + Handle handle = generation | (slot << 15); return MakeResult(handle); } diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 0a2de4270..81f85643b 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -58,7 +58,7 @@ std::shared_ptr HLERequestContext::SleepClientThread( { Handle event_handle = InvalidHandle; - SchedulerLockAndSleep lock(kernel, event_handle, thread.get(), static_cast(timeout)); + SchedulerLockAndSleep lock(kernel, event_handle, thread.get(), timeout); thread->SetHLECallback( [context = *this, callback](std::shared_ptr thread) mutable -> bool { ThreadWakeupReason reason = thread->GetSignalingResult() == RESULT_TIMEOUT diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 56e14da6b..b2b5b8adf 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -171,7 +171,7 @@ struct KernelCore::Impl { const auto type = static_cast(THREADTYPE_KERNEL | THREADTYPE_HLE | THREADTYPE_SUSPEND); auto thread_res = - Thread::Create(system, type, std::move(name), 0, 0, 0, static_cast(i), 0, + Thread::Create(system, type, std::move(name), 0, 0, 0, static_cast(i), 0, nullptr, std::move(init_func), init_func_parameter); suspend_threads[i] = std::move(thread_res).Unwrap(); diff --git a/src/core/hle/kernel/memory/address_space_info.cpp b/src/core/hle/kernel/memory/address_space_info.cpp index 6cf43ba24..e4288cab4 100644 --- a/src/core/hle/kernel/memory/address_space_info.cpp +++ b/src/core/hle/kernel/memory/address_space_info.cpp @@ -96,7 +96,6 @@ u64 AddressSpaceInfo::GetAddressSpaceStart(std::size_t width, Type type) { return AddressSpaceInfos[AddressSpaceIndices39Bit[index]].address; } UNREACHABLE(); - return 0; } std::size_t AddressSpaceInfo::GetAddressSpaceSize(std::size_t width, Type type) { @@ -113,7 +112,6 @@ std::size_t AddressSpaceInfo::GetAddressSpaceSize(std::size_t width, Type type) return AddressSpaceInfos[AddressSpaceIndices39Bit[index]].size; } UNREACHABLE(); - return 0; } } // namespace Kernel::Memory diff --git a/src/core/hle/kernel/memory/memory_manager.cpp b/src/core/hle/kernel/memory/memory_manager.cpp index a96157c37..acf13585c 100644 --- a/src/core/hle/kernel/memory/memory_manager.cpp +++ b/src/core/hle/kernel/memory/memory_manager.cpp @@ -71,7 +71,7 @@ VAddr MemoryManager::AllocateContinuous(std::size_t num_pages, std::size_t align } // If we allocated more than we need, free some - const auto allocated_pages{PageHeap::GetBlockNumPages(static_cast(heap_index))}; + const auto allocated_pages{PageHeap::GetBlockNumPages(heap_index)}; if (allocated_pages > num_pages) { chosen_manager.Free(allocated_block + num_pages * PageSize, allocated_pages - num_pages); } @@ -112,7 +112,7 @@ ResultCode MemoryManager::Allocate(PageLinkedList& page_list, std::size_t num_pa // Keep allocating until we've allocated all our pages for (s32 index{heap_index}; index >= 0 && num_pages > 0; index--) { - const auto pages_per_alloc{PageHeap::GetBlockNumPages(static_cast(index))}; + const auto pages_per_alloc{PageHeap::GetBlockNumPages(index)}; while (num_pages >= pages_per_alloc) { // Allocate a block diff --git a/src/core/hle/kernel/memory/page_heap.cpp b/src/core/hle/kernel/memory/page_heap.cpp index 7890b8c1a..0ab1f7205 100644 --- a/src/core/hle/kernel/memory/page_heap.cpp +++ b/src/core/hle/kernel/memory/page_heap.cpp @@ -33,12 +33,11 @@ void PageHeap::Initialize(VAddr address, std::size_t size, std::size_t metadata_ } VAddr PageHeap::AllocateBlock(s32 index) { - const auto u_index = static_cast(index); - const auto needed_size{blocks[u_index].GetSize()}; + const std::size_t needed_size{blocks[index].GetSize()}; - for (auto i = u_index; i < MemoryBlockPageShifts.size(); i++) { - if (const VAddr addr = blocks[i].PopBlock(); addr != 0) { - if (const std::size_t allocated_size = blocks[i].GetSize(); + for (s32 i{index}; i < static_cast(MemoryBlockPageShifts.size()); i++) { + if (const VAddr addr{blocks[i].PopBlock()}; addr) { + if (const std::size_t allocated_size{blocks[i].GetSize()}; allocated_size > needed_size) { Free(addr + needed_size, (allocated_size - needed_size) / PageSize); } @@ -51,7 +50,7 @@ VAddr PageHeap::AllocateBlock(s32 index) { void PageHeap::FreeBlock(VAddr block, s32 index) { do { - block = blocks[static_cast(index++)].PushBlock(block); + block = blocks[index++].PushBlock(block); } while (block != 0); } @@ -70,7 +69,7 @@ void PageHeap::Free(VAddr addr, std::size_t num_pages) { VAddr after_start{end}; VAddr after_end{end}; while (big_index >= 0) { - const std::size_t block_size{blocks[static_cast(big_index)].GetSize()}; + const std::size_t block_size{blocks[big_index].GetSize()}; const VAddr big_start{Common::AlignUp((start), block_size)}; const VAddr big_end{Common::AlignDown((end), block_size)}; if (big_start < big_end) { @@ -88,7 +87,7 @@ void PageHeap::Free(VAddr addr, std::size_t num_pages) { // Free space before the big blocks for (s32 i{big_index - 1}; i >= 0; i--) { - const std::size_t block_size{blocks[static_cast(i)].GetSize()}; + const std::size_t block_size{blocks[i].GetSize()}; while (before_start + block_size <= before_end) { before_end -= block_size; FreeBlock(before_end, i); @@ -97,7 +96,7 @@ void PageHeap::Free(VAddr addr, std::size_t num_pages) { // Free space after the big blocks for (s32 i{big_index - 1}; i >= 0; i--) { - const std::size_t block_size{blocks[static_cast(i)].GetSize()}; + const std::size_t block_size{blocks[i].GetSize()}; while (after_start + block_size <= after_end) { FreeBlock(after_start, i); after_start += block_size; diff --git a/src/core/hle/kernel/memory/page_heap.h b/src/core/hle/kernel/memory/page_heap.h index 92a2bce04..22b0de860 100644 --- a/src/core/hle/kernel/memory/page_heap.h +++ b/src/core/hle/kernel/memory/page_heap.h @@ -34,9 +34,7 @@ public: static constexpr s32 GetBlockIndex(std::size_t num_pages) { for (s32 i{static_cast(NumMemoryBlockPageShifts) - 1}; i >= 0; i--) { - const auto shift_index = static_cast(i); - if (num_pages >= - (static_cast(1) << MemoryBlockPageShifts[shift_index]) / PageSize) { + if (num_pages >= (static_cast(1) << MemoryBlockPageShifts[i]) / PageSize) { return i; } } @@ -88,7 +86,7 @@ private: // Set the bitmap pointers for (s32 depth{GetHighestDepthIndex()}; depth >= 0; depth--) { - bit_storages[static_cast(depth)] = storage; + bit_storages[depth] = storage; size = Common::AlignUp(size, 64) / 64; storage += size; } @@ -101,7 +99,7 @@ private: s32 depth{}; do { - const u64 v{bit_storages[static_cast(depth)][offset]}; + const u64 v{bit_storages[depth][offset]}; if (v == 0) { // Non-zero depth indicates that a previous level had a free block ASSERT(depth == 0); @@ -127,7 +125,7 @@ private: constexpr bool ClearRange(std::size_t offset, std::size_t count) { const s32 depth{GetHighestDepthIndex()}; const auto bit_ind{offset / 64}; - u64* bits{bit_storages[static_cast(depth)]}; + u64* bits{bit_storages[depth]}; if (count < 64) { const auto shift{offset % 64}; ASSERT(shift + count <= 64); @@ -179,11 +177,11 @@ private: const auto which{offset % 64}; const u64 mask{1ULL << which}; - u64* bit{std::addressof(bit_storages[static_cast(depth)][ind])}; + u64* bit{std::addressof(bit_storages[depth][ind])}; const u64 v{*bit}; ASSERT((v & mask) == 0); *bit = v | mask; - if (v != 0) { + if (v) { break; } offset = ind; @@ -197,12 +195,12 @@ private: const auto which{offset % 64}; const u64 mask{1ULL << which}; - u64* bit{std::addressof(bit_storages[static_cast(depth)][ind])}; + u64* bit{std::addressof(bit_storages[depth][ind])}; u64 v{*bit}; ASSERT((v & mask) != 0); v &= ~mask; *bit = v; - if (v != 0) { + if (v) { break; } offset = ind; diff --git a/src/core/hle/kernel/memory/page_table.cpp b/src/core/hle/kernel/memory/page_table.cpp index 4f759d078..a3fadb533 100644 --- a/src/core/hle/kernel/memory/page_table.cpp +++ b/src/core/hle/kernel/memory/page_table.cpp @@ -414,8 +414,7 @@ ResultCode PageTable::MapPhysicalMemory(VAddr addr, std::size_t size) { const std::size_t remaining_pages{remaining_size / PageSize}; if (process->GetResourceLimit() && - !process->GetResourceLimit()->Reserve(ResourceType::PhysicalMemory, - static_cast(remaining_size))) { + !process->GetResourceLimit()->Reserve(ResourceType::PhysicalMemory, remaining_size)) { return ERR_RESOURCE_LIMIT_EXCEEDED; } @@ -779,8 +778,7 @@ ResultVal PageTable::SetHeapSize(std::size_t size) { auto process{system.Kernel().CurrentProcess()}; if (process->GetResourceLimit() && delta != 0 && - !process->GetResourceLimit()->Reserve(ResourceType::PhysicalMemory, - static_cast(delta))) { + !process->GetResourceLimit()->Reserve(ResourceType::PhysicalMemory, delta)) { return ERR_RESOURCE_LIMIT_EXCEEDED; } diff --git a/src/core/hle/kernel/physical_core.h b/src/core/hle/kernel/physical_core.h index 6cb59d0fc..d7a7a951c 100644 --- a/src/core/hle/kernel/physical_core.h +++ b/src/core/hle/kernel/physical_core.h @@ -34,7 +34,7 @@ public: PhysicalCore& operator=(const PhysicalCore&) = delete; PhysicalCore(PhysicalCore&&) = default; - PhysicalCore& operator=(PhysicalCore&&) = delete; + PhysicalCore& operator=(PhysicalCore&&) = default; void Idle(); /// Interrupt this physical core. diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 0b39f2955..ff9d9248b 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -137,10 +137,9 @@ std::shared_ptr Process::GetResourceLimit() const { } u64 Process::GetTotalPhysicalMemoryAvailable() const { - const u64 capacity{ - static_cast(resource_limit->GetCurrentResourceValue(ResourceType::PhysicalMemory)) + - page_table->GetTotalHeapSize() + GetSystemResourceSize() + image_size + - main_thread_stack_size}; + const u64 capacity{resource_limit->GetCurrentResourceValue(ResourceType::PhysicalMemory) + + page_table->GetTotalHeapSize() + GetSystemResourceSize() + image_size + + main_thread_stack_size}; if (capacity < memory_usage_capacity) { return capacity; @@ -280,12 +279,12 @@ ResultCode Process::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, // Set initial resource limits resource_limit->SetLimitValue( ResourceType::PhysicalMemory, - static_cast(kernel.MemoryManager().GetSize(Memory::MemoryManager::Pool::Application))); + kernel.MemoryManager().GetSize(Memory::MemoryManager::Pool::Application)); resource_limit->SetLimitValue(ResourceType::Threads, 608); resource_limit->SetLimitValue(ResourceType::Events, 700); resource_limit->SetLimitValue(ResourceType::TransferMemory, 128); resource_limit->SetLimitValue(ResourceType::Sessions, 894); - ASSERT(resource_limit->Reserve(ResourceType::PhysicalMemory, static_cast(code_size))); + ASSERT(resource_limit->Reserve(ResourceType::PhysicalMemory, code_size)); // Create TLS region tls_region_address = CreateTLSRegion(); @@ -301,9 +300,9 @@ void Process::Run(s32 main_thread_priority, u64 stack_size) { ChangeStatus(ProcessStatus::Running); - SetupMainThread(system, *this, static_cast(main_thread_priority), main_thread_stack_top); + SetupMainThread(system, *this, main_thread_priority, main_thread_stack_top); resource_limit->Reserve(ResourceType::Threads, 1); - resource_limit->Reserve(ResourceType::PhysicalMemory, static_cast(main_thread_stack_size)); + resource_limit->Reserve(ResourceType::PhysicalMemory, main_thread_stack_size); } void Process::PrepareForTermination() { @@ -364,7 +363,7 @@ VAddr Process::CreateTLSRegion() { ->AllocateAndMapMemory(1, Memory::PageSize, true, start, size / Memory::PageSize, Memory::MemoryState::ThreadLocal, Memory::MemoryPermission::ReadAndWrite, tls_map_addr) - .ValueOr(0U)}; + .ValueOr(0)}; ASSERT(tls_page_addr); diff --git a/src/core/hle/kernel/resource_limit.cpp b/src/core/hle/kernel/resource_limit.cpp index e94093f24..212e442f4 100644 --- a/src/core/hle/kernel/resource_limit.cpp +++ b/src/core/hle/kernel/resource_limit.cpp @@ -43,8 +43,8 @@ void ResourceLimit::Release(ResourceType resource, u64 amount) { void ResourceLimit::Release(ResourceType resource, u64 used_amount, u64 available_amount) { const std::size_t index{ResourceTypeToIndex(resource)}; - current[index] -= static_cast(used_amount); - available[index] -= static_cast(available_amount); + current[index] -= used_amount; + available[index] -= available_amount; } std::shared_ptr ResourceLimit::Create(KernelCore& kernel) { diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp index 4a9a762f3..6b7db5372 100644 --- a/src/core/hle/kernel/scheduler.cpp +++ b/src/core/hle/kernel/scheduler.cpp @@ -89,11 +89,9 @@ u32 GlobalScheduler::SelectThreads() { while (iter != suggested_queue[core_id].end()) { suggested = *iter; iter++; - const s32 suggested_core_id = suggested->GetProcessorID(); - Thread* top_thread = suggested_core_id >= 0 - ? top_threads[static_cast(suggested_core_id)] - : nullptr; - + s32 suggested_core_id = suggested->GetProcessorID(); + Thread* top_thread = + suggested_core_id >= 0 ? top_threads[suggested_core_id] : nullptr; if (top_thread != suggested) { if (top_thread != nullptr && top_thread->GetPriority() < THREADPRIO_MAX_CORE_MIGRATION) { @@ -104,19 +102,16 @@ u32 GlobalScheduler::SelectThreads() { TransferToCore(suggested->GetPriority(), static_cast(core_id), suggested); break; } - suggested = nullptr; migration_candidates[num_candidates++] = suggested_core_id; } - // Step 3: Select a suggested thread from another core if (suggested == nullptr) { for (std::size_t i = 0; i < num_candidates; i++) { - const auto candidate_core = static_cast(migration_candidates[i]); + s32 candidate_core = migration_candidates[i]; suggested = top_threads[candidate_core]; auto it = scheduled_queue[candidate_core].begin(); - ++it; - + it++; Thread* next = it != scheduled_queue[candidate_core].end() ? *it : nullptr; if (next != nullptr) { TransferToCore(suggested->GetPriority(), static_cast(core_id), @@ -133,8 +128,7 @@ u32 GlobalScheduler::SelectThreads() { idle_cores &= ~(1U << core_id); } - - u32 cores_needing_context_switch = 0; + u32 cores_needing_context_switch{}; for (u32 core = 0; core < Core::Hardware::NUM_CPU_CORES; core++) { Scheduler& sched = kernel.Scheduler(core); ASSERT(top_threads[core] == nullptr || @@ -192,16 +186,13 @@ bool GlobalScheduler::YieldThreadAndBalanceLoad(Thread* yielding_thread) { for (auto& thread : suggested_queue[core_id]) { const s32 source_core = thread->GetProcessorID(); if (source_core >= 0) { - const auto sanitized_source_core = static_cast(source_core); - - if (current_threads[sanitized_source_core] != nullptr) { - if (thread == current_threads[sanitized_source_core] || - current_threads[sanitized_source_core]->GetPriority() < min_regular_priority) { + if (current_threads[source_core] != nullptr) { + if (thread == current_threads[source_core] || + current_threads[source_core]->GetPriority() < min_regular_priority) { continue; } } } - if (next_thread->GetLastRunningTicks() >= thread->GetLastRunningTicks() || next_thread->GetPriority() < thread->GetPriority()) { if (thread->GetPriority() <= priority) { @@ -249,25 +240,17 @@ bool GlobalScheduler::YieldThreadAndWaitForLoadBalancing(Thread* yielding_thread for (std::size_t i = 0; i < current_threads.size(); i++) { current_threads[i] = scheduled_queue[i].empty() ? nullptr : scheduled_queue[i].front(); } - for (auto& thread : suggested_queue[core_id]) { const s32 source_core = thread->GetProcessorID(); - if (source_core < 0) { - continue; - } - - const auto sanitized_source_core = static_cast(source_core); - if (thread == current_threads[sanitized_source_core]) { + if (source_core < 0 || thread == current_threads[source_core]) { continue; } - - if (current_threads[sanitized_source_core] == nullptr || - current_threads[sanitized_source_core]->GetPriority() >= min_regular_priority) { + if (current_threads[source_core] == nullptr || + current_threads[source_core]->GetPriority() >= min_regular_priority) { winner = thread; } break; } - if (winner != nullptr) { if (winner != yielding_thread) { TransferToCore(winner->GetPriority(), static_cast(core_id), winner); @@ -309,22 +292,17 @@ void GlobalScheduler::PreemptThreads() { if (thread->GetPriority() != priority) { continue; } - if (source_core >= 0) { - const auto sanitized_source_core = static_cast(source_core); - Thread* next_thread = scheduled_queue[sanitized_source_core].empty() + Thread* next_thread = scheduled_queue[source_core].empty() ? nullptr - : scheduled_queue[sanitized_source_core].front(); - + : scheduled_queue[source_core].front(); if (next_thread != nullptr && next_thread->GetPriority() < 2) { break; } - if (next_thread == thread) { continue; } } - if (current_thread != nullptr && current_thread->GetLastRunningTicks() >= thread->GetLastRunningTicks()) { winner = thread; @@ -344,22 +322,17 @@ void GlobalScheduler::PreemptThreads() { if (thread->GetPriority() < priority) { continue; } - if (source_core >= 0) { - const auto sanitized_source_core = static_cast(source_core); - Thread* next_thread = scheduled_queue[sanitized_source_core].empty() + Thread* next_thread = scheduled_queue[source_core].empty() ? nullptr - : scheduled_queue[sanitized_source_core].front(); - + : scheduled_queue[source_core].front(); if (next_thread != nullptr && next_thread->GetPriority() < 2) { break; } - if (next_thread == thread) { continue; } } - if (current_thread != nullptr && current_thread->GetLastRunningTicks() >= thread->GetLastRunningTicks()) { winner = thread; @@ -379,11 +352,11 @@ void GlobalScheduler::PreemptThreads() { void GlobalScheduler::EnableInterruptAndSchedule(u32 cores_pending_reschedule, Core::EmuThreadHandle global_thread) { - const u32 current_core = global_thread.host_handle; + u32 current_core = global_thread.host_handle; bool must_context_switch = global_thread.guest_handle != InvalidHandle && (current_core < Core::Hardware::NUM_CPU_CORES); while (cores_pending_reschedule != 0) { - const u32 core = Common::CountTrailingZeroes32(cores_pending_reschedule); + u32 core = Common::CountTrailingZeroes32(cores_pending_reschedule); ASSERT(core < Core::Hardware::NUM_CPU_CORES); if (!must_context_switch || core != current_core) { auto& phys_core = kernel.PhysicalCore(core); @@ -393,7 +366,6 @@ void GlobalScheduler::EnableInterruptAndSchedule(u32 cores_pending_reschedule, } cores_pending_reschedule &= ~(1U << core); } - if (must_context_switch) { auto& core_scheduler = kernel.CurrentScheduler(); kernel.ExitSVCProfile(); @@ -831,11 +803,9 @@ void Scheduler::Initialize() { std::string name = "Idle Thread Id:" + std::to_string(core_id); std::function init_func = Core::CpuManager::GetIdleThreadStartFunc(); void* init_func_parameter = system.GetCpuManager().GetStartFuncParamater(); - const auto type = static_cast(THREADTYPE_KERNEL | THREADTYPE_HLE | THREADTYPE_IDLE); - auto thread_res = - Thread::Create(system, type, std::move(name), 0, 64, 0, static_cast(core_id), 0, - nullptr, std::move(init_func), init_func_parameter); - + ThreadType type = static_cast(THREADTYPE_KERNEL | THREADTYPE_HLE | THREADTYPE_IDLE); + auto thread_res = Thread::Create(system, type, name, 0, 64, 0, static_cast(core_id), 0, + nullptr, std::move(init_func), init_func_parameter); idle_thread = std::move(thread_res).Unwrap(); } diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index b8623e831..bafd1ced7 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -482,8 +482,7 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr static ResultCode WaitSynchronization32(Core::System& system, u32 timeout_low, u32 handles_address, s32 handle_count, u32 timeout_high, Handle* index) { const s64 nano_seconds{(static_cast(timeout_high) << 32) | static_cast(timeout_low)}; - return WaitSynchronization(system, index, handles_address, static_cast(handle_count), - nano_seconds); + return WaitSynchronization(system, index, handles_address, handle_count, nano_seconds); } /// Resumes a thread waiting on WaitSynchronization @@ -2003,7 +2002,7 @@ static ResultCode GetThreadCoreMask(Core::System& system, Handle thread_handle, return ERR_INVALID_HANDLE; } - *core = static_cast(thread->GetIdealCore()); + *core = thread->GetIdealCore(); *mask = thread->GetAffinityMask(); return RESULT_SUCCESS; @@ -2071,7 +2070,7 @@ static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle, return ERR_INVALID_HANDLE; } - return thread->SetCoreAndAffinityMask(static_cast(core), affinity_mask); + return thread->SetCoreAndAffinityMask(core, affinity_mask); } static ResultCode SetThreadCoreMask32(Core::System& system, Handle thread_handle, u32 core, diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h index 9284a4c84..0b6dd9df0 100644 --- a/src/core/hle/kernel/svc_wrap.h +++ b/src/core/hle/kernel/svc_wrap.h @@ -11,11 +11,11 @@ namespace Kernel { -static inline u64 Param(const Core::System& system, std::size_t n) { +static inline u64 Param(const Core::System& system, int n) { return system.CurrentArmInterface().GetReg(n); } -static inline u32 Param32(const Core::System& system, std::size_t n) { +static inline u32 Param32(const Core::System& system, int n) { return static_cast(system.CurrentArmInterface().GetReg(n)); } @@ -29,7 +29,7 @@ static inline void FuncReturn(Core::System& system, u64 result) { } static inline void FuncReturn32(Core::System& system, u32 result) { - system.CurrentArmInterface().SetReg(0, static_cast(result)); + system.CurrentArmInterface().SetReg(0, (u64)result); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -386,10 +386,9 @@ template void SvcWrap32(Core::System& system) { Handle param_1 = 0; - const u32 retval = - func(system, ¶m_1, Param32(system, 0), Param32(system, 1), Param32(system, 2), - Param32(system, 3), static_cast(Param32(system, 4))) - .raw; + const u32 retval = func(system, ¶m_1, Param32(system, 0), Param32(system, 1), + Param32(system, 2), Param32(system, 3), Param32(system, 4)) + .raw; system.CurrentArmInterface().SetReg(1, param_1); FuncReturn(system, retval); @@ -543,8 +542,8 @@ void SvcWrap32(Core::System& system) { template void SvcWrap32(Core::System& system) { u32 param_1 = 0; - const u32 retval = func(system, Param32(system, 0), Param32(system, 1), - static_cast(Param32(system, 2)), Param32(system, 3), ¶m_1) + const u32 retval = func(system, Param32(system, 0), Param32(system, 1), Param32(system, 2), + Param32(system, 3), ¶m_1) .raw; system.CurrentArmInterface().SetReg(1, param_1); FuncReturn(system, retval); diff --git a/src/core/hle/kernel/synchronization.cpp b/src/core/hle/kernel/synchronization.cpp index 653f722b3..8b875d853 100644 --- a/src/core/hle/kernel/synchronization.cpp +++ b/src/core/hle/kernel/synchronization.cpp @@ -51,7 +51,7 @@ std::pair Synchronization::WaitFor( // We found a ready object, acquire it and set the result value SynchronizationObject* object = itr->get(); object->Acquire(thread); - const auto index = static_cast(std::distance(sync_objects.begin(), itr)); + const u32 index = static_cast(std::distance(sync_objects.begin(), itr)); lock.CancelSleep(); return {RESULT_SUCCESS, index}; } @@ -105,7 +105,7 @@ std::pair Synchronization::WaitFor( }); ASSERT(itr != sync_objects.end()); signaling_object->Acquire(thread); - const auto index = static_cast(std::distance(sync_objects.begin(), itr)); + const u32 index = static_cast(std::distance(sync_objects.begin(), itr)); return {signaling_result, index}; } return {signaling_result, -1}; diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 323e740e9..d132aba34 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -525,7 +525,7 @@ ResultCode Thread::SetCoreAndAffinityMask(s32 new_core, u64 new_affinity_mask) { if (old_affinity_mask != new_affinity_mask) { const s32 old_core = processor_id; if (processor_id >= 0 && ((affinity_mask >> processor_id) & 1) == 0) { - if (ideal_core < 0) { + if (static_cast(ideal_core) < 0) { processor_id = HighestSetCore(affinity_mask, Core::Hardware::NUM_CPU_CORES); } else { processor_id = ideal_core; diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 21b22ca45..8daf79fac 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -470,7 +470,7 @@ public: bool InvokeHLECallback(std::shared_ptr thread); - s32 GetIdealCore() const { + u32 GetIdealCore() const { return ideal_core; } @@ -654,8 +654,8 @@ private: Scheduler* scheduler = nullptr; - s32 ideal_core = -1; - u64 affinity_mask = 1; + u32 ideal_core{0xFFFFFFFF}; + u64 affinity_mask{0x1}; s32 ideal_core_override = -1; u64 affinity_mask_override = 0x1; -- cgit v1.2.3