diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-01 02:39:24 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-01 02:39:24 -0500 |
| commit | cd0c176275687a552bc546395bd2a39c92a3dd1b (patch) | |
| tree | d6ddc16fd59d851a093700bad8dd8baca1c914dc | |
| parent | 82f7d186848681e2530c9fa8b196b55fad0f4823 (diff) | |
| parent | 9c3de597257be9911a5eeb86c33962b15d87a701 (diff) | |
Merge pull request #98 from nekernel-org/develop
Develop: Updated paper, containers, and container types.
| -rw-r--r-- | docs/tex/binary_mutex.tex | 4 | ||||
| -rw-r--r-- | docs/tex/core_process_scheduler.tex | 2 | ||||
| -rw-r--r-- | src/boot/BootKit/Qr.h | 4 | ||||
| -rw-r--r-- | src/boot/BootKit/QrPrelude.h | 8 | ||||
| -rw-r--r-- | src/kernel/KernelKit/PCI/Device.h | 6 | ||||
| -rw-r--r-- | src/kernel/NeKit/KernelPanic.h | 8 | ||||
| -rw-r--r-- | src/kernel/NeKit/OwnPtr.h | 6 | ||||
| -rw-r--r-- | src/kernel/SignalKit/Signals.h | 8 | ||||
| -rw-r--r-- | src/libDDK/DriverKit/c++/driver_base.h | 8 | ||||
| -rw-r--r-- | src/libSystem/SystemKit/Verify.h | 2 |
10 files changed, 36 insertions, 20 deletions
diff --git a/docs/tex/binary_mutex.tex b/docs/tex/binary_mutex.tex index 66869fd2..f5d54743 100644 --- a/docs/tex/binary_mutex.tex +++ b/docs/tex/binary_mutex.tex @@ -44,10 +44,10 @@ class BinaryMutex final { public: bool IsLocked() const; - bool Unlock() ; + bool Unlock(); public: - BOOL WaitForProcess(const UInt32& sec) ; + BOOL WaitForProcess(const UInt32& sec); public: bool Lock(USER_PROCESS* process); diff --git a/docs/tex/core_process_scheduler.tex b/docs/tex/core_process_scheduler.tex index 1722040e..a19267a3 100644 --- a/docs/tex/core_process_scheduler.tex +++ b/docs/tex/core_process_scheduler.tex @@ -55,7 +55,7 @@ class UserProcessTeam final { Array<USER_PROCESS, kSchedProcessLimitPerTeam>& AsArray(); Ref<USER_PROCESS>& AsRef(); - ProcessID& Id() ; + ProcessID& Id(); public: USER_PROCESS_ARRAY mProcessList; diff --git a/src/boot/BootKit/Qr.h b/src/boot/BootKit/Qr.h index f5ac5f2e..ab4696cc 100644 --- a/src/boot/BootKit/Qr.h +++ b/src/boot/BootKit/Qr.h @@ -3,7 +3,7 @@ #include <BootKit/Shared/base.h> #include <BootKit/Shared/bit.h> - +#include <NeKit/KernelPanic.h> #include <BootKit/QrPrelude.h> #include <BootKit/Support.h> #include <CompilerKit/Detail.h> @@ -265,7 +265,7 @@ struct Qr { void apply_mask(int mask, uint8_t* patterns); private: - static_assert(V >= 1 && V <= 40, "invalid version"); + STATIC_PASS(V >= 1 && V <= 40, "invalid version"); static constexpr int SIDE = 17 + V * 4; static constexpr int N_BITS = SIDE * SIDE; static constexpr int N_ALIGN = V == 1 ? 0 : V / 7 + 2; diff --git a/src/boot/BootKit/QrPrelude.h b/src/boot/BootKit/QrPrelude.h index e89fad7a..7b09fdb0 100644 --- a/src/boot/BootKit/QrPrelude.h +++ b/src/boot/BootKit/QrPrelude.h @@ -1 +1,9 @@ +/* ======================================== + + Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +======================================== */ + +#pragma once + #include <BootKit/BitManip.h>
\ No newline at end of file diff --git a/src/kernel/KernelKit/PCI/Device.h b/src/kernel/KernelKit/PCI/Device.h index c8caf67c..e9c5a683 100644 --- a/src/kernel/KernelKit/PCI/Device.h +++ b/src/kernel/KernelKit/PCI/Device.h @@ -3,9 +3,11 @@ Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. ======================================== */ + #pragma once #include <NeKit/Config.h> +#include <NeKit/KernelPanic.h> namespace Kernel::PCI { enum class PciConfigKind : UShort { @@ -38,13 +40,13 @@ class Device final { public: template <typename T> UInt Read(UInt bar) { - static_assert(sizeof(T) <= sizeof(UInt32), "64-bit PCI addressing is unsupported"); + STATIC_PASS(sizeof(T) <= sizeof(UInt32), "64-bit PCI addressing is unsupported"); return Read(bar, sizeof(T)); } template <typename T> void Write(UInt bar, UIntPtr data) { - static_assert(sizeof(T) <= sizeof(UInt32), "64-bit PCI addressing is unsupported"); + STATIC_PASS(sizeof(T) <= sizeof(UInt32), "64-bit PCI addressing is unsupported"); Write(bar, data, sizeof(T)); } diff --git a/src/kernel/NeKit/KernelPanic.h b/src/kernel/NeKit/KernelPanic.h index cba8897c..a12ff73c 100644 --- a/src/kernel/NeKit/KernelPanic.h +++ b/src/kernel/NeKit/KernelPanic.h @@ -9,11 +9,8 @@ #include <NeKit/Config.h> -namespace Kernel { -void ke_runtime_check(bool expr, const Char* file, const Char* line); -} - -#define MUST_PASS_COMPILER(EXPR, MSG) static_assert(EXPR, MSG) +/// @brief Checks during compile time whether a condition passes. +#define STATIC_PASS(EXPR, MSG) static_assert(EXPR, MSG) #ifdef TRY #undef TRY @@ -65,5 +62,6 @@ enum RUNTIME_CHECK { typedef enum RUNTIME_CHECK RTL_RUNTIME_CHECK; namespace Kernel { +void ke_runtime_check(bool expr, const Char* file, const Char* line); void ke_panic(const Int32& id, const Char* message = nullptr); } // namespace Kernel diff --git a/src/kernel/NeKit/OwnPtr.h b/src/kernel/NeKit/OwnPtr.h index 2c493b1b..18a31bd1 100644 --- a/src/kernel/NeKit/OwnPtr.h +++ b/src/kernel/NeKit/OwnPtr.h @@ -10,6 +10,7 @@ #include <NeKit/Config.h> #include <NeKit/KernelPanic.h> #include <NeKit/Ref.h> +#include <NeKit/ErrorOr.h> namespace Kernel { template <typename T> @@ -56,8 +57,11 @@ class OwnPtr final { T* fCls{nullptr}; }; +template <typename T> +using OwnOr = ErrorOr<OwnPtr<T>>; + template <typename T, typename... Args> -inline OwnPtr<T> make_ptr(Args... args) { +inline OwnPtr<T> make_ptr(Args&&... args) { OwnPtr<T> ret; ret.template New<Args...>(forward(args)...); diff --git a/src/kernel/SignalKit/Signals.h b/src/kernel/SignalKit/Signals.h index cb7abfa1..700a4f41 100644 --- a/src/kernel/SignalKit/Signals.h +++ b/src/kernel/SignalKit/Signals.h @@ -7,7 +7,9 @@ #pragma once #include <NeKit/Config.h> +#include <NeKit/KernelPanic.h> +#define SIGBAD 0 /* bad signal*/ #define SIGKILL 1 /* kill */ #define SIGPAUS 2 /* pause */ #define SIGEXEC 3 /* execute */ @@ -34,7 +36,7 @@ inline constexpr auto kKernelSignalSeed = 0x0895034f9fUL; /// @brief Generate signal from **Sig** template <rt_signal_kind Sig, SizeT Seed = kUserSignalSeed> inline rt_signal_kind sig_generate_unique() { - static_assert(Sig > 0, "Signal is zero (invalid)"); + STATIC_PASS(Sig > SIGBAD, "Signal is zero (invalid)"); return Sig ^ Seed; } @@ -44,8 +46,8 @@ inline BOOL sig_matches_seed(rt_signal_kind sig) { return (sig & 0xFF000000) == (Seed & 0xFF000000); } -/// @brief Validate signal from **sig** +/// @brief Validate signal from **sig** and whtether the signal is greater than SIGDTCH. inline BOOL sig_validate_unique(rt_signal_kind sig) { - return sig > 0; + return sig > SIGBAD && sig > SIGDTCH; } } // namespace Kernel diff --git a/src/libDDK/DriverKit/c++/driver_base.h b/src/libDDK/DriverKit/c++/driver_base.h index c130ba8b..97f07f2a 100644 --- a/src/libDDK/DriverKit/c++/driver_base.h +++ b/src/libDDK/DriverKit/c++/driver_base.h @@ -20,6 +20,8 @@ /// @author Amlal El Mahrouss namespace Kernel::DDK { +constexpr auto kInvalidType = 0; + class IDriverBase { public: explicit IDriverBase() = default; @@ -32,17 +34,17 @@ class IDriverBase { virtual BOOL IsCastable() { return NO; } virtual constexpr BOOL IsActive() { return NO; } virtual PtrType Leak() { return nullptr; } - virtual constexpr Int32 Type() { return 0; } + virtual constexpr Int32 Type() { return kInvalidType; } }; /// @brief This concept requires the Driver to be IDriverBase compliant. template <typename T> concept IsValidDriver = requires(T driver_base) { - { driver_base.IsActive() && driver_base.Type() > 0 }; + { driver_base.IsActive() && driver_base.Type() > kInvalidType }; }; /// @brief Consteval helper to detect whether a template is truly based on IDriverBase. /// @note This helper is consteval only. template <IsValidDriver T> -inline consteval void ce_ddk_is_valid(T) {} +consteval void ce_ddk_is_valid(T) {} } // namespace Kernel::DDK diff --git a/src/libSystem/SystemKit/Verify.h b/src/libSystem/SystemKit/Verify.h index 7d15435a..b99dbecc 100644 --- a/src/libSystem/SystemKit/Verify.h +++ b/src/libSystem/SystemKit/Verify.h @@ -33,7 +33,7 @@ struct must_cast_traits<T, T> { /// @author Amlal El Mahrouss /// @brief Safe constexpr cast. template <typename T, typename R> -inline constexpr R* sys_constexpr_cast(T* ptr) { +constexpr R* sys_constexpr_cast(T* ptr) { static_assert(must_cast_traits<T, R>::value, "constexpr cast failed! types are mismatching!"); return static_cast<R*>(ptr); } |
