annotate libgo/runtime/panic.c @ 138:fc828634a951

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 08 Nov 2018 14:17:14 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // Copyright 2012 The Go Authors. All rights reserved.
kono
parents:
diff changeset
2 // Use of this source code is governed by a BSD-style
kono
parents:
diff changeset
3 // license that can be found in the LICENSE file.
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 #include "runtime.h"
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 extern void gothrow(String) __attribute__((noreturn));
kono
parents:
diff changeset
8 extern void gothrow(String) __asm__(GOSYM_PREFIX "runtime.throw");
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 void
kono
parents:
diff changeset
11 runtime_throw(const char *s)
kono
parents:
diff changeset
12 {
kono
parents:
diff changeset
13 gothrow(runtime_gostringnocopy((const byte *)s));
kono
parents:
diff changeset
14 }
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 void
kono
parents:
diff changeset
17 runtime_panicstring(const char *s)
kono
parents:
diff changeset
18 {
kono
parents:
diff changeset
19 M* mp;
kono
parents:
diff changeset
20 Eface err;
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 mp = runtime_m();
kono
parents:
diff changeset
23 if (mp != nil) {
kono
parents:
diff changeset
24 if(mp->mallocing) {
kono
parents:
diff changeset
25 runtime_printf("panic: %s\n", s);
kono
parents:
diff changeset
26 runtime_throw("panic during malloc");
kono
parents:
diff changeset
27 }
kono
parents:
diff changeset
28 if(mp->gcing) {
kono
parents:
diff changeset
29 runtime_printf("panic: %s\n", s);
kono
parents:
diff changeset
30 runtime_throw("panic during gc");
kono
parents:
diff changeset
31 }
kono
parents:
diff changeset
32 if(mp->locks) {
kono
parents:
diff changeset
33 runtime_printf("panic: %s\n", s);
kono
parents:
diff changeset
34 runtime_throw("panic holding locks");
kono
parents:
diff changeset
35 }
kono
parents:
diff changeset
36 }
kono
parents:
diff changeset
37 runtime_newErrorCString(s, &err);
kono
parents:
diff changeset
38 runtime_panic(err);
kono
parents:
diff changeset
39 }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
40
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
41 extern void runtime_abort(void) __asm__(GOSYM_PREFIX "runtime.abort");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
42
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
43 void
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
44 runtime_abort()
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
45 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
46 abort();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
47 }