blob: 0e805b1456ccd6011af61bf9bb4093622e92bfe9 (
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
|
// CODYlib -*- mode:c++ -*-
// Copyright (C) 2019-2020 Nathan Sidwell, nathan@acm.org
// License: Apache v2.0
// Cody
#include "internal.hh"
// C
#include <csignal>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
namespace Cody {
#if NMS_CHECKING
void (AssertFailed) (Location loc) noexcept
{
(HCF) ("assertion failed", loc);
}
void (Unreachable) (Location loc) noexcept
{
(HCF) ("unreachable reached", loc);
}
#endif
void (HCF) (char const *msg
#if NMS_CHECKING
, Location const loc
#endif
) noexcept
{ // HCF - you goofed!
#if !NMS_CHECKING
constexpr Location loc (nullptr, 0);
#endif
fprintf (stderr, "CODYlib: %s", msg ? msg : "internal error");
if (char const *file = loc.File ())
{
char const *src = SRCDIR;
if (src[0])
{
size_t l = strlen (src);
if (!strncmp (src, file, l) && file[l] == '/')
file += l + 1;
}
fprintf (stderr, " at %s:%u", file, loc.Line ());
}
fprintf (stderr, "\n");
raise (SIGABRT);
exit (2);
}
}
|