// unw.c --- stack unwinding -*- C -*- // // Copyright (c) 2026 Martin Michalec // // SPDX-License-Identifier: MIT // // This file is part of COSMOS Codebase. // // Commentary: // // Code: #include "unw.h" #include "dbg.h" #include "lgr.h" #include UNW_DEFINE_REASON (INVAL, "Invalid argument"); THREAD_LOCAL const struct unw_reason *_unw_reason; THREAD_LOCAL int _unw_code; THREAD_LOCAL struct unw_frame *_unw_top; void _unw (const struct unw_reason *reason, int code) { DBG_ASSERT_NN (reason); DBG_ASSERT_NN (reason->sym); DBG_ASSERT_NN (reason->msg); DBG_ASSERT_NZ (code, "%d"); _unw_reason = reason; _unw_code = code; if (_unw_top) longjmp (_unw_top->jmp, code); CTX_FATAL ("Unhandled %s (%s) with code: %d", reason->sym, reason->msg, code); abort (); } // unw.c ends here