blob: fb5a85709ea19b55cdf573860b131ab91a1b338f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
// MIT License, Copyright (c) 2020 Marvin Borner
#ifndef ASSERT_H
#define ASSERT_H
#include <print.h>
#ifdef KERNEL
#include <proc.h>
#define assert(exp) \
{ \
if (!(exp)) { \
printf("%s:%d: %s: Kernel assertion '%s' failed\n", __FILE__, __LINE__, \
__func__, #exp); \
__asm__ volatile("cli\nhlt"); \
} \
}
#elif defined(USER)
#define assert(exp) \
{ \
if (!(exp)) \
err(1, "%s:%d: %s: Assertion '%s' failed\n", __FILE__, __LINE__, __func__, \
#exp); \
}
#endif
#endif
|