From 2dc45e8cac33313e847f6097cbe2ba3bb3ceab2a Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sat, 28 Feb 2015 20:42:57 -0500 Subject: Implement paging --- libc/include/stdlib.h | 4 ++++ libc/stdlib.c | 7 +++++++ 2 files changed, 11 insertions(+) (limited to 'libc') diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index 49116df..ffe9073 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -2,6 +2,7 @@ #define _STDLIB_H_ #include +#include /* this is by no means standards-compliant... but who cares? :P */ @@ -18,5 +19,8 @@ void srand(unsigned int); int abs(int); void *malloc(size_t); int snprintf(char*, int, const char*, ...); +void assert_fail(const char*, const char*, int); + +#define assert(x) if(!(x))assert_fail(__func__, __FILE__, __LINE__); #endif diff --git a/libc/stdlib.c b/libc/stdlib.c index c6a9c3d..bb30039 100644 --- a/libc/stdlib.c +++ b/libc/stdlib.c @@ -2,6 +2,7 @@ #include #include #include +#include "panic.h" /* adapted from */ char* itoa(int val, int base) @@ -150,3 +151,9 @@ int snprintf(char *buf, int sz, const char *fmt, ...) va_end(ap); return 0; } + +void assert_fail(const char *func, const char *file, int line) +{ + printf("\nAssertion failed in function %s in file %s, line %d\n", func, file, line); + panic("assertion failed!\n"); +} -- cgit v1.1