Fixed type conversion ambiguity

This commit is contained in:
Huw Pascoe 2017-09-27 00:26:09 +01:00
parent b07af7dda8
commit a13ab958cb
32 changed files with 97 additions and 91 deletions

View file

@ -37,7 +37,7 @@ SharedPtr<Object> HLERequestContext::GetIncomingHandle(u32 id_from_cmdbuf) const
u32 HLERequestContext::AddOutgoingHandle(SharedPtr<Object> object) {
request_handles.push_back(std::move(object));
return request_handles.size() - 1;
return static_cast<u32>(request_handles.size() - 1);
}
void HLERequestContext::ClearIncomingObjects() {

View file

@ -90,7 +90,7 @@ void Mutex::UpdatePriority() {
if (!holding_thread)
return;
s32 best_priority = THREADPRIO_LOWEST;
u32 best_priority = THREADPRIO_LOWEST;
for (auto& waiter : GetWaitingThreads()) {
if (waiter->current_priority < best_priority)
best_priority = waiter->current_priority;

View file

@ -61,7 +61,7 @@ s32 ResourceLimit::GetCurrentResourceValue(u32 resource) const {
}
}
s32 ResourceLimit::GetMaxResourceValue(u32 resource) const {
u32 ResourceLimit::GetMaxResourceValue(u32 resource) const {
switch (resource) {
case PRIORITY:
return max_priority;

View file

@ -67,7 +67,7 @@ public:
* @param resource Requested resource type
* @returns The max value of the resource type
*/
s32 GetMaxResourceValue(u32 resource) const;
u32 GetMaxResourceValue(u32 resource) const;
/// Name of resource limit object.
std::string name;

View file

@ -42,7 +42,8 @@ SharedPtr<SharedMemory> SharedMemory::Create(SharedPtr<Process> owner_process, u
memory_region->used += size;
shared_memory->linear_heap_phys_address =
Memory::FCRAM_PADDR + memory_region->base + shared_memory->backing_block_offset;
Memory::FCRAM_PADDR + memory_region->base +
static_cast<PAddr>(shared_memory->backing_block_offset);
// Increase the amount of used linear heap memory for the owner process.
if (shared_memory->owner_process != nullptr) {

View file

@ -114,7 +114,7 @@ public:
/// Backing memory for this shared memory block.
std::shared_ptr<std::vector<u8>> backing_block;
/// Offset into the backing block for this shared memory.
u32 backing_block_offset;
size_t backing_block_offset;
/// Size of the memory block. Page-aligned.
u32 size;
/// Permission restrictions applied to the process which created the block.

View file

@ -111,7 +111,7 @@ void Thread::Stop() {
Thread* ArbitrateHighestPriorityThread(u32 address) {
Thread* highest_priority_thread = nullptr;
s32 priority = THREADPRIO_LOWEST;
u32 priority = THREADPRIO_LOWEST;
// Iterate through threads, find highest priority thread that is waiting to be arbitrated...
for (auto& thread : thread_list) {
@ -311,7 +311,7 @@ static void DebugThreadQueue() {
}
for (auto& t : thread_list) {
s32 priority = ready_queue.contains(t.get());
u32 priority = ready_queue.contains(t.get());
if (priority != -1) {
LOG_DEBUG(Kernel, "0x%02X %u", priority, t->GetObjectId());
}
@ -422,7 +422,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
return ERR_OUT_OF_MEMORY;
}
u32 offset = linheap_memory->size();
size_t offset = linheap_memory->size();
// Allocate some memory from the end of the linear heap for this region.
linheap_memory->insert(linheap_memory->end(), Memory::PAGE_SIZE, 0);
@ -430,7 +430,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
owner_process->linear_heap_used += Memory::PAGE_SIZE;
tls_slots.emplace_back(0); // The page is completely available at the start
available_page = tls_slots.size() - 1;
available_page = static_cast<u32>(tls_slots.size() - 1);
available_slot = 0; // Use the first slot in the new page
auto& vm_manager = owner_process->vm_manager;
@ -457,7 +457,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
return MakeResult<SharedPtr<Thread>>(std::move(thread));
}
void Thread::SetPriority(s32 priority) {
void Thread::SetPriority(u32 priority) {
ASSERT_MSG(priority <= THREADPRIO_LOWEST && priority >= THREADPRIO_HIGHEST,
"Invalid priority value.");
// If thread was ready, adjust queues
@ -470,7 +470,7 @@ void Thread::SetPriority(s32 priority) {
}
void Thread::UpdatePriority() {
s32 best_priority = nominal_priority;
u32 best_priority = nominal_priority;
for (auto& mutex : held_mutexes) {
if (mutex->priority < best_priority)
best_priority = mutex->priority;
@ -478,7 +478,7 @@ void Thread::UpdatePriority() {
BoostPriority(best_priority);
}
void Thread::BoostPriority(s32 priority) {
void Thread::BoostPriority(u32 priority) {
// If thread was ready, adjust queues
if (status == THREADSTATUS_READY)
ready_queue.move(this, current_priority, priority);
@ -487,7 +487,7 @@ void Thread::BoostPriority(s32 priority) {
current_priority = priority;
}
SharedPtr<Thread> SetupMainThread(u32 entry_point, s32 priority, SharedPtr<Process> owner_process) {
SharedPtr<Thread> SetupMainThread(u32 entry_point, u32 priority, SharedPtr<Process> owner_process) {
// Initialize new "main" thread
auto thread_res = Thread::Create("main", entry_point, priority, 0, THREADPROCESSORID_0,
Memory::HEAP_VADDR_END, owner_process);
@ -531,7 +531,7 @@ void Thread::SetWaitSynchronizationOutput(s32 output) {
s32 Thread::GetWaitObjectIndex(WaitObject* object) const {
ASSERT_MSG(!wait_objects.empty(), "Thread is not waiting for anything");
auto match = std::find(wait_objects.rbegin(), wait_objects.rend(), object);
return std::distance(match, wait_objects.rend()) - 1;
return static_cast<s32>(std::distance(match, wait_objects.rend()) - 1);
}
////////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -15,7 +15,7 @@
#include "core/hle/kernel/wait_object.h"
#include "core/hle/result.h"
enum ThreadPriority : s32 {
enum ThreadPriority : u32 {
THREADPRIO_HIGHEST = 0, ///< Highest thread priority
THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps
THREADPRIO_DEFAULT = 48, ///< Default thread priority for userland apps
@ -82,7 +82,7 @@ public:
* Gets the thread's current priority
* @return The current thread's priority
*/
s32 GetPriority() const {
u32 GetPriority() const {
return current_priority;
}
@ -90,7 +90,7 @@ public:
* Sets the thread's current priority
* @param priority The new priority
*/
void SetPriority(s32 priority);
void SetPriority(u32 priority);
/**
* Boost's a thread's priority to the best priority among the thread's held mutexes.
@ -102,7 +102,7 @@ public:
* Temporarily boosts the thread's priority until the next time it is scheduled
* @param priority The new priority
*/
void BoostPriority(s32 priority);
void BoostPriority(u32 priority);
/**
* Gets the thread's thread ID
@ -176,8 +176,8 @@ public:
u32 entry_point;
u32 stack_top;
s32 nominal_priority; ///< Nominal thread priority, as set by the emulated application
s32 current_priority; ///< Current thread priority, can be temporarily changed
u32 nominal_priority; ///< Nominal thread priority, as set by the emulated application
u32 current_priority; ///< Current thread priority, can be temporarily changed
u64 last_running_ticks; ///< CPU tick when thread was last running
@ -219,7 +219,7 @@ private:
* @param owner_process The parent process for the main thread
* @return A shared pointer to the main thread
*/
SharedPtr<Thread> SetupMainThread(u32 entry_point, s32 priority, SharedPtr<Process> owner_process);
SharedPtr<Thread> SetupMainThread(u32 entry_point, u32 priority, SharedPtr<Process> owner_process);
/**
* Returns whether there are any threads that are ready to run.

View file

@ -34,7 +34,7 @@ void WaitObject::RemoveWaitingThread(Thread* thread) {
SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() {
Thread* candidate = nullptr;
s32 candidate_priority = THREADPRIO_LOWEST + 1;
u32 candidate_priority = THREADPRIO_LOWEST + 1;
for (const auto& thread : waiting_threads) {
// The list of waiting threads must not contain threads that are not waiting to be awakened.