From ca34109b59c92df1698c69455cab59ad0d105aab Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 28 Aug 2025 11:58:09 +0200 Subject: fix: LibC++: rename `sqr` to `surd`. Signed-off-by: Amlal El Mahrouss --- dev/LibC++/base_math.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dev/LibC++') diff --git a/dev/LibC++/base_math.h b/dev/LibC++/base_math.h index ca6aace..94c34e8 100644 --- a/dev/LibC++/base_math.h +++ b/dev/LibC++/base_math.h @@ -37,7 +37,7 @@ inline real_type pow(real_type in) { /// @brief Square of function, with Base template argument. /// @param of Base argument to find sqquare of template -inline real_type sqr(real_type in) { +inline real_type surd(real_type in) { if (in == 0) return 0; return pow<1 / Base>(in); -- cgit v1.2.3 From 7258392baba60c0f4d71ff62ca4e50015cd22ae4 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 28 Aug 2025 13:47:46 +0200 Subject: hotpatch: fix `surd` function. Signed-off-by: Amlal El Mahrouss --- dev/LibC++/base_math.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'dev/LibC++') diff --git a/dev/LibC++/base_math.h b/dev/LibC++/base_math.h index 94c34e8..220d357 100644 --- a/dev/LibC++/base_math.h +++ b/dev/LibC++/base_math.h @@ -18,6 +18,8 @@ typedef float real_type; #endif namespace std::base_math { +inline constexpr static auto not_a_number = NAN; + /// @brief Power function, with Repeat argument. template inline real_type pow(real_type in) { @@ -39,8 +41,14 @@ inline real_type pow(real_type in) { template inline real_type surd(real_type in) { if (in == 0) return 0; + if (in == 1) return 1; + if (Base == 1) return in; + + auto x = in / Base; + + if (Base == 2) return (x + in / x) / 2; - return pow<1 / Base>(in); + return not_a_number; } /// @brief Linear interpolation equation solver. -- cgit v1.2.3 From bca7a28c57adbb585de1e7b6ef0b1990d0837c4f Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 28 Aug 2025 13:54:54 +0200 Subject: feat: base_math.h: fixing the `surd` function for powers other than 2. Signed-off-by: Amlal El Mahrouss --- dev/LibC++/base_math.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'dev/LibC++') diff --git a/dev/LibC++/base_math.h b/dev/LibC++/base_math.h index 220d357..cf4313f 100644 --- a/dev/LibC++/base_math.h +++ b/dev/LibC++/base_math.h @@ -36,17 +36,30 @@ inline real_type pow(real_type in) { return result; } +inline real_type sqrt(real_type in) { + if (in == 0) return 0; + if (in == not_a_number) return not_a_number; + + auto constexpr const static Base = 2; + + auto x = in / Base; + + for (int i = 0; i < 10; ++i) { + x = (x + in / x) / Base; + } + + return x; +} + /// @brief Square of function, with Base template argument. /// @param of Base argument to find sqquare of template inline real_type surd(real_type in) { if (in == 0) return 0; if (in == 1) return 1; + if (Base == 1) return in; - - auto x = in / Base; - - if (Base == 2) return (x + in / x) / 2; + if (Base == 2) return sqrt(in); return not_a_number; } -- cgit v1.2.3 From 9a45caab02bb1fa426dda0b1ed584a8cbb27d27d Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 30 Aug 2025 21:47:55 +0200 Subject: feat: debugger_kit: debugger contract modifications for NeKernel. Signed-off-by: Amlal El Mahrouss --- dev/DebuggerKit/DebuggerContract.h | 2 ++ dev/DebuggerKit/NeKernelContract.h | 12 ++++++------ dev/LibC++/base_math.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'dev/LibC++') diff --git a/dev/DebuggerKit/DebuggerContract.h b/dev/DebuggerKit/DebuggerContract.h index 48c3603..9ee17d1 100644 --- a/dev/DebuggerKit/DebuggerContract.h +++ b/dev/DebuggerKit/DebuggerContract.h @@ -8,6 +8,8 @@ #include #include +#define DK_DEBUGGER_CONTRACT : public ::DebuggerKit::DebuggerContract + namespace DebuggerKit { class DebuggerContract; diff --git a/dev/DebuggerKit/NeKernelContract.h b/dev/DebuggerKit/NeKernelContract.h index d5315ef..ddea826 100644 --- a/dev/DebuggerKit/NeKernelContract.h +++ b/dev/DebuggerKit/NeKernelContract.h @@ -21,10 +21,11 @@ namespace Detail { inline constexpr auto kDebugPort = 51820; inline constexpr auto kDebugMagic = "VMK1.0.0;"; inline constexpr auto kDebugVersion = 0x0100; - typedef char rt_debug_cmd[kDebugCmdLen]; + typedef char dk_debug_cmd_type[kDebugCmdLen]; + typedef int64_t dk_socket_type; } // namespace Detail -class NeKernelContract : public DebuggerContract { +class NeKernelContract DK_DEBUGGER_CONTRACT { public: NeKernelContract(); virtual ~NeKernelContract() override; @@ -33,8 +34,6 @@ class NeKernelContract : public DebuggerContract { NeKernelContract& operator=(const NeKernelContract&) = default; NeKernelContract(const NeKernelContract&) = default; - // Override additional methods from DebuggerContract - public: bool Attach(std::string path, std::string arg_v, ProcessID& pid) noexcept override; bool BreakAt(std::string symbol) noexcept override; @@ -43,8 +42,9 @@ class NeKernelContract : public DebuggerContract { bool Detach() noexcept override; private: - std::string m_kernel_path{}; - int64_t m_socket{0}; + dk_debug_cmd_type m_buffer; + std::string m_kernel_path{}; + dk_socket_type m_socket{0}; }; } // namespace DebuggerKit::NeKernel diff --git a/dev/LibC++/base_math.h b/dev/LibC++/base_math.h index cf4313f..7c9f34d 100644 --- a/dev/LibC++/base_math.h +++ b/dev/LibC++/base_math.h @@ -57,7 +57,7 @@ template inline real_type surd(real_type in) { if (in == 0) return 0; if (in == 1) return 1; - + if (Base == 1) return in; if (Base == 2) return sqrt(in); -- cgit v1.2.3