os_windows.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2014 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. package runtime
  5. import "unsafe"
  6. type stdFunction *byte
  7. func stdcall0(fn stdFunction) uintptr
  8. func stdcall1(fn stdFunction, a0 uintptr) uintptr
  9. func stdcall2(fn stdFunction, a0, a1 uintptr) uintptr
  10. func stdcall3(fn stdFunction, a0, a1, a2 uintptr) uintptr
  11. func stdcall4(fn stdFunction, a0, a1, a2, a3 uintptr) uintptr
  12. func stdcall5(fn stdFunction, a0, a1, a2, a3, a4 uintptr) uintptr
  13. func stdcall6(fn stdFunction, a0, a1, a2, a3, a4, a5 uintptr) uintptr
  14. func stdcall7(fn stdFunction, a0, a1, a2, a3, a4, a5, a6 uintptr) uintptr
  15. func asmstdcall(fn unsafe.Pointer)
  16. func getlasterror() uint32
  17. func setlasterror(err uint32)
  18. func usleep1(usec uint32)
  19. func netpollinit()
  20. func netpollopen(fd uintptr, pd *pollDesc) int32
  21. func netpollclose(fd uintptr) int32
  22. func netpollarm(pd *pollDesc, mode int)
  23. func os_sigpipe() {
  24. gothrow("too many writes on closed pipe")
  25. }
  26. func sigpanic() {
  27. g := getg()
  28. if !canpanic(g) {
  29. gothrow("unexpected signal during runtime execution")
  30. }
  31. switch uint32(g.sig) {
  32. case _EXCEPTION_ACCESS_VIOLATION:
  33. if g.sigcode1 < 0x1000 || g.paniconfault {
  34. panicmem()
  35. }
  36. print("unexpected fault address ", hex(g.sigcode1), "\n")
  37. gothrow("fault")
  38. case _EXCEPTION_INT_DIVIDE_BY_ZERO:
  39. panicdivide()
  40. case _EXCEPTION_INT_OVERFLOW:
  41. panicoverflow()
  42. case _EXCEPTION_FLT_DENORMAL_OPERAND,
  43. _EXCEPTION_FLT_DIVIDE_BY_ZERO,
  44. _EXCEPTION_FLT_INEXACT_RESULT,
  45. _EXCEPTION_FLT_OVERFLOW,
  46. _EXCEPTION_FLT_UNDERFLOW:
  47. panicfloat()
  48. }
  49. gothrow("fault")
  50. }