mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-03-04 00:27:40 +00:00
[orbis-kernel] Implement utils::kstring
This commit is contained in:
parent
932bb30e79
commit
0d7b090032
@ -2,6 +2,7 @@
|
||||
|
||||
#include "utils/Rc.hpp"
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <map>
|
||||
@ -31,6 +32,7 @@ template <typename T> struct kallocator {
|
||||
}
|
||||
};
|
||||
|
||||
using kstring = std::basic_string<char, std::char_traits<char>, kallocator<char>>;
|
||||
template <typename T> using kvector = std::vector<T, kallocator<T>>;
|
||||
template <typename T> using kdeque = std::deque<T, kallocator<T>>;
|
||||
template <typename K, typename T, typename Cmp = std::less<>>
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
std::size_t align = __STDCPP_DEFAULT_NEW_ALIGNMENT__);
|
||||
static void kfree(void *ptr, std::size_t size);
|
||||
|
||||
std::pair<EventFlag *, bool> createEventFlag(std::string name, std::int32_t flags) {
|
||||
std::pair<EventFlag *, bool> createEventFlag(utils::kstring name, std::int32_t flags) {
|
||||
auto [it, inserted] = m_event_flags.try_emplace(std::move(name), knew<EventFlag>(flags));
|
||||
return { it->second.get(), inserted };
|
||||
}
|
||||
@ -40,7 +40,7 @@ public:
|
||||
private:
|
||||
mutable shared_mutex m_proc_mtx;
|
||||
utils::LinkedNode<Process> *m_processes = nullptr;
|
||||
kmap<std::string, Ref<EventFlag>> m_event_flags;
|
||||
utils::kmap<utils::kstring, Ref<EventFlag>> m_event_flags;
|
||||
|
||||
struct node {
|
||||
std::size_t size;
|
||||
|
@ -16,7 +16,7 @@ struct Thread;
|
||||
struct Process;
|
||||
|
||||
struct ModuleNeeded {
|
||||
std::string name;
|
||||
utils::kstring name;
|
||||
std::uint16_t version;
|
||||
std::uint16_t attr;
|
||||
bool isExport;
|
||||
@ -68,7 +68,7 @@ struct Relocation {
|
||||
|
||||
struct Module final {
|
||||
Process *proc{};
|
||||
std::string vfsPath;
|
||||
utils::kstring vfsPath;
|
||||
char moduleName[256]{};
|
||||
char soName[256]{};
|
||||
ModuleHandle id{};
|
||||
@ -116,7 +116,7 @@ struct Module final {
|
||||
utils::kvector<ModuleNeeded> neededLibraries;
|
||||
utils::kvector<utils::Ref<Module>> importedModules;
|
||||
utils::kvector<utils::Ref<Module>> namespaceModules;
|
||||
utils::kvector<std::string> needed;
|
||||
utils::kvector<utils::kstring> needed;
|
||||
|
||||
std::atomic<unsigned> references{0};
|
||||
unsigned _total_size = 0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "module/Module.hpp"
|
||||
#include "KernelAllocator.hpp"
|
||||
#include "thread.hpp"
|
||||
#include <utility>
|
||||
|
||||
@ -108,7 +109,7 @@ static orbis::SysResult doRelocation(orbis::Process *process,
|
||||
return std::pair(defModule.get(), defSym.address);
|
||||
}
|
||||
|
||||
foundInLibs.push_back(defLib.name);
|
||||
foundInLibs.emplace_back(std::string_view(defLib.name));
|
||||
}
|
||||
|
||||
for (auto nsDefModule : defModule->namespaceModules) {
|
||||
|
@ -19,7 +19,7 @@ void io_device_instance_init(IoDevice *device, IoDeviceInstance *instance) {
|
||||
}
|
||||
|
||||
struct HostIoDevice : IoDevice {
|
||||
std::string hostPath;
|
||||
orbis::utils::kstring hostPath;
|
||||
};
|
||||
|
||||
struct HostIoDeviceInstance : IoDeviceInstance {
|
||||
|
@ -588,7 +588,7 @@ Ref<orbis::Module> rx::linker::loadModule(std::span<std::byte> image,
|
||||
} else {
|
||||
name = patchSoName(name);
|
||||
if (name != "libSceFreeTypeOptBm") { // TODO
|
||||
result->needed.push_back(std::string(name));
|
||||
result->needed.emplace_back(name);
|
||||
result->needed.back() += ".prx";
|
||||
}
|
||||
}
|
||||
|
@ -453,14 +453,14 @@ orbis::SysResult exit(orbis::Thread *thread, orbis::sint status) {
|
||||
|
||||
SysResult processNeeded(Thread *thread) {
|
||||
while (true) {
|
||||
std::set<std::string> allNeededObjects;
|
||||
std::set<std::string, std::less<>> allNeededObjects;
|
||||
auto proc = thread->tproc;
|
||||
std::map<std::string, Module *> loadedModules;
|
||||
std::map<std::string, Module *> loadedObjects;
|
||||
std::map<std::string, Module *, std::less<>> loadedModules;
|
||||
std::map<std::string, Module *, std::less<>> loadedObjects;
|
||||
|
||||
for (auto [id, module] : proc->modulesMap) {
|
||||
for (const auto &object : module->needed) {
|
||||
allNeededObjects.insert(object);
|
||||
allNeededObjects.emplace(object.begin(), object.end());
|
||||
}
|
||||
|
||||
loadedModules[module->moduleName] = module;
|
||||
@ -509,9 +509,9 @@ SysResult processNeeded(Thread *thread) {
|
||||
module->importedModules.clear();
|
||||
module->importedModules.reserve(module->neededModules.size());
|
||||
for (auto mod : module->neededModules) {
|
||||
if (auto it = loadedModules.find(mod.name);
|
||||
if (auto it = loadedModules.find(std::string_view(mod.name));
|
||||
it != loadedModules.end()) {
|
||||
module->importedModules.push_back(loadedModules.at(mod.name));
|
||||
module->importedModules.emplace_back(it->second);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user