asserts.hpp

This commit is contained in:
2023-10-26 11:16:11 +02:00
parent 1feb134302
commit 63ddd59c68
21 changed files with 48 additions and 29 deletions

View File

@@ -2,6 +2,7 @@
#include <cstdint>
#include <new>
#include "asserts.hpp"
#include "gdt.hpp"
#include "globals.hpp"
#include "idt.hpp"
@@ -12,7 +13,6 @@
#include "memman.hpp"
#include "misc.hpp"
#include "paging.hpp"
#include "serial.hpp"
AddressSpace *BOOT_AddressSpace;
alignas(AddressSpace) char BOOT_AddressSpace_storage[sizeof(AddressSpace)];

View File

@@ -1,9 +1,9 @@
#include "idt.hpp"
#include "asserts.hpp"
#include "gdt.hpp"
#include "io.hpp"
#include "misc.hpp"
#include "serial.hpp"
#include "task.hpp"
#include "timer.hpp"

View File

@@ -7,6 +7,7 @@
#include "SkipList.hpp"
#include "String.hpp"
#include "TestTemplates.hpp"
#include "asserts.hpp"
#include "globals.hpp"
#include "kmem.hpp"
#include "limine_fb.hpp"
@@ -14,7 +15,6 @@
#include "misc.hpp"
#include "mutex.hpp"
#include "rand.h"
#include "serial.hpp"
#include "task.hpp"
#include "timer.hpp"
#include "tty.hpp"

View File

@@ -2,10 +2,10 @@
#include "LockGuard.hpp"
#include "Spinlock.hpp"
#include "asserts.hpp"
#include "globals.hpp"
#include "memman.hpp"
#include "paging.hpp"
#include "serial.hpp"
#include "task.hpp"
#include "string.h"

View File

@@ -5,9 +5,9 @@
#include "memman.hpp"
#include "LockGuard.hpp"
#include "Spinlock.hpp"
#include "asserts.hpp"
#include "misc.hpp"
#include "paging.hpp"
#include "serial.hpp"
#include <stddef.h>

View File

@@ -3,10 +3,10 @@
//
#include "paging.hpp"
#include "asserts.hpp"
#include "limine.h"
#include "memman.hpp"
#include "misc.hpp"
#include "serial.hpp"
// Returns a free page frame in HHDM
static uint64_t *get_free_frame() {

View File

@@ -2,7 +2,7 @@
// Created by Stepan Usatiuk on 12.08.2023.
//
#include "serial.hpp"
#include "asserts.hpp"
#include <stdint.h>

View File

@@ -15,15 +15,5 @@ char read_serial();
int is_transmit_empty();
void write_serial(char a);
void writestr(const char *a);
extern "C" {
static inline void _assert2(int val, const char *msg) {
if (!val) {
writestr(msg);
_hcf();
}
}
}
#define assert2(x, y) _assert2(x, y)
#define assert(x) _assert2(x, "Assertion failed")
#endif//OS1_SERIAL_H

View File

@@ -6,12 +6,12 @@
#include "LockGuard.hpp"
#include "SkipList.hpp"
#include "Spinlock.hpp"
#include "asserts.hpp"
#include "gdt.hpp"
#include "kmem.hpp"
#include "misc.hpp"
#include "mutex.hpp"
#include "paging.hpp"
#include "serial.hpp"
#include "string.h"
#include "timer.hpp"
#include "tty.hpp"

View File

@@ -6,9 +6,9 @@
#include "LockGuard.hpp"
#include "Vector.hpp"
#include "asserts.hpp"
#include "kmem.hpp"
#include "mutex.hpp"
#include "serial.hpp"
static Mutex ttysMutex;

View File

@@ -1,5 +1,5 @@
target_include_directories(kernel.elf PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_sources(kernel.elf PRIVATE mutex.cpp cppsupport.cpp Spinlock.cpp LockGuard.cpp rand.cpp)
target_sources(kernel.elf PRIVATE mutex.cpp cppsupport.cpp Spinlock.cpp LockGuard.cpp rand.cpp VMA.cpp asserts.cpp)
add_subdirectory(templates)

View File

@@ -5,7 +5,7 @@
#ifndef OS2_SPINLOCK_H
#define OS2_SPINLOCK_H
#include "serial.hpp"
#include "asserts.hpp"
#include "task.hpp"
#include <atomic>
#include <cstdint>

5
src/kernel/asserts.cpp Normal file
View File

@@ -0,0 +1,5 @@
//
// Created by Stepan Usatiuk on 26.10.2023.
//
#include "asserts.hpp"

24
src/kernel/asserts.hpp Normal file
View File

@@ -0,0 +1,24 @@
//
// Created by Stepan Usatiuk on 26.10.2023.
//
#ifndef OS2_ASSERTS_HPP
#define OS2_ASSERTS_HPP
#include "misc.hpp"
#include "serial.hpp"
extern "C" {
static inline void _assert2(int val, const char *msg) {
if (!val) {
writestr(msg);
_hcf();
}
}
}
#define assert2(x, y) _assert2(x, y)
#define assert(x) _assert2(x, "Assertion failed")
#endif//OS2_ASSERTS_HPP

View File

@@ -5,9 +5,9 @@
#include <cstddef>
#include <cstdint>
#include "asserts.hpp"
#include "kmem.hpp"
#include "misc.hpp"
#include "serial.hpp"
#if UINT32_MAX == UINTPTR_MAX
#define STACK_CHK_GUARD 0xb079a218

View File

@@ -4,7 +4,7 @@
#include "mutex.hpp"
#include "LockGuard.hpp"
#include "serial.hpp"
#include "asserts.hpp"
#include "task.hpp"
#include "timer.hpp"

View File

@@ -9,7 +9,7 @@
#include <cstdint>
#include <utility>
#include "serial.hpp"
#include "asserts.hpp"
template<typename T>
class List {
@@ -37,7 +37,7 @@ public:
}
template<class... Args>
Node* create_node(Args &&...args) {
Node *create_node(Args &&...args) {
return new Node{std::forward<Args>(args)..., nullptr};
}

View File

@@ -6,8 +6,8 @@
#include <type_traits>
#include <utility>
#include "asserts.hpp"
#include "rand.h"
#include "serial.hpp"
template<typename K, typename V>
class SkipList {

View File

@@ -4,8 +4,8 @@
#include <cstdlib>
#include <utility>
#include "asserts.hpp"
#include "kmem.hpp"
#include "serial.hpp"
#include "string.h"
class String {

View File

@@ -11,7 +11,7 @@
#include "SkipListSet.hpp"
#include "String.hpp"
#include "Vector.hpp"
#include "serial.hpp"
#include "asserts.hpp"
#include "tty.hpp"

View File

@@ -3,8 +3,8 @@
#include <new>
#include "asserts.hpp"
#include "kmem.hpp"
#include "serial.hpp"
#include "string.h"
class VectorTester;