Retro68/gcc/libgo/runtime/panic.c

36 lines
823 B
C
Raw Normal View History

2014-09-21 17:33:12 +00:00
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "runtime.h"
extern void gothrow(String) __attribute__((noreturn));
extern void gothrow(String) __asm__(GOSYM_PREFIX "runtime.throw");
2015-08-28 15:33:40 +00:00
2014-09-21 17:33:12 +00:00
void
runtime_throw(const char *s)
{
gothrow(runtime_gostringnocopy((const byte *)s));
2014-09-21 17:33:12 +00:00
}
void
runtime_panicstring(const char *s)
{
Eface err;
if(runtime_m()->mallocing) {
runtime_printf("panic: %s\n", s);
runtime_throw("panic during malloc");
}
if(runtime_m()->gcing) {
runtime_printf("panic: %s\n", s);
runtime_throw("panic during gc");
}
2015-08-28 15:33:40 +00:00
if(runtime_m()->locks) {
runtime_printf("panic: %s\n", s);
runtime_throw("panic holding locks");
}
2014-09-21 17:33:12 +00:00
runtime_newErrorCString(s, &err);
runtime_panic(err);
}