summaryrefslogtreecommitdiff
path: root/kernel/libc/include/assert.h
blob: 1b631acae7d9a689fb07a8d6cb36c407bffdb176 (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
#include <log.h>
#include <stdio.h>

// This infinite loop is needed for GCC to understand that
// aFailed does not return. No clue why the attribute does
// help solve the issue.
#define assert(expr)                                                           \
  {                                                                            \
    if (!(expr)) {                                                             \
      aFailed(__FILE__, __LINE__);                                             \
      for (;;)                                                                 \
        ;                                                                      \
    }                                                                          \
  }

#define ASSERT_BUT_FIXME_PROPOGATE(expr)                                       \
  {                                                                            \
    if (!(expr))                                                               \
      kprintf("Performing assert that should have been a propogated error.");  \
    assert(expr);                                                              \
  }

void aFailed(char *f, int l);
#define ASSERT_NOT_REACHED {assert(0)}