]>
Commit | Line | Data |
---|---|---|
4ccad563 ILT |
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. | |
4 | ||
5 | #include "runtime.h" | |
4ccad563 | 6 | |
9d1e3afb ILT |
7 | extern void gothrow(String) __attribute__((noreturn)); |
8 | extern void gothrow(String) __asm__(GOSYM_PREFIX "runtime.throw"); | |
00d86ac9 | 9 | |
4ccad563 ILT |
10 | void |
11 | runtime_throw(const char *s) | |
12 | { | |
9d1e3afb | 13 | gothrow(runtime_gostringnocopy((const byte *)s)); |
4a2bb7fc ILT |
14 | } |
15 | ||
4ccad563 ILT |
16 | void |
17 | runtime_panicstring(const char *s) | |
18 | { | |
aa8901e9 | 19 | G *gp; |
4ccad563 ILT |
20 | Eface err; |
21 | ||
aa8901e9 ILT |
22 | gp = runtime_g(); |
23 | if (gp == nil) { | |
24 | runtime_printf("panic: %s\n", s); | |
25 | runtime_throw("panic with no g"); | |
26 | } | |
27 | if (gp->m == nil) { | |
28 | runtime_printf("panic: %s\n", s); | |
29 | runtime_throw("panic with no m"); | |
30 | } | |
31 | if (gp->m->curg != gp) { | |
32 | runtime_printf("panic: %s\n", s); | |
33 | runtime_throw("panic on system stack"); | |
34 | } | |
35 | if (gp->m->mallocing != 0) { | |
36 | runtime_printf("panic: %s\n", s); | |
37 | runtime_throw("panic during malloc"); | |
38 | } | |
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"); | |
43 | } | |
44 | if (gp->m->locks != 0) { | |
45 | runtime_printf("panic: %s\n", s); | |
46 | runtime_throw("panic holding locks"); | |
00d86ac9 | 47 | } |
8a9f2a6b | 48 | runtime_newErrorCString((uintptr) s, &err); |
4ccad563 ILT |
49 | runtime_panic(err); |
50 | } | |
dd931d9b ILT |
51 | |
52 | extern void runtime_abort(void) __asm__(GOSYM_PREFIX "runtime.abort"); | |
53 | ||
54 | void | |
55 | runtime_abort() | |
56 | { | |
57 | abort(); | |
58 | } |