PatchworkOS  19e446b
A non-POSIX operating system.
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#elif defined(_BOOT_)
10#include <efi.h>
11
12#endif
13
14void _assert_99(const char* const message1, const char* const function, const char* const message2)
15{
16#ifdef _KERNEL_
17 panic(NULL, "%s %s %s %s", message1, function, message2, errno != 0 ? strerror(errno) : "errno not set");
18#elif defined(_BOOT_)
19 Print(L"%a %a %a\n", message1, function, message2);
20 for (;;)
21 {
22 __asm__("cli; hlt");
23 }
24#else
25 fputs(message1, stderr);
26 fputs(function, stderr);
27 fputs(message2, stderr);
28 abort();
29#endif
30}
31
32void _assert_89(const char* const message)
33{
34#ifdef _KERNEL_
35 panic(NULL, message);
36#elif defined(_BOOT_)
37 Print(L"%a\n", message);
38 for (;;)
39 {
40 __asm__("cli; hlt");
41 }
42#else
43 fputs(message, stderr);
44 abort();
45#endif
46}
void _assert_99(const char *const message1, const char *const function, const char *const message2)
Definition assert.c:14
void _assert_89(const char *const message)
Definition assert.c:32
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
Definition panic.c:292
#define errno
Error number variable.
Definition errno.h:27
#define NULL
Pointer error value.
Definition NULL.h:25
FILE * stderr
Definition std_streams.c:19
_PUBLIC int fputs(const char *_RESTRICT s, FILE *_RESTRICT stream)
Definition fputs.c:5
_PUBLIC _NORETURN void abort(void)
Definition abort.c:9
_PUBLIC char * strerror(int errnum)
Definition strerror.c:6