diff options
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/DebuggerKit/DebuggerContract.h | 2 | ||||
| -rw-r--r-- | dev/DebuggerKit/NeKernelContract.h | 12 | ||||
| -rw-r--r-- | dev/LibC++/base_math.h | 25 |
3 files changed, 31 insertions, 8 deletions
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 <string> #include <unordered_map> +#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 ca6aace..7c9f34d 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 <size_t Exponent> inline real_type pow(real_type in) { @@ -34,13 +36,32 @@ 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 <size_t Base> -inline real_type sqr(real_type in) { +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); - return pow<1 / Base>(in); + return not_a_number; } /// @brief Linear interpolation equation solver. |
