Added an assert impl
This commit is contained in:
parent
77eeec9627
commit
3896c5ffa8
3 changed files with 27 additions and 0 deletions
|
@ -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
11
assert/assert.cpp
Normal 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
15
include/assert.h
Normal 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
|
Loading…
Reference in a new issue