mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-20 09:55:07 -04:00
Integrate new result macros. (#1780)
* result: try out some experimental shenanigans * result: sketch out some more shenanigans * result: see what it looks like to convert kernel to use result conds instead of guards * make rest of kernel use experimental new macro-ing
This commit is contained in:
parent
375ba615be
commit
96f95b9f95
109 changed files with 1355 additions and 1380 deletions
|
@ -52,13 +52,10 @@ namespace ams::kern::svc {
|
|||
|
||||
/* Register the handle in the table. */
|
||||
R_TRY(handle_table.Add(out_server_handle, std::addressof(port->GetServerPort())));
|
||||
auto handle_guard = SCOPE_GUARD { handle_table.Remove(*out_server_handle); };
|
||||
ON_RESULT_FAILURE { handle_table.Remove(*out_server_handle); };
|
||||
|
||||
/* Create a new object name. */
|
||||
R_TRY(KObjectName::NewFromName(std::addressof(port->GetClientPort()), name));
|
||||
|
||||
/* We succeeded, so don't leak the handle. */
|
||||
handle_guard.Cancel();
|
||||
} else /* if (max_sessions == 0) */ {
|
||||
/* Ensure that this else case is correct. */
|
||||
MESOSPHERE_AUDIT(max_sessions == 0);
|
||||
|
@ -70,7 +67,7 @@ namespace ams::kern::svc {
|
|||
R_TRY(KObjectName::Delete<KClientPort>(name));
|
||||
}
|
||||
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result CreatePort(ams::svc::Handle *out_server, ams::svc::Handle *out_client, int32_t max_sessions, bool is_light, uintptr_t name) {
|
||||
|
@ -100,14 +97,10 @@ namespace ams::kern::svc {
|
|||
R_TRY(handle_table.Add(out_client, std::addressof(port->GetClientPort())));
|
||||
|
||||
/* Ensure that we maintaing a clean handle state on exit. */
|
||||
auto handle_guard = SCOPE_GUARD { handle_table.Remove(*out_client); };
|
||||
ON_RESULT_FAILURE { handle_table.Remove(*out_client); };
|
||||
|
||||
/* Add the server to the handle table. */
|
||||
R_TRY(handle_table.Add(out_server, std::addressof(port->GetServerPort())));
|
||||
|
||||
/* We succeeded! */
|
||||
handle_guard.Cancel();
|
||||
return ResultSuccess();
|
||||
R_RETURN(handle_table.Add(out_server, std::addressof(port->GetServerPort())));
|
||||
}
|
||||
|
||||
Result ConnectToNamedPort(ams::svc::Handle *out, KUserPointer<const char *> user_name) {
|
||||
|
@ -128,7 +121,7 @@ namespace ams::kern::svc {
|
|||
/* Reserve a handle for the port. */
|
||||
/* NOTE: Nintendo really does write directly to the output handle here. */
|
||||
R_TRY(handle_table.Reserve(out));
|
||||
auto handle_guard = SCOPE_GUARD { handle_table.Unreserve(*out); };
|
||||
ON_RESULT_FAILURE { handle_table.Unreserve(*out); };
|
||||
|
||||
/* Create a session. */
|
||||
KClientSession *session;
|
||||
|
@ -139,8 +132,7 @@ namespace ams::kern::svc {
|
|||
session->Close();
|
||||
|
||||
/* We succeeded. */
|
||||
handle_guard.Cancel();
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
Result ConnectToPort(ams::svc::Handle *out, ams::svc::Handle port) {
|
||||
|
@ -154,7 +146,7 @@ namespace ams::kern::svc {
|
|||
/* Reserve a handle for the port. */
|
||||
/* NOTE: Nintendo really does write directly to the output handle here. */
|
||||
R_TRY(handle_table.Reserve(out));
|
||||
auto handle_guard = SCOPE_GUARD { handle_table.Unreserve(*out); };
|
||||
ON_RESULT_FAILURE { handle_table.Unreserve(*out); };
|
||||
|
||||
/* Create the session. */
|
||||
KAutoObject *session;
|
||||
|
@ -169,8 +161,7 @@ namespace ams::kern::svc {
|
|||
session->Close();
|
||||
|
||||
/* We succeeded. */
|
||||
handle_guard.Cancel();
|
||||
return ResultSuccess();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -178,37 +169,37 @@ namespace ams::kern::svc {
|
|||
/* ============================= 64 ABI ============================= */
|
||||
|
||||
Result ConnectToNamedPort64(ams::svc::Handle *out_handle, KUserPointer<const char *> name) {
|
||||
return ConnectToNamedPort(out_handle, name);
|
||||
R_RETURN(ConnectToNamedPort(out_handle, name));
|
||||
}
|
||||
|
||||
Result CreatePort64(ams::svc::Handle *out_server_handle, ams::svc::Handle *out_client_handle, int32_t max_sessions, bool is_light, ams::svc::Address name) {
|
||||
return CreatePort(out_server_handle, out_client_handle, max_sessions, is_light, name);
|
||||
R_RETURN(CreatePort(out_server_handle, out_client_handle, max_sessions, is_light, name));
|
||||
}
|
||||
|
||||
Result ManageNamedPort64(ams::svc::Handle *out_server_handle, KUserPointer<const char *> name, int32_t max_sessions) {
|
||||
return ManageNamedPort(out_server_handle, name, max_sessions);
|
||||
R_RETURN(ManageNamedPort(out_server_handle, name, max_sessions));
|
||||
}
|
||||
|
||||
Result ConnectToPort64(ams::svc::Handle *out_handle, ams::svc::Handle port) {
|
||||
return ConnectToPort(out_handle, port);
|
||||
R_RETURN(ConnectToPort(out_handle, port));
|
||||
}
|
||||
|
||||
/* ============================= 64From32 ABI ============================= */
|
||||
|
||||
Result ConnectToNamedPort64From32(ams::svc::Handle *out_handle, KUserPointer<const char *> name) {
|
||||
return ConnectToNamedPort(out_handle, name);
|
||||
R_RETURN(ConnectToNamedPort(out_handle, name));
|
||||
}
|
||||
|
||||
Result CreatePort64From32(ams::svc::Handle *out_server_handle, ams::svc::Handle *out_client_handle, int32_t max_sessions, bool is_light, ams::svc::Address name) {
|
||||
return CreatePort(out_server_handle, out_client_handle, max_sessions, is_light, name);
|
||||
R_RETURN(CreatePort(out_server_handle, out_client_handle, max_sessions, is_light, name));
|
||||
}
|
||||
|
||||
Result ManageNamedPort64From32(ams::svc::Handle *out_server_handle, KUserPointer<const char *> name, int32_t max_sessions) {
|
||||
return ManageNamedPort(out_server_handle, name, max_sessions);
|
||||
R_RETURN(ManageNamedPort(out_server_handle, name, max_sessions));
|
||||
}
|
||||
|
||||
Result ConnectToPort64From32(ams::svc::Handle *out_handle, ams::svc::Handle port) {
|
||||
return ConnectToPort(out_handle, port);
|
||||
R_RETURN(ConnectToPort(out_handle, port));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue