mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
Introduce svcWaitForSynchronizationSingle to clean up code
This commit is contained in:
parent
94658b9f60
commit
d8061f67bd
@ -81,3 +81,8 @@ Result svcMapProcessMemory(void* dst, Handle proc, u64 src, u64 size);
|
||||
Result svcCreateProcess(Handle* out, void* proc_info, u32* caps, u64 cap_num);
|
||||
Result svcStartProcess(Handle proc, s32 main_prio, s32 default_cpu, u32 stack_size);
|
||||
u64 svcCallSecureMonitor(SecmonArgs* regs);
|
||||
|
||||
static inline Result svcWaitSynchronizationSingle(Handle handle, u64 timeout) {
|
||||
s32 tmp;
|
||||
return svcWaitSynchronization(&tmp, &handle, 1, timeout);
|
||||
}
|
||||
|
@ -451,14 +451,16 @@ Result _gfxGraphicBufferInit(s32 buf, u32 nvmap_handle) {
|
||||
}
|
||||
|
||||
static void _waitevent(Handle *handle) {
|
||||
s32 tmpindex=0;
|
||||
Result rc=0, rc2=0;
|
||||
|
||||
svcResetSignal(*handle);
|
||||
|
||||
do {
|
||||
rc = svcWaitSynchronization(&tmpindex, handle, 1, U64_MAX);
|
||||
if (R_SUCCEEDED(rc)) rc2 = svcResetSignal(*handle);
|
||||
rc = svcWaitSynchronizationSingle(*handle, U64_MAX);
|
||||
|
||||
if (R_SUCCEEDED(rc))
|
||||
rc2 = svcResetSignal(*handle);
|
||||
|
||||
} while(R_FAILED(rc) || (rc2 & 0x3FFFFF)==0xFA01);
|
||||
|
||||
if (R_FAILED(rc2)) fatalSimple(rc2);
|
||||
|
@ -109,9 +109,7 @@ Result threadStart(Thread* t) {
|
||||
}
|
||||
|
||||
Result threadWaitForExit(Thread* t) {
|
||||
Handle handle = t->handle;
|
||||
s32 idx = 0;
|
||||
return svcWaitSynchronization(&idx, &handle, 1, -1);
|
||||
return svcWaitSynchronizationSingle(t->handle, -1);
|
||||
}
|
||||
|
||||
Result threadClose(Thread* t) {
|
||||
|
@ -139,7 +139,6 @@ static Result _usbCommsRead(void* buffer, size_t size, size_t *transferredSize)
|
||||
u8 *bufptr = (u8*)buffer;
|
||||
u8 *transfer_buffer = NULL;
|
||||
u8 transfer_type=0;
|
||||
s32 tmpindex=0;
|
||||
u32 chunksize=0;
|
||||
u32 tmp_transferredSize = 0;
|
||||
size_t total_transferredSize=0;
|
||||
@ -175,7 +174,7 @@ static Result _usbCommsRead(void* buffer, size_t size, size_t *transferredSize)
|
||||
if (R_FAILED(ret)) return ret;
|
||||
|
||||
//Wait for the transfer to finish.
|
||||
svcWaitSynchronization(&tmpindex, &g_usbComms_endpoint_out->CompletionEvent, 1, U64_MAX);
|
||||
svcWaitSynchronizationSingle(g_usbComms_endpoint_out->CompletionEvent, U64_MAX);
|
||||
svcClearEvent(g_usbComms_endpoint_out->CompletionEvent);
|
||||
|
||||
ret = usbDsEndpoint_GetReportData(g_usbComms_endpoint_out, &reportdata);
|
||||
@ -206,7 +205,6 @@ static Result _usbCommsWrite(const void* buffer, size_t size, size_t *transferre
|
||||
u32 chunksize=0;
|
||||
u8 *bufptr = (u8*)buffer;
|
||||
u8 *transfer_buffer = NULL;
|
||||
s32 tmpindex=0;
|
||||
u32 tmp_transferredSize = 0;
|
||||
size_t total_transferredSize=0;
|
||||
usbDsReportData reportdata;
|
||||
@ -239,7 +237,7 @@ static Result _usbCommsWrite(const void* buffer, size_t size, size_t *transferre
|
||||
if(R_FAILED(ret))return ret;
|
||||
|
||||
//Wait for the transfer to finish.
|
||||
svcWaitSynchronization(&tmpindex, &g_usbComms_endpoint_in->CompletionEvent, 1, U64_MAX);
|
||||
svcWaitSynchronizationSingle(g_usbComms_endpoint_in->CompletionEvent, U64_MAX);
|
||||
svcClearEvent(g_usbComms_endpoint_in->CompletionEvent);
|
||||
|
||||
ret = usbDsEndpoint_GetReportData(g_usbComms_endpoint_in, &reportdata);
|
||||
|
@ -142,8 +142,7 @@ Result appletInitialize(void)
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
do {
|
||||
s32 tmp_index=0;
|
||||
svcWaitSynchronization(&tmp_index, &g_appletMessageEventHandle, 1, U64_MAX);
|
||||
svcWaitSynchronizationSingle(g_appletMessageEventHandle, U64_MAX);
|
||||
|
||||
u32 msg;
|
||||
rc = _appletReceiveMessage(&msg);
|
||||
@ -839,11 +838,10 @@ u8 appletGetFocusState(void) {
|
||||
}
|
||||
|
||||
bool appletMainLoop(void) {
|
||||
Result rc=0;
|
||||
u32 msg=0;
|
||||
s32 tmpindex=0;
|
||||
Result rc;
|
||||
u32 msg = 0;
|
||||
|
||||
if (R_FAILED(svcWaitSynchronization(&tmpindex, &g_appletMessageEventHandle, 1, 0)))
|
||||
if (R_FAILED(svcWaitSynchronizationSingle(g_appletMessageEventHandle, 0)))
|
||||
return true;
|
||||
|
||||
rc = _appletReceiveMessage(&msg);
|
||||
|
@ -299,16 +299,15 @@ Result usbDsGetState(u32 *out) {
|
||||
}
|
||||
|
||||
Result usbDsWaitReady(void) {
|
||||
Result rc = 0;
|
||||
u32 state=0;
|
||||
s32 tmpindex = 0;
|
||||
Result rc;
|
||||
u32 state = 0;
|
||||
|
||||
rc = usbDsGetState(&state);
|
||||
if (R_FAILED(rc)) return rc;
|
||||
|
||||
while(R_SUCCEEDED(rc) && state!=5)
|
||||
while (R_SUCCEEDED(rc) && state != 5)
|
||||
{
|
||||
svcWaitSynchronization(&tmpindex, &g_usbDsStateChangeEvent, 1, U64_MAX);
|
||||
svcWaitSynchronizationSingle(g_usbDsStateChangeEvent, U64_MAX);
|
||||
svcClearEvent(g_usbDsStateChangeEvent);
|
||||
rc = usbDsGetState(&state);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user