Commit 64f33880 authored by Alex Brainman's avatar Alex Brainman Committed by Russ Cox

syscall: mingw implemntation of Errstr()

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/621041
parent fa462f37
...@@ -6,7 +6,7 @@ include ../../Make.$(GOARCH) ...@@ -6,7 +6,7 @@ include ../../Make.$(GOARCH)
TARG=syscall TARG=syscall
GOFILES=\ GOFILES=\
errstr.go\ str.go\
exec.go\ exec.go\
syscall.go\ syscall.go\
syscall_$(GOARCH).go\ syscall_$(GOARCH).go\
...@@ -17,7 +17,21 @@ GOFILES=\ ...@@ -17,7 +17,21 @@ GOFILES=\
zsysnum_$(GOOS)_$(GOARCH).go\ zsysnum_$(GOOS)_$(GOARCH).go\
ztypes_$(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=\ OFILES=\
asm_$(GOOS)_$(GOARCH).$O\ asm_$(GOOS)_$(GOARCH).$O\
GOFILES+=$(GOFILES_$(GOOS))
include ../../Make.pkg include ../../Make.pkg
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
package syscall package syscall
func str(val int) string { // do it here rather than with fmt to avoid dependency func str(val int) string { // do it here rather than with fmt to avoid dependency
if val < 0 { if val < 0 {
return "-" + str(-val) return "-" + str(-val)
...@@ -19,10 +18,3 @@ func str(val int) string { // do it here rather than with fmt to avoid dependenc ...@@ -19,10 +18,3 @@ func str(val int) string { // do it here rather than with fmt to avoid dependenc
buf[i] = byte(val + '0') buf[i] = byte(val + '0')
return string(buf[i:]) 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 ( ...@@ -24,7 +24,7 @@ import (
) )
func abort(funcname string, err int) { 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) { func print_version(v uint32) {
...@@ -99,11 +99,9 @@ func getSysProcAddr(m uint32, pname string) uintptr { ...@@ -99,11 +99,9 @@ func getSysProcAddr(m uint32, pname string) uintptr {
//sys GetVersion() (ver uint32, errno int) //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 //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 Errstr(errno int) string {
func GetErrstr(errno int) string {
if errno == EMINGW { if errno == EMINGW {
return errors[errno] return "not supported by windows"
} }
var b = make([]uint16, 300) var b = make([]uint16, 300)
n, err := FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ARGUMENT_ARRAY, 0, uint32(errno), 0, b, nil) n, err := FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ARGUMENT_ARRAY, 0, uint32(errno), 0, b, nil)
......
// 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 ( ...@@ -12,8 +12,3 @@ const (
// TODO(brainman): should use value for EMINGW that does not clashes with anything else // TODO(brainman): should use value for EMINGW that does not clashes with anything else
EMINGW = 99999 /* otherwise unused */ EMINGW = 99999 /* otherwise unused */
) )
// Error table
var errors = [...]string{
EMINGW: "not supported by windows",
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment