PatchworkOS
Loading...
Searching...
No Matches
assert.c
Go to the documentation of this file.
1#include <assert.h>
2#include <errno.h>
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6
7#ifdef __KERNEL__
8#include <kernel/log/panic.h>
9#endif
10
11void _assert_99(const char* const message1, const char* const function, const char* const message2)
12{
13#ifdef __KERNEL__
14 panic(NULL, "%s %s %s %s", message1, function, message2, errno != 0 ? strerror(errno) : "errno not set");
15#else
16 fputs(message1, stderr);
17 fputs(function, stderr);
18 fputs(message2, stderr);
19 abort();
20#endif
21}
22
23void _assert_89(const char* const message)
24{
25#ifdef __KERNEL__
26 panic(NULL, message);
27#else
28 fputs(message, stderr);
29 abort();
30#endif
31}
void _assert_99(const char *const message1, const char *const function, const char *const message2)
Definition assert.c:11
void _assert_89(const char *const message)
Definition assert.c:23
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
Definition panic.c:362
#define errno
Error number variable.
Definition errno.h:27
#define NULL
Pointer error value.
Definition NULL.h:23
FILE * stderr
Definition std_streams.c:18
_PUBLIC int fputs(const char *_RESTRICT s, FILE *_RESTRICT stream)
Definition fputs.c:5
_PUBLIC _NORETURN void abort(void)
Definition abort.c:7
_PUBLIC char * strerror(int errnum)
Definition strerror.c:6