From 7ec2bda484072982e75666508863ef9903331191 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 8 Apr 2024 00:44:48 +0200 Subject: Kernel/URL.cxx: Remove useless protocols for a kernel. - remove IteratorInterface for NewFS, design change have been done. Kernel/NewFS.cxx: Document code. --- Private/CFKit/URL.hpp | 6 +-- Private/CRT/__cxxkit_alloca.hxx | 12 ----- Private/CRT/__cxxkit_defines.hxx | 85 -------------------------------- Private/CRT/__mpcc_alloca.hxx | 12 +++++ Private/CRT/__mpcc_defines.hxx | 85 ++++++++++++++++++++++++++++++++ Private/FSKit/NewFSIteratorInterface.hxx | 51 ------------------- Private/NewKit/Defines.hpp | 2 +- Private/Source/FS/NewFS.cxx | 35 ++++++++++++- Private/Source/URL.cxx | 15 +++--- 9 files changed, 141 insertions(+), 162 deletions(-) delete mode 100644 Private/CRT/__cxxkit_alloca.hxx delete mode 100644 Private/CRT/__cxxkit_defines.hxx create mode 100644 Private/CRT/__mpcc_alloca.hxx create mode 100644 Private/CRT/__mpcc_defines.hxx delete mode 100644 Private/FSKit/NewFSIteratorInterface.hxx diff --git a/Private/CFKit/URL.hpp b/Private/CFKit/URL.hpp index 748b3cf0..41693e0e 100644 --- a/Private/CFKit/URL.hpp +++ b/Private/CFKit/URL.hpp @@ -11,10 +11,10 @@ #include namespace NewOS { -class Url final { +class URL final { public: - explicit Url(StringView &strUrl); - ~Url(); + explicit URL(StringView &strUrl); + ~URL(); public: Ref> Location() noexcept; diff --git a/Private/CRT/__cxxkit_alloca.hxx b/Private/CRT/__cxxkit_alloca.hxx deleted file mode 100644 index e106a373..00000000 --- a/Private/CRT/__cxxkit_alloca.hxx +++ /dev/null @@ -1,12 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -typedef void* ptr_type; -typedef __SIZE_TYPE__ size_type; - -inline void* __cxxkit_alloca_gcc(size_type sz) { return __builtin_alloca(sz); } diff --git a/Private/CRT/__cxxkit_defines.hxx b/Private/CRT/__cxxkit_defines.hxx deleted file mode 100644 index 54b50716..00000000 --- a/Private/CRT/__cxxkit_defines.hxx +++ /dev/null @@ -1,85 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#ifndef __CXXKIT_DEF__ -#define __CXXKIT_DEF__ - -typedef __SIZE_TYPE__ size_t; - -#ifdef __LP64__ -typedef long int ssize_t; -#else -typedef int ssize_t; -#endif // __LP64__ - -typedef size_t ptrdiff_t; -typedef size_t uintptr_t; -typedef void *voidptr_t; -typedef void *any_t; -typedef char *caddr_t; - -#ifndef NULL -#define NULL ((voidptr_t)0) -#endif // !null - -#ifdef __GNUC__ -#include -#define __cxxkit_alloca(sz) __cxxkit_alloca_gcc(sz) -#elif defined(__MPCC__) - -#define __alloca(sz) __cxxkit_alloca(sz) -#endif - -#define __deref(ptr) (*(ptr)) - -#ifdef __cplusplus -#define __init_decl() \ - extern "C" \ - { -#define __fini_decl() \ - } \ - ; -#else -#define __init_decl() -#define __fini_decl() -#endif - -#if __has_builtin(__builtin_alloca) -#define alloca(sz) __builtin_alloca(sz) -#ifdef __alloca -#undef __alloca -#endif -#define __alloca alloca -#else -#warning alloca not detected -#endif - -typedef long long off_t; -typedef unsigned long long uoff_t; - -typedef union float_cast { - struct - { - unsigned int mantissa : 23; - unsigned int exponent : 8; - unsigned int sign : 1; - }; - - float f; -} __attribute__((packed)) float_cast_t; - -typedef union double_cast { - struct - { - unsigned long long int mantissa : 52; - unsigned int exponent : 11; - unsigned int sign : 1; - }; - - double f; -} __attribute__((packed)) double_cast_t; - -#endif /* __CXXKIT_DEF__ */ diff --git a/Private/CRT/__mpcc_alloca.hxx b/Private/CRT/__mpcc_alloca.hxx new file mode 100644 index 00000000..5b6d81e4 --- /dev/null +++ b/Private/CRT/__mpcc_alloca.hxx @@ -0,0 +1,12 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +typedef void* ptr_type; +typedef __SIZE_TYPE__ size_type; + +inline void* __mpcc_alloca_gcc(size_type sz) { return __builtin_alloca(sz); } diff --git a/Private/CRT/__mpcc_defines.hxx b/Private/CRT/__mpcc_defines.hxx new file mode 100644 index 00000000..a9436a1b --- /dev/null +++ b/Private/CRT/__mpcc_defines.hxx @@ -0,0 +1,85 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#ifndef __MPCC_DEF__ +#define __MPCC_DEF__ + +typedef __SIZE_TYPE__ size_t; + +#ifdef __LP64__ +typedef long int ssize_t; +#else +typedef int ssize_t; +#endif // __LP64__ + +typedef size_t ptrdiff_t; +typedef size_t uintptr_t; +typedef void *voidptr_t; +typedef void *any_t; +typedef char *caddr_t; + +#ifndef NULL +#define NULL ((voidptr_t)0) +#endif // !null + +#ifdef __GNUC__ +#include +#define __mpcc_alloca(sz) __mpcc_alloca_gcc(sz) +#elif defined(__MPCC__) + +#define __alloca(sz) __mpcc_alloca(sz) +#endif + +#define __deref(ptr) (*(ptr)) + +#ifdef __cplusplus +#define __init_decl() \ + extern "C" \ + { +#define __fini_decl() \ + } \ + ; +#else +#define __init_decl() +#define __fini_decl() +#endif + +#if __has_builtin(__builtin_alloca) +#define alloca(sz) __builtin_alloca(sz) +#ifdef __alloca +#undef __alloca +#endif +#define __alloca alloca +#else +#warning alloca not detected +#endif + +typedef long long off_t; +typedef unsigned long long uoff_t; + +typedef union float_cast { + struct + { + unsigned int mantissa : 23; + unsigned int exponent : 8; + unsigned int sign : 1; + }; + + float f; +} __attribute__((packed)) float_cast_t; + +typedef union double_cast { + struct + { + unsigned long long int mantissa : 52; + unsigned int exponent : 11; + unsigned int sign : 1; + }; + + double f; +} __attribute__((packed)) double_cast_t; + +#endif /* __MPCC_DEF__ */ diff --git a/Private/FSKit/NewFSIteratorInterface.hxx b/Private/FSKit/NewFSIteratorInterface.hxx deleted file mode 100644 index d0d35c76..00000000 --- a/Private/FSKit/NewFSIteratorInterface.hxx +++ /dev/null @@ -1,51 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include -#include - -namespace NewOS { -namespace Indexer { -class NewFSIteratorInterface; - -using IndexElement = VoidPtr; - -/// -/// @name NewFSIteratorInterface -/// @brief Stores relevant information for file indexing. -/// - -class NewFSIteratorInterface { - public: - explicit NewFSIteratorInterface() = default; - virtual ~NewFSIteratorInterface() = default; - - public: - NEWOS_COPY_DEFAULT(NewFSIteratorInterface); - - public: - void Append(IndexableProperty& indexProp) { fProps.Add(indexProp); } - - MutableArray& Leak() { return fProps; } - - Boolean Find(IndexProperty& filters) { - for (size_t i = 0; i < fProps.Count(); ++i) { - if (StringBuilder::Equals(fProps[i].Leak().LeakProperty().Path, - filters.Path)) { - return i; - } - } - - return 0; - } - - private: - MutableArray fProps; -}; -} // namespace Indexer -} // namespace NewOS diff --git a/Private/NewKit/Defines.hpp b/Private/NewKit/Defines.hpp index e2951174..a3b86234 100644 --- a/Private/NewKit/Defines.hpp +++ b/Private/NewKit/Defines.hpp @@ -11,7 +11,7 @@ #define NEWKIT_VERSION "1.01" #if !defined(_INC_NO_STDC_HEADERS) && defined(__GNUC__) -#include +#include #endif #ifdef __has_feature diff --git a/Private/Source/FS/NewFS.cxx b/Private/Source/FS/NewFS.cxx index ac38400a..012cb3d2 100644 --- a/Private/Source/FS/NewFS.cxx +++ b/Private/Source/FS/NewFS.cxx @@ -162,36 +162,69 @@ bool NewFSParser::WriteCatalog(_Input _Output NewCatalog* catalog, return false; } +/// @brief +/// @param catalogName +/// @return _Output NewCatalog* NewFSParser::FindCatalog(_Input const char* catalogName) { return nullptr; } +/// @brief +/// @param name +/// @return _Output NewCatalog* NewFSParser::GetCatalog(_Input const char* name) { return nullptr; } +/// @brief +/// @param catalog +/// @return Boolean NewFSParser::CloseCatalog(_Input _Output NewCatalog* catalog) { return false; } +/// @brief +/// @param catalog +/// @return Boolean NewFSParser::RemoveCatalog(_Input _Output NewCatalog* catalog) { return false; } - +/// @brief +/// @param catalog +/// @param dataSz +/// @return VoidPtr NewFSParser::ReadCatalog(_Input _Output NewCatalog* catalog, SizeT dataSz) { return nullptr; } +/// @brief +/// @param catalog +/// @param off +/// @return bool NewFSParser::Seek(_Input _Output NewCatalog* catalog, SizeT off) { return false; } +/// @brief +/// @param catalog +/// @return SizeT NewFSParser::Tell(_Input _Output NewCatalog* catalog) { return 0; } +/// @brief +/// @param sz +/// @return STATIC Lba ke_find_free_fork(SizeT sz) { return 0; } + +/// @brief +/// @param sz +/// @return STATIC Lba ke_find_free_catalog(SizeT sz) { return 0; } + +/// @brief +/// @param sz +/// @return STATIC Lba ke_find_free_data(SizeT sz) { return 0; } namespace NewOS::Detail { diff --git a/Private/Source/URL.cxx b/Private/Source/URL.cxx index ebb325c1..090c7c66 100644 --- a/Private/Source/URL.cxx +++ b/Private/Source/URL.cxx @@ -11,18 +11,15 @@ /// BUGS: 0 namespace NewOS { -Url::Url(StringView &strUrl) : fUrlView(strUrl, false) {} +URL::URL(StringView &strUrl) : fUrlView(strUrl, false) {} -Url::~Url() = default; +URL::~URL() = default; constexpr const char *kURLProtocols[] = { - "file", // Filesystem protocol - "ping", // Ping protocol. - "telnet", // Telnet protocol - "ssh", // SSH protocol + "file", // Filesystem protocol }; -constexpr const int kUrlOutSz = 3; //! such as: :// +constexpr const int kUrlOutSz = 1; //! such as: :// constexpr const int kProtosCount = 4; constexpr const int kRangeSz = 4096; @@ -62,7 +59,7 @@ ErrorOr url_extract_protocol(const char *url) { return view; } -Ref> Url::Location() noexcept { +Ref> URL::Location() noexcept { const char *src = fUrlView.Leak().CData(); auto loc = url_extract_location(src); @@ -71,7 +68,7 @@ Ref> Url::Location() noexcept { return Ref>(loc); } -Ref> Url::Protocol() noexcept { +Ref> URL::Protocol() noexcept { const char *src = fUrlView.Leak().CData(); auto loc = url_extract_protocol(src); -- cgit v1.2.3