summaryrefslogtreecommitdiff
path: root/lib/mlibc/sysdeps/managarm/generic/ensure.cpp
blob: ab0d84fdb2fda6410f475d000f265e87b19c068d (plain)
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
28
29
30
31
32
33
34
35
36
37
38

#include <stdint.h>
#include <string.h>
#include <assert.h>

#include <bits/ensure.h>
#include <mlibc/debug.hpp>
#include <mlibc/all-sysdeps.hpp>

#include <hel.h>
#include <hel-syscalls.h>

void __frigg_assert_fail(const char *assertion, const char *file, unsigned int line,
		const char *function) {
	mlibc::panicLogger() << "In function " << function
			<< ", file " << file << ":" << line << "\n"
			<< "__ensure(" << assertion << ") failed" << frg::endlog;
}

namespace mlibc {
	void sys_libc_log(const char *message) {
		// This implementation is inherently signal-safe.
		size_t n = 0;
		while(message[n])
			n++;
		HEL_CHECK(helLog(message, n));
	}

	void sys_libc_panic() {
		// This implementation is inherently signal-safe.
		const char *message = "mlibc: Panic!";
		size_t n = 0;
		while(message[n])
			n++;
		helPanic(message, n);
	}
}