diff options
| author | Hector Chu <hectorchu@gmail.com> | 2011-01-19 15:10:15 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2011-01-19 15:10:15 -0500 |
| commit | aae5f912135f3db73b9731e6e755b3d6eae9cda0 (patch) | |
| tree | 3f902f6889c400b6a78cb0d6700081f4acc72627 /src/pkg/runtime/windows/thread.c | |
| parent | 48d2de7eb9a4ed30faf29abebbbbb205b308cb33 (diff) | |
| download | go-aae5f912135f3db73b9731e6e755b3d6eae9cda0.tar.xz | |
windows: implement exception handling
R=rsc, brainman
CC=golang-dev
https://golang.org/cl/4079041
Diffstat (limited to 'src/pkg/runtime/windows/thread.c')
| -rw-r--r-- | src/pkg/runtime/windows/thread.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/pkg/runtime/windows/thread.c b/src/pkg/runtime/windows/thread.c index 9b51813373..5ab5128eb7 100644 --- a/src/pkg/runtime/windows/thread.c +++ b/src/pkg/runtime/windows/thread.c @@ -3,6 +3,7 @@ // license that can be found in the LICENSE file. #include "runtime.h" +#include "defs.h" #include "os.h" #pragma dynimport runtime·LoadLibraryEx LoadLibraryExA "kernel32.dll" @@ -215,3 +216,43 @@ runtime·syscall(StdcallParams *p) p->err = (uintptr)runtime·stdcall_raw(runtime·GetLastError, 0, &a); runtime·exitsyscall(); } + +uint32 +runtime·issigpanic(uint32 code) +{ + switch(code) { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_INT_DIVIDE_BY_ZERO: + case EXCEPTION_INT_OVERFLOW: + case EXCEPTION_FLT_DENORMAL_OPERAND: + case EXCEPTION_FLT_DIVIDE_BY_ZERO: + case EXCEPTION_FLT_INEXACT_RESULT: + case EXCEPTION_FLT_OVERFLOW: + case EXCEPTION_FLT_UNDERFLOW: + return 1; + } + return 0; +} + +void +runtime·sigpanic(void) +{ + switch(g->sig) { + case EXCEPTION_ACCESS_VIOLATION: + if(g->sigcode1 < 0x1000) + runtime·panicstring("invalid memory address or nil pointer dereference"); + runtime·printf("unexpected fault address %p\n", g->sigcode1); + runtime·throw("fault"); + case EXCEPTION_INT_DIVIDE_BY_ZERO: + runtime·panicstring("integer divide by zero"); + case EXCEPTION_INT_OVERFLOW: + runtime·panicstring("integer overflow"); + case EXCEPTION_FLT_DENORMAL_OPERAND: + case EXCEPTION_FLT_DIVIDE_BY_ZERO: + case EXCEPTION_FLT_INEXACT_RESULT: + case EXCEPTION_FLT_OVERFLOW: + case EXCEPTION_FLT_UNDERFLOW: + runtime·panicstring("floating point error"); + } + runtime·throw("fault"); +} |
