ams: support building unit test programs on windows/linux/macos

This commit is contained in:
Michael Scire 2022-03-06 12:08:20 -08:00 committed by SciresM
parent 9a38be201a
commit 64a97576d0
756 changed files with 33359 additions and 9372 deletions

View file

@ -75,7 +75,7 @@ namespace ams::htc::server::driver {
R_UNLESS(!m_disconnection_emulation_enabled, htclow::ResultConnectionFailure());
/* Begin connecting. */
u32 task_id;
u32 task_id{};
R_TRY(m_manager->ConnectBegin(std::addressof(task_id), GetHtclowChannel(channel, m_module_id)));
/* Wait for the task to complete. */
@ -104,7 +104,7 @@ namespace ams::htc::server::driver {
size_t sent;
for (sent = 0; sent < static_cast<size_t>(src_size); sent += cur_send) {
/* Begin sending. */
u32 task_id;
u32 task_id{};
R_TRY(m_manager->SendBegin(std::addressof(task_id), std::addressof(cur_send), static_cast<const u8 *>(src) + sent, static_cast<size_t>(src_size) - sent, GetHtclowChannel(channel, m_module_id)));
/* Wait for the task to complete. */
@ -125,7 +125,7 @@ namespace ams::htc::server::driver {
const bool blocking = option != htclow::ReceiveOption_NonBlocking;
/* Begin receiving. */
u32 task_id;
u32 task_id{};
R_TRY(m_manager->ReceiveBegin(std::addressof(task_id), GetHtclowChannel(channel, m_module_id), blocking ? 1 : 0));
/* Wait for the task to complete. */

View file

@ -28,7 +28,7 @@ namespace ams::htc::server {
using ServerOptions = sf::hipc::DefaultServerManagerOptions;
using ServerManager = sf::hipc::ServerManager<NumServers, ServerOptions, MaxSessions>;
constinit util::TypedStorage<ServerManager> g_server_manager_storage;
constinit util::TypedStorage<ServerManager> g_server_manager_storage = {};
constinit ServerManager *g_server_manager = nullptr;
constinit HtcmiscImpl *g_misc_impl = nullptr;

View file

@ -82,7 +82,7 @@ namespace ams::htc::server {
Result HtcmiscImpl::GetEnvironmentVariable(size_t *out_size, char *dst, size_t dst_size, const char *name, size_t name_size) {
/* Begin the task. */
u32 task_id;
u32 task_id{};
R_TRY(m_rpc_client.Begin<rpc::GetEnvironmentVariableTask>(std::addressof(task_id), name, name_size));
/* Wait for the task to complete. */
@ -96,7 +96,7 @@ namespace ams::htc::server {
Result HtcmiscImpl::GetEnvironmentVariableLength(size_t *out_size, const char *name, size_t name_size) {
/* Begin the task. */
u32 task_id;
u32 task_id{};
R_TRY(m_rpc_client.Begin<rpc::GetEnvironmentVariableLengthTask>(std::addressof(task_id), name, name_size));
/* Wait for the task to complete. */
@ -110,7 +110,7 @@ namespace ams::htc::server {
Result HtcmiscImpl::RunOnHostBegin(u32 *out_task_id, os::NativeHandle *out_event, const char *args, size_t args_size) {
/* Begin the task. */
u32 task_id;
u32 task_id{};
R_TRY(m_rpc_client.Begin<rpc::RunOnHostTask>(std::addressof(task_id), args, args_size));
/* Detach the task. */

View file

@ -59,7 +59,7 @@ namespace ams::htc::server::rpc {
HtcmiscPacketCategory category;
HtcmiscPacketType type;
s64 body_size;
u32 task_id;
u32 task_id{};
u64 params[5];
char data[];
};

View file

@ -287,7 +287,7 @@ namespace ams::htc::server::rpc {
while (true) {
/* Get a task. */
Task *task;
u32 task_id;
u32 task_id{};
PacketCategory category;
do {
/* Dequeue a task. */

View file

@ -112,7 +112,7 @@ namespace ams::htc::server::rpc {
std::scoped_lock lk(m_mutex);
/* Allocate a free task id. */
u32 task_id;
u32 task_id{};
R_TRY(m_task_id_free_list.Allocate(std::addressof(task_id)));
/* Create the new task. */

View file

@ -34,11 +34,17 @@ namespace ams::htc::server::rpc {
/* htcs::ReceiveSmallTask/htcs::ReceiveSendTask are the largest tasks, containing an inline 0xE000 buffer. */
/* We allow for ~0x100 task overhead from the additional events those contain. */
/* NOTE: Nintendo hardcodes a maximum size of 0xE1D8, despite SendSmallTask being 0xE098 as of latest check. */
#if defined(ATMOSPHERE_OS_HORIZON)
static constexpr size_t MaxTaskSize = 0xE100;
#elif defined(ATMOSPHERE_OS_MACOS)
static constexpr size_t MaxTaskSize = 0xE400;
#else
static constexpr size_t MaxTaskSize = 0xE1D8;
#endif
using TaskStorage = typename std::aligned_storage<MaxTaskSize, alignof(void *)>::type;
private:
bool m_valid[MaxRpcCount];
TaskStorage m_storages[MaxRpcCount];
bool m_valid[MaxRpcCount]{};
TaskStorage m_storages[MaxRpcCount]{};
private:
template<typename T>
ALWAYS_INLINE T *GetPointer(u32 index) {

View file

@ -32,7 +32,7 @@ namespace ams::htc::server::rpc {
PacketCategory category;
u16 type;
s64 body_size;
u32 task_id;
u32 task_id{};
u64 params[5];
char data[];
};