add some asserts

This commit is contained in:
Michael Shaw 2023-05-04 02:02:17 -04:00
commit 39c778d2f0
7 changed files with 34 additions and 6 deletions

17
include/assert.h Normal file
View file

@ -0,0 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _ASSERT_H_
#define _ASSERT_H_
#ifdef KDEBUG
#define assert(expr) \
do { \
if (!(expr)) { \
printf(LOG_ERROR "assertion failed: %s, file %s, line %d\n", #expr, __FILE__, __LINE__); \
yield(); \
} \
} while (0)
#else
#define assert(expr) ((void)0)
#endif
#endif /* _ASSERT_H_ */

View file

@ -10,6 +10,7 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#include <kernel/bitwise.h>
@ -20,6 +21,8 @@
#define MB (1024 * KB)
#define GB (1024 * MB)
void yield();
typedef uintptr_t paddr_t;
#endif /* _COMMON_H_ */