mirror of https://github.com/golang/go.git
syscall: mingw implemntation of Errstr()
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/621041
This commit is contained in:
parent
fa462f37e3
commit
64f33880e5
|
|
@ -6,7 +6,7 @@ include ../../Make.$(GOARCH)
|
|||
|
||||
TARG=syscall
|
||||
GOFILES=\
|
||||
errstr.go\
|
||||
str.go\
|
||||
exec.go\
|
||||
syscall.go\
|
||||
syscall_$(GOARCH).go\
|
||||
|
|
@ -17,7 +17,21 @@ GOFILES=\
|
|||
zsysnum_$(GOOS)_$(GOARCH).go\
|
||||
ztypes_$(GOOS)_$(GOARCH).go\
|
||||
|
||||
GOFILES_freebsd=\
|
||||
syscall_unix.go\
|
||||
|
||||
GOFILES_darwin=\
|
||||
syscall_unix.go\
|
||||
|
||||
GOFILES_linux=\
|
||||
syscall_unix.go\
|
||||
|
||||
GOFILES_nacl=\
|
||||
syscall_unix.go\
|
||||
|
||||
OFILES=\
|
||||
asm_$(GOOS)_$(GOARCH).$O\
|
||||
|
||||
GOFILES+=$(GOFILES_$(GOOS))
|
||||
|
||||
include ../../Make.pkg
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
package syscall
|
||||
|
||||
|
||||
func str(val int) string { // do it here rather than with fmt to avoid dependency
|
||||
if val < 0 {
|
||||
return "-" + str(-val)
|
||||
|
|
@ -19,10 +18,3 @@ func str(val int) string { // do it here rather than with fmt to avoid dependenc
|
|||
buf[i] = byte(val + '0')
|
||||
return string(buf[i:])
|
||||
}
|
||||
|
||||
func Errstr(errno int) string {
|
||||
if errno < 0 || errno >= int(len(errors)) {
|
||||
return "error " + str(errno)
|
||||
}
|
||||
return errors[errno]
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ import (
|
|||
)
|
||||
|
||||
func abort(funcname string, err int) {
|
||||
panic(funcname+" failed: (", err, ") ", syscall.GetErrstr(err), "\n")
|
||||
panic(funcname+" failed: (", err, ") ", syscall.Errstr(err), "\n")
|
||||
}
|
||||
|
||||
func print_version(v uint32) {
|
||||
|
|
@ -99,11 +99,9 @@ func getSysProcAddr(m uint32, pname string) uintptr {
|
|||
//sys GetVersion() (ver uint32, errno int)
|
||||
//sys FormatMessage(flags uint32, msgsrc uint32, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, errno int) = FormatMessageW
|
||||
|
||||
// TODO(brainman): maybe GetErrstr should replace Errstr alltogether
|
||||
|
||||
func GetErrstr(errno int) string {
|
||||
func Errstr(errno int) string {
|
||||
if errno == EMINGW {
|
||||
return errors[errno]
|
||||
return "not supported by windows"
|
||||
}
|
||||
var b = make([]uint16, 300)
|
||||
n, err := FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ARGUMENT_ARRAY, 0, uint32(errno), 0, b, nil)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright 2009 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 syscall
|
||||
|
||||
func Errstr(errno int) string {
|
||||
if errno < 0 || errno >= int(len(errors)) {
|
||||
return "error " + str(errno)
|
||||
}
|
||||
return errors[errno]
|
||||
}
|
||||
|
|
@ -12,8 +12,3 @@ const (
|
|||
// TODO(brainman): should use value for EMINGW that does not clashes with anything else
|
||||
EMINGW = 99999 /* otherwise unused */
|
||||
)
|
||||
|
||||
// Error table
|
||||
var errors = [...]string{
|
||||
EMINGW: "not supported by windows",
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue