mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-27 22:06:27 -05:00
b879fb84a2
The reason this would never be true is that ideal_processor is a u8 and THREADPROCESSORID_DEFAULT is an s32. In this case, it boils down to how arithmetic conversions are performed before performing the comparison. If an unsigned value has a lesser conversion rank (aka smaller size) than the signed type being compared, then the unsigned value is promoted to the signed value (i.e. u8 -> s32 happens before the comparison). No sign-extension occurs here either. An alternative phrasing: Say we have a variable named core and it's given a value of -2. u8 core = -2; This becomes 254 due to the lack of sign. During integral promotion to the signed type, this still remains as 254, and therefore the condition will always be true, because no matter what value the u8 is given it will never be -2 in terms of 32 bits. Now, if one type was a s32 and one was a u32, this would be entirely different, since they have the same bit width (and the signed type would be converted to unsigned instead of the other way around) but would still have its representation preserved in terms of bits, allowing the comparison to be false in some cases, as opposed to being true all the time. --- We also get rid of two signed/unsigned comparison warnings while we're at it. |
||
---|---|---|
.. | ||
address_arbiter.cpp | ||
address_arbiter.h | ||
client_port.cpp | ||
client_port.h | ||
client_session.cpp | ||
client_session.h | ||
errors.h | ||
event.cpp | ||
event.h | ||
handle_table.cpp | ||
handle_table.h | ||
hle_ipc.cpp | ||
hle_ipc.h | ||
kernel.cpp | ||
kernel.h | ||
memory.cpp | ||
memory.h | ||
mutex.cpp | ||
mutex.h | ||
object_address_table.cpp | ||
object_address_table.h | ||
process.cpp | ||
process.h | ||
resource_limit.cpp | ||
resource_limit.h | ||
scheduler.cpp | ||
scheduler.h | ||
server_port.cpp | ||
server_port.h | ||
server_session.cpp | ||
server_session.h | ||
session.cpp | ||
session.h | ||
shared_memory.cpp | ||
shared_memory.h | ||
svc.cpp | ||
svc.h | ||
svc_wrap.h | ||
thread.cpp | ||
thread.h | ||
timer.cpp | ||
timer.h | ||
vm_manager.cpp | ||
vm_manager.h | ||
wait_object.cpp | ||
wait_object.h |