go.sys: update package names

Semi-automatic migration from package syscall to package {plan9,windows,unix}.
No builds attempted yet, but this gets a lot of noise behind us so subsequent
CLs will be more concise and easier to follow.
Subsequent CLs will have semantic content.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/121520043
This commit is contained in:
Rob Pike
2014-08-11 15:58:26 -07:00
parent 20acc5cf31
commit 8442dd2c63
214 changed files with 372 additions and 825 deletions
+1 -1
View File
@@ -3,5 +3,5 @@
// license that can be found in the LICENSE file.
//
// System calls for 386, Windows are implemented in ../runtime/syscall_windows.goc
// System calls for 386, Windows are implemented in runtime/syscall_windows.goc
//
+1 -1
View File
@@ -3,5 +3,5 @@
// license that can be found in the LICENSE file.
//
// System calls for amd64, Windows are implemented in ../runtime/syscall_windows.goc
// System calls for amd64, Windows are implemented in runtime/syscall_windows.goc
//
+6 -6
View File
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package syscall
package windows
import (
"sync"
@@ -19,14 +19,14 @@ type DLLError struct {
func (e *DLLError) Error() string { return e.Msg }
// Implemented in ../runtime/syscall_windows.goc.
// Implemented in runtime/syscall_windows.goc.
func Syscall(trap, nargs, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
func Syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
func Syscall9(trap, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno)
func Syscall12(trap, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12 uintptr) (r1, r2 uintptr, err Errno)
func Syscall15(trap, nargs, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2 uintptr, err Errno)
func loadlibrary(filename *uint16) (handle uintptr, err Errno)
func getprocaddress(handle uintptr, procname *uint8) (proc uintptr, err Errno)
func loadlibrary(filename *uint16) (handle uintptr, err Errno) // TODO: must be exported.
func getprocaddress(handle uintptr, procname *uint8) (proc uintptr, err Errno) // TODO: must be exported.
// A DLL implements access to a single DLL.
type DLL struct {
@@ -120,7 +120,7 @@ func (p *Proc) Addr() uintptr {
// The returned error is always non-nil, constructed from the result of GetLastError.
// Callers must inspect the primary return value to decide whether an error occurred
// (according to the semantics of the specific function being called) before consulting
// the error. The error will be guaranteed to contain syscall.Errno.
// the error. The error will be guaranteed to contain windows.Errno.
func (p *Proc) Call(a ...uintptr) (r1, r2 uintptr, lastErr error) {
switch len(a) {
case 0:
@@ -272,7 +272,7 @@ func (p *LazyProc) Addr() uintptr {
// The returned error is always non-nil, constructed from the result of GetLastError.
// Callers must inspect the primary return value to decide whether an error occurred
// (according to the semantics of the specific function being called) before consulting
// the error. The error will be guaranteed to contain syscall.Errno.
// the error. The error will be guaranteed to contain windows.Errno.
func (p *LazyProc) Call(a ...uintptr) (r1, r2 uintptr, lastErr error) {
p.mustFind()
return p.proc.Call(a...)
+1 -1
View File
@@ -4,7 +4,7 @@
// Windows environment variables.
package syscall
package windows
import (
"unicode/utf16"
+1 -1
View File
@@ -4,7 +4,7 @@
// Fork, exec, wait, etc.
package syscall
package windows
import (
"sync"
+1 -126
View File
@@ -3,7 +3,7 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# The syscall package provides access to the raw system call
# The windows package provides access to the raw system call
# interface of the underlying operating system. Porting Go to
# a new architecture/operating system combination requires
# some manual effort, though there are tools that automate
@@ -112,122 +112,6 @@ _* | *_ | _)
echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
exit 1
;;
darwin_386)
mkerrors="$mkerrors -m32"
mksyscall="./mksyscall.pl -l32"
mksysnum="./mksysnum_darwin.pl /usr/include/sys/syscall.h"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
darwin_amd64)
mkerrors="$mkerrors -m64"
mksysnum="./mksysnum_darwin.pl /usr/include/sys/syscall.h"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
dragonfly_386)
mkerrors="$mkerrors -m32"
mksyscall="./mksyscall.pl -l32 -dragonfly"
mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
dragonfly_amd64)
mkerrors="$mkerrors -m64"
mksyscall="./mksyscall.pl -dragonfly"
mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
freebsd_386)
mkerrors="$mkerrors -m32"
mksyscall="./mksyscall.pl -l32"
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
freebsd_amd64)
mkerrors="$mkerrors -m64"
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
freebsd_arm)
mkerrors="$mkerrors"
mksyscall="./mksyscall.pl -l32 -arm"
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
# Let the type of C char be singed for making the bare syscall
# API consistent across over platforms.
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
;;
linux_386)
mkerrors="$mkerrors -m32"
mksyscall="./mksyscall.pl -l32"
mksysnum="./mksysnum_linux.pl /usr/include/asm/unistd_32.h"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
linux_amd64)
unistd_h=$(ls -1 /usr/include/asm/unistd_64.h /usr/include/x86_64-linux-gnu/asm/unistd_64.h 2>/dev/null | head -1)
if [ "$unistd_h" = "" ]; then
echo >&2 cannot find unistd_64.h
exit 1
fi
mkerrors="$mkerrors -m64"
mksysnum="./mksysnum_linux.pl $unistd_h"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
linux_arm)
mkerrors="$mkerrors"
mksyscall="./mksyscall.pl -l32 -arm"
mksysnum="curl -s 'http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/arch/arm/include/uapi/asm/unistd.h' | ./mksysnum_linux.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
nacl_386)
mkerrors=""
mksyscall="./mksyscall.pl -l32 -nacl"
mksysnum=""
mktypes=""
;;
nacl_amd64p32)
mkerrors=""
mksyscall="./mksyscall.pl -nacl"
mksysnum=""
mktypes=""
;;
netbsd_386)
mkerrors="$mkerrors -m32"
mksyscall="./mksyscall.pl -l32 -netbsd"
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
netbsd_amd64)
mkerrors="$mkerrors -m64"
mksyscall="./mksyscall.pl -netbsd"
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
openbsd_386)
mkerrors="$mkerrors -m32"
mksyscall="./mksyscall.pl -l32 -openbsd"
mksysctl="./mksysctl_openbsd.pl"
zsysctl="zsysctl_openbsd.go"
mksysnum="curl -s 'http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
openbsd_amd64)
mkerrors="$mkerrors -m64"
mksyscall="./mksyscall.pl -openbsd"
mksysctl="./mksysctl_openbsd.pl"
zsysctl="zsysctl_openbsd.go"
mksysnum="curl -s 'http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
plan9_386)
mkerrors=
mksyscall="./mksyscall.pl -l32 -plan9"
mksysnum="./mksysnum_plan9.sh /n/sources/plan9/sys/src/libc/9syscall/sys.h"
mktypes="XXX"
;;
solaris_amd64)
mksyscall="./mksyscall_solaris.pl"
mkerrors="$mkerrors -m64"
mksysnum=
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
windows_*)
mksyscall=
mkerrors=
@@ -247,15 +131,6 @@ esac
echo "./mksyscall_windows syscall_windows.go security_windows.go syscall_$GOOSARCH.go |gofmt >zsyscall_$GOOSARCH.go"
echo "rm -f ./mksyscall_windows"
;;
*)
syscall_goos="syscall_$GOOS.go"
case "$GOOS" in
darwin | dragonfly | freebsd | netbsd | openbsd)
syscall_goos="syscall_bsd.go $syscall_goos"
;;
esac
if [ -n "$mksyscall" ]; then echo "$mksyscall $syscall_goos syscall_$GOOSARCH.go |gofmt >zsyscall_$GOOSARCH.go"; fi
;;
esac
if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
+2 -2
View File
@@ -4,7 +4,7 @@
# license that can be found in the LICENSE file.
# This program reads a file containing function prototypes
# (like syscall_darwin.go) and generates system call bodies.
# (like syscall_windows.go) and generates system call bodies.
# The prototypes are marked by lines beginning with "//sys"
# and read like func declarations if //sys is replaced by func, but:
# * The parameter lists must give a name for each argument.
@@ -304,7 +304,7 @@ print <<EOF;
// $cmdline
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
package syscall
package windows
import "unsafe"
+14 -14
View File
@@ -69,11 +69,11 @@ func packagename() string {
return packageName
}
func syscalldot() string {
if packageName == "syscall" {
func windowsdot() string {
if packageName == "windows" {
return ""
}
return "syscall."
return "windows."
}
// Param is function parameter
@@ -265,7 +265,7 @@ func (r *Rets) useLongHandleErrorCode(retvar string) string {
if r.FailCond != "" {
cond = strings.Replace(r.FailCond, "failretval", retvar, 1)
}
return fmt.Sprintf(code, cond, syscalldot())
return fmt.Sprintf(code, cond, windowsdot())
}
// SetErrorCode returns source code that sets return parameters.
@@ -280,7 +280,7 @@ func (r *Rets) SetErrorCode() string {
return r.useLongHandleErrorCode("r1")
}
if r.Type == "error" {
return fmt.Sprintf(code, r.Name, syscalldot())
return fmt.Sprintf(code, r.Name, windowsdot())
}
s := ""
switch {
@@ -297,7 +297,7 @@ func (r *Rets) SetErrorCode() string {
return s + "\n\t" + r.useLongHandleErrorCode(r.Name)
}
// Fn describes syscall function.
// Fn describes a syscall function.
type Fn struct {
Name string
Params []*Param
@@ -493,9 +493,9 @@ func (f *Fn) SyscallParamCount() int {
func (f *Fn) Syscall() string {
c := f.SyscallParamCount()
if c == 3 {
return syscalldot() + "Syscall"
return windowsdot() + "Syscall"
}
return syscalldot() + "Syscall" + strconv.Itoa(c)
return windowsdot() + "Syscall" + strconv.Itoa(c)
}
// SyscallParamList returns source code for SyscallX parameters for function f.
@@ -520,9 +520,9 @@ func (f *Fn) IsUTF16() bool {
// StrconvFunc returns name of Go string to OS string function for f.
func (f *Fn) StrconvFunc() string {
if f.IsUTF16() {
return syscalldot() + "UTF16PtrFromString"
return windowsdot() + "UTF16PtrFromString"
}
return syscalldot() + "BytePtrFromString"
return windowsdot() + "BytePtrFromString"
}
// StrconvType returns Go type name used for OS string for f.
@@ -619,7 +619,7 @@ func (src *Source) ParseFile(path string) error {
// Generate output source file from a source set src.
func (src *Source) Generate(w io.Writer) error {
funcMap := template.FuncMap{
"syscalldot": syscalldot,
"windowsdot": windowsdot,
"packagename": packagename,
}
t := template.Must(template.New("main").Funcs(funcMap).Parse(srcTemplate))
@@ -660,8 +660,8 @@ const srcTemplate = `
package {{packagename}}
import "unsafe"{{if syscalldot}}
import "syscall"{{end}}
import "unsafe"{{if windowsdot}}
import "windows"{{end}}
var (
{{template "dlls" .}}
@@ -671,7 +671,7 @@ var (
{{/* help functions */}}
{{define "dlls"}}{{range .DLLs}} mod{{.}} = {{syscalldot}}NewLazyDLL("{{.}}.dll")
{{define "dlls"}}{{range .DLLs}} mod{{.}} = {{windowsdot}}NewLazyDLL("{{.}}.dll")
{{end}}{{end}}
{{define "funcnames"}}{{range .Funcs}} proc{{.DLLFuncName}} = mod{{.DLLName}}.NewProc("{{.DLLFuncName}}")
+1 -1
View File
@@ -4,7 +4,7 @@
// +build race
package syscall
package windows
import (
"runtime"
+1 -1
View File
@@ -4,7 +4,7 @@
// +build !race
package syscall
package windows
import (
"unsafe"
+1 -1
View File
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package syscall
package windows
import (
"unsafe"
+1 -1
View File
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package syscall
package windows
func itoa(val int) string { // do it here rather than with fmt to avoid dependency
if val < 0 {
+7 -7
View File
@@ -2,22 +2,22 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package syscall contains an interface to the low-level operating system
// primitives. The details vary depending on the underlying system, and
// by default, godoc will display the syscall documentation for the current
// Package windows contains an interface to the low-level operating system
// primitives. OS details vary depending on the underlying system, and
// by default, godoc will display the OS-specific documentation for the current
// system. If you want godoc to display syscall documentation for another
// system, set $GOOS and $GOARCH to the desired system. For example, if
// you want to view documentation for freebsd/arm on linux/amd64, set $GOOS
// to freebsd and $GOARCH to arm.
// The primary use of syscall is inside other packages that provide a more
// The primary use of this package is inside other packages that provide a more
// portable interface to the system, such as "os", "time" and "net". Use
// those packages rather than this one if you can.
// For details of the functions and data types in this package consult
// the manuals for the appropriate operating system.
// These calls return err == nil to indicate success; otherwise
// err is an operating system error describing the failure.
// On most systems, that error has type syscall.Errno.
package syscall
// That error has type windows.Errno.
package windows
// StringByteSlice is deprecated. Use ByteSliceFromString instead.
// If s contains a NUL byte this function panics instead of
@@ -25,7 +25,7 @@ package syscall
func StringByteSlice(s string) []byte {
a, err := ByteSliceFromString(s)
if err != nil {
panic("syscall: string with NUL passed to StringByteSlice")
panic("windows: string with NUL passed to StringByteSlice")
}
return a
}
+4 -4
View File
@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package syscall_test
package windows_test
import (
"syscall"
"testing"
"windows"
)
func testSetGetenv(t *testing.T, key, value string) {
err := syscall.Setenv(key, value)
err := windows.Setenv(key, value)
if err != nil {
t.Fatalf("Setenv failed to set %q: %v", value, err)
}
newvalue, found := syscall.Getenv(key)
newvalue, found := windows.Getenv(key)
if !found {
t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value)
}
+4 -4
View File
@@ -4,7 +4,7 @@
// Windows system calls.
package syscall
package windows
import (
errorspkg "errors"
@@ -23,7 +23,7 @@ const InvalidHandle = ^Handle(0)
func StringToUTF16(s string) []uint16 {
a, err := UTF16FromString(s)
if err != nil {
panic("syscall: string with NUL passed to StringToUTF16")
panic("windows: string with NUL passed to StringToUTF16")
}
return a
}
@@ -108,7 +108,7 @@ func (e Errno) Timeout() bool {
// Converts a Go function to a function pointer conforming
// to the stdcall or cdecl calling convention. This is useful when
// interoperating with Windows code requiring callbacks.
// Implemented in ../runtime/syscall_windows.goc
// Implemented in runtime/syscall_windows.goc
func NewCallback(fn interface{}) uintptr
func NewCallbackCDecl(fn interface{}) uintptr
@@ -816,7 +816,7 @@ func (w WaitStatus) Signaled() bool { return false }
func (w WaitStatus) TrapCause() int { return -1 }
// Timespec is an invented structure on Windows, but here for
// consistency with the syscall package for other operating systems.
// consistency with the corresponding package for other operating systems.
type Timespec struct {
Sec int64
Nsec int64
+1 -1
View File
@@ -2,4 +2,4 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package syscall
package windows
+1 -1
View File
@@ -2,4 +2,4 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package syscall
package windows
+10 -10
View File
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package syscall_test
package windows_test
import (
"io/ioutil"
"os"
"path/filepath"
"syscall"
"testing"
"windows"
)
func TestWin32finddata(t *testing.T) {
@@ -27,7 +27,7 @@ func TestWin32finddata(t *testing.T) {
f.Close()
type X struct {
fd syscall.Win32finddata
fd windows.Win32finddata
got byte
pad [10]byte // to protect ourselves
@@ -35,12 +35,12 @@ func TestWin32finddata(t *testing.T) {
var want byte = 2 // it is unlikely to have this character in the filename
x := X{got: want}
pathp, _ := syscall.UTF16PtrFromString(path)
h, err := syscall.FindFirstFile(pathp, &(x.fd))
pathp, _ := windows.UTF16PtrFromString(path)
h, err := windows.FindFirstFile(pathp, &(x.fd))
if err != nil {
t.Fatalf("FindFirstFile failed: %v", err)
}
err = syscall.FindClose(h)
err = windows.FindClose(h)
if err != nil {
t.Fatalf("FindClose failed: %v", err)
}
@@ -55,16 +55,16 @@ func abort(funcname string, err error) {
}
func ExampleLoadLibrary() {
h, err := syscall.LoadLibrary("kernel32.dll")
h, err := windows.LoadLibrary("kernel32.dll")
if err != nil {
abort("LoadLibrary", err)
}
defer syscall.FreeLibrary(h)
proc, err := syscall.GetProcAddress(h, "GetVersion")
defer windows.FreeLibrary(h)
proc, err := windows.GetProcAddress(h, "GetVersion")
if err != nil {
abort("GetProcAddress", err)
}
r, _, _ := syscall.Syscall(uintptr(proc), 0, 0, 0, 0)
r, _, _ := windows.Syscall(uintptr(proc), 0, 0, 0, 0)
major := byte(r)
minor := uint8(r >> 8)
build := uint16(r >> 16)
+1 -1
View File
@@ -1,7 +1,7 @@
// mkerrors_windows.sh -m32
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
package syscall
package windows
// Go names for Windows errors.
const (
+1 -1
View File
@@ -2,4 +2,4 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package syscall
package windows
+1 -1
View File
@@ -2,4 +2,4 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package syscall
package windows
+1 -1
View File
@@ -1,7 +1,7 @@
// go build mksyscall_windows.go && ./mksyscall_windows syscall_windows.go security_windows.go syscall_windows_386.go
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
package syscall
package windows
import "unsafe"
+1 -1
View File
@@ -1,7 +1,7 @@
// go build mksyscall_windows.go && ./mksyscall_windows syscall_windows.go security_windows.go syscall_windows_amd64.go
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
package syscall
package windows
import "unsafe"
+1 -1
View File
@@ -1,3 +1,3 @@
// nothing to see here
package syscall
package windows
+1 -1
View File
@@ -1,3 +1,3 @@
// nothing to see here
package syscall
package windows
+1 -1
View File
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package syscall
package windows
const (
// Windows errors.
+1 -1
View File
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package syscall
package windows
type WSAData struct {
Version uint16
+1 -1
View File
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package syscall
package windows
type WSAData struct {
Version uint16