mirror of
https://github.com/PabloMK7/citra.git
synced 2025-09-11 21:30:05 +00:00
code: Use std::span where appropriate (#6658)
* code: Use std::span when possible * code: Prefix memcpy and memcmp with std::
This commit is contained in:
parent
4ccd9f24fb
commit
cf9bb90ae3
106 changed files with 362 additions and 329 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
@ -230,7 +231,7 @@ public:
|
|||
/// Retrieves a process from the current list of processes.
|
||||
std::shared_ptr<Process> GetProcessById(u32 process_id) const;
|
||||
|
||||
const std::vector<std::shared_ptr<Process>>& GetProcessList() const {
|
||||
std::span<const std::shared_ptr<Process>> GetProcessList() const {
|
||||
return process_list;
|
||||
}
|
||||
|
||||
|
|
|
@ -543,13 +543,15 @@ void SVC::ExitProcess() {
|
|||
current_process->status = ProcessStatus::Exited;
|
||||
|
||||
// Stop all the process threads that are currently waiting for objects.
|
||||
auto& thread_list = kernel.GetCurrentThreadManager().GetThreadList();
|
||||
const auto thread_list = kernel.GetCurrentThreadManager().GetThreadList();
|
||||
for (auto& thread : thread_list) {
|
||||
if (thread->owner_process.lock() != current_process)
|
||||
if (thread->owner_process.lock() != current_process) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (thread.get() == kernel.GetCurrentThreadManager().GetCurrentThread())
|
||||
if (thread.get() == kernel.GetCurrentThreadManager().GetCurrentThread()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO(Subv): When are the other running/ready threads terminated?
|
||||
ASSERT_MSG(thread->status == ThreadStatus::WaitSynchAny ||
|
||||
|
@ -695,7 +697,7 @@ ResultCode SVC::OpenThread(Handle* out_handle, Handle process_handle, u32 thread
|
|||
}
|
||||
|
||||
for (u32 core_id = 0; core_id < system.GetNumCores(); core_id++) {
|
||||
auto& thread_list = kernel.GetThreadManager(core_id).GetThreadList();
|
||||
const auto thread_list = kernel.GetThreadManager(core_id).GetThreadList();
|
||||
for (auto& thread : thread_list) {
|
||||
if (thread->owner_process.lock() == process && thread.get()->thread_id == thread_id) {
|
||||
auto result_handle = kernel.GetCurrentProcess()->handle_table.Create(thread);
|
||||
|
@ -2092,7 +2094,7 @@ ResultCode SVC::ControlProcess(Handle process_handle, u32 process_OP, u32 varg2,
|
|||
}
|
||||
case ControlProcessOP::PROCESSOP_SCHEDULE_THREADS_WITHOUT_TLS_MAGIC: {
|
||||
for (u32 core_id = 0; core_id < system.GetNumCores(); core_id++) {
|
||||
auto& thread_list = kernel.GetThreadManager(core_id).GetThreadList();
|
||||
const auto thread_list = kernel.GetThreadManager(core_id).GetThreadList();
|
||||
for (auto& thread : thread_list) {
|
||||
if (thread->owner_process.lock() != process) {
|
||||
continue;
|
||||
|
|
|
@ -304,7 +304,7 @@ void ThreadManager::DebugThreadQueue() {
|
|||
* alloc_needed: Whether there's a need to allocate a new TLS page (All pages are full).
|
||||
*/
|
||||
static std::tuple<std::size_t, std::size_t, bool> GetFreeThreadLocalSlot(
|
||||
const std::vector<std::bitset<8>>& tls_slots) {
|
||||
std::span<const std::bitset<8>> tls_slots) {
|
||||
// Iterate over all the allocated pages, and try to find one where not all slots are used.
|
||||
for (std::size_t page = 0; page < tls_slots.size(); ++page) {
|
||||
const auto& page_tls_slots = tls_slots[page];
|
||||
|
@ -527,7 +527,7 @@ ThreadManager::~ThreadManager() {
|
|||
}
|
||||
}
|
||||
|
||||
const std::vector<std::shared_ptr<Thread>>& ThreadManager::GetThreadList() {
|
||||
std::span<const std::shared_ptr<Thread>> ThreadManager::GetThreadList() {
|
||||
return thread_list;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
@ -113,7 +114,7 @@ public:
|
|||
/**
|
||||
* Get a const reference to the thread list for debug use
|
||||
*/
|
||||
const std::vector<std::shared_ptr<Thread>>& GetThreadList();
|
||||
std::span<const std::shared_ptr<Thread>> GetThreadList();
|
||||
|
||||
void SetCPU(ARM_Interface& cpu_) {
|
||||
cpu = &cpu_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue