Restructured and rewritten entire codebase

This commit is contained in:
Alex
2023-10-09 01:16:24 +03:00
parent 446a571018
commit 889e1522a3
484 changed files with 15683 additions and 14032 deletions

155
tests/cpuid.cpp Normal file
View File

@ -0,0 +1,155 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifdef DEBUG
#include <types.h>
#include <memory.hpp>
#include <debug.h>
extern bool DebuggerIsAttached;
__constructor void TestCPUIDStructs()
{
if (!DebuggerIsAttached)
return;
if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_AMD) == 0)
{
CPU::x86::AMD::CPUID0x00000000 cpuid0;
CPU::x86::AMD::CPUID0x00000001 cpuid1;
CPU::x86::AMD::CPUID0x00000005 cpuid5;
CPU::x86::AMD::CPUID0x00000006 cpuid6;
CPU::x86::AMD::CPUID0x00000007 cpuid7;
CPU::x86::AMD::CPUID0x0000000B_ECX_0 cpuidB_C_0;
CPU::x86::AMD::CPUID0x0000000B_ECX_1 cpuidB_C_1;
CPU::x86::AMD::CPUID0x0000000D_ECX_0 cpuidD_C_0;
CPU::x86::AMD::CPUID0x0000000D_ECX_1 cpuidD_C_1;
CPU::x86::AMD::CPUID0x0000000D_ECX_2 cpuidD_C_2;
CPU::x86::AMD::CPUID0x0000000D_ECX_11 cpuidD_C_11;
CPU::x86::AMD::CPUID0x0000000D_ECX_12 cpuidD_C_12;
CPU::x86::AMD::CPUID0x0000000D_ECX_3E cpuidD_C_3E;
CPU::x86::AMD::CPUID0x80000000 cpuid80000000;
CPU::x86::AMD::CPUID0x80000001 cpuid80000001;
CPU::x86::AMD::CPUID0x80000002 cpuid80000002;
CPU::x86::AMD::CPUID0x80000003 cpuid80000003;
CPU::x86::AMD::CPUID0x80000004 cpuid80000004;
CPU::x86::AMD::CPUID0x80000005 cpuid80000005;
CPU::x86::AMD::CPUID0x80000006 cpuid80000006;
CPU::x86::AMD::CPUID0x80000007 cpuid80000007;
CPU::x86::AMD::CPUID0x80000008 cpuid80000008;
CPU::x86::AMD::CPUID0x8000000A cpuid8000000A;
CPU::x86::AMD::CPUID0x80000019 cpuid80000019;
CPU::x86::AMD::CPUID0x8000001A cpuid8000001A;
CPU::x86::AMD::CPUID0x8000001B cpuid8000001B;
CPU::x86::AMD::CPUID0x8000001C cpuid8000001C;
CPU::x86::AMD::CPUID0x8000001D cpuid8000001D;
CPU::x86::AMD::CPUID0x8000001E cpuid8000001E;
CPU::x86::AMD::CPUID0x8000001F cpuid8000001F;
CPU::x86::AMD::CPUID0x80000020 cpuid80000020;
CPU::x86::AMD::CPUID0x80000021 cpuid80000021;
CPU::x86::AMD::CPUID0x80000022 cpuid80000022;
CPU::x86::AMD::CPUID0x80000023 cpuid80000023;
CPU::x86::AMD::CPUID0x80000026 cpuid80000026;
cpuid0.Get();
cpuid1.Get();
cpuid5.Get();
cpuid6.Get();
cpuid7.Get();
cpuidB_C_0.Get();
cpuidB_C_1.Get();
cpuidD_C_0.Get();
cpuidD_C_1.Get();
cpuidD_C_2.Get();
cpuidD_C_11.Get();
cpuidD_C_12.Get();
cpuidD_C_3E.Get();
cpuid80000000.Get();
cpuid80000001.Get();
cpuid80000002.Get();
cpuid80000003.Get();
cpuid80000004.Get();
cpuid80000005.Get();
cpuid80000006.Get();
cpuid80000007.Get();
cpuid80000008.Get();
cpuid8000000A.Get();
cpuid80000019.Get();
cpuid8000001A.Get();
cpuid8000001B.Get();
cpuid8000001C.Get();
cpuid8000001D.Get();
cpuid8000001E.Get();
cpuid8000001F.Get();
cpuid80000020.Get();
cpuid80000021.Get();
cpuid80000022.Get();
cpuid80000023.Get();
cpuid80000026.Get();
// asmv("int3");
}
else if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_INTEL) == 0)
{
CPU::x86::Intel::CPUID0x00000000 cpuid0;
CPU::x86::Intel::CPUID0x00000001 cpuid1;
CPU::x86::Intel::CPUID0x00000002 cpuid2;
CPU::x86::Intel::CPUID0x00000003 cpuid3;
CPU::x86::Intel::CPUID0x00000004_1 cpuid4_1;
CPU::x86::Intel::CPUID0x00000005 cpuid5;
CPU::x86::Intel::CPUID0x00000006 cpuid6;
CPU::x86::Intel::CPUID0x00000007_0 cpuid7_0;
CPU::x86::Intel::CPUID0x00000007_1 cpuid7_1;
CPU::x86::Intel::CPUID0x0000000A cpuidA;
CPU::x86::Intel::CPUID0x00000015 cpuid15;
CPU::x86::Intel::CPUID0x00000016 cpuid16;
CPU::x86::Intel::CPUID0x80000000 cpuid80000000;
CPU::x86::Intel::CPUID0x80000001 cpuid80000001;
CPU::x86::Intel::CPUID0x80000002 cpuid80000002;
CPU::x86::Intel::CPUID0x80000003 cpuid80000003;
CPU::x86::Intel::CPUID0x80000004 cpuid80000004;
CPU::x86::Intel::CPUID0x80000006 cpuid80000006;
CPU::x86::Intel::CPUID0x80000008 cpuid80000008;
CPU::x86::Intel::CPUID0x8000000A cpuid8000000A;
cpuid0.Get();
cpuid1.Get();
cpuid2.Get();
cpuid3.Get();
cpuid4_1.Get();
cpuid5.Get();
cpuid6.Get();
cpuid7_0.Get();
cpuid7_1.Get();
cpuidA.Get();
cpuid15.Get();
cpuid16.Get();
cpuid80000000.Get();
cpuid80000001.Get();
cpuid80000002.Get();
cpuid80000003.Get();
cpuid80000004.Get();
cpuid80000006.Get();
cpuid80000008.Get();
cpuid8000000A.Get();
// asmv("int3");
}
}
#endif // DEBUG

64
tests/lsof.cpp Normal file
View File

@ -0,0 +1,64 @@
#ifdef DEBUG
#include "t.h"
#include "../kernel.h"
using vfs::Node;
using vfs::NodeType;
static int ShowOpenFiles = 0;
void lsof()
{
thisThread->Rename("Debug File List");
thisThread->SetPriority(Tasking::Idle);
while (ShowOpenFiles == 0)
CPU::Pause();
thisThread->SetPriority(Tasking::High);
fs->Create("/dummy_lsof_file", NodeType::FILE);
fopen("/dummy_lsof_file", "r");
while (true)
{
while (ShowOpenFiles == 0)
CPU::Pause();
Video::ScreenBuffer *sb = Display->GetBuffer(0);
for (short i = 0; i < 500; i++)
{
for (short j = 0; j < 500; j++)
{
uint32_t *Pixel = (uint32_t *)((uintptr_t)sb->Buffer + (j * sb->Width + i) * (bInfo.Framebuffer[0].BitsPerPixel / 8));
*Pixel = 0x222222;
}
}
uint32_t tmpX, tmpY;
Display->GetBufferCursor(0, &tmpX, &tmpY);
Display->SetBufferCursor(0, 0, 0);
printf("\eF02C21Open Files (%ld):\e00AAAA\n",
TaskManager->GetProcessList().size());
foreach (auto Proc in TaskManager->GetProcessList())
{
if (!Proc)
continue;
printf("%s:\n", Proc->Name);
std::vector<vfs::FileDescriptorTable::Fildes> fds_array =
Proc->FileDescriptors->GetFileDescriptors();
foreach (auto fd in fds_array)
printf(" %d: %s\n", fd.Descriptor,
fd.Handle->node->FullPath);
}
Display->SetBufferCursor(0, tmpX, tmpY);
if (!Config.BootAnimation)
Display->SetBuffer(0);
}
}
#endif // DEBUG

159
tests/macros.cpp Normal file
View File

@ -0,0 +1,159 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifdef DEBUG
#include <types.h>
#include <memory/macro.hpp>
#include <memory/vma.hpp>
#include <assert.h>
#include <debug.h>
#include <filesystem.hpp>
#include "../syscalls.h"
/* static assert, no constructor needed */
#ifdef a64
#if UINTPTR_MAX != UINT64_MAX
#error "uintptr_t is not 64-bit!"
#endif // UINTPTR_MAX != UINT64_MAX
#endif // a64
#ifdef a32
#if UINTPTR_MAX != UINT32_MAX
#error "uintptr_t is not 32-bit!"
#endif // UINTPTR_MAX != UINT32_MAX
#endif // a32
#ifdef aa64
#if UINTPTR_MAX != UINT64_MAX
#error "uintptr_t is not 64-bit!"
#endif // UINTPTR_MAX != UINT64_MAX
#endif // aa64
void TestSeekMacros()
{
static_assert(sc_SEEK_SET == SEEK_SET);
static_assert(sc_SEEK_CUR == SEEK_CUR);
static_assert(sc_SEEK_END == SEEK_END);
}
__constructor void TestMacros()
{
{
int a = TO_PAGES(4096);
int b = FROM_PAGES(1);
debug("a: 4096 -> %d", a);
debug("b: a -> %d", b);
if (a != 1)
{
error("t1: TO_PAGES is not equal to 1");
inf_loop;
}
if (b != 4096)
{
error("t1: FROM_PAGES is not equal to 4096");
inf_loop;
}
}
{
int a = TO_PAGES(4097);
int b = FROM_PAGES(2);
debug("a: 4097 -> %d", a);
debug("b: a -> %d", b);
if (a != 2)
{
error("t2: TO_PAGES is not equal to 2");
inf_loop;
}
if (b != 8192)
{
error("t2: FROM_PAGES is not equal to 8192");
inf_loop;
}
}
{
int a = 10;
assert(a == 10);
const char *str = "Hello";
assert(str != nullptr && str[0] == 'H');
bool flag = false;
assert(!flag);
}
debug("-------------------------");
{
uint64_t bytes = PAGE_SIZE;
uint64_t pgs = 1;
for (int i = 0; i < 128; i++)
{
uint64_t cnv_to_pgs = TO_PAGES(bytes);
uint64_t cnv_from_pgs = FROM_PAGES(pgs);
if (cnv_to_pgs != pgs)
{
error("TO_PAGES is not equal to %d (pages: %d)", pgs, cnv_to_pgs);
inf_loop;
}
if (cnv_from_pgs != bytes)
{
error("FROM_PAGES is not equal to %d (bytes: %d)", bytes, cnv_from_pgs);
inf_loop;
}
bytes += PAGE_SIZE;
pgs++;
}
}
{
debug("Testing ROUND_UP and ROUND_DOWN");
int x = 0x101;
int y = 0x100;
int result;
result = ROUND_UP(x, y);
if (result != 0x200)
{
error("ERROR: ROUND_UP failed: %d != 0x200", result);
inf_loop;
}
result = ROUND_DOWN(x, y);
if (result != 0x100)
{
error("ERROR: ROUND_DOWN failed: %d != 0x100", result);
inf_loop;
}
}
}
#endif // DEBUG

260
tests/mem_allocs.cpp Normal file
View File

@ -0,0 +1,260 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifdef DEBUG
#include <memory.hpp>
#include <debug.h>
#include <string>
/* Originally from: https://github.com/EnderIce2/FennixProject/blob/main/kernel/test.cpp */
#define MEMTEST_ITERATIONS 1024
class test_mem_new_delete
{
public:
test_mem_new_delete();
~test_mem_new_delete();
};
test_mem_new_delete::test_mem_new_delete()
{
for (char i = 0; i < 2; i++)
;
}
test_mem_new_delete::~test_mem_new_delete()
{
for (char i = 0; i < 2; i++)
;
}
extern bool DebuggerIsAttached;
void TestMemoryAllocation()
{
#ifdef a32
return; /* Not ready for now. */
#endif
if (DebuggerIsAttached)
{
debug("The test is disabled when the debugger is enabled.");
return;
}
void *tmpAlloc1 = kmalloc(176);
void *tmpAlloc2 = kmalloc(511);
void *tmpAlloc3 = kmalloc(1027);
void *tmpAlloc4 = kmalloc(1569);
for (int repeat = 0; repeat < 4; repeat++)
{
debug("---------------[TEST %d]---------------\n", repeat);
debug("Single Page Request Test");
{
uintptr_t prq1 = (uintptr_t)KernelAllocator.RequestPage();
KernelAllocator.FreePage((void *)prq1);
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
KernelAllocator.FreePage(KernelAllocator.RequestPage());
uintptr_t prq2 = (uintptr_t)KernelAllocator.RequestPage();
KernelAllocator.FreePage((void *)prq2);
debug(" Result:\t\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
assert(prq1 == prq2);
}
debug("Multiple Page Request Test");
{
uintptr_t prq1 = (uintptr_t)KernelAllocator.RequestPages(10);
KernelAllocator.FreePages((void *)prq1, 10);
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
KernelAllocator.FreePages(KernelAllocator.RequestPages(20), 20);
uintptr_t prq2 = (uintptr_t)KernelAllocator.RequestPages(10);
KernelAllocator.FreePages((void *)prq2, 10);
debug(" Result:\t\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
assert(prq1 == prq2);
}
debug("Multiple Fixed Malloc Test");
{
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
kfree((void *)prq1);
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
{
kfree(kmalloc(0x10000));
kfree(kmalloc(0x1000));
kfree(kmalloc(0x100));
kfree(kmalloc(0x10));
kfree(kmalloc(0x1));
}
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
kfree((void *)prq2);
debug(" Result:\t\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
assert(prq1 == prq2);
}
debug("Multiple Dynamic Malloc Test");
{
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
kfree((void *)prq1);
for (size_t i = 1; i < MEMTEST_ITERATIONS; i++)
kfree(kmalloc(i));
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
kfree((void *)prq2);
debug(" Result:\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
assert(prq1 == prq2);
}
debug("New/Delete Test");
{
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
kfree((void *)prq1);
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
{
test_mem_new_delete *t = new test_mem_new_delete();
delete t;
}
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
kfree((void *)prq2);
debug(" Result: \t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
assert(prq1 == prq2);
}
debug("New/Delete Fixed Array Test");
{
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
kfree((void *)prq1);
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
{
char *t = new char[128];
delete[] t;
}
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
kfree((void *)prq2);
debug(" Result: \t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
assert(prq1 == prq2);
}
debug("New/Delete Dynamic Array Test");
{
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
kfree((void *)prq1);
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
{
if (i == 0)
continue;
char *t = new char[i];
delete[] t;
}
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
kfree((void *)prq2);
debug(" Result:\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
assert(prq1 == prq2);
}
debug("calloc Test");
{
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
kfree((void *)prq1);
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
{
char *t = (char *)kcalloc(128, 1);
kfree(t);
}
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
kfree((void *)prq2);
debug(" Result:\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
assert(prq1 == prq2);
}
debug("realloc Test");
{
uintptr_t prq1 = (uintptr_t)kmalloc(0x1000);
kfree((void *)prq1);
for (size_t i = 0; i < MEMTEST_ITERATIONS; i++)
{
char *t = (char *)kmalloc(128);
t = (char *)krealloc(t, 256);
kfree(t);
}
uintptr_t prq2 = (uintptr_t)kmalloc(0x1000);
kfree((void *)prq2);
debug(" Result:\t1-[%#lx]; 2-[%#lx]", (void *)prq1, (void *)prq2);
assert(prq1 == prq2);
}
}
kfree(tmpAlloc1);
kfree(tmpAlloc2);
kfree(tmpAlloc3);
kfree(tmpAlloc4);
debug("Memory Stress Test");
for (size_t i = 1; i < 0x1000; i++)
kfree(kmalloc(i));
debug("Invalid Usage Test");
kfree(tmpAlloc1);
kfree(tmpAlloc2);
kfree(tmpAlloc3);
kfree(tmpAlloc4);
/* Allocation functions have assertions to check for invalid usage */
// void *InvMlc = kmalloc(0);
// assert(InvMlc == nullptr);
// krealloc(InvMlc, 0);
// assert(InvMlc == nullptr);
// kcalloc(0, 0);
// assert(InvMlc == nullptr);
// kcalloc(1, 0);
// assert(InvMlc == nullptr);
// kcalloc(0, 1);
// assert(InvMlc == nullptr);
// kfree(InvMlc);
debug("Memory Test Complete");
}
#endif // DEBUG

147
tests/mem_ops.cpp Normal file
View File

@ -0,0 +1,147 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifdef DEBUG
#include <types.h>
#include <memory.hpp>
#include <convert.h>
extern bool DebuggerIsAttached;
extern Memory::MemoryAllocatorType AllocatorType;
__constructor void TestMemoryOperations()
{
if (DebuggerIsAttached)
{
debug("The test is disabled when the debugger is enabled.");
return;
}
if (AllocatorType == Memory::MemoryAllocatorType::Pages)
{
debug("The test is disabled when the allocator is set to pages.");
return;
}
int arr1[5] = {1, 2, 3, 4, 5};
int arr2[5] = {0, 0, 0, 0, 0};
char str1[] = "Hello";
char str2[] = "World";
memcpy_unsafe(arr2, arr1, sizeof(arr1));
debug("memcpy: arr2[0]=%d, arr2[1]=%d, arr2[2]=%d, arr2[3]=%d, arr2[4]=%d",
arr2[0], arr2[1], arr2[2], arr2[3], arr2[4]);
if (memcmp(arr1, arr2, sizeof(arr1)) != 0)
{
error("memcpy failed!");
inf_loop;
}
memset_unsafe(arr2, 0, sizeof(arr2));
debug("memset: arr2[0]=%d, arr2[1]=%d, arr2[2]=%d, arr2[3]=%d, arr2[4]=%d",
arr2[0], arr2[1], arr2[2], arr2[3], arr2[4]);
if (memcmp(arr1, arr2, sizeof(arr1)) == 0)
{
error("memset failed!");
inf_loop;
}
memmove_unsafe(str1 + 3, str1, strlen(str1) + 1);
debug("memmove: str1=%s", str1);
if (strcmp(str1, "HelHello") != 0)
{
error("memmove failed!");
inf_loop;
}
char carr[512];
char carrTo[16];
for (size_t i = 0; i < 512; i++)
{
for (size_t i = 0; i < 16; i++)
carrTo[i] = 'a';
for (size_t i = 0; i < 512; i += 16)
memcpy_unsafe(carr + i, carrTo, 16);
for (size_t i = 0; i < 512; i++)
{
if (carr[i] != 'a')
{
error("memcpy failed!");
while (1)
;
}
}
{
char carrFull[512];
for (size_t i = 0; i < 512; i++)
carrFull[i] = 'b';
memcpy_unsafe(carr, carrFull, 512);
for (size_t i = 0; i < 512; i++)
{
if (carr[i] != 'b')
{
error("memcpy failed!");
while (1)
;
}
}
}
}
for (size_t i = 0; i < 512; i++)
{
for (size_t i = 0; i < 512; i += 16)
memset_unsafe(carr + i, 'c', 16);
for (size_t i = 0; i < 512; i++)
{
if (carr[i] != 'c')
{
error("memcpy failed!");
while (1)
;
}
}
}
for (size_t i = 0; i < 512; i++)
{
memset_unsafe(carr, 'd', 512);
for (size_t i = 0; i < 512; i++)
{
if (carr[i] != 'd')
{
error("memset failed!");
while (1)
;
}
}
}
debug("Memory operations test passed");
}
#endif

68
tests/rng.cpp Normal file
View File

@ -0,0 +1,68 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifdef DEBUG
#include <rand.hpp>
#include <debug.h>
#include <cpu.hpp>
__constructor void TestRandom()
{
int RDRANDFlag = 0;
if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_AMD) == 0)
{
CPU::x86::AMD::CPUID0x00000001 cpuid;
cpuid.Get();
RDRANDFlag = cpuid.ECX.RDRAND;
}
else if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_INTEL) == 0)
{
CPU::x86::Intel::CPUID0x00000001 cpuid;
cpuid.Get();
RDRANDFlag = cpuid.ECX.RDRAND;
}
if (strcmp(CPU::Hypervisor(), x86_CPUID_VENDOR_TCG) == 0)
RDRANDFlag = 0;
#if defined(a86)
if (RDRANDFlag)
{
uintptr_t RDSEEDValue = 0;
asmv("1: rdseed %0; jnc 1b"
: "=r"(RDSEEDValue));
debug("RDSEED: %ld", RDSEEDValue);
}
#endif
Random::ChangeSeed(0xdeadbeef);
uint16_t Seeds16[16];
uint32_t Seeds32[16];
uint64_t Seeds64[16];
for (short i = 0; i < 16; i++)
{
Seeds16[i] = Random::rand16();
Seeds32[i] = Random::rand32();
Seeds64[i] = Random::rand64();
}
debug("Random 16: %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld", Seeds16[0], Seeds16[1], Seeds16[2], Seeds16[3], Seeds16[4], Seeds16[5], Seeds16[6], Seeds16[7], Seeds16[8], Seeds16[9], Seeds16[10], Seeds16[11], Seeds16[12], Seeds16[13], Seeds16[14], Seeds16[15]);
debug("Random 32: %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld", Seeds32[0], Seeds32[1], Seeds32[2], Seeds32[3], Seeds32[4], Seeds32[5], Seeds32[6], Seeds32[7], Seeds32[8], Seeds32[9], Seeds32[10], Seeds32[11], Seeds32[12], Seeds32[13], Seeds32[14], Seeds32[15]);
debug("Random 64: %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld", Seeds64[0], Seeds64[1], Seeds64[2], Seeds64[3], Seeds64[4], Seeds64[5], Seeds64[6], Seeds64[7], Seeds64[8], Seeds64[9], Seeds64[10], Seeds64[11], Seeds64[12], Seeds64[13], Seeds64[14], Seeds64[15]);
}
#endif // DEBUG

69
tests/std.cpp Normal file
View File

@ -0,0 +1,69 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifdef DEBUG
#include <std.hpp>
#include <assert.h>
#include <vector>
void Test_std()
{
std::atomic_int a = 0;
a++;
assert(a == 1);
int b = a.exchange(2);
assert(b == 1);
assert(a == 2);
/* ---------------------------- */
std::vector<int> intVector;
intVector.push_back(10);
intVector.push_back(20);
intVector.push_back(30);
assert(intVector.size() == 3);
assert(intVector[0] == 10);
assert(intVector[1] == 20);
assert(intVector[2] == 30);
intVector.pop_back();
assert(intVector.size() == 2);
intVector.clear();
assert(intVector.empty());
intVector.push_back(1);
intVector.push_back(1);
intVector.push_back(1);
intVector.push_back(1);
intVector.push_back(1);
intVector.erase(intVector.end() - 1);
assert(intVector.size() == 4);
debug("0: %#lx", intVector[0]);
debug("1: %#lx", intVector[1]);
debug("2: %#lx", intVector[2]);
debug("3: %#lx", intVector[3]);
debug("4: %#lx", intVector[4]);
debug("std: OK");
}
#endif // DEBUG

153
tests/std_string.cpp Normal file
View File

@ -0,0 +1,153 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifdef DEBUG
#include <std/string.hpp>
#include <memory.hpp>
#include <debug.h>
void TestString()
{
char *sanity_alloc = (char *)kmalloc(1024);
for (int i = 0; i < 1024; i++)
sanity_alloc[i] = 'A';
std::string hw("Hello, world!");
for (int i = 0; i < 1024; i++)
if (sanity_alloc[i] != 'A')
{
error("Sanity check failed! %d", i);
inf_loop;
}
debug("String length: %d", hw.length());
debug("String capacity: %d", hw.capacity());
debug("String data: %s", hw.c_str());
if (hw == "Hello, world!" && hw != "World, hello!")
debug("String comparison works!");
else
{
error("String comparison doesn't work! \"%s\"", hw.c_str());
inf_loop;
}
for (int i = 0; i < 1024; i++)
if (sanity_alloc[i] != 'A')
{
error("Sanity check failed! %d", i);
inf_loop;
}
kfree(sanity_alloc);
std::string hi("Hi");
char chi[3];
chi[0] = hi[0];
chi[1] = hi[1];
chi[2] = '\0';
if (strcmp(chi, "Hi") == 0)
debug("String indexing works!");
else
{
error("String indexing doesn't work! \"%s\" \"%s\"", chi, hi.c_str());
inf_loop;
}
sanity_alloc = (char *)kmalloc(1024);
for (int i = 0; i < 1024; i++)
sanity_alloc[i] = 'A';
hi << " there!";
if (hi == "Hi there!")
debug("String concatenation works!");
else
{
error("String concatenation doesn't work! \"%s\"", hi.c_str());
inf_loop;
}
hi << " " << hw;
if (hi == "Hi there! Hello, world!")
debug("String concatenation works!");
else
{
error("String concatenation doesn't work! \"%s\"", hi.c_str());
inf_loop;
}
std::string eq0("Hello, world!");
std::string eq1("Hello, world!");
std::string eq2("World, hello!");
if (eq0 == eq1)
debug("String equality works!");
else
{
error("String equality doesn't work! \"%s\" \"%s\"", eq0.c_str(), eq1.c_str());
inf_loop;
}
if (eq0 != eq2)
debug("String inequality works!");
else
{
error("String inequality doesn't work! \"%s\" \"%s\"", eq0.c_str(), eq2.c_str());
inf_loop;
}
char chw[14];
int i = 0;
foreach (auto c in hw)
{
chw[i] = c;
i++;
}
chw[i] = '\0';
if (strcmp(chw, "Hello, world!") == 0)
debug("String iteration works!");
else
{
error("String iteration doesn't work! \"%s\" \"%s\" %d", chw, hw.c_str(), i);
inf_loop;
}
std::string a("Hello");
std::string b("World");
std::string c;
c = a + ", " + b + "!";
if (c == "Hello, World!")
debug("String addition works!");
else
{
error("String addition doesn't work! \"%s\"", c.c_str());
inf_loop;
}
for (int i = 0; i < 1024; i++)
if (sanity_alloc[i] != 'A')
{
error("Sanity check failed! %d", i);
inf_loop;
}
kfree(sanity_alloc);
}
#endif // DEBUG

35
tests/t.h Normal file
View File

@ -0,0 +1,35 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_non_constructor_tests_H__
#define __FENNIX_KERNEL_non_constructor_tests_H__
#ifdef DEBUG
#include <types.h>
#include <filesystem.hpp>
void TestString();
void Test_std();
void TestMemoryAllocation();
void tasking_test_fb();
void tasking_test_mutex();
void lsof();
void TaskMgr();
void TreeFS(vfs::Node *node, int Depth);
#endif // DEBUG
#endif // !__FENNIX_KERNEL_non_constructor_tests_H__

50
tests/tasking_mutex.cpp Normal file
View File

@ -0,0 +1,50 @@
#ifdef DEBUG
#include "t.h"
#include "../kernel.h"
#include <mutex>
std::mutex test_mutex;
void mutex_test_long()
{
while (true)
{
test_mutex.lock();
debug("Long Thread %d got mutex",
thisThread->ID);
// TaskManager->Sleep(2000);
test_mutex.unlock();
}
}
void mutex_test()
{
while (true)
{
test_mutex.lock();
debug("Thread %d got mutex",
thisThread->ID);
// TaskManager->Sleep(200);
test_mutex.unlock();
}
}
void tasking_test_mutex()
{
TaskManager->CreateThread(thisProcess, Tasking::IP(mutex_test_long));
TaskManager->Yield();
TaskManager->CreateThread(thisProcess, Tasking::IP(mutex_test));
TaskManager->CreateThread(thisProcess, Tasking::IP(mutex_test));
TaskManager->CreateThread(thisProcess, Tasking::IP(mutex_test));
TaskManager->CreateThread(thisProcess, Tasking::IP(mutex_test));
TaskManager->CreateThread(thisProcess, Tasking::IP(mutex_test));
TaskManager->CreateThread(thisProcess, Tasking::IP(mutex_test));
TaskManager->CreateThread(thisProcess, Tasking::IP(mutex_test));
TaskManager->CreateThread(thisProcess, Tasking::IP(mutex_test));
TaskManager->CreateThread(thisProcess, Tasking::IP(mutex_test));
ilp;
}
#endif // DEBUG

96
tests/tasking_rgb.cpp Normal file
View File

@ -0,0 +1,96 @@
#ifdef DEBUG
#include "t.h"
#include "../kernel.h"
BootInfo::FramebufferInfo fb_ptr{};
void tasking_test_fb_loop(int x, int y, uint32_t color)
{
assert(fb_ptr.BaseAddress != nullptr);
while (true)
{
for (int i = 0; i < 16; i++)
{
uint32_t *Pixel = (uint32_t *)((uintptr_t)fb_ptr.BaseAddress +
((y + i) * fb_ptr.Width + x) *
(fb_ptr.BitsPerPixel / 8));
for (int j = 0; j < 16; j++)
{
*Pixel = color;
Pixel++;
}
}
}
}
void TTfbL_red() { tasking_test_fb_loop(0, 0, 0xFFFF0000); }
void TTfbL_green() { tasking_test_fb_loop(16, 0, 0xFF00FF00); }
void TTfbL_blue() { tasking_test_fb_loop(32, 0, 0xFF0000FF); }
void TTfbL_white() { tasking_test_fb_loop(48, 0, 0xFFFFFFFF); }
void TTfbL_gray() { tasking_test_fb_loop(64, 0, 0xFF888888); }
void TTfbL_red_neg() { tasking_test_fb_loop(0, 0, 0xFF00FFFF); }
void TTfbL_green_neg() { tasking_test_fb_loop(16, 0, 0xFFFF00FF); }
void TTfbL_blue_neg() { tasking_test_fb_loop(32, 0, 0xFFFFFF00); }
void TTfbL_white_neg() { tasking_test_fb_loop(48, 0, 0xFF000000); }
void TTfbL_gray_neg() { tasking_test_fb_loop(64, 0, 0xFF777777); }
void TTfbL_rainbow_fct(int offset)
{
while (true)
{
/* AARRGGBB*/
static uint32_t color = 0xFF000000;
for (int i = 0; i < 64; i++)
{
uint32_t *Pixel = (uint32_t *)((uintptr_t)fb_ptr.BaseAddress +
((offset + i) * fb_ptr.Width) *
(fb_ptr.BitsPerPixel / 8));
for (int j = 0; j < 16; j++)
{
*Pixel = color;
Pixel++;
}
}
if (color >= 0xFFFFFFFF)
color = 0xFF000000;
color++;
}
}
void TTfbL_rainbow_idle() { TTfbL_rainbow_fct(16); }
void TTfbL_rainbow_low() { TTfbL_rainbow_fct(80); }
void TTfbL_rainbow_norm() { TTfbL_rainbow_fct(144); }
void TTfbL_rainbow_high() { TTfbL_rainbow_fct(208); }
void TTfbL_rainbow_crit() { TTfbL_rainbow_fct(272); }
void tasking_test_fb()
{
fb_ptr = Display->GetFramebufferStruct();
TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_red));
TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_green));
TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_blue));
TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_white));
TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_gray));
TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_red_neg));
TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_green_neg));
TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_blue_neg));
TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_white_neg));
TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_gray_neg));
{
CriticalSection cs; /* Start all threads at the same time */
auto tti = TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_rainbow_idle));
auto ttl = TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_rainbow_low));
auto ttn = TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_rainbow_norm));
auto tth = TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_rainbow_high));
auto ttc = TaskManager->CreateThread(thisProcess, Tasking::IP(TTfbL_rainbow_crit));
tti->SetPriority(Tasking::TaskPriority::Idle);
ttl->SetPriority(Tasking::TaskPriority::Low);
ttn->SetPriority(Tasking::TaskPriority::Normal);
tth->SetPriority(Tasking::TaskPriority::High);
ttc->SetPriority(Tasking::TaskPriority::Critical);
}
// Exit
}
#endif // DEBUG

169
tests/taskmgr.cpp Normal file
View File

@ -0,0 +1,169 @@
#ifdef DEBUG
#include "t.h"
#include "../kernel.h"
const char *Statuses[] = {
"FF0000", /* Unknown */
"AAFF00", /* Ready */
"00AA00", /* Running */
"FFAA11", /* Sleeping */
"FFAA0F", /* Blocked */
"FFAA0F", /* Stopped */
"FFAA5F", /* Waiting */
"FF0088", /* Zombie */
"FF0000", /* Terminated */
};
const char *StatusesSign[] = {
"Unknown",
"Ready",
"Run",
"Sleep",
"Block",
"Stop",
"Wait",
"Zombie",
"Terminated",
};
const char *SuccessSourceStrings[] = {
"Unknown",
"GetNextAvailableThread",
"GetNextAvailableProcess",
"SchedulerSearchProcessThread",
};
void TaskMgr_Dummy100Usage()
{
while (1)
;
}
void TaskMgr_Dummy0Usage()
{
while (1)
TaskManager->Sleep(1000000);
}
uint64_t GetUsage(uint64_t OldSystemTime, Tasking::TaskInfo *Info)
{
/* https://github.com/reactos/reactos/blob/560671a784c1e0e0aa7590df5e0598c1e2f41f5a/base/applications/taskmgr/perfdata.c#L347 */
if (Info->OldKernelTime || Info->OldUserTime)
{
uint64_t SystemTime = TimeManager->GetCounter() - OldSystemTime;
uint64_t CurrentTime = Info->KernelTime + Info->UserTime;
uint64_t OldTime = Info->OldKernelTime + Info->OldUserTime;
uint64_t CpuUsage = (CurrentTime - OldTime) / SystemTime;
CpuUsage = CpuUsage * 100;
// debug("CurrentTime: %ld OldTime: %ld Time Diff: %ld Usage: %ld%%",
// CurrentTime, OldTime, SystemTime, CpuUsage);
Info->OldKernelTime = Info->KernelTime;
Info->OldUserTime = Info->UserTime;
return CpuUsage;
}
Info->OldKernelTime = Info->KernelTime;
Info->OldUserTime = Info->UserTime;
return 0;
}
static int ShowTaskManager = 0;
void TaskMgr()
{
thisThread->Rename("Debug Task Manager");
thisThread->SetPriority(Tasking::Idle);
while (ShowTaskManager == 0)
CPU::Pause();
thisThread->SetPriority(Tasking::High);
TaskManager->CreateThread(thisProcess, Tasking::IP(TaskMgr_Dummy100Usage))->Rename("Dummy 100% Usage");
TaskManager->CreateThread(thisProcess, Tasking::IP(TaskMgr_Dummy0Usage))->Rename("Dummy 0% Usage");
while (true)
{
while (ShowTaskManager == 0)
CPU::Pause();
static int sanity = 0;
Video::ScreenBuffer *sb = Display->GetBuffer(0);
for (short i = 0; i < 1000; i++)
{
for (short j = 0; j < 500; j++)
{
uint32_t *Pixel = (uint32_t *)((uintptr_t)sb->Buffer + (j * sb->Width + i) * (bInfo.Framebuffer[0].BitsPerPixel / 8));
*Pixel = 0x222222;
}
}
uint32_t tmpX, tmpY;
Display->GetBufferCursor(0, &tmpX, &tmpY);
Display->SetBufferCursor(0, 0, 0);
printf("\eF02C21Task Manager\n");
static uint64_t OldSystemTime = 0;
foreach (auto Proc in TaskManager->GetProcessList())
{
if (!Proc)
continue;
int State = Proc->State.load();
uint64_t ProcessCpuUsage = GetUsage(OldSystemTime, &Proc->Info);
#if defined(a64)
printf("\e%s-> \eAABBCC%s \e00AAAA%s %ld%% (KT: %ld UT: %ld)\n",
Statuses[State], Proc->Name, StatusesSign[State],
ProcessCpuUsage, Proc->Info.KernelTime, Proc->Info.UserTime);
#elif defined(a32)
printf("\e%s-> \eAABBCC%s \e00AAAA%s %lld%% (KT: %lld UT: %lld)\n",
Statuses[State], Proc->Name, StatusesSign[State],
ProcessCpuUsage, Proc->Info.KernelTime, Proc->Info.UserTime);
#elif defined(aa64)
#endif
foreach (auto Thd in Proc->Threads)
{
if (!Thd)
continue;
State = Thd->State.load();
uint64_t ThreadCpuUsage = GetUsage(OldSystemTime, &Thd->Info);
#if defined(a64)
printf(" \e%s-> \eAABBCC%s \e00AAAA%s %ld%% (KT: %ld UT: %ld, IP: \e24FF2B%#lx \eEDFF24%s\e00AAAA)\n\eAABBCC",
Statuses[State], Thd->Name, StatusesSign[State], ThreadCpuUsage, Thd->Info.KernelTime,
Thd->Info.UserTime, Thd->Registers.rip,
Thd->Parent->ELFSymbolTable ? Thd->Parent->ELFSymbolTable->GetSymbolFromAddress(Thd->Registers.rip) : "unknown");
#elif defined(a32)
printf(" \e%s-> \eAABBCC%s \e00AAAA%s %lld%% (KT: %lld UT: %lld, IP: \e24FF2B%#x \eEDFF24%s\e00AAAA)\n\eAABBCC",
Statuses[State], Thd->Name, StatusesSign[State], ThreadCpuUsage, Thd->Info.KernelTime,
Thd->Info.UserTime, Thd->Registers.eip,
Thd->Parent->ELFSymbolTable ? Thd->Parent->ELFSymbolTable->GetSymbolFromAddress(Thd->Registers.eip) : "unknown");
#elif defined(aa64)
#endif
}
}
OldSystemTime = TimeManager->GetCounter();
#if defined(a64)
register uintptr_t CurrentStackAddress asm("rsp");
printf("Sanity: %d, Stack: %#lx", sanity++, CurrentStackAddress);
#elif defined(a32)
register uintptr_t CurrentStackAddress asm("esp");
printf("Sanity: %d, Stack: %#x", sanity++, CurrentStackAddress);
#elif defined(aa64)
register uintptr_t CurrentStackAddress asm("sp");
printf("Sanity: %d, Stack: %#lx", sanity++, CurrentStackAddress);
#endif
if (sanity > 1000)
sanity = 0;
Display->SetBufferCursor(0, tmpX, tmpY);
if (!Config.BootAnimation)
Display->SetBuffer(0);
TaskManager->Sleep(100);
}
}
#endif // DEBUG

