diff --git a/BAN/BAN/String.cpp b/BAN/BAN/String.cpp index 54eee434..cf71211c 100644 --- a/BAN/BAN/String.cpp +++ b/BAN/BAN/String.cpp @@ -5,7 +5,6 @@ #include #include -#include #include namespace BAN @@ -200,7 +199,7 @@ namespace BAN { if (m_capasity >= size) return {}; - size_type new_cap = BAN::max(size, m_capasity * 1.5f); + size_type new_cap = BAN::Math::max(size, m_capasity * 1.5f); void* new_data = BAN::allocator(new_cap); if (new_data == nullptr) return Error::FromString("String: Could not allocate memory"); diff --git a/BAN/BAN/StringView.cpp b/BAN/BAN/StringView.cpp index 53306b80..95fa60c5 100644 --- a/BAN/BAN/StringView.cpp +++ b/BAN/BAN/StringView.cpp @@ -2,7 +2,6 @@ #include #include -#include #include namespace BAN diff --git a/BAN/include/BAN/Array.h b/BAN/include/BAN/Array.h index ad5ea4ef..1a7dc83e 100644 --- a/BAN/include/BAN/Array.h +++ b/BAN/include/BAN/Array.h @@ -1,6 +1,7 @@ #pragma once -#include +#include + #include namespace BAN diff --git a/BAN/include/BAN/Math.h b/BAN/include/BAN/Math.h index c699bbca..b98356f3 100644 --- a/BAN/include/BAN/Math.h +++ b/BAN/include/BAN/Math.h @@ -1,6 +1,6 @@ #pragma once -namespace BAN +namespace BAN::Math { template @@ -21,4 +21,23 @@ namespace BAN return x < min ? min : x > max ? max : x; } + template + T gcd(T a, T b) + { + T t; + while (b) + { + t = b; + b = a % b; + a = t; + } + return a; + } + + template + T lcm(T a, T b) + { + return a / gcd(a, b) * b; + } + } \ No newline at end of file diff --git a/BAN/include/BAN/Memory.h b/BAN/include/BAN/Memory.h index 9643cd16..01c44181 100644 --- a/BAN/include/BAN/Memory.h +++ b/BAN/include/BAN/Memory.h @@ -9,11 +9,11 @@ namespace BAN { #if defined(__is_kernel) - static constexpr auto& allocator = kmalloc; - static constexpr auto& deallocator = kfree; + static constexpr void*(&allocator)(size_t) = kmalloc; + static constexpr void(&deallocator)(void*) = kfree; #else - static constexpr auto& allocator = malloc; - static constexpr auto& deallocator = free; + static constexpr void*(&allocator)(size_t) = malloc; + static constexpr void(&deallocator)(void*) = free; #endif template diff --git a/BAN/include/BAN/Queue.h b/BAN/include/BAN/Queue.h index a43617d3..506f5997 100644 --- a/BAN/include/BAN/Queue.h +++ b/BAN/include/BAN/Queue.h @@ -4,7 +4,6 @@ #include #include -#include #include #include @@ -96,7 +95,7 @@ namespace BAN if (m_capacity > size) return {}; - size_type new_cap = BAN::max(m_capacity * 1.5f, m_capacity + 1); + size_type new_cap = BAN::Math::max(m_capacity * 1.5f, m_capacity + 1); void* new_data = BAN::allocator(new_cap * sizeof(T)); if (new_data == nullptr) return Error::FromString("Queue: Could not allocate memory"); diff --git a/BAN/include/BAN/Vector.h b/BAN/include/BAN/Vector.h index a0b3bd71..e7d63fd5 100644 --- a/BAN/include/BAN/Vector.h +++ b/BAN/include/BAN/Vector.h @@ -4,7 +4,6 @@ #include #include -#include #include namespace BAN @@ -208,7 +207,7 @@ namespace BAN { if (m_capasity >= size) return {}; - size_type new_cap = BAN::max(size, m_capasity * 1.5f); + size_type new_cap = BAN::Math::max(size, m_capasity * 1.5f); void* new_data = BAN::allocator(new_cap * sizeof(T)); if (new_data == nullptr) return Error::FromString("Vector: Could not allocate memory"); diff --git a/kernel/arch/i386/boot.S b/kernel/arch/i386/boot.S index 88e9895e..501647d3 100644 --- a/kernel/arch/i386/boot.S +++ b/kernel/arch/i386/boot.S @@ -113,7 +113,6 @@ _start: orl $0x80000000, %ecx movl %ecx, %cr0 - xchgw %bx, %bx # call global constuctors call _init @@ -121,6 +120,7 @@ _start: call kernel_main system_halt: + xchgw %bx, %bx cli 1: hlt jmp 1b diff --git a/kernel/kernel/Shell.cpp b/kernel/kernel/Shell.cpp index f3230b96..839d5558 100644 --- a/kernel/kernel/Shell.cpp +++ b/kernel/kernel/Shell.cpp @@ -282,8 +282,8 @@ namespace Kernel { m_mouse_pos.exists = true; m_tty->RenderFromBuffer(m_mouse_pos.x, m_mouse_pos.y); - m_mouse_pos.x = clamp(m_mouse_pos.x + event.dx, 0, m_tty->Width() - 1); - m_mouse_pos.y = clamp(m_mouse_pos.y - event.dy, 0, m_tty->Height() - 1); + m_mouse_pos.x = Math::clamp(m_mouse_pos.x + event.dx, 0, m_tty->Width() - 1); + m_mouse_pos.y = Math::clamp(m_mouse_pos.y - event.dy, 0, m_tty->Height() - 1); VESA::PutBitmapAt(s_pointer, m_mouse_pos.x, m_mouse_pos.y, VESA::Color::BRIGHT_WHITE); }