OLD | NEW |
1 // Use of this source file is governed by a BSD-style | 1 // Use of this source file is governed by a BSD-style |
2 // license that can be found in the LICENSE file.` | 2 // license that can be found in the LICENSE file.` |
3 | 3 |
4 #include "runtime.h" | 4 #include "runtime.h" |
5 #include "defs.h" | 5 #include "defs.h" |
6 #include "os.h" | 6 #include "os.h" |
| 7 #include "stack.h" |
7 | 8 |
8 extern SigTab runtime·sigtab[]; | 9 extern SigTab runtime·sigtab[]; |
9 extern int32 runtime·sys_umtx_op(uint32*, int32, uint32, void*, void*); | 10 extern int32 runtime·sys_umtx_op(uint32*, int32, uint32, void*, void*); |
10 | 11 |
11 // FreeBSD's umtx_op syscall is effectively the same as Linux's futex, and | 12 // FreeBSD's umtx_op syscall is effectively the same as Linux's futex, and |
12 // thus the code is largely similar. See linux/thread.c for comments. | 13 // thus the code is largely similar. See linux/thread.c for comments. |
13 | 14 |
14 static void | 15 static void |
15 umtx_wait(uint32 *addr, uint32 val) | 16 umtx_wait(uint32 *addr, uint32 val) |
16 { | 17 { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 { | 169 { |
169 runtime·goenvs_unix(); | 170 runtime·goenvs_unix(); |
170 } | 171 } |
171 | 172 |
172 // Called to initialize a new m (including the bootstrap m). | 173 // Called to initialize a new m (including the bootstrap m). |
173 void | 174 void |
174 runtime·minit(void) | 175 runtime·minit(void) |
175 { | 176 { |
176 // Initialize signal handling | 177 // Initialize signal handling |
177 m->gsignal = runtime·malg(32*1024); | 178 m->gsignal = runtime·malg(32*1024); |
178 » runtime·signalstack(m->gsignal->stackguard, 32*1024); | 179 » runtime·signalstack(m->gsignal->stackguard - StackGuard, 32*1024); |
179 } | 180 } |
180 | 181 |
181 void | 182 void |
182 runtime·sigpanic(void) | 183 runtime·sigpanic(void) |
183 { | 184 { |
184 switch(g->sig) { | 185 switch(g->sig) { |
185 case SIGBUS: | 186 case SIGBUS: |
186 if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) | 187 if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) |
187 runtime·panicstring("invalid memory address or nil point
er dereference"); | 188 runtime·panicstring("invalid memory address or nil point
er dereference"); |
188 runtime·printf("unexpected fault address %p\n", g->sigcode1); | 189 runtime·printf("unexpected fault address %p\n", g->sigcode1); |
189 runtime·throw("fault"); | 190 runtime·throw("fault"); |
190 case SIGSEGV: | 191 case SIGSEGV: |
191 if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode
0 == SEGV_ACCERR) && g->sigcode1 < 0x1000) | 192 if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode
0 == SEGV_ACCERR) && g->sigcode1 < 0x1000) |
192 runtime·panicstring("invalid memory address or nil point
er dereference"); | 193 runtime·panicstring("invalid memory address or nil point
er dereference"); |
193 runtime·printf("unexpected fault address %p\n", g->sigcode1); | 194 runtime·printf("unexpected fault address %p\n", g->sigcode1); |
194 runtime·throw("fault"); | 195 runtime·throw("fault"); |
195 case SIGFPE: | 196 case SIGFPE: |
196 switch(g->sigcode0) { | 197 switch(g->sigcode0) { |
197 case FPE_INTDIV: | 198 case FPE_INTDIV: |
198 runtime·panicstring("integer divide by zero"); | 199 runtime·panicstring("integer divide by zero"); |
199 case FPE_INTOVF: | 200 case FPE_INTOVF: |
200 runtime·panicstring("integer overflow"); | 201 runtime·panicstring("integer overflow"); |
201 } | 202 } |
202 runtime·panicstring("floating point error"); | 203 runtime·panicstring("floating point error"); |
203 } | 204 } |
204 runtime·panicstring(runtime·sigtab[g->sig].name); | 205 runtime·panicstring(runtime·sigtab[g->sig].name); |
205 } | 206 } |
OLD | NEW |