21
tests/treefs.cpp Normal file
View File

@ -0,0 +1,21 @@
#ifdef DEBUG
#include "t.h"
#include "../kernel.h"
void TreeFS(vfs::Node *node, int Depth)
{
return;
foreach (auto Chld in node->Children)
{
printf("%*c %s\eFFFFFF\n", Depth, ' ', Chld->Name);
if (!Config.BootAnimation)
Display->SetBuffer(0);
TaskManager->Sleep(100);
TreeFS(Chld, Depth + 1);
}
}
#endif // DEBUG

123
tests/types_sizes.cpp Normal file
View File

@ -0,0 +1,123 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifdef DEBUG
#include <debug.h>
__constructor void TestTypeSize()
{
debug("--- INT TYPES ---");
debug("sizeof(__INT8_TYPE__) = %lld", sizeof(__INT8_TYPE__));
debug("sizeof(__INT16_TYPE__) = %lld", sizeof(__INT16_TYPE__));
debug("sizeof(__INT32_TYPE__) = %lld", sizeof(__INT32_TYPE__));
debug("sizeof(__INT64_TYPE__) = %lld", sizeof(__INT64_TYPE__));
debug("-- UINT TYPES ---");
debug("sizeof(__UINT8_TYPE__) = %lld", sizeof(__INT8_TYPE__));
debug("sizeof(__UINT16_TYPE__) = %lld", sizeof(__INT16_TYPE__));
debug("sizeof(__UINT32_TYPE__) = %lld", sizeof(__INT32_TYPE__));
debug("sizeof(__UINT64_TYPE__) = %lld", sizeof(__INT64_TYPE__));
debug("--- INT LEAST TYPES ---");
debug("sizeof(__INT_LEAST8_TYPE__) = %lld", sizeof(__INT_LEAST8_TYPE__));
debug("sizeof(__INT_LEAST16_TYPE__) = %lld", sizeof(__INT_LEAST16_TYPE__));
debug("sizeof(__INT_LEAST32_TYPE__) = %lld", sizeof(__INT_LEAST32_TYPE__));
debug("sizeof(__INT_LEAST64_TYPE__) = %lld", sizeof(__INT_LEAST64_TYPE__));
debug("--- UINT LEAST TYPES ---");
debug("sizeof(__UINT_LEAST8_TYPE__) = %lld", sizeof(__UINT_LEAST8_TYPE__));
debug("sizeof(__UINT_LEAST16_TYPE__) = %lld", sizeof(__UINT_LEAST16_TYPE__));
debug("sizeof(__UINT_LEAST32_TYPE__) = %lld", sizeof(__UINT_LEAST32_TYPE__));
debug("sizeof(__UINT_LEAST64_TYPE__) = %lld", sizeof(__UINT_LEAST64_TYPE__));
debug("--- INT FAST TYPES ---");
debug("sizeof(__INT_FAST8_TYPE__) = %lld", sizeof(__INT_FAST8_TYPE__));
debug("sizeof(__INT_FAST16_TYPE__) = %lld", sizeof(__INT_FAST16_TYPE__));
debug("sizeof(__INT_FAST32_TYPE__) = %lld", sizeof(__INT_FAST32_TYPE__));
debug("sizeof(__INT_FAST64_TYPE__) = %lld", sizeof(__INT_FAST64_TYPE__));
debug("--- UINT FAST TYPES ---");
debug("sizeof(__UINT_FAST8_TYPE__) = %lld", sizeof(__UINT_FAST8_TYPE__));
debug("sizeof(__UINT_FAST16_TYPE__) = %lld", sizeof(__UINT_FAST16_TYPE__));
debug("sizeof(__UINT_FAST32_TYPE__) = %lld", sizeof(__UINT_FAST32_TYPE__));
debug("sizeof(__UINT_FAST64_TYPE__) = %lld", sizeof(__UINT_FAST64_TYPE__));
debug("--- INTPTR TYPES ---");
debug("sizeof(__INTPTR_TYPE__) = %lld", sizeof(__INTPTR_TYPE__));
debug("sizeof(__UINTPTR_TYPE__) = %lld", sizeof(__UINTPTR_TYPE__));
debug("--- OTHER TYPES ---");
debug("sizeof(__PTRDIFF_TYPE__) = %lld", sizeof(__PTRDIFF_TYPE__));
debug("sizeof(__SIZE_TYPE__) = %lld", sizeof(__SIZE_TYPE__));
debug("sizeof(__WCHAR_TYPE__) = %lld", sizeof(__WCHAR_TYPE__));
debug("sizeof(__WINT_TYPE__) = %lld", sizeof(__WINT_TYPE__));
debug("sizeof(__SIG_ATOMIC_TYPE__) = %lld", sizeof(__SIG_ATOMIC_TYPE__));
debug("--- INTX MAX TYPES ---");
debug("__INT8_MAX__ = %#llx", __INT8_MAX__);
debug("__INT16_MAX__ = %#llx", __INT16_MAX__);
debug("__INT32_MAX__ = %#llx", __INT32_MAX__);
debug("__INT64_MAX__ = %#llx", __INT64_MAX__);
debug("--- UINTX MAX TYPES ---");
debug("__UINT8_MAX__ = %#llx", __UINT8_MAX__);
debug("__UINT16_MAX__ = %#llx", __UINT16_MAX__);
debug("__UINT32_MAX__ = %#llx", __UINT32_MAX__);
debug("__UINT64_MAX__ = %#llx", __UINT64_MAX__);
// debug("--- INTMAX TYPES ---");
// debug("__INTMAX_TYPE__ = %#llx", __INTMAX_TYPE__);
// debug("__UINTMAX_TYPE__ = %#llx", __UINTMAX_TYPE__);
debug("--- INTLEASTX MAX ---");
debug("__INT_LEAST8_MAX__ = %#llx", __INT_LEAST8_MAX__);
debug("__INT_LEAST16_MAX__ = %#llx", __INT_LEAST16_MAX__);
debug("__INT_LEAST32_MAX__ = %#llx", __INT_LEAST32_MAX__);
debug("__INT_LEAST64_MAX__ = %#llx", __INT_LEAST64_MAX__);
debug("--- UINTLEASTX MAX ---");
debug("__UINT_LEAST8_MAX__ = %#llx", __UINT_LEAST8_MAX__);
debug("__UINT_LEAST16_MAX__ = %#llx", __UINT_LEAST16_MAX__);
debug("--- INTFASTX MAX ---");
debug("__INT_FAST8_MAX__ = %#llx", __INT_FAST8_MAX__);
debug("__INT_FAST16_MAX__ = %#llx", __INT_FAST16_MAX__);
debug("__INT_FAST32_MAX__ = %#llx", __INT_FAST32_MAX__);
debug("__INT_FAST64_MAX__ = %#llx", __INT_FAST64_MAX__);
debug("--- UINTFASTX MAX ---");
debug("__UINT_FAST8_MAX__ = %#llx", __UINT_FAST8_MAX__);
debug("__UINT_FAST16_MAX__ = %#llx", __UINT_FAST16_MAX__);
debug("__UINT_FAST32_MAX__ = %#llx", __UINT_FAST32_MAX__);
debug("__UINT_FAST64_MAX__ = %#llx", __UINT_FAST64_MAX__);
debug("--- INTPTR MAX ---");
debug("__INTPTR_MAX__ = %#llx", __INTPTR_MAX__);
debug("__UINTPTR_MAX__ = %#llx", __UINTPTR_MAX__);
debug("--- OTHER MAX ---");
debug("__PTRDIFF_MAX__ = %#llx", __PTRDIFF_MAX__);
debug("__SIZE_MAX__ = %#llx", __SIZE_MAX__);
debug("__WCHAR_MAX__ = %#llx", __WCHAR_MAX__);
debug("__WINT_MAX__ = %#llx", __WINT_MAX__);
debug("__SIG_ATOMIC_MAX__ = %#llx", __SIG_ATOMIC_MAX__);
debug("__INTMAX_MAX__ = %#llx", __INTMAX_MAX__);
debug("__UINTMAX_MAX__ = %#llx", __UINTMAX_MAX__);
}
#endif // DEBUG