Doc: Add Standard-Names ustrunc and sstrunc for integer modes
[official-gcc.git] / libgo / runtime / panic.c
blob48382194dfab61338adfa1d5fa8f5dd3015e341c
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 G *gp;
20 Eface err;
22 gp = runtime_g();
23 if (gp == nil) {
24 runtime_printf("panic: %s\n", s);
25 runtime_throw("panic with no g");
27 if (gp->m == nil) {
28 runtime_printf("panic: %s\n", s);
29 runtime_throw("panic with no m");
31 if (gp->m->curg != gp) {
32 runtime_printf("panic: %s\n", s);
33 runtime_throw("panic on system stack");
35 if (gp->m->mallocing != 0) {
36 runtime_printf("panic: %s\n", s);
37 runtime_throw("panic during malloc");
39 if (gp->m->preemptoff.len != 0) {
40 runtime_printf("panic: %s\n", s);
41 runtime_printf("preempt off reason: %S\n", gp->m->preemptoff);
42 runtime_throw("panic during preemptoff");
44 if (gp->m->locks != 0) {
45 runtime_printf("panic: %s\n", s);
46 runtime_throw("panic holding locks");
48 runtime_newErrorCString((uintptr) s, &err);
49 runtime_panic(err);
52 extern void runtime_abort(void) __asm__(GOSYM_PREFIX "runtime.abort");
54 void
55 runtime_abort()
57 abort();