mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
Nobodys perfect
This commit is contained in:
parent
74b14f4c63
commit
b82ad0b099
@ -13,12 +13,12 @@ void mutexLock(Mutex* m) {
|
|||||||
u32 self = _GetTag();
|
u32 self = _GetTag();
|
||||||
u32 cur = __sync_val_compare_and_swap(&m->Tag, 0, self);
|
u32 cur = __sync_val_compare_and_swap(&m->Tag, 0, self);
|
||||||
|
|
||||||
if (cur == 0) {
|
|
||||||
// We won the race!
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
if (cur == 0) {
|
||||||
|
// We won the race!
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((cur &~ HAS_LISTENERS) == self) {
|
if ((cur &~ HAS_LISTENERS) == self) {
|
||||||
// Kernel assigned it to us!
|
// Kernel assigned it to us!
|
||||||
return;
|
return;
|
||||||
@ -39,11 +39,6 @@ void mutexLock(Mutex* m) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur = __sync_val_compare_and_swap(&m->Tag, 0, self);
|
cur = __sync_val_compare_and_swap(&m->Tag, 0, self);
|
||||||
|
|
||||||
if (cur == 0) {
|
|
||||||
// We won the race!
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,36 +7,34 @@ Result fsInitialize() {
|
|||||||
Result rc = smGetService(&g_fsHandle, "fsp-srv");
|
Result rc = smGetService(&g_fsHandle, "fsp-srv");
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
|
IpcCommand c;
|
||||||
|
ipcInitialize(&c);
|
||||||
|
ipcSendPid(&c);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 cmd_id;
|
||||||
|
u64 unk;
|
||||||
|
} *raw;
|
||||||
|
|
||||||
|
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||||
|
|
||||||
|
raw->magic = SFCI_MAGIC;
|
||||||
|
raw->cmd_id = 1;
|
||||||
|
raw->unk = 0;
|
||||||
|
|
||||||
|
rc = ipcDispatch(g_fsHandle);
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
IpcCommand c;
|
IpcCommandResponse r;
|
||||||
ipcInitialize(&c);
|
ipcParseResponse(&r);
|
||||||
ipcSendPid(&c);
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
u64 magic;
|
u64 magic;
|
||||||
u64 cmd_id;
|
u64 result;
|
||||||
u64 unk;
|
} *resp = r.Raw;
|
||||||
} *raw;
|
|
||||||
|
|
||||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
rc = resp->result;
|
||||||
|
|
||||||
raw->magic = SFCI_MAGIC;
|
|
||||||
raw->cmd_id = 1;
|
|
||||||
raw->unk = 0;
|
|
||||||
|
|
||||||
rc = ipcDispatch(g_fsHandle);
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
|
||||||
IpcCommandResponse r;
|
|
||||||
ipcParseResponse(&r);
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 result;
|
|
||||||
} *resp = r.Raw;
|
|
||||||
|
|
||||||
rc = resp->result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user