baremetal: implement C assert

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-05-08 00:00:02 +00:00
parent 406ee82cf3
commit 40169f7427
9 changed files with 101 additions and 37 deletions

View File

@@ -1,5 +1,18 @@
#include <lkmc.h>
/* Let's see what happens when an assert fails.
*
* Outcome on Ubuntu 19.04 shows the failure line:
*
* assert_fail.out: /path/to/linux-kernel-module-cheat/userland/c/assert_fail.c:15: main: Assertion `0' failed.
*
* and exit status 134 == 128 + 6, which corresponds to SIGABORT (6).
*/
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
int main(void) {
lkmc_assert_fail();
assert(0);
puts("here");
return EXIT_SUCCESS;
}