summaryrefslogtreecommitdiffhomepage
path: root/Private/NewKit/RuntimeCheck.hpp
blob: c5978aad6dfdda070c5592205d4281506912d73b (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

/*
 *	========================================================
 *
 *	HCore
 * 	Copyright Mahrouss Logic, all rights reserved.
 *
 * 	========================================================
 */

#pragma once

#include <NewKit/Defines.hpp>

namespace HCore
{
void runtime_check(bool bExpression, const char *file, const char *line);
}

#define MUST_PASS_COMPILER(EXPR, MSG) static_assert(EXPR, MSG)
#define MUST_PASS(EXPR) HCore::runtime_check(EXPR, __FILE__, " %d -> ")
#define assert(EXPR) MUST_PASS(EXPR, RUNTIME_CHECK_EXPRESSION)

enum RUNTIME_CHECK
{
    RUNTIME_CHECK_FAILED = -1,
    RUNTIME_CHECK_POINTER = 0,
    RUNTIME_CHECK_EXPRESSION,
    RUNTIME_CHECK_FILE,
    RUNTIME_CHECK_IPC,
    RUNTIME_CHECK_TLS,
    RUNTIME_CHECK_LD,
    RUNTIME_CHECK_HANDSHAKE,
    RUNTIME_CHECK_ACPI,
    RUNTIME_CHECK_INVALID_PRIVILEGE,
    RUNTIME_CHECK_PROCESS,
    RUNTIME_CHECK_BAD_BEHAVIOR,
    RUNTIME_CHECK_COUNT,
    RUNTIME_CHECK_BOOTSTRAP,
};

namespace HCore
{
class DumpManager final
{
  public:
    static void Dump(void)
    {
        // TODO:
    }
};

void ke_stop(const Int &id);
} // namespace HCore

#ifdef TRY
#undef TRY
#endif

#define INIT(OBJ, TYPE, ...) TYPE OBJ = TYPE(__VA_ARGS__)

#define TRY(FN)                                                                                                        \
    if (!FN())                                                                                                         \
    {                                                                                                                  \
        MUST_PASS(false);                                                                                              \
    }