libstrat: namespace hossynch.hpp

This commit is contained in:
Michael Scire
2019-09-24 03:15:36 -07:00
committed by SciresM
parent 73d904036d
commit bb223eb5ae
57 changed files with 923 additions and 773 deletions

View File

@@ -93,7 +93,7 @@ void __appExit(void) {
int main(int argc, char **argv)
{
consoleDebugInit(debugDevice_SVC);
HosThread initializer_thread;
sts::os::Thread initializer_thread;
LaunchAllMitmModules();

View File

@@ -27,7 +27,7 @@
#include "ns_mitm/nsmitm_main.hpp"
#include "hid_mitm/hidmitm_main.hpp"
static HosThread g_module_threads[MitmModuleId_Count];
static sts::os::Thread g_module_threads[MitmModuleId_Count];
static const struct {
ThreadFunc main;

View File

@@ -145,7 +145,7 @@ Result DirectorySaveDataFileSystem::GetFullPath(char *out, size_t out_size, cons
}
void DirectorySaveDataFileSystem::OnWritableFileClose() {
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
this->open_writable_files--;
/* TODO: Abort if < 0? N does not. */
@@ -171,7 +171,7 @@ Result DirectorySaveDataFileSystem::CreateFileImpl(const FsPath &path, uint64_t
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->CreateFile(full_path, size, flags);
}
@@ -179,7 +179,7 @@ Result DirectorySaveDataFileSystem::DeleteFileImpl(const FsPath &path) {
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->DeleteFile(full_path);
}
@@ -187,7 +187,7 @@ Result DirectorySaveDataFileSystem::CreateDirectoryImpl(const FsPath &path) {
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->CreateDirectory(full_path);
}
@@ -195,7 +195,7 @@ Result DirectorySaveDataFileSystem::DeleteDirectoryImpl(const FsPath &path) {
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->DeleteDirectory(full_path);
}
@@ -203,7 +203,7 @@ Result DirectorySaveDataFileSystem::DeleteDirectoryRecursivelyImpl(const FsPath
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->DeleteDirectoryRecursively(full_path);
}
@@ -212,7 +212,7 @@ Result DirectorySaveDataFileSystem::RenameFileImpl(const FsPath &old_path, const
R_TRY(GetFullPath(full_old_path, old_path));
R_TRY(GetFullPath(full_new_path, new_path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->RenameFile(full_old_path, full_new_path);
}
@@ -221,7 +221,7 @@ Result DirectorySaveDataFileSystem::RenameDirectoryImpl(const FsPath &old_path,
R_TRY(GetFullPath(full_old_path, old_path));
R_TRY(GetFullPath(full_new_path, new_path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->RenameDirectory(full_old_path, full_new_path);
}
@@ -229,7 +229,7 @@ Result DirectorySaveDataFileSystem::GetEntryTypeImpl(DirectoryEntryType *out, co
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->GetEntryType(out, full_path);
}
@@ -237,7 +237,7 @@ Result DirectorySaveDataFileSystem::OpenFileImpl(std::unique_ptr<IFile> &out_fil
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
{
/* Open the raw file. */
@@ -265,7 +265,7 @@ Result DirectorySaveDataFileSystem::OpenDirectoryImpl(std::unique_ptr<IDirectory
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->OpenDirectory(out_dir, full_path, mode);
}
@@ -278,7 +278,7 @@ Result DirectorySaveDataFileSystem::CommitImpl() {
/* will be deleted if there is an error during synchronization. */
/* Instead, we will synchronize first, then delete committed, then rename. */
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
/* Ensure we don't have any open writable files. */
if (this->open_writable_files != 0) {
@@ -320,7 +320,7 @@ Result DirectorySaveDataFileSystem::CleanDirectoryRecursivelyImpl(const FsPath &
FsPath full_path;
R_TRY(GetFullPath(full_path, path));
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
return this->fs->CleanDirectoryRecursively(full_path);
}

View File

@@ -37,7 +37,7 @@ class DirectorySaveDataFileSystem : public IFileSystem {
std::unique_ptr<IFileSystem> unique_fs;
std::unique_ptr<IFileSystem> proxy_save_fs;
IFileSystem *fs;
HosMutex lock;
sts::os::Mutex lock;
size_t open_writable_files = 0;
public:

View File

@@ -20,7 +20,7 @@
#include "fsmitm_boot0storage.hpp"
static HosMutex g_boot0_mutex;
static sts::os::Mutex g_boot0_mutex;
static u8 g_boot0_bct_buffer[Boot0Storage::BctEndOffset];
bool Boot0Storage::CanModifyBctPubks() {
@@ -37,13 +37,13 @@ bool Boot0Storage::CanModifyBctPubks() {
}
Result Boot0Storage::Read(void *_buffer, size_t size, u64 offset) {
std::scoped_lock<HosMutex> lk{g_boot0_mutex};
std::scoped_lock lk{g_boot0_mutex};
return Base::Read(_buffer, size, offset);
}
Result Boot0Storage::Write(void *_buffer, size_t size, u64 offset) {
std::scoped_lock<HosMutex> lk{g_boot0_mutex};
std::scoped_lock lk{g_boot0_mutex};
u8 *buffer = static_cast<u8 *>(_buffer);

View File

@@ -36,11 +36,11 @@
#include "../debug.hpp"
static HosMutex g_StorageCacheLock;
static sts::os::Mutex g_StorageCacheLock;
static std::unordered_map<u64, std::weak_ptr<IStorageInterface>> g_StorageCache;
static bool StorageCacheGetEntry(sts::ncm::TitleId title_id, std::shared_ptr<IStorageInterface> *out) {
std::scoped_lock<HosMutex> lock(g_StorageCacheLock);
std::scoped_lock lock(g_StorageCacheLock);
if (g_StorageCache.find(static_cast<u64>(title_id)) == g_StorageCache.end()) {
return false;
}
@@ -54,7 +54,7 @@ static bool StorageCacheGetEntry(sts::ncm::TitleId title_id, std::shared_ptr<ISt
}
static void StorageCacheSetEntry(sts::ncm::TitleId title_id, std::shared_ptr<IStorageInterface> *ptr) {
std::scoped_lock<HosMutex> lock(g_StorageCacheLock);
std::scoped_lock lock(g_StorageCacheLock);
/* Ensure we always use the cached copy if present. */
if (g_StorageCache.find(static_cast<u64>(title_id)) != g_StorageCache.end()) {

View File

@@ -64,7 +64,7 @@ bool SetMitmService::IsValidRegionCode(u32 region_code) {
}
Result SetMitmService::EnsureLocale() {
std::scoped_lock<HosMutex> lk(this->lock);
std::scoped_lock lk(this->lock);
if (!this->got_locale) {
std::memset(&this->locale, 0xCC, sizeof(this->locale));

View File

@@ -31,7 +31,7 @@ class SetMitmService : public IMitmServiceObject {
GetAvailableLanguageCodes = 1,
};
private:
HosMutex lock;
sts::os::Mutex lock;
OverrideLocale locale;
bool got_locale;
public:

View File

@@ -19,13 +19,13 @@
#include "setsys_firmware_version.hpp"
static HosMutex g_version_mutex;
static sts::os::Mutex g_version_mutex;
static bool g_got_version = false;
static SetSysFirmwareVersion g_ams_fw_version = {0};
static SetSysFirmwareVersion g_fw_version = {0};
void VersionManager::Initialize() {
std::scoped_lock<HosMutex> lock(g_version_mutex);
std::scoped_lock lock(g_version_mutex);
if (g_got_version) {
return;

View File

@@ -35,7 +35,7 @@ struct SettingsItemValue {
std::map<std::string, SettingsItemValue> g_settings_items;
static bool g_threw_fatal = false;
static HosThread g_fatal_thread;
static sts::os::Thread g_fatal_thread;
static void FatalThreadFunc(void *arg) {
svcSleepThread(5000000000ULL);

View File

@@ -29,7 +29,9 @@
#include "bpc_mitm/bpcmitm_reboot_manager.hpp"
static FsFileSystem g_sd_filesystem = {0};
static HosSignal g_sd_signal, g_hid_signal;
/* Non-autoclear events for SD/HID init. */
static sts::os::Event g_sd_event(false), g_hid_event(false);
static std::vector<u64> g_mitm_flagged_tids;
static std::vector<u64> g_disable_mitm_flagged_tids;
@@ -286,7 +288,7 @@ void Utils::InitializeThreadFunc(void *args) {
SettingsItemManager::LoadConfiguration();
/* Signal to waiters that we are ready. */
g_sd_signal.Signal();
g_sd_event.Signal();
/* Initialize HID. */
while (!g_has_hid_session) {
@@ -301,7 +303,7 @@ void Utils::InitializeThreadFunc(void *args) {
}
/* Signal to waiters that we are ready. */
g_hid_signal.Signal();
g_hid_event.Signal();
}
bool Utils::IsSdInitialized() {
@@ -309,7 +311,7 @@ bool Utils::IsSdInitialized() {
}
void Utils::WaitSdInitialized() {
g_sd_signal.Wait();
g_sd_event.Wait();
}
bool Utils::IsHidAvailable() {
@@ -317,7 +319,7 @@ bool Utils::IsHidAvailable() {
}
void Utils::WaitHidAvailable() {
g_hid_signal.Wait();
g_hid_event.Wait();
}
Result Utils::OpenSdFile(const char *fn, int flags, FsFile *out) {