aboutsummaryrefslogtreecommitdiff
path: root/libk/stdlib/abort.cc
blob: 41bf991221a52fd3f22169567636ed8bee7f949c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "stdlib.h"

void abort() {
  /*
   * On gcc, a 'while(true) {}' will infinitely loop
   * but clang will optimize it away on -O2 if it's empty
   * therefore, add no-op
   */

  asm volatile("cli");
  while (true) asm volatile("hlt");
  __builtin_unreachable();
}

extern "C" void print_exception(uint8_t irq) {
  printk("exception ", uhex{irq}, '\n');
  asm volatile("cli");
  while (true) asm volatile("hlt");
  __builtin_unreachable();
};