Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/system/lib/wasmfs/support.cpp
6174 views
1
// Copyright 2022 The Emscripten Authors. All rights reserved.
2
// Emscripten is available under two separate licenses, the MIT license and the
3
// University of Illinois/NCSA Open Source License. Both these licenses can be
4
// found in the LICENSE file.
5
6
#ifdef __EMSCRIPTEN__
7
// In emscripten, avoid iostream to avoid using WasmFS code during logging.
8
#include <emscripten/console.h>
9
#else
10
#include <iostream>
11
#endif
12
13
#include "support.h"
14
15
namespace wasmfs {
16
17
void handle_unreachable(const char* msg, const char* file, unsigned line) {
18
#ifndef NDEBUG
19
#ifdef __EMSCRIPTEN__
20
if (msg) {
21
emscripten_err(msg);
22
}
23
emscripten_err("UNREACHABLE executed");
24
if (file) {
25
emscripten_errf("at %s:%d", file, line);
26
}
27
#else // EMSCRIPTEN
28
if (msg) {
29
std::cerr << msg << "\n";
30
}
31
std::cerr << "UNREACHABLE executed";
32
if (file) {
33
std::cerr << " at " << file << ":" << line;
34
}
35
std::cerr << "!\n";
36
#endif
37
// TODO: sanitizer integration, see binaryen's similar code
38
#endif
39
__builtin_trap();
40
}
41
42
} // namespace wasmfs
43
44