results: use R_VALUE for comparisons

This commit is contained in:
Michael Scire 2020-11-30 17:24:11 -08:00 committed by fincs
parent c95b46c053
commit e5ae43f4c2
9 changed files with 16 additions and 16 deletions

View File

@ -224,7 +224,7 @@ Result nwindowDequeueBuffer(NWindow* nw, s32* out_slot, NvMultiFence* out_fence)
do { do {
eventWait(&nw->event, UINT64_MAX); eventWait(&nw->event, UINT64_MAX);
rc = bqDequeueBuffer(&nw->bq, true, nw->width, nw->height, nw->format, nw->usage, &slot, &fence); rc = bqDequeueBuffer(&nw->bq, true, nw->width, nw->height, nw->format, nw->usage, &slot, &fence);
} while (rc == MAKERESULT(Module_LibnxBinder, LibnxBinderError_WouldBlock)); } while (R_VALUE(rc) == MAKERESULT(Module_LibnxBinder, LibnxBinderError_WouldBlock));
} }
else else
rc = bqDequeueBuffer(&nw->bq, false, nw->width, nw->height, nw->format, nw->usage, &slot, &fence); rc = bqDequeueBuffer(&nw->bq, false, nw->width, nw->height, nw->format, nw->usage, &slot, &fence);

View File

