[orbis-kernel] Implement utils::kstring

This commit is contained in:
Ivan Chikish 2023-07-05 13:08:13 +03:00
parent 932bb30e79
commit 0d7b090032
7 changed files with 18 additions and 15 deletions

View file

@ -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<>>

View file

@ -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;

View file

@ -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;