Path: blob/main/system/lib/wasmfs/support.cpp
6174 views
// Copyright 2022 The Emscripten Authors. All rights reserved.1// Emscripten is available under two separate licenses, the MIT license and the2// University of Illinois/NCSA Open Source License. Both these licenses can be3// found in the LICENSE file.45#ifdef __EMSCRIPTEN__6// In emscripten, avoid iostream to avoid using WasmFS code during logging.7#include <emscripten/console.h>8#else9#include <iostream>10#endif1112#include "support.h"1314namespace wasmfs {1516void handle_unreachable(const char* msg, const char* file, unsigned line) {17#ifndef NDEBUG18#ifdef __EMSCRIPTEN__19if (msg) {20emscripten_err(msg);21}22emscripten_err("UNREACHABLE executed");23if (file) {24emscripten_errf("at %s:%d", file, line);25}26#else // EMSCRIPTEN27if (msg) {28std::cerr << msg << "\n";29}30std::cerr << "UNREACHABLE executed";31if (file) {32std::cerr << " at " << file << ":" << line;33}34std::cerr << "!\n";35#endif36// TODO: sanitizer integration, see binaryen's similar code37#endif38__builtin_trap();39}4041} // namespace wasmfs424344