mirror of
https://github.com/golang/go
synced 2024-10-03 06:21:21 -06:00
f584c05fcc
Error detection code copied from syscall, where presumably we actually do it right. Note that we throw the errno away. The runtime doesn't use it. Fixes #10052 Change-Id: I8de77dda6bf287276b137646c26b84fa61554ec8 Reviewed-on: https://go-review.googlesource.com/6571 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
// Copyright 2014 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package runtime
|
|
|
|
import "unsafe"
|
|
|
|
type stdFunction *byte
|
|
|
|
//go:linkname os_sigpipe os.sigpipe
|
|
func os_sigpipe() {
|
|
throw("too many writes on closed pipe")
|
|
}
|
|
|
|
func sigpanic() {
|
|
g := getg()
|
|
if !canpanic(g) {
|
|
throw("unexpected signal during runtime execution")
|
|
}
|
|
|
|
switch uint32(g.sig) {
|
|
case _EXCEPTION_ACCESS_VIOLATION:
|
|
if g.sigcode1 < 0x1000 || g.paniconfault {
|
|
panicmem()
|
|
}
|
|
print("unexpected fault address ", hex(g.sigcode1), "\n")
|
|
throw("fault")
|
|
case _EXCEPTION_INT_DIVIDE_BY_ZERO:
|
|
panicdivide()
|
|
case _EXCEPTION_INT_OVERFLOW:
|
|
panicoverflow()
|
|
case _EXCEPTION_FLT_DENORMAL_OPERAND,
|
|
_EXCEPTION_FLT_DIVIDE_BY_ZERO,
|
|
_EXCEPTION_FLT_INEXACT_RESULT,
|
|
_EXCEPTION_FLT_OVERFLOW,
|
|
_EXCEPTION_FLT_UNDERFLOW:
|
|
panicfloat()
|
|
}
|
|
throw("fault")
|
|
}
|
|
|
|
// Stubs so tests can link correctly. These should never be called.
|
|
func open(name *byte, mode, perm int32) int32 {
|
|
throw("unimplemented")
|
|
return -1
|
|
}
|
|
func close(fd int32) int32 {
|
|
throw("unimplemented")
|
|
return -1
|
|
}
|
|
func read(fd int32, p unsafe.Pointer, n int32) int32 {
|
|
throw("unimplemented")
|
|
return -1
|
|
}
|