summaryrefslogtreecommitdiff
path: root/src/util.c
blob: b5122968783fa3e362b7d73903b7785a4d1bb030 (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
#include "util.h"
#include "gc.h"
#include "platform.h"
#include <stdarg.h>
#include <stdio.h>

noreturn void assume__failed(const char *file, int line, const char *expr) {
  panic_begin();
  fprintf(stderr, "%s:%d: assertion failed: %s\n\n", file, line, expr);
  gc_debug();
  panic_end();
}

noreturn void todo__impl(const char *file, int line, const char *fmt, ...) {
  panic_begin();
  printf("%s:%d: TODO: ", file, line);
  va_list ap;
  va_start(ap, fmt);
  vprintf(fmt, ap);
  va_end(ap);
  printf("\n");
  gc_debug();
  panic_end();
}

noreturn void unreachable__impl(const char *file, int line, const char *fmt,
                                ...) {
  panic_begin();
  printf("%s:%d: unreachable code entered: ", file, line);
  va_list ap;
  va_start(ap, fmt);
  vprintf(fmt, ap);
  va_end(ap);
  printf("\n");
  gc_debug();
  panic_end();
}