@ -11,7 +11,7 @@ Result condvarWaitTimeout(CondVar* c, Mutex* m, u64 timeout) {
rc = svcWaitProcessWideKeyAtomic((u32*)m, c, getThreadVars()->handle, timeout); rc = svcWaitProcessWideKeyAtomic((u32*)m, c, getThreadVars()->handle, timeout);
// On timeout, we need to acquire it manually. // On timeout, we need to acquire it manually.
if (rc == 0xEA01) if (R_VALUE(rc) == 0xEA01)
mutexLock(m); mutexLock(m);
return rc; return rc;

View File

@ -176,13 +176,13 @@ void virtmemSetup(void) {
// Forgive me. // Forgive me.
g_IsLegacyKernel = true; g_IsLegacyKernel = true;
rc = svcUnmapMemory((void*)0xFFFFFFFFFFFFE000UL, (void*)0xFFFFFE000UL, 0x1000); rc = svcUnmapMemory((void*)0xFFFFFFFFFFFFE000UL, (void*)0xFFFFFE000UL, 0x1000);
if (rc == KERNELRESULT(InvalidMemoryState)) { if (R_VALUE(rc) == KERNELRESULT(InvalidMemoryState)) {
// Invalid src-address error means that a valid 36-bit address was rejected. // Invalid src-address error means that a valid 36-bit address was rejected.
// Thus we are 32-bit. // Thus we are 32-bit.
_memregionInitHardcoded(&g_AslrRegion, 0x200000ull, 0x100000000ull); _memregionInitHardcoded(&g_AslrRegion, 0x200000ull, 0x100000000ull);
_memregionInitHardcoded(&g_StackRegion, 0x200000ull, 0x40000000ull); _memregionInitHardcoded(&g_StackRegion, 0x200000ull, 0x40000000ull);
} }
else if (rc == KERNELRESULT(InvalidMemoryRange)) { else if (R_VALUE(rc) == KERNELRESULT(InvalidMemoryRange)) {
// Invalid dst-address error means our 36-bit src-address was valid. // Invalid dst-address error means our 36-bit src-address was valid.
// Thus we are 36-bit. // Thus we are 36-bit.
_memregionInitHardcoded(&g_AslrRegion, 0x8000000ull, 0x1000000000ull); _memregionInitHardcoded(&g_AslrRegion, 0x8000000ull, 0x1000000000ull);

View File

@ -88,7 +88,7 @@ static Result _nvFenceEventWaitCommon(Event* event, u32 event_id, s32 timeout_us
if (timeout_us >= 0) if (timeout_us >= 0)
timeout_ns = (u64)1000*timeout_us; timeout_ns = (u64)1000*timeout_us;
Result rc = eventWait(event, timeout_ns); Result rc = eventWait(event, timeout_ns);
if ((rc & 0x3FFFFF) == 0xEA01) { // timeout if (R_VALUE(rc) == 0xEA01) { // timeout
nvioctlNvhostCtrl_EventSignal(g_ctrl_fd, event_id); nvioctlNvhostCtrl_EventSignal(g_ctrl_fd, event_id);
rc = MAKERESULT(Module_LibnxNvidia, LibnxNvidiaError_Timeout); rc = MAKERESULT(Module_LibnxNvidia, LibnxNvidiaError_Timeout);
} }
@ -103,7 +103,7 @@ static Result _nvFenceWait_200(NvFence* f, s32 timeout_us)
Event* event = _nvGetEvent(event_id); Event* event = _nvGetEvent(event_id);
if (event) { if (event) {
rc = nvioctlNvhostCtrl_EventWaitAsync(g_ctrl_fd, f->id, f->value, timeout_us, event_id); rc = nvioctlNvhostCtrl_EventWaitAsync(g_ctrl_fd, f->id, f->value, timeout_us, event_id);
if (rc == MAKERESULT(Module_LibnxNvidia, LibnxNvidiaError_Timeout)) if (R_VALUE(rc) == MAKERESULT(Module_LibnxNvidia, LibnxNvidiaError_Timeout))
rc = _nvFenceEventWaitCommon(event, 0x10000000 | event_id, timeout_us); rc = _nvFenceEventWaitCommon(event, 0x10000000 | event_id, timeout_us);
} }
_nvFreeEventSlot(event_id); _nvFreeEventSlot(event_id);
@ -115,7 +115,7 @@ static Result _nvFenceWait_100(NvFence* f, s32 timeout_us)
{ {
u32 event_id; u32 event_id;
Result rc = nvioctlNvhostCtrl_EventWait(g_ctrl_fd, f->id, f->value, timeout_us, 0, &event_id); Result rc = nvioctlNvhostCtrl_EventWait(g_ctrl_fd, f->id, f->value, timeout_us, 0, &event_id);
if (rc == MAKERESULT(Module_LibnxNvidia, LibnxNvidiaError_Timeout) && timeout_us) { if (R_VALUE(rc) == MAKERESULT(Module_LibnxNvidia, LibnxNvidiaError_Timeout) && timeout_us) {
Event event; Event event;
rc = nvQueryEvent(g_ctrl_fd, event_id, &event); rc = nvQueryEvent(g_ctrl_fd, event_id, &event);
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {

View File

@ -802,7 +802,7 @@ fsdev_write(struct _reent *r,
} }
rc = fsFileWrite(&file->fd, file->offset, ptr, len, FsWriteOption_None); rc = fsFileWrite(&file->fd, file->offset, ptr, len, FsWriteOption_None);
if(rc == 0xD401) if(R_VALUE(rc) == 0xD401)
return fsdev_write_safe(r, fd, ptr, len); return fsdev_write_safe(r, fd, ptr, len);
if(R_FAILED(rc)) if(R_FAILED(rc))
{ {
@ -911,7 +911,7 @@ fsdev_read(struct _reent *r,
/* read the data */ /* read the data */
rc = fsFileRead(&file->fd, file->offset, ptr, len, FsReadOption_None, &bytes); rc = fsFileRead(&file->fd, file->offset, ptr, len, FsReadOption_None, &bytes);
if(rc == 0xD401) if(R_VALUE(rc) == 0xD401)
return fsdev_read_safe(r, fd, ptr, len); return fsdev_read_safe(r, fd, ptr, len);
if(R_SUCCEEDED(rc)) if(R_SUCCEEDED(rc))
{ {
@ -1707,7 +1707,7 @@ fsdev_getmtime(const char *name,
if(fs_path.data == NULL) if(fs_path.data == NULL)
return -1;*/ return -1;*/
/*if(rc == 0) /*if(R_SUCCEEDED(rc))
{*/ {*/
/* convert from milliseconds to seconds */ /* convert from milliseconds to seconds */
//*mtime /= 1000; //*mtime /= 1000;

View File

@ -113,7 +113,7 @@ static ssize_t _romfs_read(romfs_mount *mount, u64 offset, void* buffer, u64 siz
rc = fsStorageRead(&mount->fd_storage, pos, buffer, size); rc = fsStorageRead(&mount->fd_storage, pos, buffer, size);
read = size; read = size;
} }
if (rc == 0xD401) return _romfs_read_safe(mount, pos, buffer, size); if (R_VALUE(rc) == 0xD401) return _romfs_read_safe(mount, pos, buffer, size);
if (R_FAILED(rc)) return -1; if (R_FAILED(rc)) return -1;
return read; return read;
} }

View File

@ -175,11 +175,11 @@ Result _appletInitialize(void) {
else else
rc = _appletOpenLibraryAppletProxy(&g_appletProxySession, CUR_PROCESS_HANDLE, attr); rc = _appletOpenLibraryAppletProxy(&g_appletProxySession, CUR_PROCESS_HANDLE, attr);
if (rc == AM_BUSY_ERROR) { if (R_VALUE(rc) == AM_BUSY_ERROR) {
svcSleepThread(10000000); svcSleepThread(10000000);
} }
} while (rc == AM_BUSY_ERROR); } while (R_VALUE(rc) == AM_BUSY_ERROR);
} }
// [7.0.0+] GetAppletCommonFunctions // [7.0.0+] GetAppletCommonFunctions

View File

@ -68,7 +68,7 @@ static Result _grcCreateGameMovieTrimmer(GrcGameMovieTrimmer *t, size_t size) {
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
rc = appletCreateGameMovieTrimmer(&t->s, &t->tmem); rc = appletCreateGameMovieTrimmer(&t->s, &t->tmem);
while(rc == retryrc) { while(R_VALUE(rc) == retryrc) {
svcSleepThread(100000000); svcSleepThread(100000000);
rc = appletCreateGameMovieTrimmer(&t->s, &t->tmem); rc = appletCreateGameMovieTrimmer(&t->s, &t->tmem);
} }
@ -184,7 +184,7 @@ Result grcCreateMovieMaker(GrcMovieMaker *m, size_t size) {
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
rc = appletCreateMovieMaker(&m->a, &m->tmem); rc = appletCreateMovieMaker(&m->a, &m->tmem);
while(rc == retryrc) { while(R_VALUE(rc) == retryrc) {
svcSleepThread(100000000); svcSleepThread(100000000);
rc = appletCreateMovieMaker(&m->a, &m->tmem); rc = appletCreateMovieMaker(&m->a, &m->tmem);
} }

View File

@ -48,7 +48,7 @@ Result _smInitialize(void) {
} }
Handle tmp; Handle tmp;
if (R_SUCCEEDED(rc) && smGetServiceOriginal(&tmp, (SmServiceName){}) == 0x415) { if (R_SUCCEEDED(rc) && R_VALUE(smGetServiceOriginal(&tmp, (SmServiceName){})) == 0x415) {
u64 pid_placeholder = 0; u64 pid_placeholder = 0;
rc = serviceDispatchIn(&g_smSrv, 0, pid_placeholder, .in_send_pid = true); rc = serviceDispatchIn(&g_smSrv, 0, pid_placeholder, .in_send_pid = true);
} }