From 5fa6721a311f1a4a71cf88502c44537e519b4787 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Fri, 8 Feb 2013 11:58:24 -0500 Subject: [PATCH] exp/ssa/interp: fix MS Windows breakage. syscall.{Kill,Write} are not portable to MS Windows, so we disable them for now. R=iant, rsc CC=golang-dev https://golang.org/cl/7312066 --- src/pkg/exp/ssa/interp/external.go | 24 +++------------- src/pkg/exp/ssa/interp/external_unix.go | 32 ++++++++++++++++++++++ src/pkg/exp/ssa/interp/external_windows.go | 19 +++++++++++++ 3 files changed, 55 insertions(+), 20 deletions(-) create mode 100644 src/pkg/exp/ssa/interp/external_unix.go create mode 100644 src/pkg/exp/ssa/interp/external_windows.go diff --git a/src/pkg/exp/ssa/interp/external.go b/src/pkg/exp/ssa/interp/external.go index e67ae5ee65..39c5fd33ba 100644 --- a/src/pkg/exp/ssa/interp/external.go +++ b/src/pkg/exp/ssa/interp/external.go @@ -1,3 +1,7 @@ +// Copyright 2013 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 interp // Emulated functions that we cannot interpret because they are @@ -173,26 +177,6 @@ func extÛ°syscallÛ°Getpid(fn *ssa.Function, args []value, slots []value) value { return syscall.Getpid() } -func extÛ°syscallÛ°Kill(fn *ssa.Function, args []value, slots []value) value { - // We could emulate syscall.Syscall but it's more effort. - err := syscall.Kill(args[0].(int), syscall.Signal(args[1].(int))) - err = err // TODO(adonovan): fix: adapt concrete err to interpreted iface (e.g. call interpreted errors.New) - return iface{} -} - -func extÛ°syscallÛ°Write(fn *ssa.Function, args []value, slots []value) value { - // We could emulate syscall.Syscall but it's more effort. - p := args[1].([]value) - b := make([]byte, 0, len(p)) - for i := range p { - b = append(b, p[i].(byte)) - } - n, _ := syscall.Write(args[0].(int), b) - err := iface{} // TODO(adonovan): fix: adapt concrete err to interpreted iface. - return tuple{n, err} - -} - // The set of remaining native functions we need to implement (as needed): // bytes/bytes.go:42:func Equal(a, b []byte) bool diff --git a/src/pkg/exp/ssa/interp/external_unix.go b/src/pkg/exp/ssa/interp/external_unix.go new file mode 100644 index 0000000000..114a0f3367 --- /dev/null +++ b/src/pkg/exp/ssa/interp/external_unix.go @@ -0,0 +1,32 @@ +// Copyright 2013 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. + +// +build !windows,!plan9 + +package interp + +import ( + "exp/ssa" + "syscall" +) + +func extÛ°syscallÛ°Kill(fn *ssa.Function, args []value, slots []value) value { + // We could emulate syscall.Syscall but it's more effort. + err := syscall.Kill(args[0].(int), syscall.Signal(args[1].(int))) + err = err // TODO(adonovan): fix: adapt concrete err to interpreted iface (e.g. call interpreted errors.New) + return iface{} +} + +func extÛ°syscallÛ°Write(fn *ssa.Function, args []value, slots []value) value { + // We could emulate syscall.Syscall but it's more effort. + p := args[1].([]value) + b := make([]byte, 0, len(p)) + for i := range p { + b = append(b, p[i].(byte)) + } + n, _ := syscall.Write(args[0].(int), b) + err := iface{} // TODO(adonovan): fix: adapt concrete err to interpreted iface. + return tuple{n, err} + +} diff --git a/src/pkg/exp/ssa/interp/external_windows.go b/src/pkg/exp/ssa/interp/external_windows.go new file mode 100644 index 0000000000..cb86d83c49 --- /dev/null +++ b/src/pkg/exp/ssa/interp/external_windows.go @@ -0,0 +1,19 @@ +// Copyright 2013 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. + +// +build windows plan9 + +package interp + +import ( + "exp/ssa" +) + +func extÛ°syscallÛ°Kill(fn *ssa.Function, args []value, slots []value) value { + panic("syscall.Kill not yet implemented") +} + +func extÛ°syscallÛ°Write(fn *ssa.Function, args []value, slots []value) value { + panic("syscall.Write not yet implemented") +} -- 2.48.1