ams: replace most remaining operator & with std::addressof

This commit is contained in:
Michael Scire
2021-10-09 14:49:53 -07:00
parent ce8aacef21
commit 1ab0bd1765
109 changed files with 587 additions and 586 deletions

View File

@@ -70,7 +70,7 @@ namespace ams::os::impl {
this->current_time = GetCurrentTick().ToTimeSpan();
TimeSpan min_timeout = 0;
MultiWaitHolderBase *min_timeout_object = this->RecalculateNextTimeout(&min_timeout, end_time);
MultiWaitHolderBase *min_timeout_object = this->RecalculateNextTimeout(std::addressof(min_timeout), end_time);
s32 index = WaitInvalid;
Result wait_result = ResultSuccess();
@@ -141,11 +141,10 @@ namespace ams::os::impl {
for (MultiWaitHolderBase &holder_base : this->multi_wait_list) {
if (auto handle = holder_base.GetHandle(); handle != os::InvalidNativeHandle) {
AMS_ASSERT(count < num);
AMS_UNUSED(num);
AMS_ABORT_UNLESS(count < num);
out_handles[count] = handle;
out_objects[count] = &holder_base;
out_objects[count] = std::addressof(holder_base);
count++;
}
}
@@ -160,7 +159,7 @@ namespace ams::os::impl {
TriBool is_signaled = holder_base.LinkToObjectList();
if (signaled_holder == nullptr && is_signaled == TriBool::True) {
signaled_holder = &holder_base;
signaled_holder = std::addressof(holder_base);
}
}
@@ -179,7 +178,7 @@ namespace ams::os::impl {
for (MultiWaitHolderBase &holder_base : this->multi_wait_list) {
if (const TimeSpan cur_time = holder_base.GetAbsoluteWakeupTime(); cur_time < min_time) {
min_timeout_holder = &holder_base;
min_timeout_holder = std::addressof(holder_base);
min_time = cur_time;
}
}

View File

@@ -27,7 +27,7 @@ namespace ams::os::impl {
public:
void SignalAllThreads() {
for (MultiWaitHolderBase &holder_base : this->object_list) {
holder_base.GetMultiWait()->SignalAndWakeupThread(&holder_base);
holder_base.GetMultiWait()->SignalAndWakeupThread(std::addressof(holder_base));
}
}

View File

@@ -20,7 +20,7 @@
namespace ams::os::impl {
#define ATOMIC_COMPARE_EXCHANGE_LOCK_COUNT(dst_ref, expected_ref, desired_ref, success, fail) \
(__atomic_compare_exchange(reinterpret_cast<u64 *>(&dst_ref), reinterpret_cast<u64 *>(&expected_ref), reinterpret_cast<u64 *>(&desired_ref), true, success, fail))
(__atomic_compare_exchange(reinterpret_cast<u64 *>(std::addressof(dst_ref)), reinterpret_cast<u64 *>(std::addressof(expected_ref)), reinterpret_cast<u64 *>(std::addressof(desired_ref)), true, success, fail))
void ReaderWriterLockHorizonImpl::AcquireReadLockWriteLocked(os::ReaderWriterLockType *rw_lock) {

View File

@@ -102,7 +102,7 @@ namespace ams::os {
AMS_ASSERT(!holder_base->IsLinked());
impl.LinkMultiWaitHolder(*holder_base);
holder_base->SetMultiWait(&impl);
holder_base->SetMultiWait(std::addressof(impl));
}
void UnlinkMultiWaitHolder(MultiWaitHolderType *holder) {

View File

@@ -30,7 +30,7 @@ namespace ams::os {
const T EffectiveMax = (std::numeric_limits<T>::max() / max) * max;
T cur_rnd;
while (true) {
os::GenerateRandomBytes(&cur_rnd, sizeof(T));
os::GenerateRandomBytes(std::addressof(cur_rnd), sizeof(T));
if (cur_rnd < EffectiveMax) {
return cur_rnd % max;
}
@@ -43,7 +43,7 @@ namespace ams::os {
std::scoped_lock lk(g_random_mutex);
if (AMS_UNLIKELY(!g_initialized_random)) {
impl::InitializeRandomImpl(&g_random);
impl::InitializeRandomImpl(std::addressof(g_random));
g_initialized_random = true;
}