gcc/
[official-gcc.git] / libgo / runtime / panic.c
blob493fde8932033abfb640da999e8539f11af4ded6
1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 #include "runtime.h"
7 extern void gothrow(String) __attribute__((noreturn));
8 extern void gothrow(String) __asm__(GOSYM_PREFIX "runtime.throw");
10 void
11 runtime_throw(const char *s)
13 gothrow(runtime_gostringnocopy((const byte *)s));
16 void
17 runtime_panicstring(const char *s)
19 Eface err;
21 if(runtime_m()->mallocing) {
22 runtime_printf("panic: %s\n", s);
23 runtime_throw("panic during malloc");
25 if(runtime_m()->gcing) {
26 runtime_printf("panic: %s\n", s);
27 runtime_throw("panic during gc");
29 if(runtime_m()->locks) {
30 runtime_printf("panic: %s\n", s);
31 runtime_throw("panic holding locks");
33 runtime_newErrorCString(s, &err);
34 runtime_panic(err);