diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-26 01:47:32 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-26 01:47:32 +0100 |
| commit | c52dbf5513ae7f106634967162da5cfb01dc5af3 (patch) | |
| tree | b6715d0fdacebd48491b9b05cf85f1d92028f84b /lib | |
| parent | 01565adb9cf5ef991196f56c7f5f7b6161daa005 (diff) | |
feat: SOCL v1.0.2, changelog soon!v1.0.2
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/detail/error.hpp | 17 | ||||
| -rw-r--r-- | lib/fix/network.hpp | 20 | ||||
| -rw-r--r-- | lib/fix/parser.hpp | 181 | ||||
| -rw-r--r-- | lib/io/print.hpp | 29 | ||||
| -rw-r--r-- | lib/logic/equiv.hpp | 102 | ||||
| -rw-r--r-- | lib/logic/math.hpp | 35 | ||||
| -rw-r--r-- | lib/logic/opt.hpp | 121 | ||||
| -rw-r--r-- | lib/memory/tracked_ptr.hpp | 195 | ||||
| -rw-r--r-- | lib/utility/cgi.hpp | 62 | ||||
| -rw-r--r-- | lib/utility/crc32.hpp | 74 | ||||
| -rw-r--r-- | lib/utility/embfs.hpp | 79 |
11 files changed, 0 insertions, 915 deletions
diff --git a/lib/detail/error.hpp b/lib/detail/error.hpp deleted file mode 100644 index 85a5e25..0000000 --- a/lib/detail/error.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * File: opt.hpp - * Author: Amlal El Mahrouss, - * Copyright 2023-2025, Amlal El Mahrouss/SNU Systems Corp all rights reserved. - */ - -#ifndef _SNU_ERR_HPP -#define _SNU_ERR_HPP - -#include <stdexcept> - -namespace snu -{ - using runtime_error = std::runtime_error; -} - -#endif // _SNU_ERR_HPP
\ No newline at end of file diff --git a/lib/fix/network.hpp b/lib/fix/network.hpp deleted file mode 100644 index 0ca0920..0000000 --- a/lib/fix/network.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/* -* File: fix/netowrk.hpp - * Purpose: Financial Information Exchange in C++ - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp all rights reserved. - */ - -#ifndef _SNU_FIX_NETWORK_HPP -#define _SNU_FIX_NETWORK_HPP - -#include <arpa/inet.h> -#include <sys/socket.h> - -namespace snu::fix -{ - class network_rx; - class network_tx; -} // namespace snu::fix - -#endif // ifndef _SNU_FIX_NETWORK_HPP
\ No newline at end of file diff --git a/lib/fix/parser.hpp b/lib/fix/parser.hpp deleted file mode 100644 index 95d05e6..0000000 --- a/lib/fix/parser.hpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * File: fix/parser.hpp - * Purpose: Financial Information Exchange parser in C++ - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp all rights reserved. - */ - -#ifndef _SNU_FIX_PARSER_HPP -#define _SNU_FIX_PARSER_HPP - -#include <cstddef> -#include <cassert> -#include <utility> -#include <string> -#include <vector> - -namespace snu::fix -{ - template <typename char_type> - struct visitor; - - template <typename char_type> - struct range; - - template <typename char_type> - struct range_data; - - /// @brief Buffer+Length structure - template <typename char_type> - using range_ptr_t = range<char_type>; - - namespace detail - { - template <typename char_type> - const char_type* begin_fix(); - - template <> - inline const char* begin_fix<char>() - { - return "FIX."; - } - - template <> - inline const char16_t* begin_fix<char16_t>() - { - return u"FIX."; - } - - template <> - inline const char8_t* begin_fix<char8_t>() - { - return u8"FIX."; - } - } // namespace detail - - template <typename char_type> - struct range final - { - char_type* bytes_; - size_t length_; - - bool is_valid() - { - return bytes_ && length_ > 0; - } - - operator bool() - { - return this->is_valid(); - } - }; - - /// @brief Convert range to usable string. - /// @note This function assumes that the range is valid and contains ASCII bytes. - template <typename char_type> - inline std::basic_string<char_type> to_string(range<char_type>& range) noexcept - { - if (range.length_ < 0) - return std::basic_string<char_type>{}; - - return std::basic_string<char_type>(range.ascii_bytes_, range.length_); - } - - /// @brief a range object containing the FIX packet values. - template <typename char_type> - class range_data final - { - public: - std::basic_string<char_type> msg_magic_; - std::size_t msg_body_len_; - std::vector<std::pair<std::basic_string<char_type>, std::basic_string<char_type>>> msg_body_; - - static inline const char_type* begin = detail::begin_fix<char_type>(); - - explicit range_data() = default; - ~range_data() = default; - - range_data& operator=(const range_data&) = default; - range_data(const range_data&) = default; - - bool is_valid() - { - return msg_magic_.starts_with(range_data<char_type>::begin); - } - - operator bool() - { - return this->is_valid(); - } - }; - - /// @brief visitor object which returns a fix::range_data instance. - template <typename char_type> - class visitor final - { - public: - static constexpr const char_type soh = '|'; - static constexpr const char_type eq = '='; - static constexpr uint32_t base = 10U; - - explicit visitor() = default; - ~visitor() = default; - - visitor& operator=(const visitor&) = default; - visitor(const visitor&) = default; - - range<char_type> operator()(const std::basic_string<char_type>& in) - { - return this->visit(in); - } - - range_data<char_type> visit(const std::basic_string<char_type>& in) - { - thread_local range_data<char_type> ret{}; - - if (in.empty()) - return ret; - - thread_local std::basic_string<char_type> in_tmp{}; - - in_tmp.reserve(in.size()); - - try - { - for (auto& ch : in) - { - if (ch != visitor::soh) - { - in_tmp += ch; - continue; - } - - std::basic_string<char_type> key = in_tmp.substr(0, in_tmp.find(visitor::eq)); - std::basic_string<char_type> val = in_tmp.substr(in_tmp.find(visitor::eq) + 1); - - if (ret.msg_magic_.empty()) - { - ret.msg_magic_ = val; - } - else - { - ret.msg_body_.emplace_back(std::make_pair(key, val)); - ret.msg_body_len_ += in_tmp.size(); - } - - in_tmp.clear(); - } - } - catch (...) - { - in_tmp.clear(); - return ret; - } - - in_tmp.clear(); - return ret; - } - }; -} // namespace snu::fix - -#endif // ifndef _SNU_FIX_PARSER_HPP diff --git a/lib/io/print.hpp b/lib/io/print.hpp deleted file mode 100644 index 0a5b5e2..0000000 --- a/lib/io/print.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * File: print.hpp - * Purpose: SNU Print library - * Author: Amlal El Mahrouss. (founder@snu.systems) - * Copyright 2025, SNU Systems Corp all rights reserved. - */ - -#ifndef _SNU_PRINT_HPP -#define _SNU_PRINT_HPP - -#include <iostream> - -namespace snu -{ - template <typename... T> - inline void print(T... fmt) - { - std::cout << std::move(fmt...); - } - - template <typename... T> - inline void println(T... fmt) - { - std::cout << std::move(fmt...); - std::cout << std::endl; - } -} // namespace snu - -#endif // ifndef _SNU_PRINT_HPP
\ No newline at end of file diff --git a/lib/logic/equiv.hpp b/lib/logic/equiv.hpp deleted file mode 100644 index 4bb5904..0000000 --- a/lib/logic/equiv.hpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * File: equiv.hpp - * Purpose: Equivalence runtime c++ header. - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp all rights reserved. - */ - -#pragma once - -namespace snu::equiv -{ - template <typename T> - struct basic_hash_trait - { - /// @brief hash from T's result. - static typename T::result hash() - { - static T val; - return val.hash(); - } - }; - - template <typename T, typename U> - struct is_same - { - static constexpr bool value = false; - - /// @brief check if hash matches what we expect. - constexpr bool operator()() noexcept - { - return T::hash() == U::hash(); - } - }; - - template <typename T> - struct is_same<T, T> - { - static constexpr bool value = true; - }; - - template <typename T, typename U> - struct is_not_same - { - static constexpr bool value = true; - - constexpr bool operator()() noexcept - { - return T::hash() != U::hash(); - } - }; - - template <typename T> - struct is_not_same<T, T> - { - static constexpr bool value = false; - }; - - template <typename T> - struct equiv_is_int8 - { - private: - T left_ = 255, right_ = 255; - - public: - using result = T; - - constexpr result hash() - { - return (left_ + right_) < 1; - } - }; - - template <typename T> - struct equiv_not_int8 - { - private: - T left_ = 255, right_ = 255; - - public: - using result = T; - - constexpr result hash() - { - return (left_ + right_) > 0; - } - }; - - template <typename T> - struct equiv_is_real - { - private: - T left_ = 5, right_ = 3; - - public: - using result = T; - - constexpr result hash() - { - return left_ / right_; - } - }; -} // namespace snu::equiv
\ No newline at end of file diff --git a/lib/logic/math.hpp b/lib/logic/math.hpp deleted file mode 100644 index 2613799..0000000 --- a/lib/logic/math.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * File: math.hpp - * Purpose: Mathematics c++ header. - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss all rights reserved. - */ - -#pragma once - -#include <cmath> - -namespace snu::math -{ - template <size_t T> - struct is_non_boolean_integer final - { - static constexpr const bool value = true; - }; - - template <> - struct is_non_boolean_integer<false> final - { - static constexpr const bool value = false; - }; - - template <> - struct is_non_boolean_integer<true> final - { - static constexpr const bool value = false; - }; - - constexpr inline auto not_a_number = NAN; - constexpr inline auto positive_infinity = INFINITY; - constexpr inline auto negative_infinity = -positive_infinity; -} // namespace snu::math
\ No newline at end of file diff --git a/lib/logic/opt.hpp b/lib/logic/opt.hpp deleted file mode 100644 index facbf2c..0000000 --- a/lib/logic/opt.hpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * File: opt.hpp - * Author: Amlal El Mahrouss, - * Copyright 2023-2025, Amlal El Mahrouss/SNU Systems Corp all rights reserved. - */ - -#ifndef _SNU_OPT_HPP -#define _SNU_OPT_HPP - -#include <lib/detail/error.hpp> -#include <utility> - -namespace snu::opt -{ - enum class return_type - { - invalid = 0, - okay = 100, - err, - count = err - okay + 1, - }; - - struct opt final - { - explicit opt(const return_type& return_type) - : m_ret(return_type) - { - } - - opt& expect(const char* input) - { - if (m_ret == return_type::err) - { - throw std::runtime_error(input); - } - - return *this; - } - - private: - return_type m_ret; - }; - - template <typename Teller, typename... Lst> - inline return_type eval(Teller tell, Lst&&... arg) - { - return tell(std::forward<Lst>(arg)...) ? return_type::okay : return_type::err; - } - - namespace traits - { - struct int_eq_teller - { - explicit int_eq_teller() - { - } - - bool operator()(int a, int b) - { - return (a == b); - } - }; - - struct int_greater_than_teller - { - explicit int_greater_than_teller() - { - } - - bool operator()(int a, int b) - { - return (a > b); - } - }; - - struct int_less_than_teller - { - explicit int_less_than_teller() - { - } - - bool operator()(int a, int b) - { - return (a < b); - } - }; - } // namespace traits - - template <typename... Lst> - inline return_type eval_less_than(Lst&&... arg) - { - static traits::int_less_than_teller eq; - return eq(std::forward<Lst>(arg)...) ? return_type::okay : return_type::err; - } - - template <typename... Lst> - inline return_type eval_eq(Lst&&... arg) - { - static traits::int_eq_teller less_than; - return less_than(std::forward<Lst>(arg)...) ? return_type::okay : return_type::err; - } - - template <typename... Lst> - inline return_type eval_greater_than(Lst&&... arg) - { - static traits::int_greater_than_teller greater_than; - return greater_than(std::forward<Lst>(arg)...) ? return_type::okay : return_type::err; - } - - inline return_type eval_true() - { - return return_type::okay; - } - - inline return_type eval_false() - { - return return_type::err; - } -} // namespace snu::opt - -#endif /* ifndef _SNU_OPT_HPP */ diff --git a/lib/memory/tracked_ptr.hpp b/lib/memory/tracked_ptr.hpp deleted file mode 100644 index ec19151..0000000 --- a/lib/memory/tracked_ptr.hpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * File: memory/tracked_ptr.hpp - * Purpose: Custom smart pointer implementation in C++ - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp all rights reserved. - */ - -#pragma once - -#include <cstddef> -#include <utility> -#include <memory> -#include <atomic> - -namespace snu::memory -{ - template <typename T> - class tracked_allocator; - - template <typename T> - class tracked_mgr; - - template <typename T, typename Mgr> - class tracked_ptr; - - template <typename T> - class tracked_allocator - { - public: - std::atomic<size_t> allocated_count_ = 0; - std::atomic<size_t> deallocated_count_ = 0; - - public: - template <typename... U> - void retain(T*& ptr, U&&... args) - { - ptr = new T(args...); - - if (ptr) - { - ++allocated_count_; - } - else - { - throw std::bad_alloc(); - } - } - - void dispose(T* ptr) - { - if (ptr) - { - if (allocated_count_) - --allocated_count_; - - ++deallocated_count_; - - delete ptr; - ptr = nullptr; - } - } - }; - - template <typename T> - class tracked_mgr - { - private: - tracked_allocator<T> allocator_; - - public: - const tracked_allocator<T>& allocator() - { - return allocator_; - } - - template <typename... U> - T* retain(U&&... args) - { - T* ptr = nullptr; - allocator_.retain(ptr, std::forward<U>(args)...); - return ptr; - } - - void dispose(T* ptr) - { - allocator_.dispose(ptr); - } - }; - - template <typename T, typename Mgr = tracked_mgr<T>> - class tracked_ptr - { - public: - static Mgr& manager() - { - static Mgr mgr; - return mgr; - } - - public: - template <typename... U> - explicit tracked_ptr(U&&... args) - : ptr_(nullptr) - { - ptr_ = tracked_ptr::manager().retain(std::forward<U>(args)...); - } - - ~tracked_ptr() noexcept - { - this->reset(); - } - - tracked_ptr(const tracked_ptr&) = delete; - tracked_ptr& operator=(const tracked_ptr&) = delete; - - public: - void reset() - { - if (ptr_) - { - tracked_ptr::manager().dispose(ptr_); - ptr_ = nullptr; - } - } - - T* get() const - { - return ptr_; - } - - T* data() - { - return ptr_; - } - - T& operator*() const - { - return *ptr_; - } - - T* operator->() const - { - return ptr_; - } - - explicit operator bool() const - { - return ptr_ != nullptr; - } - - void swap(tracked_ptr& other) - { - std::swap(ptr_, other.ptr_); - } - - public: - tracked_ptr(tracked_ptr&& other) noexcept - : ptr_(other.ptr_) - { - other.ptr_ = nullptr; - } - - tracked_ptr& operator=(tracked_ptr&& other) noexcept - { - if (this != &other) - { - this->reset(); - ptr_ = other.ptr_; - other.ptr_ = nullptr; - } - - return *this; - } - - private: - T* ptr_ = nullptr; - }; - - template <typename T> - inline auto make_tracked(T arg) -> tracked_ptr<T> { - return tracked_ptr<T>(std::forward<T>(arg)); - } - - - template <typename U, typename... T> - inline auto make_tracked(T&&... arg) -> tracked_ptr<U> { - return tracked_ptr<U>(std::forward<T>(arg)...); - } - - template <typename T> - inline void swap(tracked_ptr<T>& a, tracked_ptr<T>& b) - { - a.swap(b); - } -} // namespace snu::memory
\ No newline at end of file diff --git a/lib/utility/cgi.hpp b/lib/utility/cgi.hpp deleted file mode 100644 index 068adf1..0000000 --- a/lib/utility/cgi.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * File: cgi.hpp - * Author: Amlal El Mahrouss, - * Copyright 2023-2025, Amlal El Mahrouss all rights reserved. - */ - -#ifndef _SNU_CGI_HPP -#define _SNU_CGI_HPP - -#include <cstdio> -#include <string> -#include <sstream> - -namespace snu -{ - namespace cgi - { - /// @brief CGI Writer class, writes to stdout; as CGI expects. - class writer final - { - writer& eval_(const std::string& mime, const std::stringstream& ss) noexcept - { - std::printf("Content-Type: %s\r\n", mime.c_str()); - std::printf("Server: %s\r\n", "snu-cpp-library"); - std::printf("Content-Length: %ld\r\n\r\n", ss.str().size()); - std::printf("%s", ss.str().c_str()); - - return *this; - } - - public: - explicit writer() = default; - ~writer() = default; - - writer& operator=(const writer&) = default; - writer(const writer&) = default; - - public: - writer& eval_html(const std::stringstream& ss_html) - { - return this->eval_("text/html", ss_html); - } - - writer& eval_xml(const std::stringstream& ss_html) - { - return this->eval_("application/xml", ss_html); - } - - writer& eval_json(const std::stringstream& ss_html) - { - return this->eval_("application/json", ss_html); - } - - writer& eval_js(const std::stringstream& ss_html) - { - return this->eval_("text/javascript", ss_html); - } - }; - } // namespace cgi -} // namespace snu - -#endif // ifndef _SNU_CGI_HPP
\ No newline at end of file diff --git a/lib/utility/crc32.hpp b/lib/utility/crc32.hpp deleted file mode 100644 index de78d4e..0000000 --- a/lib/utility/crc32.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * File: embfs.hpp - * Purpose: Embedded File System. - * Author: Amlal El Mahrouss, - * Copyright 2025, Amlal El Mahrouss all rights reserved. - */ - -#ifndef _SNU_CRC32_HPP -#define _SNU_CRC32_HPP - -#include <cstdint> -#include <cstddef> - -/// @brief Crc32 implementation in C++ -/// @author Amlal EL Mahrouss (founder@snu.systems) - -namespace snu::crc32 -{ - namespace details - { - inline constexpr const std::uint16_t g_crc_sz = 256; - - inline std::uint32_t g_crc_table[g_crc_sz] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, - 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, - 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, - 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, - 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, - 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, - 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, - 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, - 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, - 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, - 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, - 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, - 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, - 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, - 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, - 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, - 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, - 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, - 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, - 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, - 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, - 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d}; - /// - - inline std::uint32_t - calculate_crc32_(const char* in, size_t len) noexcept - { - if (!in || *in == 0) - return ~0; - - std::uint32_t crc = 0xffffffff; - - while ((len--) > 0) - crc = (crc >> 8) ^ g_crc_table[(crc ^ *(in++)) & 0xFF]; - - return ~crc; - } - } // namespace details -} // namespace snu::crc32 - -#endif // !_SNU_CRC32_HPP
\ No newline at end of file diff --git a/lib/utility/embfs.hpp b/lib/utility/embfs.hpp deleted file mode 100644 index 8d5dbdf..0000000 --- a/lib/utility/embfs.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * File: embfs.hpp - * Purpose: Embedded File System. - * Author: Amlal El Mahrouss (founder@snu.systems) - * Copyright 2025, Amlal El Mahrouss all rights reserved. - */ - -#ifndef _SNU_EMBFS_HPP -#define _SNU_EMBFS_HPP - -#include <cstdint> -#include <cstddef> - -/// @brief A filesystem designed for tiny storage medias. -/// @author Amlal EL Mahrouss (founder@snu.systems) - -namespace snu::embfs -{ - namespace details - { - struct embfs_superblock; - struct embfs_inode; - - inline constexpr const size_t _superblock_name_len = 16; - inline constexpr const size_t _superblock_reserve_len = 462; - inline constexpr const size_t _inode_name_len = 128; - inline constexpr const size_t _inode_arr_len = 12; - inline constexpr const size_t _inode_lookup_len = 8; - -#ifdef EMBFS_28BIT_LBA - typedef std::uint32_t lba_t; -#elif defined(EMBFS_48BIT_LBA) - typedef std::uint64_t lba_t; -#else - typedef std::uint32_t lba_t; -#endif - - typedef std::int16_t sword_t; - typedef std::int32_t sdword_t; - - typedef std::uint8_t utf8_char_t; - - /// @brief Superblock data structure - struct embfs_superblock - { - sword_t s_block_mag; - sdword_t s_num_inodes; - sdword_t s_part_size; - sdword_t s_part_used; - sdword_t s_version; - sword_t s_sector_sz; - lba_t s_inode_start; - lba_t s_inode_end; - utf8_char_t s_name[_superblock_name_len]; - utf8_char_t s_reserved[_superblock_reserve_len]; - }; - - /// @brief Indexed node structure. - /// @brief i_name file name - /// @brief i_size_virt, i_size_phys: virtual and physical (sector count) size. - /// @brief i_offset direct block pointer. - /// @brief i_checksum crc32 checksum. - /// @brief i_flags_perms flags and permissions - /// @brief i_acl_* ACL to keep track of inode allocation status. - struct embfs_inode - { - utf8_char_t i_name[_inode_name_len]; - sword_t i_size_virt, i_size_phys; - lba_t i_offset[_inode_lookup_len]; - sword_t i_checksum, i_flags_perms; - lba_t i_acl_creat, i_acl_edit, i_acl_delet; - }; - - /// @brief Indexed node linear array. - typedef embfs_inode embfs_inode_arr_t[_inode_arr_len]; - } // namespace details -} // namespace snu::embfs - -#endif // ifndef _SNU_EMBFS_HPP
\ No newline at end of file |
