Added an assert impl

This commit is contained in:
Morten Delenk 2016-07-27 12:12:22 +02:00
parent 77eeec9627
commit 3896c5ffa8
No known key found for this signature in database
GPG key ID: 3F818D0F65DCB490
3 changed files with 27 additions and 0 deletions

View file

@ -1 +1,2 @@
# libc-kernel
This is a series of source code files containing the C library MTGos links against internally.

11
assert/assert.cpp Normal file
View file

@ -0,0 +1,11 @@
#include <assert.h>
#include <base.hpp>
#include <text_DISP.hpp>
void "C" __assert(const char *msg, const char *file, int line, int res) {
if(!res) {
MTGosHAL::err << "assert(" << msg << ") failed in " << file << " at line " << line << "!\n";
MTGosHAL::err << "Kernel panic.\n";
for(;;);
}
assert(0);
}

15
include/assert.h Normal file
View file

@ -0,0 +1,15 @@
#ifndef __ASSERT_H
#define __ASSERT_H
#ifdef __cplusplus
extern "C" {
#endif
void __assert(const char *msg, const char *file, int line, int res);
#ifdef NDEBUG
#define assert(EX)
#else
#define assert(EX) (void)(__assert(#EX, __FILE__, __LINE__, EX))
#endif
#ifdef __cplusplus
}
#endif
#endif