CS350 COS
COS
Loading...
Searching...
No Matches
kassert.h
Go to the documentation of this file.
1
2#ifndef __KASSERT_H__
3#define __KASSERT_H__
4
5#include <sys/cdefs.h>
6#include <sys/sysctl.h>
7
8#define ASSERT(_x) \
9 if (!(_x)) { \
10 Debug_Assert("ASSERT("#_x"): %s %s:%d\n", \
11 __FUNCTION__, __FILE__, __LINE__); \
12 }
13#define NOT_IMPLEMENTED() \
14 if (1) { \
15 Debug_Assert("NOT_IMPLEMENTED(): %s %s:%d\n", \
16 __FUNCTION__, __FILE__, __LINE__); \
17 }
18#define PANIC Panic
19
20NO_RETURN void Panic(const char *str);
21
22int kprintf(const char *fmt, ...);
23NO_RETURN void Debug_Assert(const char *fmt, ...);
24
25#define static_assert _Static_assert
26
27// Alert
28#define Alert(_module, _format, ...) kprintf(#_module ": " _format, ##__VA_ARGS__)
29// Warning
30#define Warning(_module, _format, ...) kprintf(#_module ": " _format, ##__VA_ARGS__)
31// Normal Logging
32#define Log(_module, _format, ...) \
33 if (SYSCTL_GETINT(log_##_module) >= 1) { \
34 kprintf(#_module ": " _format, ##__VA_ARGS__); \
35 }
36// Debug Logging
37#define DLOG(_module, _format, ...) \
38 if (SYSCTL_GETINT(log_##_module) >= 5) { \
39 kprintf(#_module ": " _format, ##__VA_ARGS__); \
40 }
41// Verbose Logging
42#define VLOG(_module, _format, ...) \
43 if (SYSCTL_GETINT(log_##_module) >= 10) { \
44 kprintf(#_module ": " _format, ##__VA_ARGS__); \
45 }
46
47#endif /* __KASSERT_H__ */
48
#define NO_RETURN
Definition: cdefs.h:13
NO_RETURN void Debug_Assert(const char *fmt,...)
Definition: printf.c:222
NO_RETURN void Panic(const char *str)
Definition: vgacons.c:164
int kprintf(const char *fmt,...)
Definition: printf.c:210