libgo: update to Go 1.11
[official-gcc.git] / libgo / runtime / panic.c
blob9cd69ee983aac7b5f894122c9e3a8229ec1815d4
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 M* mp;
20 Eface err;
22 mp = runtime_m();
23 if (mp != nil) {
24 if(mp->mallocing) {
25 runtime_printf("panic: %s\n", s);
26 runtime_throw("panic during malloc");
28 if(mp->gcing) {
29 runtime_printf("panic: %s\n", s);
30 runtime_throw("panic during gc");
32 if(mp->locks) {
33 runtime_printf("panic: %s\n", s);
34 runtime_throw("panic holding locks");
37 runtime_newErrorCString(s, &err);
38 runtime_panic(err);
41 extern void runtime_abort(void) __asm__(GOSYM_PREFIX "runtime.abort");
43 void
44 runtime_abort()
46 abort();