diff options
| author | 2018-08-02 12:01:22 -0400 | |
|---|---|---|
| committer | 2018-08-02 12:01:25 -0400 | |
| commit | 6058c84b79327960052036fbecd490f20f2d5c51 (patch) | |
| tree | 660a47053151d8a5c1df3061b81e8137888beeae /src/core/hle/kernel/thread.cpp | |
| parent | kernel/thread: Make GetFreeThreadLocalSlot() reference parameter a const refe... (diff) | |
| download | yuzu-6058c84b79327960052036fbecd490f20f2d5c51.tar.gz yuzu-6058c84b79327960052036fbecd490f20f2d5c51.tar.xz yuzu-6058c84b79327960052036fbecd490f20f2d5c51.zip | |
kernel/thread: Make GetFreeThreadLocalSlot()'s loop indices size_t
Avoids using a u32 to compare against a range of size_t, which can be a
source of warnings. While we're at it, compress a std::tie into a
structured binding.
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 02bdca802..8af84d8cc 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -252,14 +252,14 @@ void Thread::ResumeFromWait() { | |||
| 252 | * slot: The index of the first free slot in the indicated page. | 252 | * slot: The index of the first free slot in the indicated page. |
| 253 | * alloc_needed: Whether there's a need to allocate a new TLS page (All pages are full). | 253 | * alloc_needed: Whether there's a need to allocate a new TLS page (All pages are full). |
| 254 | */ | 254 | */ |
| 255 | static std::tuple<u32, u32, bool> GetFreeThreadLocalSlot( | 255 | static std::tuple<std::size_t, std::size_t, bool> GetFreeThreadLocalSlot( |
| 256 | const std::vector<std::bitset<8>>& tls_slots) { | 256 | const std::vector<std::bitset<8>>& tls_slots) { |
| 257 | // Iterate over all the allocated pages, and try to find one where not all slots are used. | 257 | // Iterate over all the allocated pages, and try to find one where not all slots are used. |
| 258 | for (unsigned page = 0; page < tls_slots.size(); ++page) { | 258 | for (std::size_t page = 0; page < tls_slots.size(); ++page) { |
| 259 | const auto& page_tls_slots = tls_slots[page]; | 259 | const auto& page_tls_slots = tls_slots[page]; |
| 260 | if (!page_tls_slots.all()) { | 260 | if (!page_tls_slots.all()) { |
| 261 | // We found a page with at least one free slot, find which slot it is | 261 | // We found a page with at least one free slot, find which slot it is |
| 262 | for (unsigned slot = 0; slot < page_tls_slots.size(); ++slot) { | 262 | for (std::size_t slot = 0; slot < page_tls_slots.size(); ++slot) { |
| 263 | if (!page_tls_slots.test(slot)) { | 263 | if (!page_tls_slots.test(slot)) { |
| 264 | return std::make_tuple(page, slot, false); | 264 | return std::make_tuple(page, slot, false); |
| 265 | } | 265 | } |
| @@ -334,11 +334,8 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, | |||
| 334 | 334 | ||
| 335 | // Find the next available TLS index, and mark it as used | 335 | // Find the next available TLS index, and mark it as used |
| 336 | auto& tls_slots = owner_process->tls_slots; | 336 | auto& tls_slots = owner_process->tls_slots; |
| 337 | bool needs_allocation = true; | ||
| 338 | u32 available_page; // Which allocated page has free space | ||
| 339 | u32 available_slot; // Which slot within the page is free | ||
| 340 | 337 | ||
| 341 | std::tie(available_page, available_slot, needs_allocation) = GetFreeThreadLocalSlot(tls_slots); | 338 | auto [available_page, available_slot, needs_allocation] = GetFreeThreadLocalSlot(tls_slots); |
| 342 | 339 | ||
| 343 | if (needs_allocation) { | 340 | if (needs_allocation) { |
| 344 | // There are no already-allocated pages with free slots, lets allocate a new one. | 341 | // There are no already-allocated pages with free slots, lets allocate a new one. |
| @@ -360,7 +357,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, | |||
| 360 | owner_process->linear_heap_used += Memory::PAGE_SIZE; | 357 | owner_process->linear_heap_used += Memory::PAGE_SIZE; |
| 361 | 358 | ||
| 362 | tls_slots.emplace_back(0); // The page is completely available at the start | 359 | tls_slots.emplace_back(0); // The page is completely available at the start |
| 363 | available_page = static_cast<u32>(tls_slots.size() - 1); | 360 | available_page = tls_slots.size() - 1; |
| 364 | available_slot = 0; // Use the first slot in the new page | 361 | available_slot = 0; // Use the first slot in the new page |
| 365 | 362 | ||
| 366 | auto& vm_manager = owner_process->vm_manager; | 363 | auto& vm_manager = owner_process->vm_manager; |