From 2f7c48ef9172ba48fa177600a12ab0d51cb9e566 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 27 Jan 2024 17:06:30 +0100 Subject: Kernel: Fix ABI for MP-CC, rename FilesystemIndexer to IndexableProperty. Public/ZipKit: Add impl for deflate/inflate. Signed-off-by: Amlal El Mahrouss --- MailMap | 2 +- Private/FSKit/FilesystemIndexer.hxx | 48 ----------------------------------- Private/FSKit/IndexableProperty.hxx | 48 +++++++++++++++++++++++++++++++++++ Private/FSKit/NewFS.hxx | 2 +- Private/FSKit/NewFSIndexer.hxx | 2 +- Private/KernelKit/Device.hpp | 9 +++---- Private/Source/CxxAbi.cxx | 45 +++++++++++++++++++++++++-------- Private/Source/IndexableProperty.cxx | 2 +- Public/SDK/ZipKit/Defines.hpp | 2 +- Public/SDK/ZipKit/NewFS-Addon.hpp | 2 +- Public/SDK/ZipKit/Zip.cpp | 32 ++++++++++++++++++++++- Public/SDK/ZipKit/Zip.hpp | 49 +++++++++++++++++++----------------- 12 files changed, 148 insertions(+), 95 deletions(-) delete mode 100644 Private/FSKit/FilesystemIndexer.hxx create mode 100644 Private/FSKit/IndexableProperty.hxx diff --git a/MailMap b/MailMap index 85b5263d..1a345d53 100644 --- a/MailMap +++ b/MailMap @@ -1 +1 @@ -amllx - amlalelmahrouss@icloud.com, amlal@mahrouss.com +33 6 58 57 30 14 +amlel - amlalelmahrouss@icloud.com, amlal@mahrouss.com +33 6 58 57 30 14 diff --git a/Private/FSKit/FilesystemIndexer.hxx b/Private/FSKit/FilesystemIndexer.hxx deleted file mode 100644 index 4ba68056..00000000 --- a/Private/FSKit/FilesystemIndexer.hxx +++ /dev/null @@ -1,48 +0,0 @@ -/* - * ======================================================== - * - * hCore - * Copyright 2024 Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#pragma once - -#include -#include - -namespace hCore -{ - namespace Indexer - { - struct IndexProperty final - { - public: - Char Drive[kDriveNameLen]; - Char Path[256]; - Char From[256]; - Char To[256]; - - }; - - class IndexableProperty final : public Property - { - public: - explicit IndexableProperty() : Property(StringBuilder::Construct("IndexableProperty").Leak().Leak()) {} - ~IndexableProperty() override = default; - - public: - IndexProperty& LeakProperty() noexcept; - - public: - void AddFlag(Int16 flag); - void RemoveFlag(Int16 flag); - - private: - IndexProperty fIndex; - UInt32 fFlags; - - }; - } -} diff --git a/Private/FSKit/IndexableProperty.hxx b/Private/FSKit/IndexableProperty.hxx new file mode 100644 index 00000000..4ba68056 --- /dev/null +++ b/Private/FSKit/IndexableProperty.hxx @@ -0,0 +1,48 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#pragma once + +#include +#include + +namespace hCore +{ + namespace Indexer + { + struct IndexProperty final + { + public: + Char Drive[kDriveNameLen]; + Char Path[256]; + Char From[256]; + Char To[256]; + + }; + + class IndexableProperty final : public Property + { + public: + explicit IndexableProperty() : Property(StringBuilder::Construct("IndexableProperty").Leak().Leak()) {} + ~IndexableProperty() override = default; + + public: + IndexProperty& LeakProperty() noexcept; + + public: + void AddFlag(Int16 flag); + void RemoveFlag(Int16 flag); + + private: + IndexProperty fIndex; + UInt32 fFlags; + + }; + } +} diff --git a/Private/FSKit/NewFS.hxx b/Private/FSKit/NewFS.hxx index f9725e22..0e935cd5 100644 --- a/Private/FSKit/NewFS.hxx +++ b/Private/FSKit/NewFS.hxx @@ -175,7 +175,7 @@ namespace hCore virtual bool WriteCatalog(NewCatalog& catalog, voidPtr data) = 0; virtual bool RemoveCatalog(NewCatalog& catalog) = 0; - void FormatDrive(DriveTraits& drive); + virtual bool Format(DriveTraits& drive) = 0; }; diff --git a/Private/FSKit/NewFSIndexer.hxx b/Private/FSKit/NewFSIndexer.hxx index fd22e4bd..c5f63059 100644 --- a/Private/FSKit/NewFSIndexer.hxx +++ b/Private/FSKit/NewFSIndexer.hxx @@ -9,7 +9,7 @@ #pragma once -#include +#include #include namespace hCore diff --git a/Private/KernelKit/Device.hpp b/Private/KernelKit/Device.hpp index b117cf7f..4ae968c2 100644 --- a/Private/KernelKit/Device.hpp +++ b/Private/KernelKit/Device.hpp @@ -35,22 +35,19 @@ namespace hCore DeviceInterface(const DeviceInterface &) = default; public: - DeviceInterface &operator<<(T Data) + DeviceInterface& operator<<(T Data) { m_Out(Data); return *this; } - DeviceInterface &operator>>(T Data) + DeviceInterface& operator>>(T Data) { m_In(Data); return *this; } - virtual const char* Name() const - { - return ("DeviceInterface"); - } + virtual const char* Name() const { return "DeviceInterface"; } operator bool() { return m_Out && m_In; } bool operator!() { return !m_Out && !m_In; } diff --git a/Private/Source/CxxAbi.cxx b/Private/Source/CxxAbi.cxx index 324c878d..4984c81a 100644 --- a/Private/Source/CxxAbi.cxx +++ b/Private/Source/CxxAbi.cxx @@ -29,7 +29,8 @@ extern "C" void __stack_chk_fail() hCore::panic(RUNTIME_CHECK_POINTER); } -extern "C" int __cxa_atexit(void (*f)(void *), void *arg, void *dso) { +extern "C" int __cxa_atexit(void (*f)(void *), void *arg, void *dso) +{ if (__atexit_func_count >= DSO_MAX_OBJECTS) return -1; @@ -42,11 +43,15 @@ extern "C" int __cxa_atexit(void (*f)(void *), void *arg, void *dso) { return 0; } -extern "C" void __cxa_finalize(void *f) { +extern "C" void __cxa_finalize(void *f) +{ uarch_t i = __atexit_func_count; - if (!f) { - while (i--) { - if (__atexit_funcs[i].destructor_func) { + if (!f) + { + while (i--) + { + if (__atexit_funcs[i].destructor_func) + { (*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr); }; } @@ -54,26 +59,32 @@ extern "C" void __cxa_finalize(void *f) { return; } - while (i--) { - if (__atexit_funcs[i].destructor_func) { + while (i--) + { + if (__atexit_funcs[i].destructor_func) + { (*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr); __atexit_funcs[i].destructor_func = 0; }; } } -namespace cxxabiv1 { - extern "C" int __cxa_guard_acquire(__guard *g) { +namespace cxxabiv1 +{ + extern "C" int __cxa_guard_acquire(__guard *g) + { (void) g; return 0; } - extern "C" int __cxa_guard_release(__guard *g) { + extern "C" int __cxa_guard_release(__guard *g) + { *(char *) g = 1; return 0; } - extern "C" void __cxa_guard_abort(__guard *g) { + extern "C" void __cxa_guard_abort(__guard *g) + { (void) g; } } // namespace cxxabiv1 @@ -87,6 +98,18 @@ namespace cxxkit for (int i = 0; i < cnt; ++i) (finis[i])(); } + + extern "C" void __init_local(void(**init)(void), int cnt) + { + for (int i = 0; i < cnt; ++i) + (init[i])(); + } + + extern "C" void __fini_local(void(**finis)(void), int cnt) + { + for (int i = 0; i < cnt; ++i) + (finis[i])(); + } } #endif diff --git a/Private/Source/IndexableProperty.cxx b/Private/Source/IndexableProperty.cxx index bb1393b5..5b49d6c1 100644 --- a/Private/Source/IndexableProperty.cxx +++ b/Private/Source/IndexableProperty.cxx @@ -9,7 +9,7 @@ //! @brief hCore NewFS Indexer. -#include +#include #include #include #include diff --git a/Public/SDK/ZipKit/Defines.hpp b/Public/SDK/ZipKit/Defines.hpp index 8f15dc6b..8c3790c6 100644 --- a/Public/SDK/ZipKit/Defines.hpp +++ b/Public/SDK/ZipKit/Defines.hpp @@ -11,4 +11,4 @@ #include -#define ZIPKIT_VERSION "1.0.0" \ No newline at end of file +#define ZIPKIT_VERSION "1.0.1" diff --git a/Public/SDK/ZipKit/NewFS-Addon.hpp b/Public/SDK/ZipKit/NewFS-Addon.hpp index 07e41f64..4bc0c4c1 100644 --- a/Public/SDK/ZipKit/NewFS-Addon.hpp +++ b/Public/SDK/ZipKit/NewFS-Addon.hpp @@ -9,7 +9,7 @@ #pragma once -// TODO: integrate MeFS compression. +// TODO: integrate NewFS compression. // MeFS catalog is compressed. #define kCatalogFlagZip 255 diff --git a/Public/SDK/ZipKit/Zip.cpp b/Public/SDK/ZipKit/Zip.cpp index e6ff73ad..a7b3e0f4 100644 --- a/Public/SDK/ZipKit/Zip.cpp +++ b/Public/SDK/ZipKit/Zip.cpp @@ -45,12 +45,42 @@ namespace ZipKit void* ZipStream::Deflate(const char* name) { + z_stream deflate_stream{ 0 }; - return nullptr; + deflate_stream.zalloc = Z_NULL; + deflate_stream.zfree = Z_NULL; + deflate_stream.opaque = Z_NULL; + + // setup "b" as the input and "c" as the compressed output + deflate_stream.avail_in = (uInt)this->fSharedSz+1; // size of input, string + terminator + deflate_stream.next_in = (Bytef *)this->fSharedData; // input char array + deflate_stream.avail_out = (uInt)this->fSharedSz; // size of output + deflate_stream.next_out = (Bytef *)this->fSharedData; // output char array + + deflateInit(deflate_stream); + deflate(&deflate_stream, Z_NO_FLUSH); + deflateEnd(&deflate_stream); + + return this->fSharedData; } void ZipStream::Inflate(const char* name, void* data) { + z_stream inflate_stream{ 0 }; + + inflate_stream.zalloc = Z_NULL; + inflate_stream.zfree = Z_NULL; + inflate_stream.opaque = Z_NULL; + + // setup "b" as the input and "c" as the compressed output + inflate_stream.avail_in = (uInt)((char*)inflate_stream.next_out - b); // size of input + + inflate_stream.next_in = (Bytef *)this->fSharedData; // input char array + inflate_stream.avail_out = (uInt)this->fSharedSz; // size of output + inflate_stream.next_out = (Bytef *)this->fSharedData; // output char array + inflateInit(inflate_stream); + inflate(&inflate_stream, Z_NO_FLUSH); + inflateEnd(&inflate_stream); } } \ No newline at end of file diff --git a/Public/SDK/ZipKit/Zip.hpp b/Public/SDK/ZipKit/Zip.hpp index be7062f2..72105bc1 100644 --- a/Public/SDK/ZipKit/Zip.hpp +++ b/Public/SDK/ZipKit/Zip.hpp @@ -1,11 +1,11 @@ /* - * ======================================================== - * - * h-core - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ +* ======================================================== +* +* h-core +* Copyright 2024 Mahrouss Logic, all rights reserved. +* +* ======================================================== +*/ #pragma once @@ -18,25 +18,28 @@ namespace ZipKit { - class ZipStream; +class ZipStream; - class ZipStream final - { - public: - explicit ZipStream(); - ~ZipStream() noexcept; +class ZipStream final +{ + public: + explicit ZipStream(); + ~ZipStream() noexcept; + + public: + HCORE_COPY_DEFAULT(ZipStream); - public: - HCORE_COPY_DEFAULT(ZipStream); + public: + MeFilePtr FlushToFile(const char* name); + void* Deflate(const char* name); + void Inflate(const char* name, void* data); - public: - MeFilePtr FlushToFile(const char* name); - void* Deflate(const char* name); - void Inflate(const char* name, void* data); + private: + VoidStar fSharedData{ nullptr }; + SizeT fSharedSz{ 0 }; - private: - void* fSharedData{ nullptr }; - SizeT fSharedSz{ 0 }; + private: + z_stream fStream; - }; +}; } -- cgit v1.2.3