diff options
Diffstat (limited to 'gcc-4.8.1/libgo/go/syscall')
66 files changed, 0 insertions, 6455 deletions
diff --git a/gcc-4.8.1/libgo/go/syscall/bpf_bsd.go b/gcc-4.8.1/libgo/go/syscall/bpf_bsd.go deleted file mode 100644 index f98036c42..000000000 --- a/gcc-4.8.1/libgo/go/syscall/bpf_bsd.go +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright 2011 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 darwin freebsd netbsd openbsd - -// Berkeley packet filter for BSD variants - -package syscall - -import ( - "unsafe" -) - -func BpfStmt(code, k int) *BpfInsn { - return &BpfInsn{Code: uint16(code), K: uint32(k)} -} - -func BpfJump(code, k, jt, jf int) *BpfInsn { - return &BpfInsn{Code: uint16(code), Jt: uint8(jt), Jf: uint8(jf), K: uint32(k)} -} - -func BpfBuflen(fd int) (int, error) { - var l int - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCGBLEN, uintptr(unsafe.Pointer(&l))) - if err != 0 { - return 0, Errno(err) - } - return l, nil -} - -func SetBpfBuflen(fd, l int) (int, error) { - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCSBLEN, uintptr(unsafe.Pointer(&l))) - if err != 0 { - return 0, Errno(err) - } - return l, nil -} - -func BpfDatalink(fd int) (int, error) { - var t int - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCGDLT, uintptr(unsafe.Pointer(&t))) - if err != 0 { - return 0, Errno(err) - } - return t, nil -} - -func SetBpfDatalink(fd, t int) (int, error) { - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCSDLT, uintptr(unsafe.Pointer(&t))) - if err != 0 { - return 0, Errno(err) - } - return t, nil -} - -func SetBpfPromisc(fd, m int) error { - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCPROMISC, uintptr(unsafe.Pointer(&m))) - if err != 0 { - return Errno(err) - } - return nil -} - -func FlushBpf(fd int) error { - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCFLUSH, 0) - if err != 0 { - return Errno(err) - } - return nil -} - -type ivalue struct { - name [IFNAMSIZ]byte - value int16 -} - -func BpfInterface(fd int, name string) (string, error) { - var iv ivalue - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCGETIF, uintptr(unsafe.Pointer(&iv))) - if err != 0 { - return "", Errno(err) - } - return name, nil -} - -func SetBpfInterface(fd int, name string) error { - var iv ivalue - copy(iv.name[:], []byte(name)) - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCSETIF, uintptr(unsafe.Pointer(&iv))) - if err != 0 { - return Errno(err) - } - return nil -} - -func BpfTimeout(fd int) (*Timeval, error) { - var tv Timeval - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCGRTIMEOUT, uintptr(unsafe.Pointer(&tv))) - if err != 0 { - return nil, Errno(err) - } - return &tv, nil -} - -func SetBpfTimeout(fd int, tv *Timeval) error { - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCSRTIMEOUT, uintptr(unsafe.Pointer(tv))) - if err != 0 { - return Errno(err) - } - return nil -} - -func BpfStats(fd int) (*BpfStat, error) { - var s BpfStat - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCGSTATS, uintptr(unsafe.Pointer(&s))) - if err != 0 { - return nil, Errno(err) - } - return &s, nil -} - -func SetBpfImmediate(fd, m int) error { - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCIMMEDIATE, uintptr(unsafe.Pointer(&m))) - if err != 0 { - return Errno(err) - } - return nil -} - -func SetBpf(fd int, i []BpfInsn) error { - var p BpfProgram - p.Len = uint32(len(i)) - p.Insns = (*BpfInsn)(unsafe.Pointer(&i[0])) - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCSETF, uintptr(unsafe.Pointer(&p))) - if err != 0 { - return Errno(err) - } - return nil -} - -func CheckBpfVersion(fd int) error { - var v BpfVersion - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCVERSION, uintptr(unsafe.Pointer(&v))) - if err != 0 { - return Errno(err) - } - if v.Major != BPF_MAJOR_VERSION || v.Minor != BPF_MINOR_VERSION { - return EINVAL - } - return nil -} - -func BpfHeadercmpl(fd int) (int, error) { - var f int - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCGHDRCMPLT, uintptr(unsafe.Pointer(&f))) - if err != 0 { - return 0, Errno(err) - } - return f, nil -} - -func SetBpfHeadercmpl(fd, f int) error { - _, _, err := Syscall(SYS_IOCTL, uintptr(fd), BIOCSHDRCMPLT, uintptr(unsafe.Pointer(&f))) - if err != 0 { - return Errno(err) - } - return nil -} diff --git a/gcc-4.8.1/libgo/go/syscall/creds_test.go b/gcc-4.8.1/libgo/go/syscall/creds_test.go deleted file mode 100644 index b1894c66b..000000000 --- a/gcc-4.8.1/libgo/go/syscall/creds_test.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2012 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 linux - -package syscall_test - -import ( - "bytes" - "net" - "os" - "syscall" - "testing" -) - -// TestSCMCredentials tests the sending and receiving of credentials -// (PID, UID, GID) in an ancillary message between two UNIX -// sockets. The SO_PASSCRED socket option is enabled on the sending -// socket for this to work. -func TestSCMCredentials(t *testing.T) { - fds, err := syscall.Socketpair(syscall.AF_LOCAL, syscall.SOCK_STREAM, 0) - if err != nil { - t.Fatalf("Socketpair: %v", err) - } - defer syscall.Close(fds[0]) - defer syscall.Close(fds[1]) - - err = syscall.SetsockoptInt(fds[0], syscall.SOL_SOCKET, syscall.SO_PASSCRED, 1) - if err != nil { - t.Fatalf("SetsockoptInt: %v", err) - } - - srvFile := os.NewFile(uintptr(fds[0]), "server") - defer srvFile.Close() - srv, err := net.FileConn(srvFile) - if err != nil { - t.Errorf("FileConn: %v", err) - return - } - defer srv.Close() - - cliFile := os.NewFile(uintptr(fds[1]), "client") - defer cliFile.Close() - cli, err := net.FileConn(cliFile) - if err != nil { - t.Errorf("FileConn: %v", err) - return - } - defer cli.Close() - - var ucred syscall.Ucred - if os.Getuid() != 0 { - ucred.Pid = int32(os.Getpid()) - ucred.Uid = 0 - ucred.Gid = 0 - oob := syscall.UnixCredentials(&ucred) - _, _, err := cli.(*net.UnixConn).WriteMsgUnix(nil, oob, nil) - if err.(*net.OpError).Err != syscall.EPERM { - t.Fatalf("WriteMsgUnix failed with %v, want EPERM", err) - } - } - - ucred.Pid = int32(os.Getpid()) - ucred.Uid = uint32(os.Getuid()) - ucred.Gid = uint32(os.Getgid()) - oob := syscall.UnixCredentials(&ucred) - - // this is going to send a dummy byte - n, oobn, err := cli.(*net.UnixConn).WriteMsgUnix(nil, oob, nil) - if err != nil { - t.Fatalf("WriteMsgUnix: %v", err) - } - if n != 0 { - t.Fatalf("WriteMsgUnix n = %d, want 0", n) - } - if oobn != len(oob) { - t.Fatalf("WriteMsgUnix oobn = %d, want %d", oobn, len(oob)) - } - - oob2 := make([]byte, 10*len(oob)) - n, oobn2, flags, _, err := srv.(*net.UnixConn).ReadMsgUnix(nil, oob2) - if err != nil { - t.Fatalf("ReadMsgUnix: %v", err) - } - if flags != 0 { - t.Fatalf("ReadMsgUnix flags = 0x%x, want 0", flags) - } - if n != 1 { - t.Fatalf("ReadMsgUnix n = %d, want 1 (dummy byte)", n) - } - if oobn2 != oobn { - // without SO_PASSCRED set on the socket, ReadMsgUnix will - // return zero oob bytes - t.Fatalf("ReadMsgUnix oobn = %d, want %d", oobn2, oobn) - } - oob2 = oob2[:oobn2] - if !bytes.Equal(oob, oob2) { - t.Fatal("ReadMsgUnix oob bytes don't match") - } - - scm, err := syscall.ParseSocketControlMessage(oob2) - if err != nil { - t.Fatalf("ParseSocketControlMessage: %v", err) - } - newUcred, err := syscall.ParseUnixCredentials(&scm[0]) - if err != nil { - t.Fatalf("ParseUnixCredentials: %v", err) - } - if *newUcred != ucred { - t.Fatalf("ParseUnixCredentials = %+v, want %+v", newUcred, ucred) - } -} diff --git a/gcc-4.8.1/libgo/go/syscall/dir_plan9.go b/gcc-4.8.1/libgo/go/syscall/dir_plan9.go deleted file mode 100644 index eee8be44a..000000000 --- a/gcc-4.8.1/libgo/go/syscall/dir_plan9.go +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright 2012 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. - -// Plan 9 directory marshalling. See intro(5). - -package syscall - -import "errors" - -var ( - ErrShortStat = errors.New("stat buffer too short") - ErrBadStat = errors.New("malformed stat buffer") -) - -// A Qid represents a 9P server's unique identification for a file. -type Qid struct { - Path uint64 // the file server's unique identification for the file - Vers uint32 // version number for given Path - Type uint8 // the type of the file (syscall.QTDIR for example) -} - -// A Dir contains the metadata for a file. -type Dir struct { - // system-modified data - Type uint16 // server type - Dev uint32 // server subtype - - // file data - Qid Qid // unique id from server - Mode uint32 // permissions - Atime uint32 // last read time - Mtime uint32 // last write time - Length int64 // file length - Name string // last element of path - Uid string // owner name - Gid string // group name - Muid string // last modifier name -} - -var nullDir = Dir{ - Type: ^uint16(0), - Dev: ^uint32(0), - Qid: Qid{ - Path: ^uint64(0), - Vers: ^uint32(0), - Type: ^uint8(0), - }, - Mode: ^uint32(0), - Atime: ^uint32(0), - Mtime: ^uint32(0), - Length: ^int64(0), -} - -// Null assigns special "don't touch" values to members of d to -// avoid modifiying them during syscall.Wstat. -func (d *Dir) Null() { *d = nullDir } - -// Marshal encodes a 9P stat message corresponding to d into b -// -// If there isn't enough space in b for a stat message, ErrShortStat is returned. -func (d *Dir) Marshal(b []byte) (n int, err error) { - n = STATFIXLEN + len(d.Name) + len(d.Uid) + len(d.Gid) + len(d.Muid) - if n > len(b) { - return n, ErrShortStat - } - - b = pbit16(b, uint16(n)-2) - b = pbit16(b, d.Type) - b = pbit32(b, d.Dev) - b = pbit64(b, d.Qid.Path) - b = pbit32(b, d.Qid.Vers) - b = pbit8(b, d.Qid.Type) - b = pbit32(b, d.Mode) - b = pbit32(b, d.Atime) - b = pbit32(b, d.Mtime) - b = pbit64(b, uint64(d.Length)) - b = pstring(b, d.Name) - b = pstring(b, d.Uid) - b = pstring(b, d.Gid) - b = pstring(b, d.Muid) - - return n, nil -} - -// UnmarshalDir decodes a single 9P stat message from b and returns the resulting Dir. -// -// If b is too small to hold a valid stat message, ErrShortStat is returned. -// -// If the stat message itself is invalid, ErrBadStat is returned. -func UnmarshalDir(b []byte) (*Dir, error) { - if len(b) < STATFIXLEN { - return nil, ErrShortStat - } - size, buf := gbit16(b) - if len(b) != int(size)+2 { - return nil, ErrBadStat - } - b = buf - - var d Dir - d.Type, b = gbit16(b) - d.Dev, b = gbit32(b) - d.Qid.Path, b = gbit64(b) - d.Qid.Vers, b = gbit32(b) - d.Qid.Type, b = gbit8(b) - d.Mode, b = gbit32(b) - d.Atime, b = gbit32(b) - d.Mtime, b = gbit32(b) - - n, b := gbit64(b) - d.Length = int64(n) - - var ok bool - if d.Name, b, ok = gstring(b); !ok { - return nil, ErrBadStat - } - if d.Uid, b, ok = gstring(b); !ok { - return nil, ErrBadStat - } - if d.Gid, b, ok = gstring(b); !ok { - return nil, ErrBadStat - } - if d.Muid, b, ok = gstring(b); !ok { - return nil, ErrBadStat - } - - return &d, nil -} - -// pbit8 copies the 8-bit number v to b and returns the remaining slice of b. -func pbit8(b []byte, v uint8) []byte { - b[0] = byte(v) - return b[1:] -} - -// pbit16 copies the 16-bit number v to b in little-endian order and returns the remaining slice of b. -func pbit16(b []byte, v uint16) []byte { - b[0] = byte(v) - b[1] = byte(v >> 8) - return b[2:] -} - -// pbit32 copies the 32-bit number v to b in little-endian order and returns the remaining slice of b. -func pbit32(b []byte, v uint32) []byte { - b[0] = byte(v) - b[1] = byte(v >> 8) - b[2] = byte(v >> 16) - b[3] = byte(v >> 24) - return b[4:] -} - -// pbit64 copies the 64-bit number v to b in little-endian order and returns the remaining slice of b. -func pbit64(b []byte, v uint64) []byte { - b[0] = byte(v) - b[1] = byte(v >> 8) - b[2] = byte(v >> 16) - b[3] = byte(v >> 24) - b[4] = byte(v >> 32) - b[5] = byte(v >> 40) - b[6] = byte(v >> 48) - b[7] = byte(v >> 56) - return b[8:] -} - -// pstring copies the string s to b, prepending it with a 16-bit length in little-endian order, and -// returning the remaining slice of b.. -func pstring(b []byte, s string) []byte { - b = pbit16(b, uint16(len(s))) - n := copy(b, s) - return b[n:] -} - -// gbit8 reads an 8-bit number from b and returns it with the remaining slice of b. -func gbit8(b []byte) (uint8, []byte) { - return uint8(b[0]), b[1:] -} - -// gbit16 reads a 16-bit number in little-endian order from b and returns it with the remaining slice of b. -func gbit16(b []byte) (uint16, []byte) { - return uint16(b[0]) | uint16(b[1])<<8, b[2:] -} - -// gbit32 reads a 32-bit number in little-endian order from b and returns it with the remaining slice of b. -func gbit32(b []byte) (uint32, []byte) { - return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24, b[4:] -} - -// gbit64 reads a 64-bit number in little-endian order from b and returns it with the remaining slice of b. -func gbit64(b []byte) (uint64, []byte) { - lo := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 - hi := uint32(b[4]) | uint32(b[5])<<8 | uint32(b[6])<<16 | uint32(b[7])<<24 - return uint64(lo) | uint64(hi)<<32, b[8:] -} - -// gstring reads a string from b, prefixed with a 16-bit length in little-endian order. -// It returns the string with the remaining slice of b and a boolean. If the length is -// greater than the number of bytes in b, the boolean will be false. -func gstring(b []byte) (string, []byte, bool) { - n, b := gbit16(b) - if int(n) > len(b) { - return "", b, false - } - return string(b[:n]), b[n:], true -} diff --git a/gcc-4.8.1/libgo/go/syscall/env_plan9.go b/gcc-4.8.1/libgo/go/syscall/env_plan9.go deleted file mode 100644 index 0f89aa9ee..000000000 --- a/gcc-4.8.1/libgo/go/syscall/env_plan9.go +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright 2011 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. - -// Plan 9 environment variables. - -package syscall - -import ( - "errors" - "sync" -) - -var ( - // envOnce guards copyenv, which populates env. - envOnce sync.Once - - // envLock guards env. - envLock sync.RWMutex - - // env maps from an environment variable to its value. - env = make(map[string]string) - - errZeroLengthKey = errors.New("zero length key") - errShortWrite = errors.New("i/o count too small") -) - -func readenv(key string) (string, error) { - fd, err := Open("/env/"+key, O_RDONLY) - if err != nil { - return "", err - } - defer Close(fd) - l, _ := Seek(fd, 0, 2) - Seek(fd, 0, 0) - buf := make([]byte, l) - n, err := Read(fd, buf) - if err != nil { - return "", err - } - if n > 0 && buf[n-1] == 0 { - buf = buf[:n-1] - } - return string(buf), nil -} - -func writeenv(key, value string) error { - fd, err := Create("/env/"+key, O_RDWR, 0666) - if err != nil { - return err - } - defer Close(fd) - b := []byte(value) - n, err := Write(fd, b) - if err != nil { - return err - } - if n != len(b) { - return errShortWrite - } - return nil -} - -func copyenv() { - fd, err := Open("/env", O_RDONLY) - if err != nil { - return - } - defer Close(fd) - files, err := readdirnames(fd) - if err != nil { - return - } - for _, key := range files { - v, err := readenv(key) - if err != nil { - continue - } - env[key] = v - } -} - -func Getenv(key string) (value string, found bool) { - if len(key) == 0 { - return "", false - } - - envLock.RLock() - defer envLock.RUnlock() - - if v, ok := env[key]; ok { - return v, true - } - v, err := readenv(key) - if err != nil { - return "", false - } - env[key] = v - return v, true -} - -func Setenv(key, value string) error { - if len(key) == 0 { - return errZeroLengthKey - } - - envLock.Lock() - defer envLock.Unlock() - - err := writeenv(key, value) - if err != nil { - return err - } - env[key] = value - return nil -} - -func Clearenv() { - envLock.Lock() - defer envLock.Unlock() - - env = make(map[string]string) - RawSyscall(SYS_RFORK, RFCENVG, 0, 0) -} - -func Environ() []string { - envLock.RLock() - defer envLock.RUnlock() - - envOnce.Do(copyenv) - a := make([]string, len(env)) - i := 0 - for k, v := range env { - a[i] = k + "=" + v - i++ - } - return a -} diff --git a/gcc-4.8.1/libgo/go/syscall/env_unix.go b/gcc-4.8.1/libgo/go/syscall/env_unix.go deleted file mode 100644 index c1a02135f..000000000 --- a/gcc-4.8.1/libgo/go/syscall/env_unix.go +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2010 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 darwin freebsd linux netbsd openbsd - -// Unix environment variables. - -package syscall - -import "sync" - -var ( - // envOnce guards initialization by copyenv, which populates env. - envOnce sync.Once - - // envLock guards env and envs. - envLock sync.RWMutex - - // env maps from an environment variable to its first occurrence in envs. - env map[string]int - - // envs is provided by the runtime. elements are expected to be - // of the form "key=value". - Envs []string -) - -// setenv_c is provided by the runtime, but is a no-op if cgo isn't -// loaded. -func setenv_c(k, v string) - -func copyenv() { - env = make(map[string]int) - for i, s := range Envs { - for j := 0; j < len(s); j++ { - if s[j] == '=' { - key := s[:j] - if _, ok := env[key]; !ok { - env[key] = i - } - break - } - } - } -} - -func Getenv(key string) (value string, found bool) { - envOnce.Do(copyenv) - if len(key) == 0 { - return "", false - } - - envLock.RLock() - defer envLock.RUnlock() - - i, ok := env[key] - if !ok { - return "", false - } - s := Envs[i] - for i := 0; i < len(s); i++ { - if s[i] == '=' { - return s[i+1:], true - } - } - return "", false -} - -func Setenv(key, value string) error { - envOnce.Do(copyenv) - if len(key) == 0 { - return EINVAL - } - - envLock.Lock() - defer envLock.Unlock() - - i, ok := env[key] - kv := key + "=" + value - if ok { - Envs[i] = kv - } else { - i = len(Envs) - Envs = append(Envs, kv) - } - env[key] = i - setenv_c(key, value) - return nil -} - -func Clearenv() { - envOnce.Do(copyenv) // prevent copyenv in Getenv/Setenv - - envLock.Lock() - defer envLock.Unlock() - - env = make(map[string]int) - Envs = []string{} - // TODO(bradfitz): pass through to C -} - -func Environ() []string { - envOnce.Do(copyenv) - envLock.RLock() - defer envLock.RUnlock() - a := make([]string, len(Envs)) - copy(a, Envs) - return a -} diff --git a/gcc-4.8.1/libgo/go/syscall/env_windows.go b/gcc-4.8.1/libgo/go/syscall/env_windows.go deleted file mode 100644 index 39bd5022e..000000000 --- a/gcc-4.8.1/libgo/go/syscall/env_windows.go +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2010 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. - -// Windows environment variables. - -package syscall - -import ( - "unicode/utf16" - "unsafe" -) - -func Getenv(key string) (value string, found bool) { - keyp, err := UTF16PtrFromString(key) - if err != nil { - return "", false - } - b := make([]uint16, 100) - n, e := GetEnvironmentVariable(keyp, &b[0], uint32(len(b))) - if n == 0 && e == ERROR_ENVVAR_NOT_FOUND { - return "", false - } - if n > uint32(len(b)) { - b = make([]uint16, n) - n, e = GetEnvironmentVariable(keyp, &b[0], uint32(len(b))) - if n > uint32(len(b)) { - n = 0 - } - } - if n == 0 { - return "", false - } - return string(utf16.Decode(b[0:n])), true -} - -func Setenv(key, value string) error { - var v *uint16 - var err error - if len(value) > 0 { - v, err = UTF16PtrFromString(value) - if err != nil { - return err - } - } - keyp, err := UTF16PtrFromString(key) - if err != nil { - return err - } - e := SetEnvironmentVariable(keyp, v) - if e != nil { - return e - } - return nil -} - -func Clearenv() { - for _, s := range Environ() { - // Environment variables can begin with = - // so start looking for the separator = at j=1. - // http://blogs.msdn.com/b/oldnewthing/archive/2010/05/06/10008132.aspx - for j := 1; j < len(s); j++ { - if s[j] == '=' { - Setenv(s[0:j], "") - break - } - } - } -} - -func Environ() []string { - s, e := GetEnvironmentStrings() - if e != nil { - return nil - } - defer FreeEnvironmentStrings(s) - r := make([]string, 0, 50) // Empty with room to grow. - for from, i, p := 0, 0, (*[1 << 24]uint16)(unsafe.Pointer(s)); true; i++ { - if p[i] == 0 { - // empty string marks the end - if i <= from { - break - } - r = append(r, string(utf16.Decode(p[from:i]))) - from = i + 1 - } - } - return r -} diff --git a/gcc-4.8.1/libgo/go/syscall/errno.c b/gcc-4.8.1/libgo/go/syscall/errno.c deleted file mode 100644 index 5cdc77304..000000000 --- a/gcc-4.8.1/libgo/go/syscall/errno.c +++ /dev/null @@ -1,27 +0,0 @@ -/* errno.c -- functions for getting and setting errno - - Copyright 2010 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. */ -#include <errno.h> -#include <stdint.h> - -#include "runtime.h" - -/* errno is typically a macro. These functions set - and get errno specific to the libc being used. */ - -uintptr_t GetErrno() __asm__ (GOSYM_PREFIX "syscall.GetErrno"); -void SetErrno(uintptr_t) __asm__ (GOSYM_PREFIX "syscall.SetErrno"); - -uintptr_t -GetErrno() -{ - return (uintptr_t) errno; -} - -void -SetErrno(uintptr_t value) -{ - errno = (int) value; -} diff --git a/gcc-4.8.1/libgo/go/syscall/errstr.go b/gcc-4.8.1/libgo/go/syscall/errstr.go deleted file mode 100644 index aa656ca7c..000000000 --- a/gcc-4.8.1/libgo/go/syscall/errstr.go +++ /dev/null @@ -1,32 +0,0 @@ -// errstr.go -- Error strings. - -// 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 - -//sysnb strerror_r(errnum int, buf []byte) (err Errno) -//strerror_r(errnum _C_int, buf *byte, buflen Size_t) _C_int - -func Errstr(errnum int) string { - for len := 128; ; len *= 2 { - b := make([]byte, len) - errno := strerror_r(errnum, b) - if errno == 0 { - i := 0 - for b[i] != 0 { - i++ - } - // Lowercase first letter: Bad -> bad, but - // STREAM -> STREAM. - if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' { - b[0] += 'a' - 'A' - } - return string(b[:i]) - } - if errno != ERANGE { - return "errstr failure" - } - } -} diff --git a/gcc-4.8.1/libgo/go/syscall/errstr_linux.go b/gcc-4.8.1/libgo/go/syscall/errstr_linux.go deleted file mode 100644 index d10476d3c..000000000 --- a/gcc-4.8.1/libgo/go/syscall/errstr_linux.go +++ /dev/null @@ -1,28 +0,0 @@ -// errstr_rtems.go -- RTEMS specific error strings. - -// Copyright 2010 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 - -import "unsafe" - -//sysnb strerror_r(errnum int, b []byte) (errstr *byte) -//strerror_r(errnum _C_int, b *byte, len Size_t) *byte - -func Errstr(errnum int) string { - a := make([]byte, 128) - p := strerror_r(errnum, a) - b := (*[1000]byte)(unsafe.Pointer(p)) - i := 0 - for b[i] != 0 { - i++ - } - // Lowercase first letter: Bad -> bad, but STREAM -> STREAM. - if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' { - c := b[0] + 'a' - 'A' - return string(c) + string(b[1:i]) - } - return string(b[:i]) -} diff --git a/gcc-4.8.1/libgo/go/syscall/errstr_nor.go b/gcc-4.8.1/libgo/go/syscall/errstr_nor.go deleted file mode 100644 index 796561add..000000000 --- a/gcc-4.8.1/libgo/go/syscall/errstr_nor.go +++ /dev/null @@ -1,41 +0,0 @@ -// errstr.go -- Error strings when there is no strerror_r. - -// Copyright 2011 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 - -import ( - "sync" - "unsafe" -) - -//sysnb strerror(errnum int) (buf *byte) -//strerror(errnum _C_int) *byte - -var errstr_lock sync.Mutex - -func Errstr(errno int) string { - errstr_lock.Lock() - - bp := strerror(errno) - b := (*[1000]byte)(unsafe.Pointer(bp)) - i := 0 - for b[i] != 0 { - i++ - } - - // Lowercase first letter: Bad -> bad, but STREAM -> STREAM. - var s string - if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' { - c := b[0] + 'a' - 'A' - s = string(c) + string(b[1:i]) - } else { - s = string(b[:i]) - } - - errstr_lock.Unlock() - - return s -} diff --git a/gcc-4.8.1/libgo/go/syscall/exec_bsd.go b/gcc-4.8.1/libgo/go/syscall/exec_bsd.go deleted file mode 100644 index c8eed532d..000000000 --- a/gcc-4.8.1/libgo/go/syscall/exec_bsd.go +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright 2011 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 darwin freebsd netbsd openbsd - -package syscall - -import ( - "unsafe" -) - -type SysProcAttr struct { - Chroot string // Chroot. - Credential *Credential // Credential. - Ptrace bool // Enable tracing. - Setsid bool // Create session. - Setpgid bool // Set process group ID to new pid (SYSV setpgrp) - Setctty bool // Set controlling terminal to fd 0 - Noctty bool // Detach fd 0 from controlling terminal -} - -// Fork, dup fd onto 0..len(fd), and exec(argv0, argvv, envv) in child. -// If a dup or exec fails, write the errno error to pipe. -// (Pipe is close-on-exec so if exec succeeds, it will be closed.) -// In the child, this function must not acquire any locks, because -// they might have been locked at the time of the fork. This means -// no rescheduling, no malloc calls, and no new stack segments. -// The calls to RawSyscall are okay because they are assembly -// functions that do not grow the stack. -func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr *ProcAttr, sys *SysProcAttr, pipe int) (pid int, err Errno) { - // Declare all variables at top in case any - // declarations require heap allocation (e.g., err1). - var ( - r1 Pid_t - err1 Errno - nextfd int - i int - ) - - fd := make([]int, len(attr.Files)) - for i, ufd := range attr.Files { - fd[i] = int(ufd) - } - - // About to call fork. - // No more allocation or calls of non-assembly functions. - r1, err1 = raw_fork() - if err1 != 0 { - return 0, err1 - } - - if r1 != 0 { - // parent; return PID - return int(r1), 0 - } - - // Fork succeeded, now in child. - - // Enable tracing if requested. - if sys.Ptrace { - err1 = raw_ptrace(_PTRACE_TRACEME, 0, nil, nil) - if err1 != 0 { - goto childerror - } - } - - // Session ID - if sys.Setsid { - err1 = raw_setsid() - if err1 != 0 { - goto childerror - } - } - - // Set process group - if sys.Setpgid { - err1 = raw_setpgid(0, 0) - if err1 != 0 { - goto childerror - } - } - - // Chroot - if chroot != nil { - err1 = raw_chroot(chroot) - if err1 != 0 { - goto childerror - } - } - - // User and groups - if cred := sys.Credential; cred != nil { - ngroups := len(cred.Groups) - if ngroups == 0 { - err2 := setgroups(0, nil) - if err2 == nil { - err1 = 0 - } else { - err1 = err2.(Errno) - } - } else { - groups := make([]Gid_t, ngroups) - for i, v := range cred.Groups { - groups[i] = Gid_t(v) - } - err2 := setgroups(ngroups, &groups[0]) - if err2 == nil { - err1 = 0 - } else { - err1 = err2.(Errno) - } - } - if err1 != 0 { - goto childerror - } - err2 := Setgid(int(cred.Gid)) - if err2 != nil { - err1 = err2.(Errno) - goto childerror - } - err2 = Setuid(int(cred.Uid)) - if err2 != nil { - err1 = err2.(Errno) - goto childerror - } - } - - // Chdir - if dir != nil { - err1 = raw_chdir(dir) - if err1 != 0 { - goto childerror - } - } - - // Pass 1: look for fd[i] < i and move those up above len(fd) - // so that pass 2 won't stomp on an fd it needs later. - nextfd = int(len(fd)) - if pipe < nextfd { - err1 = raw_dup2(pipe, nextfd) - if err1 != 0 { - goto childerror - } - raw_fcntl(nextfd, F_SETFD, FD_CLOEXEC) - pipe = nextfd - nextfd++ - } - for i = 0; i < len(fd); i++ { - if fd[i] >= 0 && fd[i] < int(i) { - err1 = raw_dup2(fd[i], nextfd) - if err1 != 0 { - goto childerror - } - raw_fcntl(nextfd, F_SETFD, FD_CLOEXEC) - fd[i] = nextfd - nextfd++ - if nextfd == pipe { // don't stomp on pipe - nextfd++ - } - } - } - - // Pass 2: dup fd[i] down onto i. - for i = 0; i < len(fd); i++ { - if fd[i] == -1 { - raw_close(i) - continue - } - if fd[i] == int(i) { - // dup2(i, i) won't clear close-on-exec flag on Linux, - // probably not elsewhere either. - _, err1 = raw_fcntl(fd[i], F_SETFD, 0) - if err1 != 0 { - goto childerror - } - continue - } - // The new fd is created NOT close-on-exec, - // which is exactly what we want. - err1 = raw_dup2(fd[i], i) - if err1 != 0 { - goto childerror - } - } - - // By convention, we don't close-on-exec the fds we are - // started with, so if len(fd) < 3, close 0, 1, 2 as needed. - // Programs that know they inherit fds >= 3 will need - // to set them close-on-exec. - for i = len(fd); i < 3; i++ { - raw_close(i) - } - - // Detach fd 0 from tty - if sys.Noctty { - _, err1 = raw_ioctl(0, TIOCNOTTY, 0) - if err1 != 0 { - goto childerror - } - } - - // Make fd 0 the tty - if sys.Setctty { - _, err1 = raw_ioctl(0, TIOCSCTTY, 0) - if err1 != 0 { - goto childerror - } - } - - // Time to exec. - err1 = raw_execve(argv0, &argv[0], &envv[0]) - -childerror: - // send error code on pipe - raw_write(pipe, (*byte)(unsafe.Pointer(&err1)), int(unsafe.Sizeof(err1))) - for { - raw_exit(253) - } - - // Calling panic is not actually safe, - // but the for loop above won't break - // and this shuts up the compiler. - panic("unreached") -} - -// Try to open a pipe with O_CLOEXEC set on both file descriptors. -func forkExecPipe(p []int) error { - err := Pipe(p) - if err != nil { - return err - } - _, err = fcntl(p[0], F_SETFD, FD_CLOEXEC) - if err != nil { - return err - } - _, err = fcntl(p[1], F_SETFD, FD_CLOEXEC) - return err -} diff --git a/gcc-4.8.1/libgo/go/syscall/exec_linux.go b/gcc-4.8.1/libgo/go/syscall/exec_linux.go deleted file mode 100644 index e29878acb..000000000 --- a/gcc-4.8.1/libgo/go/syscall/exec_linux.go +++ /dev/null @@ -1,269 +0,0 @@ -// Copyright 2011 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 linux - -package syscall - -import ( - "unsafe" -) - -//sysnb raw_prctl(option int, arg2 int, arg3 int, arg4 int, arg5 int) (ret int, err Errno) -//prctl(option _C_int, arg2 _C_long, arg3 _C_long, arg4 _C_long, arg5 _C_long) _C_int - -type SysProcAttr struct { - Chroot string // Chroot. - Credential *Credential // Credential. - Ptrace bool // Enable tracing. - Setsid bool // Create session. - Setpgid bool // Set process group ID to new pid (SYSV setpgrp) - Setctty bool // Set controlling terminal to fd Ctty (only meaningful if Setsid is set) - Noctty bool // Detach fd 0 from controlling terminal - Ctty int // Controlling TTY fd (Linux only) - Pdeathsig Signal // Signal that the process will get when its parent dies (Linux only) -} - -// Fork, dup fd onto 0..len(fd), and exec(argv0, argvv, envv) in child. -// If a dup or exec fails, write the errno error to pipe. -// (Pipe is close-on-exec so if exec succeeds, it will be closed.) -// In the child, this function must not acquire any locks, because -// they might have been locked at the time of the fork. This means -// no rescheduling, no malloc calls, and no new stack segments. -// The calls to RawSyscall are okay because they are assembly -// functions that do not grow the stack. -func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr *ProcAttr, sys *SysProcAttr, pipe int) (pid int, err Errno) { - // Declare all variables at top in case any - // declarations require heap allocation (e.g., err1). - var ( - r1 Pid_t - err1 Errno - nextfd int - i int - ) - - // guard against side effects of shuffling fds below. - fd := make([]int, len(attr.Files)) - for i, ufd := range attr.Files { - fd[i] = int(ufd) - } - - // About to call fork. - // No more allocation or calls of non-assembly functions. - r1, err1 = raw_fork() - if err1 != 0 { - return 0, err1 - } - - if r1 != 0 { - // parent; return PID - return int(r1), 0 - } - - // Fork succeeded, now in child. - - // Parent death signal - if sys.Pdeathsig != 0 { - _, err1 = raw_prctl(PR_SET_PDEATHSIG, int(sys.Pdeathsig), 0, 0, 0) - if err1 != 0 { - goto childerror - } - - // Signal self if parent is already dead. This might cause a - // duplicate signal in rare cases, but it won't matter when - // using SIGKILL. - ppid := Getppid() - if ppid == 1 { - pid = Getpid() - err2 := Kill(pid, sys.Pdeathsig) - if err2 != nil { - err1 = err2.(Errno) - goto childerror - } - } - } - - // Enable tracing if requested. - if sys.Ptrace { - err1 = raw_ptrace(_PTRACE_TRACEME, 0, nil, nil) - if err1 != 0 { - goto childerror - } - } - - // Session ID - if sys.Setsid { - err1 = raw_setsid() - if err1 != 0 { - goto childerror - } - } - - // Set process group - if sys.Setpgid { - err1 = raw_setpgid(0, 0) - if err1 != 0 { - goto childerror - } - } - - // Chroot - if chroot != nil { - err1 = raw_chroot(chroot) - if err1 != 0 { - goto childerror - } - } - - // User and groups - if cred := sys.Credential; cred != nil { - ngroups := len(cred.Groups) - if ngroups == 0 { - err2 := setgroups(0, nil) - if err2 == nil { - err1 = 0 - } else { - err1 = err2.(Errno) - } - } else { - groups := make([]Gid_t, ngroups) - for i, v := range cred.Groups { - groups[i] = Gid_t(v) - } - err2 := setgroups(ngroups, &groups[0]) - if err2 == nil { - err1 = 0 - } else { - err1 = err2.(Errno) - } - } - if err1 != 0 { - goto childerror - } - err2 := Setgid(int(cred.Gid)) - if err2 != nil { - err1 = err2.(Errno) - goto childerror - } - err2 = Setuid(int(cred.Uid)) - if err2 != nil { - err1 = err2.(Errno) - goto childerror - } - } - - // Chdir - if dir != nil { - err1 = raw_chdir(dir) - if err1 != 0 { - goto childerror - } - } - - // Pass 1: look for fd[i] < i and move those up above len(fd) - // so that pass 2 won't stomp on an fd it needs later. - nextfd = int(len(fd)) - if pipe < nextfd { - err1 = raw_dup2(pipe, nextfd) - if err1 != 0 { - goto childerror - } - raw_fcntl(nextfd, F_SETFD, FD_CLOEXEC) - pipe = nextfd - nextfd++ - } - for i = 0; i < len(fd); i++ { - if fd[i] >= 0 && fd[i] < int(i) { - err1 = raw_dup2(fd[i], nextfd) - if err1 != 0 { - goto childerror - } - raw_fcntl(nextfd, F_SETFD, FD_CLOEXEC) - fd[i] = nextfd - nextfd++ - if nextfd == pipe { // don't stomp on pipe - nextfd++ - } - } - } - - // Pass 2: dup fd[i] down onto i. - for i = 0; i < len(fd); i++ { - if fd[i] == -1 { - raw_close(i) - continue - } - if fd[i] == int(i) { - // dup2(i, i) won't clear close-on-exec flag on Linux, - // probably not elsewhere either. - _, err1 = raw_fcntl(fd[i], F_SETFD, 0) - if err1 != 0 { - goto childerror - } - continue - } - // The new fd is created NOT close-on-exec, - // which is exactly what we want. - err1 = raw_dup2(fd[i], i) - if err1 != 0 { - goto childerror - } - } - - // By convention, we don't close-on-exec the fds we are - // started with, so if len(fd) < 3, close 0, 1, 2 as needed. - // Programs that know they inherit fds >= 3 will need - // to set them close-on-exec. - for i = len(fd); i < 3; i++ { - raw_close(i) - } - - // Detach fd 0 from tty - if sys.Noctty { - _, err1 = raw_ioctl(0, TIOCNOTTY, 0) - if err1 != 0 { - goto childerror - } - } - - // Make fd 0 the tty - if sys.Setctty && sys.Ctty >= 0 { - _, err1 = raw_ioctl(0, TIOCSCTTY, sys.Ctty) - if err1 != 0 { - goto childerror - } - } - - // Time to exec. - err1 = raw_execve(argv0, &argv[0], &envv[0]) - -childerror: - // send error code on pipe - raw_write(pipe, (*byte)(unsafe.Pointer(&err1)), int(unsafe.Sizeof(err1))) - for { - raw_exit(253) - } - - // Calling panic is not actually safe, - // but the for loop above won't break - // and this shuts up the compiler. - panic("unreached") -} - -// Try to open a pipe with O_CLOEXEC set on both file descriptors. -func forkExecPipe(p []int) (err error) { - err = Pipe2(p, O_CLOEXEC) - // pipe2 was added in 2.6.27 and our minimum requirement is 2.6.23, so it - // might not be implemented. - if err == ENOSYS { - if err = Pipe(p); err != nil { - return - } - if _, err = fcntl(p[0], F_SETFD, FD_CLOEXEC); err != nil { - return - } - _, err = fcntl(p[1], F_SETFD, FD_CLOEXEC) - } - return -} diff --git a/gcc-4.8.1/libgo/go/syscall/exec_stubs.go b/gcc-4.8.1/libgo/go/syscall/exec_stubs.go deleted file mode 100644 index 35bb17487..000000000 --- a/gcc-4.8.1/libgo/go/syscall/exec_stubs.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2010 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. - -// Stubs for fork, exec and wait. - -package syscall - -func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []int) (pid int, err int) { - return -1, ENOSYS -} - -func Exec(argv0 string, argv []string, envv []string) (err int) { - return ENOSYS -} - -func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) { - return -1, ENOSYS -} - -func (w WaitStatus) Exited() bool { return false } -func (w WaitStatus) Signaled() bool { return false } -func (w WaitStatus) Stopped() bool { return false } -func (w WaitStatus) Continued() bool { return false } -func (w WaitStatus) CoreDump() bool { return false } -func (w WaitStatus) ExitStatus() int { return 0 } -func (w WaitStatus) Signal() int { return 0 } -func (w WaitStatus) StopSignal() int { return 0 } -func (w WaitStatus) TrapCause() int { return 0 } - -func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno { - return ENOSYS -} diff --git a/gcc-4.8.1/libgo/go/syscall/exec_unix.go b/gcc-4.8.1/libgo/go/syscall/exec_unix.go deleted file mode 100644 index d4aa959c1..000000000 --- a/gcc-4.8.1/libgo/go/syscall/exec_unix.go +++ /dev/null @@ -1,293 +0,0 @@ -// 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. - -// +build darwin freebsd linux netbsd openbsd - -// Fork, exec, wait, etc. - -package syscall - -import ( - "runtime" - "sync" - "unsafe" -) - -//sysnb raw_fork() (pid Pid_t, err Errno) -//fork() Pid_t - -//sysnb raw_setsid() (err Errno) -//setsid() Pid_t - -//sysnb raw_setpgid(pid int, pgid int) (err Errno) -//setpgid(pid Pid_t, pgid Pid_t) _C_int - -//sysnb raw_chroot(path *byte) (err Errno) -//chroot(path *byte) _C_int - -//sysnb raw_chdir(path *byte) (err Errno) -//chdir(path *byte) _C_int - -//sysnb raw_fcntl(fd int, cmd int, arg int) (val int, err Errno) -//fcntl(fd _C_int, cmd _C_int, arg _C_int) _C_int - -//sysnb raw_close(fd int) (err Errno) -//close(fd _C_int) _C_int - -//sysnb raw_ioctl(fd int, cmd int, val int) (rval int, err Errno) -//ioctl(fd _C_int, cmd _C_int, val _C_int) _C_int - -//sysnb raw_execve(argv0 *byte, argv **byte, envv **byte) (err Errno) -//execve(argv0 *byte, argv **byte, envv **byte) _C_int - -//sysnb raw_write(fd int, buf *byte, count int) (err Errno) -//write(fd _C_int, buf *byte, count Size_t) Ssize_t - -//sysnb raw_exit(status int) -//_exit(status _C_int) - -//sysnb raw_dup2(oldfd int, newfd int) (err Errno) -//dup2(oldfd _C_int, newfd _C_int) _C_int - -// Lock synchronizing creation of new file descriptors with fork. -// -// We want the child in a fork/exec sequence to inherit only the -// file descriptors we intend. To do that, we mark all file -// descriptors close-on-exec and then, in the child, explicitly -// unmark the ones we want the exec'ed program to keep. -// Unix doesn't make this easy: there is, in general, no way to -// allocate a new file descriptor close-on-exec. Instead you -// have to allocate the descriptor and then mark it close-on-exec. -// If a fork happens between those two events, the child's exec -// will inherit an unwanted file descriptor. -// -// This lock solves that race: the create new fd/mark close-on-exec -// operation is done holding ForkLock for reading, and the fork itself -// is done holding ForkLock for writing. At least, that's the idea. -// There are some complications. -// -// Some system calls that create new file descriptors can block -// for arbitrarily long times: open on a hung NFS server or named -// pipe, accept on a socket, and so on. We can't reasonably grab -// the lock across those operations. -// -// It is worse to inherit some file descriptors than others. -// If a non-malicious child accidentally inherits an open ordinary file, -// that's not a big deal. On the other hand, if a long-lived child -// accidentally inherits the write end of a pipe, then the reader -// of that pipe will not see EOF until that child exits, potentially -// causing the parent program to hang. This is a common problem -// in threaded C programs that use popen. -// -// Luckily, the file descriptors that are most important not to -// inherit are not the ones that can take an arbitrarily long time -// to create: pipe returns instantly, and the net package uses -// non-blocking I/O to accept on a listening socket. -// The rules for which file descriptor-creating operations use the -// ForkLock are as follows: -// -// 1) Pipe. Does not block. Use the ForkLock. -// 2) Socket. Does not block. Use the ForkLock. -// 3) Accept. If using non-blocking mode, use the ForkLock. -// Otherwise, live with the race. -// 4) Open. Can block. Use O_CLOEXEC if available (GNU/Linux). -// Otherwise, live with the race. -// 5) Dup. Does not block. Use the ForkLock. -// On GNU/Linux, could use fcntl F_DUPFD_CLOEXEC -// instead of the ForkLock, but only for dup(fd, -1). - -var ForkLock sync.RWMutex - -// StringSlicePtr is deprecated. Use SlicePtrFromStrings instead. -// If any string contains a NUL byte this function panics instead -// of returning an error. -func StringSlicePtr(ss []string) []*byte { - bb := make([]*byte, len(ss)+1) - for i := 0; i < len(ss); i++ { - bb[i] = StringBytePtr(ss[i]) - } - bb[len(ss)] = nil - return bb -} - -// SlicePtrFromStrings converts a slice of strings to a slice of -// pointers to NUL-terminated byte slices. If any string contains -// a NUL byte, it returns (nil, EINVAL). -func SlicePtrFromStrings(ss []string) ([]*byte, error) { - var err error - bb := make([]*byte, len(ss)+1) - for i := 0; i < len(ss); i++ { - bb[i], err = BytePtrFromString(ss[i]) - if err != nil { - return nil, err - } - } - bb[len(ss)] = nil - return bb, nil -} - -func CloseOnExec(fd int) { fcntl(fd, F_SETFD, FD_CLOEXEC) } - -func SetNonblock(fd int, nonblocking bool) (err error) { - flag, err := fcntl(fd, F_GETFL, 0) - if err != nil { - return err - } - if nonblocking { - flag |= O_NONBLOCK - } else { - flag &= ^O_NONBLOCK - } - _, err = fcntl(fd, F_SETFL, flag) - return err -} - -// Credential holds user and group identities to be assumed -// by a child process started by StartProcess. -type Credential struct { - Uid uint32 // User ID. - Gid uint32 // Group ID. - Groups []uint32 // Supplementary group IDs. -} - -// ProcAttr holds attributes that will be applied to a new process started -// by StartProcess. -type ProcAttr struct { - Dir string // Current working directory. - Env []string // Environment. - Files []uintptr // File descriptors. - Sys *SysProcAttr -} - -var zeroProcAttr ProcAttr -var zeroSysProcAttr SysProcAttr - -func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) { - var p [2]int - var n int - var err1 Errno - var wstatus WaitStatus - - if attr == nil { - attr = &zeroProcAttr - } - sys := attr.Sys - if sys == nil { - sys = &zeroSysProcAttr - } - - p[0] = -1 - p[1] = -1 - - // Convert args to C form. - argv0p, err := BytePtrFromString(argv0) - if err != nil { - return 0, err - } - argvp, err := SlicePtrFromStrings(argv) - if err != nil { - return 0, err - } - envvp, err := SlicePtrFromStrings(attr.Env) - if err != nil { - return 0, err - } - - if runtime.GOOS == "freebsd" && len(argv[0]) > len(argv0) { - argvp[0] = argv0p - } - - var chroot *byte - if sys.Chroot != "" { - chroot, err = BytePtrFromString(sys.Chroot) - if err != nil { - return 0, err - } - } - var dir *byte - if attr.Dir != "" { - dir, err = BytePtrFromString(attr.Dir) - if err != nil { - return 0, err - } - } - - // Acquire the fork lock so that no other threads - // create new fds that are not yet close-on-exec - // before we fork. - ForkLock.Lock() - - // Allocate child status pipe close on exec. - if err = forkExecPipe(p[:]); err != nil { - goto error - } - - // Kick off child. - pid, err1 = forkAndExecInChild(argv0p, argvp, envvp, chroot, dir, attr, sys, p[1]) - if err1 != 0 { - goto error - } - ForkLock.Unlock() - - // Read child error status from pipe. - Close(p[1]) - n, err = readlen(p[0], (*byte)(unsafe.Pointer(&err1)), int(unsafe.Sizeof(err1))) - Close(p[0]) - if err != nil || n != 0 { - if n == int(unsafe.Sizeof(err1)) { - err = Errno(err1) - } - if err == nil { - err = EPIPE - } - - // Child failed; wait for it to exit, to make sure - // the zombies don't accumulate. - _, err1 := Wait4(pid, &wstatus, 0, nil) - for err1 == EINTR { - _, err1 = Wait4(pid, &wstatus, 0, nil) - } - return 0, err - } - - // Read got EOF, so pipe closed on exec, so exec succeeded. - return pid, nil - -error: - if p[0] >= 0 { - Close(p[0]) - Close(p[1]) - } - ForkLock.Unlock() - return 0, err -} - -// Combination of fork and exec, careful to be thread safe. -func ForkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) { - return forkExec(argv0, argv, attr) -} - -// StartProcess wraps ForkExec for package os. -func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle uintptr, err error) { - pid, err = forkExec(argv0, argv, attr) - return pid, 0, err -} - -// Ordinary exec. -func Exec(argv0 string, argv []string, envv []string) (err error) { - argv0p, err := BytePtrFromString(argv0) - if err != nil { - return err - } - argvp, err := SlicePtrFromStrings(argv) - if err != nil { - return err - } - envvp, err := SlicePtrFromStrings(envv) - if err != nil { - return err - } - err1 := raw_execve(argv0p, &argvp[0], &envvp[0]) - return Errno(err1) -} diff --git a/gcc-4.8.1/libgo/go/syscall/exec_windows.go b/gcc-4.8.1/libgo/go/syscall/exec_windows.go deleted file mode 100644 index 82abc0715..000000000 --- a/gcc-4.8.1/libgo/go/syscall/exec_windows.go +++ /dev/null @@ -1,341 +0,0 @@ -// 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. - -// Fork, exec, wait, etc. - -package syscall - -import ( - "sync" - "unicode/utf16" - "unsafe" -) - -var ForkLock sync.RWMutex - -// EscapeArg rewrites command line argument s as prescribed -// in http://msdn.microsoft.com/en-us/library/ms880421. -// This function returns "" (2 double quotes) if s is empty. -// Alternatively, these transformations are done: -// - every back slash (\) is doubled, but only if immediately -// followed by double quote ("); -// - every double quote (") is escaped by back slash (\); -// - finally, s is wrapped with double quotes (arg -> "arg"), -// but only if there is space or tab inside s. -func EscapeArg(s string) string { - if len(s) == 0 { - return "\"\"" - } - n := len(s) - hasSpace := false - for i := 0; i < len(s); i++ { - switch s[i] { - case '"', '\\': - n++ - case ' ', '\t': - hasSpace = true - } - } - if hasSpace { - n += 2 - } - if n == len(s) { - return s - } - - qs := make([]byte, n) - j := 0 - if hasSpace { - qs[j] = '"' - j++ - } - slashes := 0 - for i := 0; i < len(s); i++ { - switch s[i] { - default: - slashes = 0 - qs[j] = s[i] - case '\\': - slashes++ - qs[j] = s[i] - case '"': - for ; slashes > 0; slashes-- { - qs[j] = '\\' - j++ - } - qs[j] = '\\' - j++ - qs[j] = s[i] - } - j++ - } - if hasSpace { - for ; slashes > 0; slashes-- { - qs[j] = '\\' - j++ - } - qs[j] = '"' - j++ - } - return string(qs[:j]) -} - -// makeCmdLine builds a command line out of args by escaping "special" -// characters and joining the arguments with spaces. -func makeCmdLine(args []string) string { - var s string - for _, v := range args { - if s != "" { - s += " " - } - s += EscapeArg(v) - } - return s -} - -// createEnvBlock converts an array of environment strings into -// the representation required by CreateProcess: a sequence of NUL -// terminated strings followed by a nil. -// Last bytes are two UCS-2 NULs, or four NUL bytes. -func createEnvBlock(envv []string) *uint16 { - if len(envv) == 0 { - return &utf16.Encode([]rune("\x00\x00"))[0] - } - length := 0 - for _, s := range envv { - length += len(s) + 1 - } - length += 1 - - b := make([]byte, length) - i := 0 - for _, s := range envv { - l := len(s) - copy(b[i:i+l], []byte(s)) - copy(b[i+l:i+l+1], []byte{0}) - i = i + l + 1 - } - copy(b[i:i+1], []byte{0}) - - return &utf16.Encode([]rune(string(b)))[0] -} - -func CloseOnExec(fd Handle) { - SetHandleInformation(Handle(fd), HANDLE_FLAG_INHERIT, 0) -} - -func SetNonblock(fd Handle, nonblocking bool) (err error) { - return nil -} - -// getFullPath retrieves the full path of the specified file. -// Just a wrapper for Windows GetFullPathName api. -func getFullPath(name string) (path string, err error) { - p, err := UTF16PtrFromString(name) - if err != nil { - return "", err - } - buf := make([]uint16, 100) - n, err := GetFullPathName(p, uint32(len(buf)), &buf[0], nil) - if err != nil { - return "", err - } - if n > uint32(len(buf)) { - // Windows is asking for bigger buffer. - buf = make([]uint16, n) - n, err = GetFullPathName(p, uint32(len(buf)), &buf[0], nil) - if err != nil { - return "", err - } - if n > uint32(len(buf)) { - return "", EINVAL - } - } - return UTF16ToString(buf[:n]), nil -} - -func isSlash(c uint8) bool { - return c == '\\' || c == '/' -} - -func normalizeDir(dir string) (name string, err error) { - ndir, err := getFullPath(dir) - if err != nil { - return "", err - } - if len(ndir) > 2 && isSlash(ndir[0]) && isSlash(ndir[1]) { - // dir cannot have \\server\share\path form - return "", EINVAL - } - return ndir, nil -} - -func volToUpper(ch int) int { - if 'a' <= ch && ch <= 'z' { - ch += 'A' - 'a' - } - return ch -} - -func joinExeDirAndFName(dir, p string) (name string, err error) { - if len(p) == 0 { - return "", EINVAL - } - if len(p) > 2 && isSlash(p[0]) && isSlash(p[1]) { - // \\server\share\path form - return p, nil - } - if len(p) > 1 && p[1] == ':' { - // has drive letter - if len(p) == 2 { - return "", EINVAL - } - if isSlash(p[2]) { - return p, nil - } else { - d, err := normalizeDir(dir) - if err != nil { - return "", err - } - if volToUpper(int(p[0])) == volToUpper(int(d[0])) { - return getFullPath(d + "\\" + p[2:]) - } else { - return getFullPath(p) - } - } - } else { - // no drive letter - d, err := normalizeDir(dir) - if err != nil { - return "", err - } - if isSlash(p[0]) { - return getFullPath(d[:2] + p) - } else { - return getFullPath(d + "\\" + p) - } - } - // we shouldn't be here - return "", EINVAL -} - -type ProcAttr struct { - Dir string - Env []string - Files []uintptr - Sys *SysProcAttr -} - -type SysProcAttr struct { - HideWindow bool - CmdLine string // used if non-empty, else the windows command line is built by escaping the arguments passed to StartProcess - CreationFlags uint32 -} - -var zeroProcAttr ProcAttr -var zeroSysProcAttr SysProcAttr - -func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle uintptr, err error) { - if len(argv0) == 0 { - return 0, 0, EWINDOWS - } - if attr == nil { - attr = &zeroProcAttr - } - sys := attr.Sys - if sys == nil { - sys = &zeroSysProcAttr - } - - if len(attr.Files) > 3 { - return 0, 0, EWINDOWS - } - - if len(attr.Dir) != 0 { - // StartProcess assumes that argv0 is relative to attr.Dir, - // because it implies Chdir(attr.Dir) before executing argv0. - // Windows CreateProcess assumes the opposite: it looks for - // argv0 relative to the current directory, and, only once the new - // process is started, it does Chdir(attr.Dir). We are adjusting - // for that difference here by making argv0 absolute. - var err error - argv0, err = joinExeDirAndFName(attr.Dir, argv0) - if err != nil { - return 0, 0, err - } - } - argv0p, err := UTF16PtrFromString(argv0) - if err != nil { - return 0, 0, err - } - - var cmdline string - // Windows CreateProcess takes the command line as a single string: - // use attr.CmdLine if set, else build the command line by escaping - // and joining each argument with spaces - if sys.CmdLine != "" { - cmdline = sys.CmdLine - } else { - cmdline = makeCmdLine(argv) - } - - var argvp *uint16 - if len(cmdline) != 0 { - argvp, err = UTF16PtrFromString(cmdline) - if err != nil { - return 0, 0, err - } - } - - var dirp *uint16 - if len(attr.Dir) != 0 { - dirp, err = UTF16PtrFromString(attr.Dir) - if err != nil { - return 0, 0, err - } - } - - // Acquire the fork lock so that no other threads - // create new fds that are not yet close-on-exec - // before we fork. - ForkLock.Lock() - defer ForkLock.Unlock() - - p, _ := GetCurrentProcess() - fd := make([]Handle, len(attr.Files)) - for i := range attr.Files { - if attr.Files[i] > 0 { - err := DuplicateHandle(p, Handle(attr.Files[i]), p, &fd[i], 0, true, DUPLICATE_SAME_ACCESS) - if err != nil { - return 0, 0, err - } - defer CloseHandle(Handle(fd[i])) - } - } - si := new(StartupInfo) - si.Cb = uint32(unsafe.Sizeof(*si)) - si.Flags = STARTF_USESTDHANDLES - if sys.HideWindow { - si.Flags |= STARTF_USESHOWWINDOW - si.ShowWindow = SW_HIDE - } - si.StdInput = fd[0] - si.StdOutput = fd[1] - si.StdErr = fd[2] - - pi := new(ProcessInformation) - - flags := sys.CreationFlags | CREATE_UNICODE_ENVIRONMENT - err = CreateProcess(argv0p, argvp, nil, nil, true, flags, createEnvBlock(attr.Env), dirp, si, pi) - if err != nil { - return 0, 0, err - } - defer CloseHandle(Handle(pi.Thread)) - - return int(pi.ProcessId), uintptr(pi.Process), nil -} - -func Exec(argv0 string, argv []string, envv []string) (err error) { - return EWINDOWS -} diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_irix.go b/gcc-4.8.1/libgo/go/syscall/libcall_irix.go deleted file mode 100644 index 50863fadf..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_irix.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2011 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 - -//sysnb raw_ptrace(request int, pid int, addr *byte, data *byte) (err Errno) -//ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_linux.go b/gcc-4.8.1/libgo/go/syscall/libcall_linux.go deleted file mode 100644 index 79de2f389..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_linux.go +++ /dev/null @@ -1,400 +0,0 @@ -// 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. - -// GNU/Linux library calls. - -package syscall - -import "unsafe" - -//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) -//openat(dirfd _C_int, path *byte, flags _C_int, mode Mode_t) _C_int - -//sys futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) -//futimesat(dirfd _C_int, path *byte, times *[2]Timeval) _C_int -func Futimesat(dirfd int, path string, tv []Timeval) (err error) { - if len(tv) != 2 { - return EINVAL - } - return futimesat(dirfd, StringBytePtr(path), (*[2]Timeval)(unsafe.Pointer(&tv[0]))) -} - -func Futimes(fd int, tv []Timeval) (err error) { - // Believe it or not, this is the best we can do on GNU/Linux - // (and is what glibc does). - return Utimes("/proc/self/fd/"+itoa(fd), tv) -} - -//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error) -//ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long - -//sysnb raw_ptrace(request int, pid int, addr *byte, data *byte) (err Errno) -//ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long - -func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err error) { - // The peek requests are machine-size oriented, so we wrap it - // to retrieve arbitrary-length data. - - // The ptrace syscall differs from glibc's ptrace. - // Peeks returns the word in *data, not as the return value. - - var buf [sizeofPtr]byte - - // Leading edge. PEEKTEXT/PEEKDATA don't require aligned - // access (PEEKUSER warns that it might), but if we don't - // align our reads, we might straddle an unmapped page - // boundary and not get the bytes leading up to the page - // boundary. - n := 0 - if addr%sizeofPtr != 0 { - err = ptrace(req, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) - if err != nil { - return 0, err - } - n += copy(out, buf[addr%sizeofPtr:]) - out = out[n:] - } - - // Remainder. - for len(out) > 0 { - // We use an internal buffer to gaurantee alignment. - // It's not documented if this is necessary, but we're paranoid. - err = ptrace(req, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0]))) - if err != nil { - return n, err - } - copied := copy(out, buf[0:]) - n += copied - out = out[copied:] - } - - return n, nil -} - -func PtracePeekText(pid int, addr uintptr, out []byte) (count int, err error) { - return ptracePeek(PTRACE_PEEKTEXT, pid, addr, out) -} - -func PtracePeekData(pid int, addr uintptr, out []byte) (count int, err error) { - return ptracePeek(PTRACE_PEEKDATA, pid, addr, out) -} - -func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (count int, err error) { - // As for ptracePeek, we need to align our accesses to deal - // with the possibility of straddling an invalid page. - - // Leading edge. - n := 0 - if addr%sizeofPtr != 0 { - var buf [sizeofPtr]byte - err = ptrace(peekReq, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) - if err != nil { - return 0, err - } - n += copy(buf[addr%sizeofPtr:], data) - word := *((*uintptr)(unsafe.Pointer(&buf[0]))) - err = ptrace(pokeReq, pid, addr-addr%sizeofPtr, word) - if err != nil { - return 0, err - } - data = data[n:] - } - - // Interior. - for len(data) > int(sizeofPtr) { - word := *((*uintptr)(unsafe.Pointer(&data[0]))) - err = ptrace(pokeReq, pid, addr+uintptr(n), word) - if err != nil { - return n, err - } - n += int(sizeofPtr) - data = data[sizeofPtr:] - } - - // Trailing edge. - if len(data) > 0 { - var buf [sizeofPtr]byte - err = ptrace(peekReq, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0]))) - if err != nil { - return n, err - } - copy(buf[0:], data) - word := *((*uintptr)(unsafe.Pointer(&buf[0]))) - err = ptrace(pokeReq, pid, addr+uintptr(n), word) - if err != nil { - return n, err - } - n += len(data) - } - - return n, nil -} - -func PtracePokeText(pid int, addr uintptr, data []byte) (count int, err error) { - return ptracePoke(PTRACE_POKETEXT, PTRACE_PEEKTEXT, pid, addr, data) -} - -func PtracePokeData(pid int, addr uintptr, data []byte) (count int, err error) { - return ptracePoke(PTRACE_POKEDATA, PTRACE_PEEKDATA, pid, addr, data) -} - -func PtraceSetOptions(pid int, options int) (err error) { - return ptrace(PTRACE_SETOPTIONS, pid, 0, uintptr(options)) -} - -func PtraceGetEventMsg(pid int) (msg uint, err error) { - var data _C_long - err = ptrace(PTRACE_GETEVENTMSG, pid, 0, uintptr(unsafe.Pointer(&data))) - msg = uint(data) - return -} - -func PtraceCont(pid int, signal int) (err error) { - return ptrace(PTRACE_CONT, pid, 0, uintptr(signal)) -} - -func PtraceSingleStep(pid int) (err error) { return ptrace(PTRACE_SINGLESTEP, pid, 0, 0) } - -func PtraceAttach(pid int) (err error) { return ptrace(PTRACE_ATTACH, pid, 0, 0) } - -func PtraceDetach(pid int) (err error) { return ptrace(PTRACE_DETACH, pid, 0, 0) } - -//sys reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) -//reboot(magic1 _C_uint, magic2 _C_uint, cmd _C_int, arg *byte) _C_int -func Reboot(cmd int) (err error) { - return reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, "") -} - -//sys accept4(fd int, sa *RawSockaddrAny, len *Socklen_t, flags int) (nfd int, err error) -//accept4(fd _C_int, sa *RawSockaddrAny, len *Socklen_t, flags _C_int) _C_int - -func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) { - var rsa RawSockaddrAny - var len Socklen_t = SizeofSockaddrAny - nfd, err = accept4(fd, &rsa, &len, flags) - if err != nil { - return -1, nil, err - } - sa, err = anyToSockaddr(&rsa) - if err != nil { - Close(nfd) - return -1, nil, err - } - return nfd, sa, nil -} - -//sys Acct(path string) (err error) -//acct(path *byte) _C_int - -//sys Adjtimex(buf *Timex) (state int, err error) -//adjtimex(buf *Timex) _C_int - -//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error) -//faccessat(dirfd _C_int, pathname *byte, mode _C_int, flags _C_int) _C_int - -//sys Fallocate(fd int, mode uint32, off int64, len int64) (err error) -//fallocate(fd _C_int, mode _C_int, offset Offset_t, len Offset_t) _C_int - -//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) -//fchmodat(dirfd _C_int, pathname *byte, mode Mode_t, flags _C_int) _C_int - -//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) -//fchownat(dirfd _C_int, path *byte, owner Uid_t, group Gid_t, flags _C_int) _C_int - -//sys Flock(fd int, how int) (err error) -//flock(fd _C_int, how _C_int) _C_int - -//sys Fstatfs(fd int, buf *Statfs_t) (err error) -//fstatfs(fd _C_int, buf *Statfs_t) _C_int - -func Gettid() (tid int) { - r1, _, _ := Syscall(SYS_GETTID, 0, 0, 0) - return int(r1) -} - -func Getdents(fd int, buf []byte) (n int, err error) { - var p *byte - if len(buf) > 0 { - p = &buf[0] - } else { - p = (*byte)(unsafe.Pointer(&_zero)) - } - Entersyscall() - s := SYS_GETDENTS64 - if s == 0 { - s = SYS_GETDENTS - } - r1, _, errno := Syscall(uintptr(s), uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(len(buf))) - n = int(r1) - if n < 0 { - err = errno - } - Exitsyscall() - return -} - -func clen(n []byte) int { - for i := 0; i < len(n); i++ { - if n[i] == 0 { - return i - } - } - return len(n) -} - -func ReadDirent(fd int, buf []byte) (n int, err error) { - return Getdents(fd, buf) -} - -func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { - origlen := len(buf) - count = 0 - for max != 0 && len(buf) > 0 { - dirent := (*Dirent)(unsafe.Pointer(&buf[0])) - buf = buf[dirent.Reclen:] - if dirent.Ino == 0 { // File absent in directory. - continue - } - bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0])) - var name = string(bytes[0:clen(bytes[:])]) - if name == "." || name == ".." { // Useless names - continue - } - max-- - count++ - names = append(names, name) - } - return origlen - len(buf), count, names -} - -//sys InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) -//inotify_add_watch(fd _C_int, pathname *byte, mask uint32) _C_int - -//sysnb InotifyInit() (fd int, err error) -//inotify_init() _C_int - -//sysnb InotifyInit1(flags int) (fd int, err error) -//inotify_init1(flags _C_int) _C_int - -//sysnb InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) -//inotify_rm_watch(fd _C_int, wd uint32) _C_int - -//sys Klogctl(typ int, buf []byte) (n int, err error) -//klogctl(typ _C_int, bufp *byte, len _C_int) _C_int - -//sys Mkdirat(dirfd int, path string, mode uint32) (err error) -//mkdirat(dirfd _C_int, path *byte, mode Mode_t) _C_int - -//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) -//mknodat(dirfd _C_int, path *byte, mode Mode_t, dev _dev_t) _C_int - -//sysnb pipe2(p *[2]_C_int, flags int) (err error) -//pipe2(p *[2]_C_int, flags _C_int) _C_int -func Pipe2(p []int, flags int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sys PivotRoot(newroot string, putold string) (err error) -//pivot_root(newroot *byte, putold *byte) _C_int - -//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) -//renameat(olddirfd _C_int, oldpath *byte, newdirfd _C_int, newpath *byte) _C_int - -//sys sendfile(outfd int, infd int, offset *Offset_t, count int) (written int, err error) -//sendfile64(outfd _C_int, infd _C_int, offset *Offset_t, count Size_t) Ssize_t -func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { - if raceenabled { - raceReleaseMerge(unsafe.Pointer(&ioSync)) - } - var soff Offset_t - var psoff *Offset_t - if offset != nil { - psoff = &soff - } - written, err = sendfile(outfd, infd, psoff, count) - if offset != nil { - *offset = int64(soff) - } - return -} - -//sys Setfsgid(gid int) (err error) -//setfsgid(gid Gid_t) _C_int - -//sys Setfsuid(uid int) (err error) -//setfsuid(uid Uid_t) _C_int - -//sysnb Setresgid(rgid int, egid int, sgid int) (err error) -//setresgid(rgid Gid_t, egid Gid_t, sgid Gid_t) _C_int - -//sysnb Setresuid(ruid int, eguid int, suid int) (err error) -//setresuid(ruid Uid_t, euid Uid_t, suid Uid_t) _C_int - -//sys splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error) -//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t -func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { - var lroff _loff_t - var plroff *_loff_t - if roff != nil { - lroff = _loff_t(*roff) - plroff = &lroff - } - var lwoff _loff_t - var plwoff *_loff_t - if woff != nil { - lwoff = _loff_t(*woff) - plwoff = &lwoff - } - n, err = splice(rfd, plroff, wfd, plwoff, len, flags) - if roff != nil { - *roff = int64(lroff) - } - if woff != nil { - *woff = int64(lwoff) - } - return -} - -//sys Statfs(path string, buf *Statfs_t) (err error) -//statfs(path *byte, buf *Statfs_t) _C_int - -//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) -//sync_file_range(fd _C_int, off Offset_t, n Offset_t, flags _C_uint) _C_int - -//sysnb Sysinfo(info *Sysinfo_t) (err error) -//sysinfo(info *Sysinfo_t) _C_int - -//sys Tee(rfd int, wfd int, len int, flags int) (n int64, err error) -//tee(rfd _C_int, wfd _C_int, len Size_t, flags _C_uint) Ssize_t - -func Tgkill(tgid int, tid int, sig Signal) error { - r1, _, errno := Syscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) - if r1 < 0 { - return errno - } - return nil -} - -//sys unlinkat(dirfd int, path string, flags int) (err error) -//unlinkat(dirfd _C_int, path *byte, flags _C_int) _C_int - -func Unlinkat(dirfd int, path string) (err error) { - return unlinkat(dirfd, path, 0) -} - -//sys Unmount(target string, flags int) (err error) = SYS_UMOUNT2 -//umount2(target *byte, flags _C_int) _C_int - -//sys Unshare(flags int) (err error) -//unshare(flags _C_int) _C_int - -//sys Ustat(dev int, ubuf *Ustat_t) (err error) -//ustat(dev _dev_t, ubuf *Ustat_t) _C_int diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_linux_386.go b/gcc-4.8.1/libgo/go/syscall/libcall_linux_386.go deleted file mode 100644 index bdf0fda6c..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_linux_386.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 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. - -// GNU/Linux library calls 386 specific. - -package syscall - -//sys Ioperm(from int, num int, on int) (err error) -//ioperm(from _C_long, num _C_long, on _C_int) _C_int - -//sys Iopl(level int) (err error) -//iopl(level _C_int) _C_int diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_linux_alpha.go b/gcc-4.8.1/libgo/go/syscall/libcall_linux_alpha.go deleted file mode 100644 index 13ccf05a6..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_linux_alpha.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 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. - -// GNU/Linux library calls Alpha specific. - -package syscall - -//sys Ioperm(from int, num int, on int) (err error) -//ioperm(from _C_long, num _C_long, on _C_int) _C_int - -//sys Iopl(level int) (err error) -//iopl(level _C_int) _C_int diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_linux_amd64.go b/gcc-4.8.1/libgo/go/syscall/libcall_linux_amd64.go deleted file mode 100644 index 675de3d94..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_linux_amd64.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 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. - -// GNU/Linux library calls amd64 specific. - -package syscall - -//sys Ioperm(from int, num int, on int) (err error) -//ioperm(from _C_long, num _C_long, on _C_int) _C_int - -//sys Iopl(level int) (err error) -//iopl(level _C_int) _C_int diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_linux_utimesnano.go b/gcc-4.8.1/libgo/go/syscall/libcall_linux_utimesnano.go deleted file mode 100644 index 90da2ae04..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_linux_utimesnano.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 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. - -// GNU/Linux version of UtimesNano. - -package syscall - -import "unsafe" - -//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) -//utimensat(dirfd _C_int, path *byte, times *[2]Timespec, flags _C_int) _C_int -func UtimesNano(path string, ts []Timespec) (err error) { - if len(ts) != 2 { - return EINVAL - } - err = utimensat(_AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) - if err != ENOSYS { - return err - } - // If the utimensat syscall isn't available (utimensat was added to Linux - // in 2.6.22, Released, 8 July 2007) then fall back to utimes - var tv [2]Timeval - for i := 0; i < 2; i++ { - tv[i].Sec = Timeval_sec_t(ts[i].Sec) - tv[i].Usec = Timeval_usec_t(ts[i].Nsec / 1000) - } - return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) -} diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_posix.go b/gcc-4.8.1/libgo/go/syscall/libcall_posix.go deleted file mode 100644 index 1e7823b54..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_posix.go +++ /dev/null @@ -1,398 +0,0 @@ -// Copyright 2011 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. - -// POSIX library calls. -// This file is compiled as ordinary Go code, -// but it is also input to mksyscall, -// which parses the //sys lines and generates library call stubs. -// Note that sometimes we use a lowercase //sys name and -// wrap it in our own nicer implementation. - -package syscall - -import "unsafe" - -/* - * Wrapped - */ - -//sysnb pipe(p *[2]_C_int) (err error) -//pipe(p *[2]_C_int) _C_int -func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe(&pp) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return -} - -//sys utimes(path string, times *[2]Timeval) (err error) -//utimes(path *byte, times *[2]Timeval) _C_int -func Utimes(path string, tv []Timeval) (err error) { - if len(tv) != 2 { - return EINVAL - } - return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) -} - -//sys getcwd(buf *byte, size Size_t) (err error) -//getcwd(buf *byte, size Size_t) *byte - -const ImplementsGetwd = true - -func Getwd() (ret string, err error) { - for len := Size_t(4096); ; len *= 2 { - b := make([]byte, len) - err := getcwd(&b[0], len) - if err == nil { - i := 0 - for b[i] != 0 { - i++ - } - return string(b[0:i]), nil - } - if err != ERANGE { - return "", err - } - } -} - -func Getcwd(buf []byte) (n int, err error) { - err = getcwd(&buf[0], Size_t(len(buf))) - if err == nil { - i := 0 - for buf[i] != 0 { - i++ - } - n = i + 1 - } - return -} - -//sysnb getgroups(size int, list *Gid_t) (nn int, err error) -//getgroups(size _C_int, list *Gid_t) _C_int - -func Getgroups() (gids []int, err error) { - n, err := getgroups(0, nil) - if err != nil { - return nil, err - } - if n == 0 { - return nil, nil - } - - // Sanity check group count. Max is 1<<16 on GNU/Linux. - if n < 0 || n > 1<<20 { - return nil, EINVAL - } - - a := make([]Gid_t, n) - n, err = getgroups(n, &a[0]) - if err != nil { - return nil, err - } - gids = make([]int, n) - for i, v := range a[0:n] { - gids[i] = int(v) - } - return -} - -//sysnb setgroups(n int, list *Gid_t) (err error) -//setgroups(n Size_t, list *Gid_t) _C_int - -func Setgroups(gids []int) (err error) { - if len(gids) == 0 { - return setgroups(0, nil) - } - - a := make([]Gid_t, len(gids)) - for i, v := range gids { - a[i] = Gid_t(v) - } - return setgroups(len(a), &a[0]) -} - -type WaitStatus uint32 - -// The WaitStatus methods are implemented in C, to pick up the macros -// #defines in <sys/wait.h>. - -func (w WaitStatus) Exited() bool -func (w WaitStatus) Signaled() bool -func (w WaitStatus) Stopped() bool -func (w WaitStatus) Continued() bool -func (w WaitStatus) CoreDump() bool -func (w WaitStatus) ExitStatus() int -func (w WaitStatus) Signal() Signal -func (w WaitStatus) StopSignal() Signal -func (w WaitStatus) TrapCause() int - -//sys Mkfifo(path string, mode uint32) (err error) -//mkfifo(path *byte, mode Mode_t) _C_int - -//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) -//select(nfd _C_int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) _C_int - -const nfdbits = int(unsafe.Sizeof(fds_bits_type) * 8) - -type FdSet struct { - Bits [(FD_SETSIZE + nfdbits - 1) / nfdbits]fds_bits_type -} - -func FDSet(fd int, set *FdSet) { - set.Bits[fd/nfdbits] |= (1 << (uint)(fd%nfdbits)) -} - -func FDClr(fd int, set *FdSet) { - set.Bits[fd/nfdbits] &^= (1 << (uint)(fd%nfdbits)) -} - -func FDIsSet(fd int, set *FdSet) bool { - if set.Bits[fd/nfdbits]&(1<<(uint)(fd%nfdbits)) != 0 { - return true - } else { - return false - } -} - -func FDZero(set *FdSet) { - for i := range set.Bits { - set.Bits[i] = 0 - } -} - -//sys Access(path string, mode uint32) (err error) -//access(path *byte, mode _C_int) _C_int - -//sys Chdir(path string) (err error) -//chdir(path *byte) _C_int - -//sys Chmod(path string, mode uint32) (err error) -//chmod(path *byte, mode Mode_t) _C_int - -//sys Chown(path string, uid int, gid int) (err error) -//chown(path *byte, uid Uid_t, gid Gid_t) _C_int - -//sys Chroot(path string) (err error) -//chroot(path *byte) _C_int - -//sys Close(fd int) (err error) -//close(fd _C_int) _C_int - -//sys Creat(path string, mode uint32) (fd int, err error) -//creat(path *byte, mode Mode_t) _C_int - -//sysnb Dup(oldfd int) (fd int, err error) -//dup(oldfd _C_int) _C_int - -//sysnb Dup2(oldfd int, newfd int) (err error) -//dup2(oldfd _C_int, newfd _C_int) _C_int - -//sys Exit(code int) -//exit(code _C_int) - -//sys Fchdir(fd int) (err error) -//fchdir(fd _C_int) _C_int - -//sys Fchmod(fd int, mode uint32) (err error) -//fchmod(fd _C_int, mode Mode_t) _C_int - -//sys Fchown(fd int, uid int, gid int) (err error) -//fchown(fd _C_int, uid Uid_t, gid Gid_t) _C_int - -//sys fcntl(fd int, cmd int, arg int) (val int, err error) -//fcntl(fd _C_int, cmd _C_int, arg _C_int) _C_int - -//sys Fdatasync(fd int) (err error) -//fdatasync(fd _C_int) _C_int - -//sys Fsync(fd int) (err error) -//fsync(fd _C_int) _C_int - -//sysnb Getegid() (egid int) -//getegid() Gid_t - -//sysnb Geteuid() (euid int) -//geteuid() Uid_t - -//sysnb Getgid() (gid int) -//getgid() Gid_t - -//sysnb Getpagesize() (pagesize int) -//getpagesize() _C_int - -//sysnb Getpgid(pid int) (pgid int, err error) -//getpgid(pid Pid_t) Pid_t - -//sysnb Getpgrp() (pid int) -//getpgrp() Pid_t - -//sysnb Getpid() (pid int) -//getpid() Pid_t - -//sysnb Getppid() (ppid int) -//getppid() Pid_t - -//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) -//getrlimit(resource _C_int, rlim *Rlimit) _C_int - -//sysnb Getrusage(who int, rusage *Rusage) (err error) -//getrusage(who _C_int, rusage *Rusage) _C_int - -//sysnb gettimeofday(tv *Timeval, tz *byte) (err error) -//gettimeofday(tv *Timeval, tz *byte) _C_int -func Gettimeofday(tv *Timeval) (err error) { - return gettimeofday(tv, nil) -} - -//sysnb Getuid() (uid int) -//getuid() Uid_t - -//sysnb Kill(pid int, sig Signal) (err error) -//kill(pid Pid_t, sig _C_int) _C_int - -//sys Lchown(path string, uid int, gid int) (err error) -//lchown(path *byte, uid Uid_t, gid Gid_t) _C_int - -//sys Link(oldpath string, newpath string) (err error) -//link(oldpath *byte, newpath *byte) _C_int - -//sys Mkdir(path string, mode uint32) (err error) -//mkdir(path *byte, mode Mode_t) _C_int - -//sys Mknod(path string, mode uint32, dev int) (err error) -//mknod(path *byte, mode Mode_t, dev _dev_t) _C_int - -//sys Mount(source string, target string, fstype string, flags uintptr, data string) (err error) -//mount(source *byte, target *byte, fstype *byte, flags _C_long, data *byte) _C_int - -//sys Nanosleep(time *Timespec, leftover *Timespec) (err error) -//nanosleep(time *Timespec, leftover *Timespec) _C_int - -//sys Pause() (err error) -//pause() _C_int - -//sys read(fd int, p []byte) (n int, err error) -//read(fd _C_int, buf *byte, count Size_t) Ssize_t - -//sys readlen(fd int, p *byte, np int) (n int, err error) -//read(fd _C_int, buf *byte, count Size_t) Ssize_t - -//sys Readlink(path string, buf []byte) (n int, err error) -//readlink(path *byte, buf *byte, bufsiz Size_t) Ssize_t - -//sys Rename(oldpath string, newpath string) (err error) -//rename(oldpath *byte, newpath *byte) _C_int - -//sys Rmdir(path string) (err error) -//rmdir(path *byte) _C_int - -//sys Setdomainname(p []byte) (err error) -//setdomainname(name *byte, len Size_t) _C_int - -//sys Sethostname(p []byte) (err error) -//sethostname(name *byte, len Size_t) _C_int - -//sysnb Setgid(gid int) (err error) -//setgid(gid Gid_t) _C_int - -//sysnb Setregid(rgid int, egid int) (err error) -//setregid(rgid Gid_t, egid Gid_t) _C_int - -//sysnb Setpgid(pid int, pgid int) (err error) -//setpgid(pid Pid_t, pgid Pid_t) _C_int - -//sysnb Setreuid(ruid int, euid int) (err error) -//setreuid(ruid Uid_t, euid Uid_t) _C_int - -//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) -//setrlimit(resource int, rlim *Rlimit) _C_int - -//sysnb Setsid() (pid int, err error) -//setsid() Pid_t - -//sysnb settimeofday(tv *Timeval, tz *byte) (err error) -//settimeofday(tv *Timeval, tz *byte) _C_int - -func Settimeofday(tv *Timeval) (err error) { - return settimeofday(tv, nil) -} - -//sysnb Setuid(uid int) (err error) -//setuid(uid Uid_t) _C_int - -//sys Symlink(oldpath string, newpath string) (err error) -//symlink(oldpath *byte, newpath *byte) _C_int - -//sys Sync() -//sync() - -//sysnb Time(t *Time_t) (tt Time_t, err error) -//time(t *Time_t) Time_t - -//sysnb Times(tms *Tms) (ticks uintptr, err error) -//times(tms *Tms) _clock_t - -//sysnb Umask(mask int) (oldmask int) -//umask(mask Mode_t) Mode_t - -//sys Unlink(path string) (err error) -//unlink(path *byte) _C_int - -//sys Utime(path string, buf *Utimbuf) (err error) -//utime(path *byte, buf *Utimbuf) _C_int - -//sys write(fd int, p []byte) (n int, err error) -//write(fd _C_int, buf *byte, count Size_t) Ssize_t - -//sys writelen(fd int, p *byte, np int) (n int, err error) -//write(fd _C_int, buf *byte, count Size_t) Ssize_t - -//sys munmap(addr uintptr, length uintptr) (err error) -//munmap(addr *byte, length Size_t) _C_int - -//sys Madvise(b []byte, advice int) (err error) -//madvise(addr *byte, len Size_t, advice _C_int) _C_int - -//sys Mprotect(b []byte, prot int) (err error) -//mprotect(addr *byte, len Size_t, prot _C_int) _C_int - -//sys Mlock(b []byte) (err error) -//mlock(addr *byte, len Size_t) _C_int - -//sys Munlock(b []byte) (err error) -//munlock(addr *byte, len Size_t) _C_int - -//sys Mlockall(flags int) (err error) -//mlockall(flags _C_int) _C_int - -//sys Munlockall() (err error) -//munlockall() _C_int - -func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } - -func NsecToTimespec(nsec int64) (ts Timespec) { - ts.Sec = Timespec_sec_t(nsec / 1e9) - ts.Nsec = Timespec_nsec_t(nsec % 1e9) - return -} - -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - -func NsecToTimeval(nsec int64) (tv Timeval) { - nsec += 999 // round up to microsecond - tv.Sec = Timeval_sec_t(nsec / 1e9) - tv.Usec = Timeval_usec_t(nsec % 1e9 / 1e3) - return -} - -//sysnb Tcgetattr(fd int, p *Termios) (err error) -//tcgetattr(fd _C_int, p *Termios) _C_int - -//sys Tcsetattr(fd int, actions int, p *Termios) (err error) -//tcsetattr(fd _C_int, actions _C_int, p *Termios) _C_int diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_posix_largefile.go b/gcc-4.8.1/libgo/go/syscall/libcall_posix_largefile.go deleted file mode 100644 index 1ad769204..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_posix_largefile.go +++ /dev/null @@ -1,37 +0,0 @@ -// 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. - -// POSIX library calls on systems which use the largefile interface. - -package syscall - -//sys Fstat(fd int, stat *Stat_t) (err error) -//fstat64(fd _C_int, stat *Stat_t) _C_int - -//sys Ftruncate(fd int, length int64) (err error) -//ftruncate64(fd _C_int, length Offset_t) _C_int - -//sys Lstat(path string, stat *Stat_t) (err error) -//lstat64(path *byte, stat *Stat_t) _C_int - -//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) -//mmap64(addr *byte, length Size_t, prot _C_int, flags _C_int, fd _C_int, offset Offset_t) *byte - -//sys Open(path string, mode int, perm uint32) (fd int, err error) -//open64(path *byte, mode _C_int, perm Mode_t) _C_int - -//sys Pread(fd int, p []byte, offset int64) (n int, err error) -//pread64(fd _C_int, buf *byte, count Size_t, offset Offset_t) Ssize_t - -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) -//pwrite64(fd _C_int, buf *byte, count Size_t, offset Offset_t) Ssize_t - -//sys Seek(fd int, offset int64, whence int) (off int64, err error) -//lseek64(fd _C_int, offset Offset_t, whence _C_int) Offset_t - -//sys Stat(path string, stat *Stat_t) (err error) -//stat64(path *byte, stat *Stat_t) _C_int - -//sys Truncate(path string, length int64) (err error) -//truncate64(path *byte, length Offset_t) _C_int diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_posix_regfile.go b/gcc-4.8.1/libgo/go/syscall/libcall_posix_regfile.go deleted file mode 100644 index 5766e0c15..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_posix_regfile.go +++ /dev/null @@ -1,38 +0,0 @@ -// 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. - -// POSIX library calls on systems which do not use the largefile -// interface. - -package syscall - -//sys Fstat(fd int, stat *Stat_t) (err error) -//fstat(fd _C_int, stat *Stat_t) _C_int - -//sys Ftruncate(fd int, length int64) (err error) -//ftruncate(fd _C_int, length Offset_t) _C_int - -//sys Lstat(path string, stat *Stat_t) (err error) -//lstat(path *byte, stat *Stat_t) _C_int - -//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) -//mmap(addr *byte, length Size_t, prot _C_int, flags _C_int, fd _C_int, offset Offset_t) *byte - -//sys Open(path string, mode int, perm uint32) (fd int, err error) -//open(path *byte, mode _C_int, perm Mode_t) _C_int - -//sys Pread(fd int, p []byte, offset int64) (n int, err error) -//pread(fd _C_int, buf *byte, count Size_t, offset Offset_t) Ssize_t - -//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) -//pwrite(fd _C_int, buf *byte, count Size_t, offset Offset_t) Ssize_t - -//sys Seek(fd int, offset int64, whence int) (off int64, err error) -//lseek(fd _C_int, offset Offset_t, whence _C_int) Offset_t - -//sys Stat(path string, stat *Stat_t) (err error) -//stat(path *byte, stat *Stat_t) _C_int - -//sys Truncate(path string, length int64) (err error) -//truncate(path *byte, length Offset_t) _C_int diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_posix_utimesnano.go b/gcc-4.8.1/libgo/go/syscall/libcall_posix_utimesnano.go deleted file mode 100644 index e0751f546..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_posix_utimesnano.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 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. - -// General POSIX version of UtimesNano. - -package syscall - -import "unsafe" - -func UtimesNano(path string, ts []Timespec) error { - // TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it - // isn't supported by darwin so this uses utimes instead - if len(ts) != 2 { - return EINVAL - } - // Not as efficient as it could be because Timespec and - // Timeval have different types in the different OSes - tv := [2]Timeval{ - NsecToTimeval(TimespecToNsec(ts[0])), - NsecToTimeval(TimespecToNsec(ts[1])), - } - return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) -} diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_solaris_386.go b/gcc-4.8.1/libgo/go/syscall/libcall_solaris_386.go deleted file mode 100644 index 20eba22a3..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_solaris_386.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2011 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 - -// 32-bit Solaris 2/x86 needs to use _nuname internally, cf. <sys/utsname.h>. -//sysnb Uname(buf *Utsname) (err error) -//_nuname(buf *Utsname) _C_int - -//sysnb raw_ptrace(request int, pid int, addr *byte, data *byte) (err Errno) -//ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_solaris_amd64.go b/gcc-4.8.1/libgo/go/syscall/libcall_solaris_amd64.go deleted file mode 100644 index 69b11ba5e..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_solaris_amd64.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2011 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 - -// 64-bit ptrace(3C) doesn't exist -func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno { - return ENOSYS -} diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_solaris_sparc.go b/gcc-4.8.1/libgo/go/syscall/libcall_solaris_sparc.go deleted file mode 100644 index 50863fadf..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_solaris_sparc.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2011 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 - -//sysnb raw_ptrace(request int, pid int, addr *byte, data *byte) (err Errno) -//ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_solaris_sparc64.go b/gcc-4.8.1/libgo/go/syscall/libcall_solaris_sparc64.go deleted file mode 100644 index 69b11ba5e..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_solaris_sparc64.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2011 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 - -// 64-bit ptrace(3C) doesn't exist -func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno { - return ENOSYS -} diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_support.go b/gcc-4.8.1/libgo/go/syscall/libcall_support.go deleted file mode 100644 index cacc55623..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_support.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2011 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. - -// Declarations for functions which are actually written in C. - -package syscall - -func Entersyscall() -func Exitsyscall() -func GetErrno() Errno -func SetErrno(Errno) - -// These functions are used by CGO and SWIG. -func Cgocall() -func CgocallDone() -func CgocallBack() -func CgocallBackDone() diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_uname.go b/gcc-4.8.1/libgo/go/syscall/libcall_uname.go deleted file mode 100644 index 1e164ef1a..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_uname.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2011 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 - -//sysnb Uname(buf *Utsname) (err error) -//uname(buf *Utsname) _C_int diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_wait4.go b/gcc-4.8.1/libgo/go/syscall/libcall_wait4.go deleted file mode 100644 index 559d78042..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_wait4.go +++ /dev/null @@ -1,20 +0,0 @@ -// 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. - -// For systems with the wait4 library call. - -package syscall - -//sys wait4(pid Pid_t, status *_C_int, options int, rusage *Rusage) (wpid Pid_t, err error) -//wait4(pid Pid_t, status *_C_int, options _C_int, rusage *Rusage) Pid_t - -func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) { - var status _C_int - r, err := wait4(Pid_t(pid), &status, options, rusage) - wpid = int(r) - if wstatus != nil { - *wstatus = WaitStatus(status) - } - return -} diff --git a/gcc-4.8.1/libgo/go/syscall/libcall_waitpid.go b/gcc-4.8.1/libgo/go/syscall/libcall_waitpid.go deleted file mode 100644 index b0e04b5ba..000000000 --- a/gcc-4.8.1/libgo/go/syscall/libcall_waitpid.go +++ /dev/null @@ -1,20 +0,0 @@ -// 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. - -// For systems with the waitpid library call. - -package syscall - -//sys waitpid(pid Pid_t, status *_C_int, options int) (wpid Pid_t, err error) -//waitpid(pid Pid_t, status *_C_int, options _C_int) Pid_t - -func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) { - var status _C_int - r, err := waitpid(Pid_t(pid), &status, options) - wpid = int(r) - if wstatus != nil { - *wstatus = WaitStatus(status) - } - return -} diff --git a/gcc-4.8.1/libgo/go/syscall/lsf_linux.go b/gcc-4.8.1/libgo/go/syscall/lsf_linux.go deleted file mode 100644 index 5296cec9c..000000000 --- a/gcc-4.8.1/libgo/go/syscall/lsf_linux.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2011 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. - -// Linux socket filter - -package syscall - -import ( - "unsafe" -) - -func LsfStmt(code, k int) *SockFilter { - return &SockFilter{Code: uint16(code), K: uint32(k)} -} - -func LsfJump(code, k, jt, jf int) *SockFilter { - return &SockFilter{Code: uint16(code), Jt: uint8(jt), Jf: uint8(jf), K: uint32(k)} -} - -func LsfSocket(ifindex, proto int) (int, error) { - var lsall SockaddrLinklayer - s, e := Socket(AF_PACKET, SOCK_RAW, proto) - if e != nil { - return 0, e - } - p := (*[2]byte)(unsafe.Pointer(&lsall.Protocol)) - p[0] = byte(proto >> 8) - p[1] = byte(proto) - lsall.Ifindex = ifindex - e = Bind(s, &lsall) - if e != nil { - Close(s) - return 0, e - } - return s, nil -} - -type iflags struct { - name [IFNAMSIZ]byte - flags uint16 -} - -func SetLsfPromisc(name string, m bool) error { - s, e := Socket(AF_INET, SOCK_DGRAM, 0) - if e != nil { - return e - } - defer Close(s) - var ifl iflags - copy(ifl.name[:], []byte(name)) - _, _, ep := Syscall(SYS_IOCTL, uintptr(s), SIOCGIFFLAGS, uintptr(unsafe.Pointer(&ifl))) - if ep != 0 { - return Errno(ep) - } - if m { - ifl.flags |= uint16(IFF_PROMISC) - } else { - ifl.flags &= ^uint16(IFF_PROMISC) - } - _, _, ep = Syscall(SYS_IOCTL, uintptr(s), SIOCSIFFLAGS, uintptr(unsafe.Pointer(&ifl))) - if ep != 0 { - return Errno(ep) - } - return nil -} - -func AttachLsf(fd int, i []SockFilter) error { - var p SockFprog - p.Len = uint16(len(i)) - p.Filter = (*SockFilter)(unsafe.Pointer(&i[0])) - return setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, (*byte)(unsafe.Pointer(&p)), Socklen_t(unsafe.Sizeof(p))) -} - -func DetachLsf(fd int) error { - var dummy int - return setsockopt(fd, SOL_SOCKET, SO_DETACH_FILTER, (*byte)(unsafe.Pointer(&dummy)), Socklen_t(unsafe.Sizeof(dummy))) -} diff --git a/gcc-4.8.1/libgo/go/syscall/mksyscall.awk b/gcc-4.8.1/libgo/go/syscall/mksyscall.awk deleted file mode 100644 index 74f0e28af..000000000 --- a/gcc-4.8.1/libgo/go/syscall/mksyscall.awk +++ /dev/null @@ -1,295 +0,0 @@ -# Copyright 2011 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. - -# This AWK script reads a Go file with comments describing syscall -# functions and the C routines they map to. It generates the Go code -# which calls the C routines. - -# The syscall functins 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. -# This includes return parameters. -# * The parameter lists must give a type for each argument: -# the (x, y, z int) shorthand is not allowed. -# * If the return parameter is an error, it must be named err. - -# A line beginning with //sysnb is like //sys, except that the -# goroutine will not be suspended during the execution of the library -# call. This must only be used for library calls which can never -# block, as otherwise the library call could cause all goroutines to -# hang. - -# After the //sys or //sysnb line comes a second line which describes -# the C function. The name must be the name of the function in the C -# library, and may be the same as the Go function. The limitations on -# the argument list are the same as for the //sys line, but there must -# be at most one result parameter, and it must be given as just a -# type, without a name. - -BEGIN { - print "// This file was automatically generated by mksyscall.awk" - print "" - print "package syscall" - print "" - print "import \"unsafe\"" - print "" - status = 0 -} - -/^\/\/sys/ { - if ($1 == "//sysnb") { - blocking = 0 - } else { - blocking = 1 - } - - line = $0 - - if (match(line, "//sys(nb)?[ ]*[a-zA-Z0-9_]+\\([^()]*\\) *(\\(([^()]+)\\))?") == 0) { - print "unmatched line:", $0 | "cat 1>&2" - status = 1 - next - } - - # Sets a[1] = //sysnb, a[2] == function name. - split(line, a, "[ (]*") - gofnname = a[2] - - off = match(line, "\\([^()]*\\)") - end = index(substr(line, off, length(line) - off + 1), ")") - gofnparams = substr(line, off + 1, end - 2) - - line = substr(line, off + end, length(line) - (off + end) + 1) - off = match(line, "\\([^()]*\\)") - if (off == 0) { - gofnresults = "" - } else { - end = index(substr(line, off, length(line) - off + 1), ")") - gofnresults = substr(line, off + 1, end - 2) - } - - getline - line = $0 - - if (match(line, "//[a-zA-Z0-9_]+\\([^()]*\\)") == 0) { - print "unmatched C line", $0, "after", gofnname | "cat 1>&2" - status = 1 - next - } - - split(line, a, "[ (]*") - cfnname = substr(a[1], 3, length(a[1]) - 2) - - off = match(line, "\\([^()]*\\)") - end = index(substr(line, off, length(line) - off + 1), ")") - cfnparams = substr(line, off + 1, end - 2) - - line = substr(line, off + end + 1, length(line) - (off + end) + 1) - while (substr(line, 1, 1) == " ") { - line = substr(line, 2, length(line) - 1) - } - end = index(line, " ") - if (end != 0) { - line = substr(line, 1, end) - } - cfnresult = line - - printf("// Automatically generated wrapper for %s/%s\n", gofnname, cfnname) - printf("//extern %s\n", cfnname) - printf("func c_%s(%s) %s\n", cfnname, cfnparams, cfnresult) - printf("func %s(%s) %s%s%s%s{\n", - gofnname, gofnparams, gofnresults == "" ? "" : "(", gofnresults, - gofnresults == "" ? "" : ")", gofnresults == "" ? "" : " ") - - loc = gofnname "/" cfnname ":" - - haserr = 0 - if (gofnresults != "") { - fields = split(gofnresults, goresults, ", *") - for (goresult = 1; goresults[goresult] != ""; goresult++) { - if (split(goresults[goresult], goparam) == 2) { - if (goparam[1] == "err") { - haserr = 1 - break - } - } - } - } - - split(gofnparams, goargs, ", *") - split(cfnparams, cargs, ", *") - args = "" - carg = 1 - for (goarg = 1; goargs[goarg] != ""; goarg++) { - if (cargs[carg] == "") { - print loc, "not enough C parameters" - } - - if (args != "") { - args = args ", " - } - - if (split(goargs[goarg], a) != 2) { - print loc, "bad parameter:", goargs[goarg] | "cat 1>&2" - status = 1 - next - } - - goname = a[1] - gotype = a[2] - - if (split(cargs[carg], a) != 2) { - print loc, "bad C parameter:", cargs[carg] | "cat 1>&2" - status = 1 - next - } - - ctype = a[2] - - if (gotype ~ /^\*/) { - if (gotype != ctype) { - print loc, "Go/C pointer type mismatch:", gotype, ctype | "cat 1>&2" - status = 1 - next - } - args = args goname - } else if (gotype == "string") { - if (ctype != "*byte") { - print loc, "Go string not matched to C *byte:", gotype, ctype | "cat 1>&2" - status = 1 - next - } - printf("\tvar _p%d *byte\n", goarg) - if (haserr) { - printf("\t_p%d, err = BytePtrFromString(%s)\n", goarg, goname) - printf("\tif err != nil {\n\t\treturn\n\t}\n") - } else { - print loc, "uses string arguments but has no error return" | "cat 1>&2" - printf("\t_p%d, _ = BytePtrFromString(%s)\n", goarg, goname) - } - args = sprintf("%s_p%d", args, goarg) - } else if (gotype ~ /^\[\](.*)/) { - if (ctype !~ /^\*/ || cargs[carg + 1] == "") { - print loc, "bad C type for slice:", gotype, ctype | "cat 1>&2" - status = 1 - next - } - - # Convert a slice into a pair of pointer, length. - # Don't try to take the address of the zeroth element of a - # nil slice. - printf("\tvar _p%d %s\n", goarg, ctype) - printf("\tif len(%s) > 0 {\n", goname) - printf("\t\t_p%d = (%s)(unsafe.Pointer(&%s[0]))\n", goarg, ctype, goname) - printf("\t} else {\n") - printf("\t\t_p%d = (%s)(unsafe.Pointer(&_zero))\n", goarg, ctype) - printf("\t}\n") - - ++carg - if (split(cargs[carg], cparam) != 2) { - print loc, "bad C parameter:", cargs[carg] | "cat 1>&2" - status = 1 - next - } - - args = sprintf("%s_p%d, %s(len(%s))", args, goarg, cparam[2], goname) - } else if (gotype == "uintptr" && ctype ~ /^\*/) { - args = sprintf("%s(%s)(unsafe.Pointer(%s))", args, ctype, goname) - } else { - args = sprintf("%s%s(%s)", args, ctype, goname) - } - - carg++ - } - - if (cargs[carg] != "") { - print loc, "too many C parameters" | "cat 1>&2" - status = 1 - next - } - - if (blocking) { - print "\tEntersyscall()" - } - - printf("\t") - if (gofnresults != "") { - printf("_r := ") - } - printf("c_%s(%s)\n", cfnname, args) - - seterr = 0 - if (gofnresults != "") { - fields = split(gofnresults, goresults, ", *") - if (fields > 2) { - print loc, "too many Go results" | "cat 1>&2" - status = 1 - next - } - usedr = 0 - for (goresult = 1; goresults[goresult] != ""; goresult++) { - if (split(goresults[goresult], goparam) != 2) { - print loc, "bad result:", goresults[goresult] | "cat 1>&2" - status = 1 - next - } - - goname = goparam[1] - gotype = goparam[2] - - if (goname == "err") { - print "\tvar errno Errno" - print "\tsetErrno := false" - if (cfnresult ~ /^\*/) { - print "\tif _r == nil {" - } else { - print "\tif _r < 0 {" - } - print "\t\terrno = GetErrno()" - print "\t\tsetErrno = true" - print "\t}" - seterr = 1 - } else if (gotype == "uintptr" && cfnresult ~ /^\*/) { - printf("\t%s = (%s)(unsafe.Pointer(_r))\n", goname, gotype) - } else { - if (usedr) { - print loc, "two parameters but no errno parameter" | "cat 1>&2" - status = 1 - next - } - printf("\t%s = (%s)(_r)\n", goname, gotype) - usedr = 1 - } - } - } - - if (blocking) { - print "\tExitsyscall()" - } - - if (seterr) { - print "\tif setErrno {" - print "\t\terr = errno" - print "\t}" - } - - if (gofnresults != "") { - print "\treturn" - } - - print "}" - - print "" - - next -} - -{ next } - -END { - if (status != 0) { - print "*** mksyscall.awk failed" | "cat 1>&2" - exit status - } -} diff --git a/gcc-4.8.1/libgo/go/syscall/netlink_linux.go b/gcc-4.8.1/libgo/go/syscall/netlink_linux.go deleted file mode 100644 index 49550ea2f..000000000 --- a/gcc-4.8.1/libgo/go/syscall/netlink_linux.go +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright 2011 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. - -// Netlink sockets and messages - -package syscall - -import "unsafe" - -// Round the length of a netlink message up to align it properly. -func nlmAlignOf(msglen int) int { - return (msglen + NLMSG_ALIGNTO - 1) & ^(NLMSG_ALIGNTO - 1) -} - -// Round the length of a netlink route attribute up to align it -// properly. -func rtaAlignOf(attrlen int) int { - return (attrlen + RTA_ALIGNTO - 1) & ^(RTA_ALIGNTO - 1) -} - -// NetlinkRouteRequest represents a request message to receive routing -// and link states from the kernel. -type NetlinkRouteRequest struct { - Header NlMsghdr - Data RtGenmsg -} - -func (rr *NetlinkRouteRequest) toWireFormat() []byte { - b := make([]byte, rr.Header.Len) - *(*uint32)(unsafe.Pointer(&b[0:4][0])) = rr.Header.Len - *(*uint16)(unsafe.Pointer(&b[4:6][0])) = rr.Header.Type - *(*uint16)(unsafe.Pointer(&b[6:8][0])) = rr.Header.Flags - *(*uint32)(unsafe.Pointer(&b[8:12][0])) = rr.Header.Seq - *(*uint32)(unsafe.Pointer(&b[12:16][0])) = rr.Header.Pid - b[16] = byte(rr.Data.Family) - return b -} - -func newNetlinkRouteRequest(proto, seq, family int) []byte { - rr := &NetlinkRouteRequest{} - rr.Header.Len = uint32(NLMSG_HDRLEN + SizeofRtGenmsg) - rr.Header.Type = uint16(proto) - rr.Header.Flags = NLM_F_DUMP | NLM_F_REQUEST - rr.Header.Seq = uint32(seq) - rr.Data.Family = uint8(family) - return rr.toWireFormat() -} - -// NetlinkRIB returns routing information base, as known as RIB, which -// consists of network facility information, states and parameters. -func NetlinkRIB(proto, family int) ([]byte, error) { - s, err := Socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE) - if err != nil { - return nil, err - } - defer Close(s) - lsa := &SockaddrNetlink{Family: AF_NETLINK} - if err := Bind(s, lsa); err != nil { - return nil, err - } - wb := newNetlinkRouteRequest(proto, 1, family) - if err := Sendto(s, wb, 0, lsa); err != nil { - return nil, err - } - var tab []byte -done: - for { - rb := make([]byte, Getpagesize()) - nr, _, err := Recvfrom(s, rb, 0) - if err != nil { - return nil, err - } - if nr < NLMSG_HDRLEN { - return nil, EINVAL - } - rb = rb[:nr] - tab = append(tab, rb...) - msgs, err := ParseNetlinkMessage(rb) - if err != nil { - return nil, err - } - for _, m := range msgs { - lsa, err := Getsockname(s) - if err != nil { - return nil, err - } - switch v := lsa.(type) { - case *SockaddrNetlink: - if m.Header.Seq != 1 || m.Header.Pid != v.Pid { - return nil, EINVAL - } - default: - return nil, EINVAL - } - if m.Header.Type == NLMSG_DONE { - break done - } - if m.Header.Type == NLMSG_ERROR { - return nil, EINVAL - } - } - } - return tab, nil -} - -// NetlinkMessage represents a netlink message. -type NetlinkMessage struct { - Header NlMsghdr - Data []byte -} - -// ParseNetlinkMessage parses b as an array of netlink messages and -// returns the slice containing the NetlinkMessage structures. -func ParseNetlinkMessage(b []byte) ([]NetlinkMessage, error) { - var msgs []NetlinkMessage - for len(b) >= NLMSG_HDRLEN { - h, dbuf, dlen, err := netlinkMessageHeaderAndData(b) - if err != nil { - return nil, err - } - m := NetlinkMessage{Header: *h, Data: dbuf[:int(h.Len)-NLMSG_HDRLEN]} - msgs = append(msgs, m) - b = b[dlen:] - } - return msgs, nil -} - -func netlinkMessageHeaderAndData(b []byte) (*NlMsghdr, []byte, int, error) { - h := (*NlMsghdr)(unsafe.Pointer(&b[0])) - if int(h.Len) < NLMSG_HDRLEN || int(h.Len) > len(b) { - return nil, nil, 0, EINVAL - } - return h, b[NLMSG_HDRLEN:], nlmAlignOf(int(h.Len)), nil -} - -// NetlinkRouteAttr represents a netlink route attribute. -type NetlinkRouteAttr struct { - Attr RtAttr - Value []byte -} - -// ParseNetlinkRouteAttr parses m's payload as an array of netlink -// route attributes and returns the slice containing the -// NetlinkRouteAttr structures. -func ParseNetlinkRouteAttr(m *NetlinkMessage) ([]NetlinkRouteAttr, error) { - var b []byte - switch m.Header.Type { - case RTM_NEWLINK, RTM_DELLINK: - b = m.Data[SizeofIfInfomsg:] - case RTM_NEWADDR, RTM_DELADDR: - b = m.Data[SizeofIfAddrmsg:] - case RTM_NEWROUTE, RTM_DELROUTE: - b = m.Data[SizeofRtMsg:] - default: - return nil, EINVAL - } - var attrs []NetlinkRouteAttr - for len(b) >= SizeofRtAttr { - a, vbuf, alen, err := netlinkRouteAttrAndValue(b) - if err != nil { - return nil, err - } - ra := NetlinkRouteAttr{Attr: *a, Value: vbuf[:int(a.Len)-SizeofRtAttr]} - attrs = append(attrs, ra) - b = b[alen:] - } - return attrs, nil -} - -func netlinkRouteAttrAndValue(b []byte) (*RtAttr, []byte, int, error) { - a := (*RtAttr)(unsafe.Pointer(&b[0])) - if int(a.Len) < SizeofRtAttr || int(a.Len) > len(b) { - return nil, nil, 0, EINVAL - } - return a, b[SizeofRtAttr:], rtaAlignOf(int(a.Len)), nil -} diff --git a/gcc-4.8.1/libgo/go/syscall/passfd_test.go b/gcc-4.8.1/libgo/go/syscall/passfd_test.go deleted file mode 100644 index 20ef39eca..000000000 --- a/gcc-4.8.1/libgo/go/syscall/passfd_test.go +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2012 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 linux darwin - -package syscall_test - -import ( - "flag" - "fmt" - "io/ioutil" - "net" - "os" - "os/exec" - "syscall" - "testing" - "time" -) - -// TestPassFD tests passing a file descriptor over a Unix socket. -// -// This test involved both a parent and child process. The parent -// process is invoked as a normal test, with "go test", which then -// runs the child process by running the current test binary with args -// "-test.run=^TestPassFD$" and an environment variable used to signal -// that the test should become the child process instead. -func TestPassFD(t *testing.T) { - if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" { - passFDChild() - return - } - - tempDir, err := ioutil.TempDir("", "TestPassFD") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(tempDir) - - fds, err := syscall.Socketpair(syscall.AF_LOCAL, syscall.SOCK_STREAM, 0) - if err != nil { - t.Fatalf("Socketpair: %v", err) - } - defer syscall.Close(fds[0]) - defer syscall.Close(fds[1]) - writeFile := os.NewFile(uintptr(fds[0]), "child-writes") - readFile := os.NewFile(uintptr(fds[1]), "parent-reads") - defer writeFile.Close() - defer readFile.Close() - - cmd := exec.Command(os.Args[0], "-test.run=^TestPassFD$", "--", tempDir) - cmd.Env = append([]string{"GO_WANT_HELPER_PROCESS=1"}, os.Environ()...) - cmd.ExtraFiles = []*os.File{writeFile} - - out, err := cmd.CombinedOutput() - if len(out) > 0 || err != nil { - t.Fatalf("child process: %q, %v", out, err) - } - - c, err := net.FileConn(readFile) - if err != nil { - t.Fatalf("FileConn: %v", err) - } - defer c.Close() - - uc, ok := c.(*net.UnixConn) - if !ok { - t.Fatalf("unexpected FileConn type; expected UnixConn, got %T", c) - } - - buf := make([]byte, 32) // expect 1 byte - oob := make([]byte, 32) // expect 24 bytes - closeUnix := time.AfterFunc(5*time.Second, func() { - t.Logf("timeout reading from unix socket") - uc.Close() - }) - _, oobn, _, _, err := uc.ReadMsgUnix(buf, oob) - closeUnix.Stop() - - scms, err := syscall.ParseSocketControlMessage(oob[:oobn]) - if err != nil { - t.Fatalf("ParseSocketControlMessage: %v", err) - } - if len(scms) != 1 { - t.Fatalf("expected 1 SocketControlMessage; got scms = %#v", scms) - } - scm := scms[0] - gotFds, err := syscall.ParseUnixRights(&scm) - if err != nil { - t.Fatalf("syscall.ParseUnixRights: %v", err) - } - if len(gotFds) != 1 { - t.Fatalf("wanted 1 fd; got %#v", gotFds) - } - - f := os.NewFile(uintptr(gotFds[0]), "fd-from-child") - defer f.Close() - - got, err := ioutil.ReadAll(f) - want := "Hello from child process!\n" - if string(got) != want { - t.Errorf("child process ReadAll: %q, %v; want %q", got, err, want) - } -} - -// passFDChild is the child process used by TestPassFD. -func passFDChild() { - defer os.Exit(0) - - // Look for our fd. It should be fd 3, but we work around an fd leak - // bug here (http://golang.org/issue/2603) to let it be elsewhere. - var uc *net.UnixConn - for fd := uintptr(3); fd <= 10; fd++ { - f := os.NewFile(fd, "unix-conn") - var ok bool - netc, _ := net.FileConn(f) - uc, ok = netc.(*net.UnixConn) - if ok { - break - } - } - if uc == nil { - fmt.Println("failed to find unix fd") - return - } - - // Make a file f to send to our parent process on uc. - // We make it in tempDir, which our parent will clean up. - flag.Parse() - tempDir := flag.Arg(0) - f, err := ioutil.TempFile(tempDir, "") - if err != nil { - fmt.Printf("TempFile: %v", err) - return - } - - f.Write([]byte("Hello from child process!\n")) - f.Seek(0, 0) - - rights := syscall.UnixRights(int(f.Fd())) - dummyByte := []byte("x") - n, oobn, err := uc.WriteMsgUnix(dummyByte, rights, nil) - if err != nil { - fmt.Printf("WriteMsgUnix: %v", err) - return - } - if n != 1 || oobn != len(rights) { - fmt.Printf("WriteMsgUnix = %d, %d; want 1, %d", n, oobn, len(rights)) - return - } -} diff --git a/gcc-4.8.1/libgo/go/syscall/race0.go b/gcc-4.8.1/libgo/go/syscall/race0.go deleted file mode 100644 index e94fb47af..000000000 --- a/gcc-4.8.1/libgo/go/syscall/race0.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 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 !race - -package syscall - -import ( - "unsafe" -) - -const raceenabled = false - -func raceAcquire(addr unsafe.Pointer) { -} - -func raceReleaseMerge(addr unsafe.Pointer) { -} diff --git a/gcc-4.8.1/libgo/go/syscall/route_bsd.go b/gcc-4.8.1/libgo/go/syscall/route_bsd.go deleted file mode 100644 index e17d976b1..000000000 --- a/gcc-4.8.1/libgo/go/syscall/route_bsd.go +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright 2011 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 darwin freebsd netbsd openbsd - -// Routing sockets and messages - -package syscall - -import ( - "unsafe" -) - -// Round the length of a raw sockaddr up to align it properly. -func rsaAlignOf(salen int) int { - salign := sizeofPtr - // NOTE: It seems like 64-bit Darwin kernel still requires 32-bit - // aligned access to BSD subsystem. - if darwinAMD64 { - salign = 4 - } - if salen == 0 { - return salign - } - return (salen + salign - 1) & ^(salign - 1) -} - -// RouteRIB returns routing information base, as known as RIB, -// which consists of network facility information, states and -// parameters. -func RouteRIB(facility, param int) ([]byte, error) { - mib := []_C_int{CTL_NET, AF_ROUTE, 0, 0, _C_int(facility), _C_int(param)} - - // Find size. - n := uintptr(0) - if err := sysctl(mib, nil, &n, nil, 0); err != nil { - return nil, err - } - if n == 0 { - return nil, nil - } - - tab := make([]byte, n) - if err := sysctl(mib, &tab[0], &n, nil, 0); err != nil { - return nil, err - } - - return tab[:n], nil -} - -// RoutingMessage represents a routing message. -type RoutingMessage interface { - sockaddr() []Sockaddr -} - -const anyMessageLen = int(unsafe.Sizeof(anyMessage{})) - -type anyMessage struct { - Msglen uint16 - Version uint8 - Type uint8 -} - -// RouteMessage represents a routing message containing routing -// entries. -type RouteMessage struct { - Header RtMsghdr - Data []byte -} - -const rtaRtMask = RTA_DST | RTA_GATEWAY | RTA_NETMASK | RTA_GENMASK - -func (m *RouteMessage) sockaddr() []Sockaddr { - var ( - af int - sas [4]Sockaddr - ) - - buf := m.Data[:] - for i := uint(0); i < RTAX_MAX; i++ { - if m.Header.Addrs&rtaRtMask&(1<<i) == 0 { - continue - } - rsa := (*RawSockaddr)(unsafe.Pointer(&buf[0])) - switch i { - case RTAX_DST, RTAX_GATEWAY: - sa, err := anyToSockaddr((*RawSockaddrAny)(unsafe.Pointer(rsa))) - if err != nil { - return nil - } - if i == RTAX_DST { - af = int(rsa.Family) - } - sas[i] = sa - case RTAX_NETMASK, RTAX_GENMASK: - switch af { - case AF_INET: - rsa4 := (*RawSockaddrInet4)(unsafe.Pointer(&buf[0])) - sa := new(SockaddrInet4) - for j := 0; rsa4.Len > 0 && j < int(rsa4.Len)-int(unsafe.Offsetof(rsa4.Addr)); j++ { - sa.Addr[j] = rsa4.Addr[j] - } - sas[i] = sa - case AF_INET6: - rsa6 := (*RawSockaddrInet6)(unsafe.Pointer(&buf[0])) - sa := new(SockaddrInet6) - for j := 0; rsa6.Len > 0 && j < int(rsa6.Len)-int(unsafe.Offsetof(rsa6.Addr)); j++ { - sa.Addr[j] = rsa6.Addr[j] - } - sas[i] = sa - } - } - buf = buf[rsaAlignOf(int(rsa.Len)):] - } - - return sas[:] -} - -// InterfaceMessage represents a routing message containing -// network interface entries. -type InterfaceMessage struct { - Header IfMsghdr - Data []byte -} - -func (m *InterfaceMessage) sockaddr() (sas []Sockaddr) { - if m.Header.Addrs&RTA_IFP == 0 { - return nil - } - sa, err := anyToSockaddr((*RawSockaddrAny)(unsafe.Pointer(&m.Data[0]))) - if err != nil { - return nil - } - return append(sas, sa) -} - -// InterfaceAddrMessage represents a routing message containing -// network interface address entries. -type InterfaceAddrMessage struct { - Header IfaMsghdr - Data []byte -} - -const rtaIfaMask = RTA_IFA | RTA_NETMASK | RTA_BRD - -func (m *InterfaceAddrMessage) sockaddr() (sas []Sockaddr) { - if m.Header.Addrs&rtaIfaMask == 0 { - return nil - } - - buf := m.Data[:] - for i := uint(0); i < RTAX_MAX; i++ { - if m.Header.Addrs&rtaIfaMask&(1<<i) == 0 { - continue - } - rsa := (*RawSockaddr)(unsafe.Pointer(&buf[0])) - switch i { - case RTAX_IFA: - sa, err := anyToSockaddr((*RawSockaddrAny)(unsafe.Pointer(rsa))) - if err != nil { - return nil - } - sas = append(sas, sa) - case RTAX_NETMASK: - if rsa.Family == AF_UNSPEC { - rsa.Family = AF_INET // an old fasion, AF_UNSPEC means AF_INET - } - sa, err := anyToSockaddr((*RawSockaddrAny)(unsafe.Pointer(rsa))) - if err != nil { - return nil - } - sas = append(sas, sa) - case RTAX_BRD: - // nothing to do - } - buf = buf[rsaAlignOf(int(rsa.Len)):] - } - - return sas -} - -// ParseRoutingMessage parses buf as routing messages and returns -// the slice containing the RoutingMessage interfaces. -func ParseRoutingMessage(buf []byte) (msgs []RoutingMessage, err error) { - for len(buf) >= anyMessageLen { - any := (*anyMessage)(unsafe.Pointer(&buf[0])) - if any.Version != RTM_VERSION { - return nil, EINVAL - } - msgs = append(msgs, any.toRoutingMessage(buf)) - buf = buf[any.Msglen:] - } - return msgs, nil -} - -// ParseRoutingMessage parses msg's payload as raw sockaddrs and -// returns the slice containing the Sockaddr interfaces. -func ParseRoutingSockaddr(msg RoutingMessage) (sas []Sockaddr, err error) { - return append(sas, msg.sockaddr()...), nil -} diff --git a/gcc-4.8.1/libgo/go/syscall/route_darwin.go b/gcc-4.8.1/libgo/go/syscall/route_darwin.go deleted file mode 100644 index 410e70a13..000000000 --- a/gcc-4.8.1/libgo/go/syscall/route_darwin.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2011 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. - -// Routing sockets and messages for Darwin - -package syscall - -import ( - "unsafe" -) - -func (any *anyMessage) toRoutingMessage(buf []byte) RoutingMessage { - switch any.Type { - case RTM_ADD, RTM_DELETE, RTM_CHANGE, RTM_GET, RTM_LOSING, RTM_REDIRECT, RTM_MISS, RTM_LOCK, RTM_RESOLVE: - p := (*RouteMessage)(unsafe.Pointer(any)) - rtm := &RouteMessage{} - rtm.Header = p.Header - rtm.Data = buf[SizeofRtMsghdr:any.Msglen] - return rtm - case RTM_IFINFO: - p := (*InterfaceMessage)(unsafe.Pointer(any)) - ifm := &InterfaceMessage{} - ifm.Header = p.Header - ifm.Data = buf[SizeofIfMsghdr:any.Msglen] - return ifm - case RTM_NEWADDR, RTM_DELADDR: - p := (*InterfaceAddrMessage)(unsafe.Pointer(any)) - ifam := &InterfaceAddrMessage{} - ifam.Header = p.Header - ifam.Data = buf[SizeofIfaMsghdr:any.Msglen] - return ifam - case RTM_NEWMADDR2, RTM_DELMADDR: - p := (*InterfaceMulticastAddrMessage)(unsafe.Pointer(any)) - ifmam := &InterfaceMulticastAddrMessage{} - ifmam.Header = p.Header - ifmam.Data = buf[SizeofIfmaMsghdr2:any.Msglen] - return ifmam - } - return nil -} - -// InterfaceMulticastAddrMessage represents a routing message -// containing network interface address entries. -type InterfaceMulticastAddrMessage struct { - Header IfmaMsghdr2 - Data []byte -} - -const rtaIfmaMask = RTA_GATEWAY | RTA_IFP | RTA_IFA - -func (m *InterfaceMulticastAddrMessage) sockaddr() (sas []Sockaddr) { - if m.Header.Addrs&rtaIfmaMask == 0 { - return nil - } - - buf := m.Data[:] - for i := uint(0); i < RTAX_MAX; i++ { - if m.Header.Addrs&rtaIfmaMask&(1<<i) == 0 { - continue - } - rsa := (*RawSockaddr)(unsafe.Pointer(&buf[0])) - switch i { - case RTAX_IFA: - sa, e := anyToSockaddr((*RawSockaddrAny)(unsafe.Pointer(rsa))) - if e != nil { - return nil - } - sas = append(sas, sa) - case RTAX_GATEWAY, RTAX_IFP: - // nothing to do - } - buf = buf[rsaAlignOf(int(rsa.Len)):] - } - - return sas -} diff --git a/gcc-4.8.1/libgo/go/syscall/route_freebsd.go b/gcc-4.8.1/libgo/go/syscall/route_freebsd.go deleted file mode 100644 index 094e17044..000000000 --- a/gcc-4.8.1/libgo/go/syscall/route_freebsd.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2011 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. - -// Routing sockets and messages for FreeBSD - -package syscall - -import ( - "unsafe" -) - -func (any *anyMessage) toRoutingMessage(buf []byte) RoutingMessage { - switch any.Type { - case RTM_ADD, RTM_DELETE, RTM_CHANGE, RTM_GET, RTM_LOSING, RTM_REDIRECT, RTM_MISS, RTM_LOCK, RTM_RESOLVE: - p := (*RouteMessage)(unsafe.Pointer(any)) - rtm := &RouteMessage{} - rtm.Header = p.Header - rtm.Data = buf[SizeofRtMsghdr:any.Msglen] - return rtm - case RTM_IFINFO: - p := (*InterfaceMessage)(unsafe.Pointer(any)) - ifm := &InterfaceMessage{} - ifm.Header = p.Header - ifm.Data = buf[SizeofIfMsghdr:any.Msglen] - return ifm - case RTM_NEWADDR, RTM_DELADDR: - p := (*InterfaceAddrMessage)(unsafe.Pointer(any)) - ifam := &InterfaceAddrMessage{} - ifam.Header = p.Header - ifam.Data = buf[SizeofIfaMsghdr:any.Msglen] - return ifam - case RTM_NEWMADDR, RTM_DELMADDR: - p := (*InterfaceMulticastAddrMessage)(unsafe.Pointer(any)) - ifmam := &InterfaceMulticastAddrMessage{} - ifmam.Header = p.Header - ifmam.Data = buf[SizeofIfmaMsghdr:any.Msglen] - return ifmam - } - return nil -} - -// InterfaceMulticastAddrMessage represents a routing message -// containing network interface address entries. -type InterfaceMulticastAddrMessage struct { - Header IfmaMsghdr - Data []byte -} - -const rtaIfmaMask = RTA_GATEWAY | RTA_IFP | RTA_IFA - -func (m *InterfaceMulticastAddrMessage) sockaddr() (sas []Sockaddr) { - if m.Header.Addrs&rtaIfmaMask == 0 { - return nil - } - - buf := m.Data[:] - for i := uint(0); i < RTAX_MAX; i++ { - if m.Header.Addrs&rtaIfmaMask&(1<<i) == 0 { - continue - } - rsa := (*RawSockaddr)(unsafe.Pointer(&buf[0])) - switch i { - case RTAX_IFA: - sa, e := anyToSockaddr((*RawSockaddrAny)(unsafe.Pointer(rsa))) - if e != nil { - return nil - } - sas = append(sas, sa) - case RTAX_GATEWAY, RTAX_IFP: - // nothing to do - } - buf = buf[rsaAlignOf(int(rsa.Len)):] - } - - return sas -} diff --git a/gcc-4.8.1/libgo/go/syscall/route_netbsd.go b/gcc-4.8.1/libgo/go/syscall/route_netbsd.go deleted file mode 100644 index d6d9031bc..000000000 --- a/gcc-4.8.1/libgo/go/syscall/route_netbsd.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2011 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. - -// Routing sockets and messages for NetBSD - -package syscall - -import ( - "unsafe" -) - -func (any *anyMessage) toRoutingMessage(buf []byte) RoutingMessage { - switch any.Type { - case RTM_ADD, RTM_DELETE, RTM_CHANGE, RTM_GET, RTM_LOSING, RTM_REDIRECT, RTM_MISS, RTM_LOCK, RTM_RESOLVE: - p := (*RouteMessage)(unsafe.Pointer(any)) - rtm := &RouteMessage{} - rtm.Header = p.Header - rtm.Data = buf[SizeofRtMsghdr:any.Msglen] - return rtm - case RTM_IFINFO: - p := (*InterfaceMessage)(unsafe.Pointer(any)) - ifm := &InterfaceMessage{} - ifm.Header = p.Header - ifm.Data = buf[SizeofIfMsghdr:any.Msglen] - return ifm - case RTM_NEWADDR, RTM_DELADDR: - p := (*InterfaceAddrMessage)(unsafe.Pointer(any)) - ifam := &InterfaceAddrMessage{} - ifam.Header = p.Header - ifam.Data = buf[SizeofIfaMsghdr:any.Msglen] - return ifam - } - return nil -} diff --git a/gcc-4.8.1/libgo/go/syscall/route_openbsd.go b/gcc-4.8.1/libgo/go/syscall/route_openbsd.go deleted file mode 100644 index 30e1cac46..000000000 --- a/gcc-4.8.1/libgo/go/syscall/route_openbsd.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2011 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. - -// Routing sockets and messages for OpenBSD - -package syscall - -import ( - "unsafe" -) - -func (any *anyMessage) toRoutingMessage(buf []byte) RoutingMessage { - switch any.Type { - case RTM_ADD, RTM_DELETE, RTM_CHANGE, RTM_GET, RTM_LOSING, RTM_REDIRECT, RTM_MISS, RTM_LOCK, RTM_RESOLVE: - p := (*RouteMessage)(unsafe.Pointer(any)) - rtm := &RouteMessage{} - rtm.Header = p.Header - rtm.Data = buf[SizeofRtMsghdr:any.Msglen] - return rtm - case RTM_IFINFO: - p := (*InterfaceMessage)(unsafe.Pointer(any)) - ifm := &InterfaceMessage{} - ifm.Header = p.Header - ifm.Data = buf[SizeofIfMsghdr:any.Msglen] - return ifm - case RTM_NEWADDR, RTM_DELADDR: - p := (*InterfaceAddrMessage)(unsafe.Pointer(any)) - ifam := &InterfaceAddrMessage{} - ifam.Header = p.Header - ifam.Data = buf[SizeofIfaMsghdr:any.Msglen] - return ifam - } - return nil -} diff --git a/gcc-4.8.1/libgo/go/syscall/security_windows.go b/gcc-4.8.1/libgo/go/syscall/security_windows.go deleted file mode 100644 index 71aef2fca..000000000 --- a/gcc-4.8.1/libgo/go/syscall/security_windows.go +++ /dev/null @@ -1,375 +0,0 @@ -// Copyright 2012 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 - -import ( - "unsafe" -) - -const ( - STANDARD_RIGHTS_REQUIRED = 0xf0000 - STANDARD_RIGHTS_READ = 0x20000 - STANDARD_RIGHTS_WRITE = 0x20000 - STANDARD_RIGHTS_EXECUTE = 0x20000 - STANDARD_RIGHTS_ALL = 0x1F0000 -) - -const ( - NameUnknown = 0 - NameFullyQualifiedDN = 1 - NameSamCompatible = 2 - NameDisplay = 3 - NameUniqueId = 6 - NameCanonical = 7 - NameUserPrincipal = 8 - NameCanonicalEx = 9 - NameServicePrincipal = 10 - NameDnsDomain = 12 -) - -// This function returns 1 byte BOOLEAN rather than the 4 byte BOOL. -// http://blogs.msdn.com/b/drnick/archive/2007/12/19/windows-and-upn-format-credentials.aspx -//sys TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) [failretval&0xff==0] = secur32.TranslateNameW -//sys GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) [failretval&0xff==0] = secur32.GetUserNameExW - -// TranslateAccountName converts a directory service -// object name from one format to another. -func TranslateAccountName(username string, from, to uint32, initSize int) (string, error) { - u, e := UTF16PtrFromString(username) - if e != nil { - return "", e - } - b := make([]uint16, 50) - n := uint32(len(b)) - e = TranslateName(u, from, to, &b[0], &n) - if e != nil { - if e != ERROR_INSUFFICIENT_BUFFER { - return "", e - } - // make receive buffers of requested size and try again - b = make([]uint16, n) - e = TranslateName(u, from, to, &b[0], &n) - if e != nil { - return "", e - } - } - return UTF16ToString(b), nil -} - -type UserInfo10 struct { - Name *uint16 - Comment *uint16 - UsrComment *uint16 - FullName *uint16 -} - -//sys NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) = netapi32.NetUserGetInfo -//sys NetApiBufferFree(buf *byte) (neterr error) = netapi32.NetApiBufferFree - -const ( - // do not reorder - SidTypeUser = 1 << iota - SidTypeGroup - SidTypeDomain - SidTypeAlias - SidTypeWellKnownGroup - SidTypeDeletedAccount - SidTypeInvalid - SidTypeUnknown - SidTypeComputer - SidTypeLabel -) - -//sys LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) = advapi32.LookupAccountSidW -//sys LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) = advapi32.LookupAccountNameW -//sys ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) = advapi32.ConvertSidToStringSidW -//sys ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) = advapi32.ConvertStringSidToSidW -//sys GetLengthSid(sid *SID) (len uint32) = advapi32.GetLengthSid -//sys CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) = advapi32.CopySid - -// The security identifier (SID) structure is a variable-length -// structure used to uniquely identify users or groups. -type SID struct{} - -// StringToSid converts a string-format security identifier -// sid into a valid, functional sid. -func StringToSid(s string) (*SID, error) { - var sid *SID - p, e := UTF16PtrFromString(s) - if e != nil { - return nil, e - } - e = ConvertStringSidToSid(p, &sid) - if e != nil { - return nil, e - } - defer LocalFree((Handle)(unsafe.Pointer(sid))) - return sid.Copy() -} - -// LookupSID retrieves a security identifier sid for the account -// and the name of the domain on which the account was found. -// System specify target computer to search. -func LookupSID(system, account string) (sid *SID, domain string, accType uint32, err error) { - if len(account) == 0 { - return nil, "", 0, EINVAL - } - acc, e := UTF16PtrFromString(account) - if e != nil { - return nil, "", 0, e - } - var sys *uint16 - if len(system) > 0 { - sys, e = UTF16PtrFromString(system) - if e != nil { - return nil, "", 0, e - } - } - db := make([]uint16, 50) - dn := uint32(len(db)) - b := make([]byte, 50) - n := uint32(len(b)) - sid = (*SID)(unsafe.Pointer(&b[0])) - e = LookupAccountName(sys, acc, sid, &n, &db[0], &dn, &accType) - if e != nil { - if e != ERROR_INSUFFICIENT_BUFFER { - return nil, "", 0, e - } - // make receive buffers of requested size and try again - b = make([]byte, n) - sid = (*SID)(unsafe.Pointer(&b[0])) - db = make([]uint16, dn) - e = LookupAccountName(sys, acc, sid, &n, &db[0], &dn, &accType) - if e != nil { - return nil, "", 0, e - } - } - return sid, UTF16ToString(db), accType, nil -} - -// String converts sid to a string format -// suitable for display, storage, or transmission. -func (sid *SID) String() (string, error) { - var s *uint16 - e := ConvertSidToStringSid(sid, &s) - if e != nil { - return "", e - } - defer LocalFree((Handle)(unsafe.Pointer(s))) - return UTF16ToString((*[256]uint16)(unsafe.Pointer(s))[:]), nil -} - -// Len returns the length, in bytes, of a valid security identifier sid. -func (sid *SID) Len() int { - return int(GetLengthSid(sid)) -} - -// Copy creates a duplicate of security identifier sid. -func (sid *SID) Copy() (*SID, error) { - b := make([]byte, sid.Len()) - sid2 := (*SID)(unsafe.Pointer(&b[0])) - e := CopySid(uint32(len(b)), sid2, sid) - if e != nil { - return nil, e - } - return sid2, nil -} - -// LookupAccount retrieves the name of the account for this sid -// and the name of the first domain on which this sid is found. -// System specify target computer to search for. -func (sid *SID) LookupAccount(system string) (account, domain string, accType uint32, err error) { - var sys *uint16 - if len(system) > 0 { - sys, err = UTF16PtrFromString(system) - if err != nil { - return "", "", 0, err - } - } - b := make([]uint16, 50) - n := uint32(len(b)) - db := make([]uint16, 50) - dn := uint32(len(db)) - e := LookupAccountSid(sys, sid, &b[0], &n, &db[0], &dn, &accType) - if e != nil { - if e != ERROR_INSUFFICIENT_BUFFER { - return "", "", 0, e - } - // make receive buffers of requested size and try again - b = make([]uint16, n) - db = make([]uint16, dn) - e = LookupAccountSid(nil, sid, &b[0], &n, &db[0], &dn, &accType) - if e != nil { - return "", "", 0, e - } - } - return UTF16ToString(b), UTF16ToString(db), accType, nil -} - -const ( - // do not reorder - TOKEN_ASSIGN_PRIMARY = 1 << iota - TOKEN_DUPLICATE - TOKEN_IMPERSONATE - TOKEN_QUERY - TOKEN_QUERY_SOURCE - TOKEN_ADJUST_PRIVILEGES - TOKEN_ADJUST_GROUPS - TOKEN_ADJUST_DEFAULT - - TOKEN_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | - TOKEN_ASSIGN_PRIMARY | - TOKEN_DUPLICATE | - TOKEN_IMPERSONATE | - TOKEN_QUERY | - TOKEN_QUERY_SOURCE | - TOKEN_ADJUST_PRIVILEGES | - TOKEN_ADJUST_GROUPS | - TOKEN_ADJUST_DEFAULT - TOKEN_READ = STANDARD_RIGHTS_READ | TOKEN_QUERY - TOKEN_WRITE = STANDARD_RIGHTS_WRITE | - TOKEN_ADJUST_PRIVILEGES | - TOKEN_ADJUST_GROUPS | - TOKEN_ADJUST_DEFAULT - TOKEN_EXECUTE = STANDARD_RIGHTS_EXECUTE -) - -const ( - // do not reorder - TokenUser = 1 + iota - TokenGroups - TokenPrivileges - TokenOwner - TokenPrimaryGroup - TokenDefaultDacl - TokenSource - TokenType - TokenImpersonationLevel - TokenStatistics - TokenRestrictedSids - TokenSessionId - TokenGroupsAndPrivileges - TokenSessionReference - TokenSandBoxInert - TokenAuditPolicy - TokenOrigin - TokenElevationType - TokenLinkedToken - TokenElevation - TokenHasRestrictions - TokenAccessInformation - TokenVirtualizationAllowed - TokenVirtualizationEnabled - TokenIntegrityLevel - TokenUIAccess - TokenMandatoryPolicy - TokenLogonSid - MaxTokenInfoClass -) - -type SIDAndAttributes struct { - Sid *SID - Attributes uint32 -} - -type Tokenuser struct { - User SIDAndAttributes -} - -type Tokenprimarygroup struct { - PrimaryGroup *SID -} - -//sys OpenProcessToken(h Handle, access uint32, token *Token) (err error) = advapi32.OpenProcessToken -//sys GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) = advapi32.GetTokenInformation -//sys GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) = userenv.GetUserProfileDirectoryW - -// An access token contains the security information for a logon session. -// The system creates an access token when a user logs on, and every -// process executed on behalf of the user has a copy of the token. -// The token identifies the user, the user's groups, and the user's -// privileges. The system uses the token to control access to securable -// objects and to control the ability of the user to perform various -// system-related operations on the local computer. -type Token Handle - -// OpenCurrentProcessToken opens the access token -// associated with current process. -func OpenCurrentProcessToken() (Token, error) { - p, e := GetCurrentProcess() - if e != nil { - return 0, e - } - var t Token - e = OpenProcessToken(p, TOKEN_QUERY, &t) - if e != nil { - return 0, e - } - return t, nil -} - -// Close releases access to access token. -func (t Token) Close() error { - return CloseHandle(Handle(t)) -} - -// getInfo retrieves a specified type of information about an access token. -func (t Token) getInfo(class uint32, initSize int) (unsafe.Pointer, error) { - b := make([]byte, initSize) - var n uint32 - e := GetTokenInformation(t, class, &b[0], uint32(len(b)), &n) - if e != nil { - if e != ERROR_INSUFFICIENT_BUFFER { - return nil, e - } - // make receive buffers of requested size and try again - b = make([]byte, n) - e = GetTokenInformation(t, class, &b[0], uint32(len(b)), &n) - if e != nil { - return nil, e - } - } - return unsafe.Pointer(&b[0]), nil -} - -// GetTokenUser retrieves access token t user account information. -func (t Token) GetTokenUser() (*Tokenuser, error) { - i, e := t.getInfo(TokenUser, 50) - if e != nil { - return nil, e - } - return (*Tokenuser)(i), nil -} - -// GetTokenPrimaryGroup retrieves access token t primary group information. -// A pointer to a SID structure representing a group that will become -// the primary group of any objects created by a process using this access token. -func (t Token) GetTokenPrimaryGroup() (*Tokenprimarygroup, error) { - i, e := t.getInfo(TokenPrimaryGroup, 50) - if e != nil { - return nil, e - } - return (*Tokenprimarygroup)(i), nil -} - -// GetUserProfileDirectory retrieves path to the -// root directory of the access token t user's profile. -func (t Token) GetUserProfileDirectory() (string, error) { - b := make([]uint16, 100) - n := uint32(len(b)) - e := GetUserProfileDirectory(t, &b[0], &n) - if e != nil { - if e != ERROR_INSUFFICIENT_BUFFER { - return "", e - } - // make receive buffers of requested size and try again - b = make([]uint16, n) - e = GetUserProfileDirectory(t, &b[0], &n) - if e != nil { - return "", e - } - } - return UTF16ToString(b), nil -} diff --git a/gcc-4.8.1/libgo/go/syscall/signame.c b/gcc-4.8.1/libgo/go/syscall/signame.c deleted file mode 100644 index 6f5c2972b..000000000 --- a/gcc-4.8.1/libgo/go/syscall/signame.c +++ /dev/null @@ -1,39 +0,0 @@ -/* signame.c -- get the name of a signal - - Copyright 2012 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. */ - -#include <string.h> - -#include "runtime.h" -#include "arch.h" -#include "malloc.h" - -String Signame (intgo sig) __asm__ (GOSYM_PREFIX "syscall.Signame"); - -String -Signame (intgo sig) -{ - const char* s = NULL; - char buf[100]; - size_t len; - byte *data; - String ret; - -#if defined(HAVE_STRSIGNAL) - s = strsignal (sig); -#endif - - if (s == NULL) - { - snprintf(buf, sizeof buf, "signal %ld", (long) sig); - s = buf; - } - len = __builtin_strlen (s); - data = runtime_mallocgc (len, FlagNoPointers, 0, 0); - __builtin_memcpy (data, s, len); - ret.str = data; - ret.len = len; - return ret; -} diff --git a/gcc-4.8.1/libgo/go/syscall/sleep_rtems.go b/gcc-4.8.1/libgo/go/syscall/sleep_rtems.go deleted file mode 100644 index 9d72203e8..000000000 --- a/gcc-4.8.1/libgo/go/syscall/sleep_rtems.go +++ /dev/null @@ -1,13 +0,0 @@ -// sleep_rtems.go -- Sleep on RTEMS. - -// Copyright 2010 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 Sleep(nsec int64) (err error) { - ts := NsecToTimespec(nsec) - err = Nanosleep(&ts, nil) - return -} diff --git a/gcc-4.8.1/libgo/go/syscall/sleep_select.go b/gcc-4.8.1/libgo/go/syscall/sleep_select.go deleted file mode 100644 index 533f554da..000000000 --- a/gcc-4.8.1/libgo/go/syscall/sleep_select.go +++ /dev/null @@ -1,13 +0,0 @@ -// sleep_select.go -- Sleep using select. - -// Copyright 2011 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 Sleep(nsec int64) (err error) { - tv := NsecToTimeval(nsec); - _, err = Select(0, nil, nil, nil, &tv); - return err; -} diff --git a/gcc-4.8.1/libgo/go/syscall/sockcmsg_linux.go b/gcc-4.8.1/libgo/go/syscall/sockcmsg_linux.go deleted file mode 100644 index a2e26a1f4..000000000 --- a/gcc-4.8.1/libgo/go/syscall/sockcmsg_linux.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2011 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. - -// Socket control messages - -package syscall - -import "unsafe" - -// UnixCredentials encodes credentials into a socket control message -// for sending to another process. This can be used for -// authentication. -func UnixCredentials(ucred *Ucred) []byte { - b := make([]byte, CmsgSpace(SizeofUcred)) - h := (*Cmsghdr)(unsafe.Pointer(&b[0])) - h.Level = SOL_SOCKET - h.Type = SCM_CREDENTIALS - h.SetLen(CmsgLen(SizeofUcred)) - *((*Ucred)(cmsgData(h))) = *ucred - return b -} - -// ParseUnixCredentials decodes a socket control message that contains -// credentials in a Ucred structure. To receive such a message, the -// SO_PASSCRED option must be enabled on the socket. -func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { - if m.Header.Level != SOL_SOCKET { - return nil, EINVAL - } - if m.Header.Type != SCM_CREDENTIALS { - return nil, EINVAL - } - ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) - return &ucred, nil -} diff --git a/gcc-4.8.1/libgo/go/syscall/sockcmsg_unix.go b/gcc-4.8.1/libgo/go/syscall/sockcmsg_unix.go deleted file mode 100644 index 951bc18fc..000000000 --- a/gcc-4.8.1/libgo/go/syscall/sockcmsg_unix.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2011 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 darwin freebsd linux netbsd openbsd - -// Socket control messages - -package syscall - -import ( - "runtime" - "unsafe" -) - -// Round the length of a raw sockaddr up to align it propery. -func cmsgAlignOf(salen int) int { - salign := int(sizeofPtr) - // NOTE: It seems like 64-bit Darwin kernel still requires 32-bit - // aligned access to BSD subsystem. - if darwinAMD64 { - salign = 4 - } - // NOTE: Solaris always uses 32-bit alignment, - // cf. _CMSG_DATA_ALIGNMENT in <sys/socket.h>. - if runtime.GOOS == "solaris" { - salign = 4 - } - if salen == 0 { - return salign - } - return (salen + salign - 1) & ^(salign - 1) -} - -// CmsgLen returns the value to store in the Len field of the Cmsghdr -// structure, taking into account any necessary alignment. -func CmsgLen(datalen int) int { - return cmsgAlignOf(SizeofCmsghdr) + datalen -} - -// CmsgSpace returns the number of bytes an ancillary element with -// payload of the passed data length occupies. -func CmsgSpace(datalen int) int { - return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) -} - -func cmsgData(h *Cmsghdr) unsafe.Pointer { - return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + SizeofCmsghdr) -} - -// SocketControlMessage represents a socket control message. -type SocketControlMessage struct { - Header Cmsghdr - Data []byte -} - -// ParseSocketControlMessage parses b as an array of socket control -// messages. -func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { - var msgs []SocketControlMessage - for len(b) >= CmsgLen(0) { - h, dbuf, err := socketControlMessageHeaderAndData(b) - if err != nil { - return nil, err - } - m := SocketControlMessage{Header: *h, Data: dbuf[:int(h.Len)-cmsgAlignOf(SizeofCmsghdr)]} - msgs = append(msgs, m) - b = b[cmsgAlignOf(int(h.Len)):] - } - return msgs, nil -} - -func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) { - h := (*Cmsghdr)(unsafe.Pointer(&b[0])) - if h.Len < SizeofCmsghdr || int(h.Len) > len(b) { - return nil, nil, EINVAL - } - return h, b[cmsgAlignOf(SizeofCmsghdr):], nil -} - -// UnixRights encodes a set of open file descriptors into a socket -// control message for sending to another process. -func UnixRights(fds ...int) []byte { - datalen := len(fds) * 4 - b := make([]byte, CmsgSpace(datalen)) - h := (*Cmsghdr)(unsafe.Pointer(&b[0])) - h.Level = SOL_SOCKET - h.Type = SCM_RIGHTS - h.SetLen(CmsgLen(datalen)) - data := uintptr(cmsgData(h)) - for _, fd := range fds { - *(*int32)(unsafe.Pointer(data)) = int32(fd) - data += 4 - } - return b -} - -// ParseUnixRights decodes a socket control message that contains an -// integer array of open file descriptors from another process. -func ParseUnixRights(m *SocketControlMessage) ([]int, error) { - if m.Header.Level != SOL_SOCKET { - return nil, EINVAL - } - if m.Header.Type != SCM_RIGHTS { - return nil, EINVAL - } - fds := make([]int, len(m.Data)>>2) - for i, j := 0, 0; i < len(m.Data); i += 4 { - fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) - j++ - } - return fds, nil -} diff --git a/gcc-4.8.1/libgo/go/syscall/socket.go b/gcc-4.8.1/libgo/go/syscall/socket.go deleted file mode 100644 index a625eb698..000000000 --- a/gcc-4.8.1/libgo/go/syscall/socket.go +++ /dev/null @@ -1,408 +0,0 @@ -// socket.go -- Socket handling. - -// 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. - -// Low-level socket interface. -// Only for implementing net package. -// DO NOT USE DIRECTLY. - -package syscall - -import "unsafe" - -// For testing: clients can set this flag to force -// creation of IPv6 sockets to return EAFNOSUPPORT. -var SocketDisableIPv6 bool - -type Sockaddr interface { - sockaddr() (ptr *RawSockaddrAny, len Socklen_t, err error) // lowercase; only we can define Sockaddrs -} - -type RawSockaddrAny struct { - Addr RawSockaddr - Pad [96]int8 -} - -const SizeofSockaddrAny = 0x1c - -type SockaddrInet4 struct { - Port int - Addr [4]byte - raw RawSockaddrInet4 -} - -func (sa *SockaddrInet4) sockaddr() (*RawSockaddrAny, Socklen_t, error) { - if sa.Port < 0 || sa.Port > 0xFFFF { - return nil, 0, EINVAL - } - sa.raw.Family = AF_INET - n := sa.raw.setLen() - p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) - p[0] = byte(sa.Port >> 8) - p[1] = byte(sa.Port) - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } - return (*RawSockaddrAny)(unsafe.Pointer(&sa.raw)), n, nil -} - -type SockaddrInet6 struct { - Port int - ZoneId uint32 - Addr [16]byte - raw RawSockaddrInet6 -} - -func (sa *SockaddrInet6) sockaddr() (*RawSockaddrAny, Socklen_t, error) { - if sa.Port < 0 || sa.Port > 0xFFFF { - return nil, 0, EINVAL - } - sa.raw.Family = AF_INET6 - n := sa.raw.setLen() - p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) - p[0] = byte(sa.Port >> 8) - p[1] = byte(sa.Port) - sa.raw.Scope_id = sa.ZoneId - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } - return (*RawSockaddrAny)(unsafe.Pointer(&sa.raw)), n, nil -} - -type SockaddrUnix struct { - Name string - raw RawSockaddrUnix -} - -func (sa *SockaddrUnix) sockaddr() (*RawSockaddrAny, Socklen_t, error) { - name := sa.Name - n := len(name) - if n >= len(sa.raw.Path) || n == 0 { - return nil, 0, EINVAL - } - sa.raw.Family = AF_UNIX - sa.raw.setLen(n) - for i := 0; i < n; i++ { - sa.raw.Path[i] = int8(name[i]) - } - // length is family (uint16), name, NUL. - sl := 2 + Socklen_t(n) + 1 - if sa.raw.Path[0] == '@' { - sa.raw.Path[0] = 0 - // Don't count trailing NUL for abstract address. - sl-- - } - - // length is family (uint16), name, NUL. - return (*RawSockaddrAny)(unsafe.Pointer(&sa.raw)), sl, nil -} - -func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { - switch rsa.Addr.Family { - case AF_UNIX: - pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa)) - sa := new(SockaddrUnix) - n, err := pp.getLen() - if err != nil { - return nil, err - } - bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0])) - sa.Name = string(bytes[0:n]) - return sa, nil - - case AF_INET: - pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa)) - sa := new(SockaddrInet4) - p := (*[2]byte)(unsafe.Pointer(&pp.Port)) - sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } - return sa, nil - - case AF_INET6: - pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa)) - sa := new(SockaddrInet6) - p := (*[2]byte)(unsafe.Pointer(&pp.Port)) - sa.Port = int(p[0])<<8 + int(p[1]) - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } - return sa, nil - } - return anyToSockaddrOS(rsa) -} - -//sys accept(fd int, sa *RawSockaddrAny, len *Socklen_t) (nfd int, err error) -//accept(fd _C_int, sa *RawSockaddrAny, len *Socklen_t) _C_int - -func Accept(fd int) (nfd int, sa Sockaddr, err error) { - var rsa RawSockaddrAny - var len Socklen_t = SizeofSockaddrAny - nfd, err = accept(fd, &rsa, &len) - if err != nil { - return - } - sa, err = anyToSockaddr(&rsa) - if err != nil { - Close(nfd) - nfd = 0 - } - return -} - -//sysnb getsockname(fd int, sa *RawSockaddrAny, len *Socklen_t) (err error) -//getsockname(fd _C_int, sa *RawSockaddrAny, len *Socklen_t) _C_int - -func Getsockname(fd int) (sa Sockaddr, err error) { - var rsa RawSockaddrAny - var len Socklen_t = SizeofSockaddrAny - if err = getsockname(fd, &rsa, &len); err != nil { - return - } - return anyToSockaddr(&rsa) -} - -//sysnb getpeername(fd int, sa *RawSockaddrAny, len *Socklen_t) (err error) -//getpeername(fd _C_int, sa *RawSockaddrAny, len *Socklen_t) _C_int - -func Getpeername(fd int) (sa Sockaddr, err error) { - var rsa RawSockaddrAny - var len Socklen_t = SizeofSockaddrAny - if err = getpeername(fd, &rsa, &len); err != nil { - return - } - return anyToSockaddr(&rsa) -} - -func Bind(fd int, sa Sockaddr) (err error) { - ptr, n, err := sa.sockaddr() - if err != nil { - return err - } - return bind(fd, ptr, n) -} - -func Connect(fd int, sa Sockaddr) (err error) { - ptr, n, err := sa.sockaddr() - if err != nil { - return err - } - return connect(fd, ptr, n) -} - -func Socket(domain, typ, proto int) (fd int, err error) { - if domain == AF_INET6 && SocketDisableIPv6 { - return -1, EAFNOSUPPORT - } - fd, err = socket(domain, typ, proto) - return -} - -func Socketpair(domain, typ, proto int) (fd [2]int, err error) { - var fdx [2]_C_int - err = socketpair(domain, typ, proto, &fdx) - if err == nil { - fd[0] = int(fdx[0]) - fd[1] = int(fdx[1]) - } - return -} - -func GetsockoptByte(fd, level, opt int) (value byte, err error) { - var n byte - vallen := Socklen_t(1) - err = getsockopt(fd, level, opt, uintptr(unsafe.Pointer(&n)), &vallen) - return n, err -} - -func GetsockoptInt(fd, level, opt int) (value int, err error) { - var n int32 - vallen := Socklen_t(4) - err = getsockopt(fd, level, opt, (uintptr)(unsafe.Pointer(&n)), &vallen) - return int(n), err -} - -func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) { - vallen := Socklen_t(4) - err = getsockopt(fd, level, opt, uintptr(unsafe.Pointer(&value[0])), &vallen) - return value, err -} - -func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) { - var value IPMreq - vallen := Socklen_t(SizeofIPMreq) - err := getsockopt(fd, level, opt, uintptr(unsafe.Pointer(&value)), &vallen) - return &value, err -} - -func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) { - var value IPMreqn - vallen := Socklen_t(SizeofIPMreqn) - err := getsockopt(fd, level, opt, uintptr(unsafe.Pointer(&value)), &vallen) - return &value, err -} - -func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) { - var value IPv6Mreq - vallen := Socklen_t(SizeofIPv6Mreq) - err := getsockopt(fd, level, opt, uintptr(unsafe.Pointer(&value)), &vallen) - return &value, err -} - -//sys setsockopt(s int, level int, name int, val *byte, vallen Socklen_t) (err error) -//setsockopt(s _C_int, level _C_int, optname _C_int, val *byte, vallen Socklen_t) _C_int - -func SetsockoptByte(fd, level, opt int, value byte) (err error) { - var n = byte(value) - return setsockopt(fd, level, opt, (*byte)(unsafe.Pointer(&n)), 1) -} - -func SetsockoptInt(fd, level, opt int, value int) (err error) { - var n = int32(value) - return setsockopt(fd, level, opt, (*byte)(unsafe.Pointer(&n)), 4) -} - -func SetsockoptInet4Addr(fd, level, opt int, value [4]byte) (err error) { - return setsockopt(fd, level, opt, (*byte)(unsafe.Pointer(&value[0])), 4) -} - -func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (err error) { - return setsockopt(fd, level, opt, (*byte)(unsafe.Pointer(tv)), Socklen_t(unsafe.Sizeof(*tv))) -} - -type Linger struct { - Onoff int32 - Linger int32 -} - -func SetsockoptLinger(fd, level, opt int, l *Linger) (err error) { - return setsockopt(fd, level, opt, (*byte)(unsafe.Pointer(l)), Socklen_t(unsafe.Sizeof(*l))) -} - -func SetsockoptIPMreq(fd, level, opt int, mreq *IPMreq) (err error) { - return setsockopt(fd, level, opt, (*byte)(unsafe.Pointer(mreq)), Socklen_t(unsafe.Sizeof(*mreq))) -} - -func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) { - return setsockopt(fd, level, opt, (*byte)(unsafe.Pointer(mreq)), Socklen_t(unsafe.Sizeof(*mreq))) -} - -func SetsockoptIPv6Mreq(fd, level, opt int, mreq *IPv6Mreq) (err error) { - return setsockopt(fd, level, opt, (*byte)(unsafe.Pointer(mreq)), Socklen_t(unsafe.Sizeof(*mreq))) -} - -func SetsockoptString(fd, level, opt int, s string) (err error) { - return setsockopt(fd, level, opt, (*byte)(unsafe.Pointer(&[]byte(s)[0])), Socklen_t(len(s))) -} - -//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *Socklen_t) (n int, err error) -//recvfrom(fd _C_int, buf *byte, len Size_t, flags _C_int, from *RawSockaddrAny, fromlen *Socklen_t) Ssize_t - -func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) { - var rsa RawSockaddrAny - var len Socklen_t = SizeofSockaddrAny - if n, err = recvfrom(fd, p, flags, &rsa, &len); err != nil { - return - } - from, err = anyToSockaddr(&rsa) - return -} - -func Sendto(fd int, p []byte, flags int, to Sockaddr) (err error) { - ptr, n, err := to.sockaddr() - if err != nil { - return err - } - return sendto(fd, p, flags, ptr, n) -} - -func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { - var msg Msghdr - var rsa RawSockaddrAny - msg.Name = (*byte)(unsafe.Pointer(&rsa)) - msg.Namelen = uint32(SizeofSockaddrAny) - var iov Iovec - if len(p) > 0 { - iov.Base = (*byte)(unsafe.Pointer(&p[0])) - iov.SetLen(len(p)) - } - var dummy byte - if len(oob) > 0 { - // receive at least one normal byte - if len(p) == 0 { - iov.Base = &dummy - iov.SetLen(1) - } - msg.Control = (*byte)(unsafe.Pointer(&oob[0])) - msg.SetControllen(len(oob)) - } - msg.Iov = &iov - msg.Iovlen = 1 - if n, err = recvmsg(fd, &msg, flags); err != nil { - return - } - oobn = int(msg.Controllen) - recvflags = int(msg.Flags) - // source address is only specified if the socket is unconnected - if rsa.Addr.Family != AF_UNSPEC { - from, err = anyToSockaddr(&rsa) - } - return -} - -func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { - var ptr *RawSockaddrAny - var salen Socklen_t - if to != nil { - var err error - ptr, salen, err = to.sockaddr() - if err != nil { - return err - } - } - var msg Msghdr - msg.Name = (*byte)(unsafe.Pointer(ptr)) - msg.Namelen = uint32(salen) - var iov Iovec - if len(p) > 0 { - iov.Base = (*byte)(unsafe.Pointer(&p[0])) - iov.SetLen(len(p)) - } - var dummy byte - if len(oob) > 0 { - // send at least one normal byte - if len(p) == 0 { - iov.Base = &dummy - iov.SetLen(1) - } - msg.Control = (*byte)(unsafe.Pointer(&oob[0])) - msg.SetControllen(len(oob)) - } - msg.Iov = &iov - msg.Iovlen = 1 - if err = sendmsg(fd, &msg, flags); err != nil { - return - } - return -} - -//sys Listen(fd int, n int) (err error) -//listen(fd _C_int, n _C_int) _C_int - -//sys Shutdown(fd int, how int) (err error) -//shutdown(fd _C_int, how _C_int) _C_int - -func (iov *Iovec) SetLen(length int) { - iov.Len = Iovec_len_t(length) -} - -func (msghdr *Msghdr) SetControllen(length int) { - msghdr.Controllen = Msghdr_controllen_t(length) -} - -func (cmsg *Cmsghdr) SetLen(length int) { - cmsg.Len = Cmsghdr_len_t(length) -} diff --git a/gcc-4.8.1/libgo/go/syscall/socket_bsd.go b/gcc-4.8.1/libgo/go/syscall/socket_bsd.go deleted file mode 100644 index be5599159..000000000 --- a/gcc-4.8.1/libgo/go/syscall/socket_bsd.go +++ /dev/null @@ -1,78 +0,0 @@ -// socket_bsd.go -- Socket handling specific to *BSD based systems. - -// Copyright 2010 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 - -const SizeofSockaddrInet4 = 16 -const SizeofSockaddrInet6 = 28 -const SizeofSockaddrUnix = 110 - -type RawSockaddrInet4 struct { - Len uint8; - Family uint8; - Port uint16; - Addr [4]byte /* in_addr */; - Zero [8]uint8; -} - -func (sa *RawSockaddrInet4) setLen() Socklen_t { - sa.Len = SizeofSockaddrInet4 - return SizeofSockaddrInet4 -} - -type RawSockaddrInet6 struct { - Len uint8; - Family uint8; - Port uint16; - Flowinfo uint32; - Addr [16]byte /* in6_addr */; - Scope_id uint32; -} - -func (sa *RawSockaddrInet6) setLen() Socklen_t { - sa.Len = SizeofSockaddrInet6 - return SizeofSockaddrInet6 -} - -type RawSockaddrUnix struct { - Len uint8; - Family uint8; - Path [108]int8; -} - -func (sa *RawSockaddrUnix) setLen(n int) { - sa.Len = uint8(3 + n) // 2 for Family, Len; 1 for NUL. -} - -func (sa *RawSockaddrUnix) getLen() (int, error) { - if sa.Len < 3 || sa.Len > SizeofSockaddrUnix { - return 0, EINVAL - } - n := int(sa.Len) - 3 // subtract leading Family, Len, terminating NUL. - for i := 0; i < n; i++ { - if sa.Path[i] == 0 { - // found early NUL; assume Len is overestimating. - n = i - break - } - } - return n, nil -} - -type RawSockaddr struct { - Len uint8; - Family uint8; - Data [14]int8; -} - -// BindToDevice binds the socket associated with fd to device. -func BindToDevice(fd int, device string) (err error) { - return ENOSYS -} - -func anyToSockaddrOS(rsa *RawSockaddrAny) (Sockaddr, error) { - return nil, EAFNOSUPPORT -} diff --git a/gcc-4.8.1/libgo/go/syscall/socket_irix.go b/gcc-4.8.1/libgo/go/syscall/socket_irix.go deleted file mode 100644 index 289769b6d..000000000 --- a/gcc-4.8.1/libgo/go/syscall/socket_irix.go +++ /dev/null @@ -1,130 +0,0 @@ -// socket_irix.go -- Socket handling specific to IRIX 6. - -// Copyright 2011 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 - -const SizeofSockaddrInet4 = 16 -const SizeofSockaddrInet6 = 28 -const SizeofSockaddrUnix = 110 - -type RawSockaddrInet4 struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]uint8 -} - -func (sa *RawSockaddrInet4) setLen() Socklen_t { - return SizeofSockaddrInet4 -} - -type RawSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -func (sa *RawSockaddrInet6) setLen() Socklen_t { - return SizeofSockaddrInet6 -} - -type RawSockaddrUnix struct { - Family uint16 - Path [108]int8 -} - -func (sa *RawSockaddrUnix) setLen(int) { -} - -func (sa *RawSockaddrUnix) getLen() (int, error) { - if sa.Path[0] == 0 { - // "Abstract" Unix domain socket. - // Rewrite leading NUL as @ for textual display. - // (This is the standard convention.) - // Not friendly to overwrite in place, - // but the callers below don't care. - sa.Path[0] = '@' - } - - // Assume path ends at NUL. - // This is not technically the GNU/Linux semantics for - // abstract Unix domain sockets--they are supposed - // to be uninterpreted fixed-size binary blobs--but - // everyone uses this convention. - n := 0 - for n < len(sa.Path)-3 && sa.Path[n] != 0 { - n++ - } - - return n, nil -} - -type RawSockaddr struct { - Family uint16 - Data [14]int8 -} - -// BindToDevice binds the socket associated with fd to device. -func BindToDevice(fd int, device string) (err error) { - return ENOSYS -} - -// <netdb.h> only provides struct addrinfo, AI_* and EAI_* if _NO_XOPEN4 -// && _NO_XOPEN5, but -D_XOPEN_SOURCE=500 is required for msg_control etc. -// in struct msghgr, so simply provide them here. -type Addrinfo struct { - Ai_flags int32 - Ai_family int32 - Ai_socktype int32 - Ai_protocol int32 - Ai_addrlen int32 - Ai_canonname *uint8 - Ai_addr *_sockaddr - Ai_next *Addrinfo -} - -const ( - AI_PASSIVE = 0x00000001 - AI_CANONNAME = 0x00000002 - AI_NUMERICHOST = 0x00000004 - AI_NUMERICSERV = 0x00000008 - AI_ALL = 0x00000100 - AI_ADDRCONFIG = 0x00000400 - AI_V4MAPPED = 0x00000800 - AI_DEFAULT = (AI_V4MAPPED | AI_ADDRCONFIG) -) - -const ( - EAI_ADDRFAMILY = 1 - EAI_AGAIN = 2 - EAI_BADFLAGS = 3 - EAI_FAIL = 4 - EAI_FAMILY = 5 - EAI_MEMORY = 6 - EAI_NODATA = 7 - EAI_NONAME = 8 - EAI_SERVICE = 9 - EAI_SOCKTYPE = 10 - EAI_SYSTEM = 11 - EAI_BADHINTS = 12 - EAI_OVERFLOW = 13 - EAI_MAX = 14 -) - -func anyToSockaddrOS(rsa *RawSockaddrAny) (Sockaddr, error) { - return nil, EAFNOSUPPORT -} - -// <netinet/in.h.h> only provides IPV6_* etc. if _NO_XOPEN4 && _NO_XOPEN5, -// so as above simply provide them here. -const ( - IPV6_UNICAST_HOPS = 48 - IPV6_MULTICAST_IF = IP_MULTICAST_IF - IPV6_MULTICAST_HOPS = IP_MULTICAST_TTL - IPV6_MULTICAST_LOOP = IP_MULTICAST_LOOP -) diff --git a/gcc-4.8.1/libgo/go/syscall/socket_linux.go b/gcc-4.8.1/libgo/go/syscall/socket_linux.go deleted file mode 100644 index 49a1625d0..000000000 --- a/gcc-4.8.1/libgo/go/syscall/socket_linux.go +++ /dev/null @@ -1,177 +0,0 @@ -// socket_linux.go -- Socket handling specific to GNU/Linux. - -// Copyright 2010 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 - -import "unsafe" - -const SizeofSockaddrInet4 = 16 -const SizeofSockaddrInet6 = 28 -const SizeofSockaddrUnix = 110 -const SizeofSockaddrLinklayer = 20 -const SizeofSockaddrNetlink = 12 - -type SockaddrLinklayer struct { - Protocol uint16 - Ifindex int - Hatype uint16 - Pkttype uint8 - Halen uint8 - Addr [8]byte - raw RawSockaddrLinklayer -} - -func (sa *SockaddrLinklayer) sockaddr() (*RawSockaddrAny, Socklen_t, error) { - if sa.Ifindex < 0 || sa.Ifindex > 0x7fffffff { - return nil, 0, EINVAL - } - sa.raw.Family = AF_PACKET - sa.raw.Protocol = sa.Protocol - sa.raw.Ifindex = int32(sa.Ifindex) - sa.raw.Hatype = sa.Hatype - sa.raw.Pkttype = sa.Pkttype - sa.raw.Halen = sa.Halen - for i := 0; i < len(sa.Addr); i++ { - sa.raw.Addr[i] = sa.Addr[i] - } - return (*RawSockaddrAny)(unsafe.Pointer(&sa.raw)), SizeofSockaddrLinklayer, nil -} - -type SockaddrNetlink struct { - Family uint16 - Pad uint16 - Pid uint32 - Groups uint32 - raw RawSockaddrNetlink -} - -func (sa *SockaddrNetlink) sockaddr() (*RawSockaddrAny, Socklen_t, error) { - sa.raw.Family = AF_NETLINK - sa.raw.Pad = sa.Pad - sa.raw.Pid = sa.Pid - sa.raw.Groups = sa.Groups - return (*RawSockaddrAny)(unsafe.Pointer(&sa.raw)), SizeofSockaddrNetlink, nil -} - -type RawSockaddrInet4 struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]uint8 -} - -func (sa *RawSockaddrInet4) setLen() Socklen_t { - return SizeofSockaddrInet4 -} - -type RawSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -func (sa *RawSockaddrInet6) setLen() Socklen_t { - return SizeofSockaddrInet6 -} - -type RawSockaddrUnix struct { - Family uint16 - Path [108]int8 -} - -func (sa *RawSockaddrUnix) setLen(int) { -} - -func (sa *RawSockaddrUnix) getLen() (int, error) { - if sa.Path[0] == 0 { - // "Abstract" Unix domain socket. - // Rewrite leading NUL as @ for textual display. - // (This is the standard convention.) - // Not friendly to overwrite in place, - // but the callers below don't care. - sa.Path[0] = '@' - } - - // Assume path ends at NUL. - // This is not technically the GNU/Linux semantics for - // abstract Unix domain sockets--they are supposed - // to be uninterpreted fixed-size binary blobs--but - // everyone uses this convention. - n := 0 - for n < len(sa.Path) && sa.Path[n] != 0 { - n++ - } - - return n, nil -} - -type RawSockaddrLinklayer struct { - Family uint16 - Protocol uint16 - Ifindex int32 - Hatype uint16 - Pkttype uint8 - Halen uint8 - Addr [8]uint8 -} - -type RawSockaddrNetlink struct { - Family uint16 - Pad uint16 - Pid uint32 - Groups uint32 -} - -type RawSockaddr struct { - Family uint16 - Data [14]int8 -} - -// BindToDevice binds the socket associated with fd to device. -func BindToDevice(fd int, device string) (err error) { - return SetsockoptString(fd, SOL_SOCKET, SO_BINDTODEVICE, device) -} - -func anyToSockaddrOS(rsa *RawSockaddrAny) (Sockaddr, error) { - switch rsa.Addr.Family { - case AF_NETLINK: - pp := (*RawSockaddrNetlink)(unsafe.Pointer(rsa)) - sa := new(SockaddrNetlink) - sa.Family = pp.Family - sa.Pad = pp.Pad - sa.Pid = pp.Pid - sa.Groups = pp.Groups - return sa, nil - - case AF_PACKET: - pp := (*RawSockaddrLinklayer)(unsafe.Pointer(rsa)) - sa := new(SockaddrLinklayer) - sa.Protocol = pp.Protocol - sa.Ifindex = int(pp.Ifindex) - sa.Hatype = pp.Hatype - sa.Pkttype = pp.Pkttype - sa.Halen = pp.Halen - for i := 0; i < len(sa.Addr); i++ { - sa.Addr[i] = pp.Addr[i] - } - return sa, nil - } - return nil, EAFNOSUPPORT -} - -//sysnb EpollCreate(size int) (fd int, err error) -//epoll_create(size _C_int) _C_int - -//sysnb EpollCreate1(flags int) (fd int, err error) -//epoll_create1(flags _C_int) _C_int - -//sysnb EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) -//epoll_ctl(epfd _C_int, op _C_int, fd _C_int, event *EpollEvent) _C_int - -//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) -//epoll_wait(epfd _C_int, events *EpollEvent, maxevents _C_int, timeout _C_int) _C_int diff --git a/gcc-4.8.1/libgo/go/syscall/socket_posix.go b/gcc-4.8.1/libgo/go/syscall/socket_posix.go deleted file mode 100644 index 06d7dab46..000000000 --- a/gcc-4.8.1/libgo/go/syscall/socket_posix.go +++ /dev/null @@ -1,31 +0,0 @@ -// socket_posix.go -- Socket handling for generic POSIX systems. - -// 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 syscall - -//sys bind(fd int, sa *RawSockaddrAny, len Socklen_t) (err error) -//bind(fd _C_int, sa *RawSockaddrAny, len Socklen_t) _C_int - -//sys connect(s int, addr *RawSockaddrAny, addrlen Socklen_t) (err error) -//connect(s _C_int, addr *RawSockaddrAny, addrlen Socklen_t) _C_int - -//sysnb socket(domain int, typ int, proto int) (fd int, err error) -//socket(domain _C_int, typ _C_int, protocol _C_int) _C_int - -//sysnb socketpair(domain int, typ int, proto int, fd *[2]_C_int) (err error) -//socketpair(domain _C_int, typ _C_int, protocol _C_int, fd *[2]_C_int) _C_int - -//sys getsockopt(s int, level int, name int, val uintptr, vallen *Socklen_t) (err error) -//getsockopt(s _C_int, level _C_int, name _C_int, val *byte, vallen *Socklen_t) _C_int - -//sys sendto(s int, buf []byte, flags int, to *RawSockaddrAny, tolen Socklen_t) (err error) -//sendto(s _C_int, buf *byte, len Size_t, flags _C_int, to *RawSockaddrAny, tolen Socklen_t) Ssize_t - -//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) -//recvmsg(s _C_int, msg *Msghdr, flags _C_int) Ssize_t - -//sys sendmsg(s int, msg *Msghdr, flags int) (err error) -//sendmsg(s _C_int, msg *Msghdr, flags _C_int) Ssize_t diff --git a/gcc-4.8.1/libgo/go/syscall/socket_solaris.go b/gcc-4.8.1/libgo/go/syscall/socket_solaris.go deleted file mode 100644 index 0a03465a3..000000000 --- a/gcc-4.8.1/libgo/go/syscall/socket_solaris.go +++ /dev/null @@ -1,80 +0,0 @@ -// socket_solaris.go -- Socket handling specific to Solaris. - -// Copyright 2010 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 - -const SizeofSockaddrInet4 = 16 -const SizeofSockaddrInet6 = 32 -const SizeofSockaddrUnix = 110 - -type RawSockaddrInet4 struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]uint8 -} - -func (sa *RawSockaddrInet4) setLen() Socklen_t { - return SizeofSockaddrInet4 -} - -type RawSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 - Src_id uint32 -} - -func (sa *RawSockaddrInet6) setLen() Socklen_t { - return SizeofSockaddrInet6 -} - -type RawSockaddrUnix struct { - Family uint16 - Path [108]int8 -} - -func (sa *RawSockaddrUnix) setLen(int) { -} - -func (sa *RawSockaddrUnix) getLen() (int, error) { - if sa.Path[0] == 0 { - // "Abstract" Unix domain socket. - // Rewrite leading NUL as @ for textual display. - // (This is the standard convention.) - // Not friendly to overwrite in place, - // but the callers below don't care. - sa.Path[0] = '@' - } - - // Assume path ends at NUL. - // This is not technically the GNU/Linux semantics for - // abstract Unix domain sockets--they are supposed - // to be uninterpreted fixed-size binary blobs--but - // everyone uses this convention. - n := 0 - for n < len(sa.Path) - 3 && sa.Path[n] != 0 { - n++ - } - - return n, nil -} - -type RawSockaddr struct { - Family uint16 - Data [14]int8 -} - -// BindToDevice binds the socket associated with fd to device. -func BindToDevice(fd int, device string) (err error) { - return ENOSYS -} - -func anyToSockaddrOS(rsa *RawSockaddrAny) (Sockaddr, error) { - return nil, EAFNOSUPPORT -} diff --git a/gcc-4.8.1/libgo/go/syscall/socket_xnet.go b/gcc-4.8.1/libgo/go/syscall/socket_xnet.go deleted file mode 100644 index 8f86c622b..000000000 --- a/gcc-4.8.1/libgo/go/syscall/socket_xnet.go +++ /dev/null @@ -1,32 +0,0 @@ -// socket_xnet.go -- Socket handling specific to Solaris. -// Enforce use of XPG 4.2 versions of socket functions. - -// 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 syscall - -//sys bind(fd int, sa *RawSockaddrAny, len Socklen_t) (err error) -//__xnet_bind(fd _C_int, sa *RawSockaddrAny, len Socklen_t) _C_int - -//sys connect(s int, addr *RawSockaddrAny, addrlen Socklen_t) (err error) -//__xnet_connect(s _C_int, addr *RawSockaddrAny, addrlen Socklen_t) _C_int - -//sysnb socket(domain int, typ int, proto int) (fd int, err error) -//__xnet_socket(domain _C_int, typ _C_int, protocol _C_int) _C_int - -//sysnb socketpair(domain int, typ int, proto int, fd *[2]_C_int) (err error) -//__xnet_socketpair(domain _C_int, typ _C_int, protocol _C_int, fd *[2]_C_int) _C_int - -//sys getsockopt(s int, level int, name int, val uintptr, vallen *Socklen_t) (err error) -//__xnet_getsockopt(s _C_int, level _C_int, name _C_int, val *byte, vallen *Socklen_t) _C_int - -//sys sendto(s int, buf []byte, flags int, to *RawSockaddrAny, tolen Socklen_t) (err error) -//__xnet_sendto(s _C_int, buf *byte, len Size_t, flags _C_int, to *RawSockaddrAny, tolen Socklen_t) Ssize_t - -//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) -//__xnet_recvmsg(s _C_int, msg *Msghdr, flags _C_int) Ssize_t - -//sys sendmsg(s int, msg *Msghdr, flags int) (err error) -//__xnet_sendmsg(s _C_int, msg *Msghdr, flags _C_int) Ssize_t diff --git a/gcc-4.8.1/libgo/go/syscall/str.go b/gcc-4.8.1/libgo/go/syscall/str.go deleted file mode 100644 index 0fce842e8..000000000 --- a/gcc-4.8.1/libgo/go/syscall/str.go +++ /dev/null @@ -1,20 +0,0 @@ -// 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 itoa(val int) string { // do it here rather than with fmt to avoid dependency - if val < 0 { - return "-" + itoa(-val) - } - var buf [32]byte // big enough for int64 - i := len(buf) - 1 - for val >= 10 { - buf[i] = byte(val%10 + '0') - i-- - val /= 10 - } - buf[i] = byte(val + '0') - return string(buf[i:]) -} diff --git a/gcc-4.8.1/libgo/go/syscall/syscall.go b/gcc-4.8.1/libgo/go/syscall/syscall.go deleted file mode 100644 index c4f212514..000000000 --- a/gcc-4.8.1/libgo/go/syscall/syscall.go +++ /dev/null @@ -1,87 +0,0 @@ -// 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 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 -// 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 -// 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 - -import "unsafe" - -// StringByteSlice is deprecated. Use ByteSliceFromString instead. -// If s contains a NUL byte this function panics instead of -// returning an error. -func StringByteSlice(s string) []byte { - a, err := ByteSliceFromString(s) - if err != nil { - panic("syscall: string with NUL passed to StringByteSlice") - } - return a -} - -// ByteSliceFromString returns a NUL-terminated slice of bytes -// containing the text of s. If s contains a NUL byte at any -// location, it returns (nil, EINVAL). -func ByteSliceFromString(s string) ([]byte, error) { - for i := 0; i < len(s); i++ { - if s[i] == 0 { - return nil, EINVAL - } - } - a := make([]byte, len(s)+1) - copy(a, s) - return a, nil -} - -// StringBytePtr is deprecated. Use BytePtrFromString instead. -// If s contains a NUL byte this function panics instead of -// returning an error. -func StringBytePtr(s string) *byte { return &StringByteSlice(s)[0] } - -// BytePtrFromString returns a pointer to a NUL-terminated array of -// bytes containing the text of s. If s contains a NUL byte at any -// location, it returns (nil, EINVAL). -func BytePtrFromString(s string) (*byte, error) { - a, err := ByteSliceFromString(s) - if err != nil { - return nil, err - } - return &a[0], nil -} - -// Single-word zero for use when we need a valid pointer to 0 bytes. -// See mksyscall.pl. -var _zero uintptr - -var dummy *byte - -const sizeofPtr uintptr = uintptr(unsafe.Sizeof(dummy)) - -func (ts *Timespec) Unix() (sec int64, nsec int64) { - return int64(ts.Sec), int64(ts.Nsec) -} - -func (tv *Timeval) Unix() (sec int64, nsec int64) { - return int64(tv.Sec), int64(tv.Usec) * 1000 -} - -func (ts *Timespec) Nano() int64 { - return int64(ts.Sec)*1e9 + int64(ts.Nsec) -} - -func (tv *Timeval) Nano() int64 { - return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 -} diff --git a/gcc-4.8.1/libgo/go/syscall/syscall_errno.go b/gcc-4.8.1/libgo/go/syscall/syscall_errno.go deleted file mode 100644 index 810572f58..000000000 --- a/gcc-4.8.1/libgo/go/syscall/syscall_errno.go +++ /dev/null @@ -1,26 +0,0 @@ -// 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 - -// An Errno is an unsigned number describing an error condition. -// It implements the error interface. The zero Errno is by convention -// a non-error, so code to convert from Errno to error should use: -// err = nil -// if errno != 0 { -// err = errno -// } -type Errno uintptr - -func (e Errno) Error() string { - return Errstr(int(e)) -} - -func (e Errno) Temporary() bool { - return e == EINTR || e == EMFILE || e.Timeout() -} - -func (e Errno) Timeout() bool { - return e == EAGAIN || e == EWOULDBLOCK || e == ETIMEDOUT -} diff --git a/gcc-4.8.1/libgo/go/syscall/syscall_linux_386.go b/gcc-4.8.1/libgo/go/syscall/syscall_linux_386.go deleted file mode 100644 index 08422def3..000000000 --- a/gcc-4.8.1/libgo/go/syscall/syscall_linux_386.go +++ /dev/null @@ -1,21 +0,0 @@ -// syscall_linux_386.go -- GNU/Linux 386 specific support - -// 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 - -import "unsafe" - -func (r *PtraceRegs) PC() uint64 { return uint64(uint32(r.Eip)) } - -func (r *PtraceRegs) SetPC(pc uint64) { r.Eip = int32(pc) } - -func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { - return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) -} - -func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { - return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) -} diff --git a/gcc-4.8.1/libgo/go/syscall/syscall_linux_alpha.go b/gcc-4.8.1/libgo/go/syscall/syscall_linux_alpha.go deleted file mode 100644 index 713546cb0..000000000 --- a/gcc-4.8.1/libgo/go/syscall/syscall_linux_alpha.go +++ /dev/null @@ -1,57 +0,0 @@ -// syscall_linux_alpha.go -- GNU/Linux ALPHA specific support - -// Copyright 2011 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 - -import "unsafe" - -type PtraceRegs struct { - R0 uint64 - R1 uint64 - R2 uint64 - R3 uint64 - R4 uint64 - R5 uint64 - R6 uint64 - R7 uint64 - R8 uint64 - R19 uint64 - R20 uint64 - R21 uint64 - R22 uint64 - R23 uint64 - R24 uint64 - R25 uint64 - R26 uint64 - R27 uint64 - R28 uint64 - Hae uint64 - Trap_a0 uint64 - Trap_a1 uint64 - Trap_a2 uint64 - Ps uint64 - Pc uint64 - Gp uint64 - R16 uint64 - R17 uint64 - R18 uint64 -} - -func (r *PtraceRegs) PC() uint64 { - return r.Pc -} - -func (r *PtraceRegs) SetPC(pc uint64) { - r.Pc = pc -} - -func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { - return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) -} - -func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { - return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) -} diff --git a/gcc-4.8.1/libgo/go/syscall/syscall_linux_amd64.go b/gcc-4.8.1/libgo/go/syscall/syscall_linux_amd64.go deleted file mode 100644 index 609faed06..000000000 --- a/gcc-4.8.1/libgo/go/syscall/syscall_linux_amd64.go +++ /dev/null @@ -1,25 +0,0 @@ -// syscall_linux_amd64.go -- GNU/Linux 386 specific support - -// 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 - -import "unsafe" - -func (r *PtraceRegs) PC() uint64 { - return r.Rip -} - -func (r *PtraceRegs) SetPC(pc uint64) { - r.Rip = pc -} - -func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { - return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) -} - -func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { - return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) -} diff --git a/gcc-4.8.1/libgo/go/syscall/syscall_solaris.go b/gcc-4.8.1/libgo/go/syscall/syscall_solaris.go deleted file mode 100644 index c1919171b..000000000 --- a/gcc-4.8.1/libgo/go/syscall/syscall_solaris.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 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 (ts *Timestruc) Unix() (sec int64, nsec int64) { - return int64(ts.Sec), int64(ts.Nsec) -} - -func (ts *Timestruc) Nano() int64 { - return int64(ts.Sec)*1e9 + int64(ts.Nsec) -} diff --git a/gcc-4.8.1/libgo/go/syscall/syscall_stubs.go b/gcc-4.8.1/libgo/go/syscall/syscall_stubs.go deleted file mode 100644 index 76c05cb54..000000000 --- a/gcc-4.8.1/libgo/go/syscall/syscall_stubs.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2010 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. - -// These are stubs. - -package syscall - -func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) { - z := -1 - return uintptr(z), 0, uintptr(ENOSYS) -} - -func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) { - z := -1 - return uintptr(z), 0, uintptr(ENOSYS) -} - -func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) { - z := -1 - return uintptr(z), 0, uintptr(ENOSYS) -} - -func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) { - z := -1 - return uintptr(z), 0, uintptr(ENOSYS) -} diff --git a/gcc-4.8.1/libgo/go/syscall/syscall_unix.go b/gcc-4.8.1/libgo/go/syscall/syscall_unix.go deleted file mode 100644 index fb62681a9..000000000 --- a/gcc-4.8.1/libgo/go/syscall/syscall_unix.go +++ /dev/null @@ -1,198 +0,0 @@ -// 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. - -// +build darwin freebsd linux netbsd openbsd - -package syscall - -import ( - "runtime" - "sync" - "unsafe" -) - -var ( - Stdin = 0 - Stdout = 1 - Stderr = 2 -) - -//extern syscall -func c_syscall32(trap int32, a1, a2, a3, a4, a5, a6 int32) int32 - -//extern syscall -func c_syscall64(trap int64, a1, a2, a3, a4, a5, a6 int64) int64 - -const darwinAMD64 = runtime.GOOS == "darwin" && runtime.GOARCH == "amd64" - -// Do a system call. We look at the size of uintptr to see how to pass -// the arguments, so that we don't pass a 64-bit value when the function -// expects a 32-bit one. -func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { - Entersyscall() - SetErrno(0) - var r uintptr - if unsafe.Sizeof(r) == 4 { - r1 := c_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), 0, 0, 0) - r = uintptr(r1) - } else { - r1 := c_syscall64(int64(trap), int64(a1), int64(a2), int64(a3), 0, 0, 0) - r = uintptr(r1) - } - err = GetErrno() - Exitsyscall() - return r, 0, err -} - -func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { - Entersyscall() - SetErrno(0) - var r uintptr - if unsafe.Sizeof(r) == 4 { - r1 := c_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), - int32(a4), int32(a5), int32(a6)) - r = uintptr(r1) - } else { - r1 := c_syscall64(int64(trap), int64(a1), int64(a2), int64(a3), - int64(a4), int64(a5), int64(a6)) - r = uintptr(r1) - } - err = GetErrno() - Exitsyscall() - return r, 0, err -} - -func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { - var r uintptr - SetErrno(0) - if unsafe.Sizeof(r) == 4 { - r1 := c_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), 0, 0, 0) - r = uintptr(r1) - } else { - r1 := c_syscall64(int64(trap), int64(a1), int64(a2), int64(a3), 0, 0, 0) - r = uintptr(r1) - } - err = GetErrno() - return r, 0, err -} - -func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { - var r uintptr - SetErrno(0) - if unsafe.Sizeof(r) == 4 { - r1 := c_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), - int32(a4), int32(a5), int32(a6)) - r = uintptr(r1) - } else { - r1 := c_syscall64(int64(trap), int64(a1), int64(a2), int64(a3), - int64(a4), int64(a5), int64(a6)) - r = uintptr(r1) - } - err = GetErrno() - return r, 0, err -} - -// Mmap manager, for use by operating system-specific implementations. -// Gccgo only has one implementation but we do this to correspond to gc. - -type mmapper struct { - sync.Mutex - active map[*byte][]byte // active mappings; key is last byte in mapping - mmap func(addr, length uintptr, prot, flags, fd int, offset int64) (uintptr, error) - munmap func(addr uintptr, length uintptr) error -} - -func (m *mmapper) Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { - if length <= 0 { - return nil, EINVAL - } - - // Map the requested memory. - addr, errno := m.mmap(0, uintptr(length), prot, flags, fd, offset) - if errno != nil { - return nil, errno - } - - // Slice memory layout - var sl = struct { - addr uintptr - len int - cap int - }{addr, length, length} - - // Use unsafe to turn sl into a []byte. - b := *(*[]byte)(unsafe.Pointer(&sl)) - - // Register mapping in m and return it. - p := &b[cap(b)-1] - m.Lock() - defer m.Unlock() - m.active[p] = b - return b, nil -} - -func (m *mmapper) Munmap(data []byte) (err error) { - if len(data) == 0 || len(data) != cap(data) { - return EINVAL - } - - // Find the base of the mapping. - p := &data[cap(data)-1] - m.Lock() - defer m.Unlock() - b := m.active[p] - if b == nil || &b[0] != &data[0] { - return EINVAL - } - - // Unmap the memory and update m. - if errno := m.munmap(uintptr(unsafe.Pointer(&b[0])), uintptr(len(b))); errno != nil { - return errno - } - m.active[p] = nil, false - return nil -} - -var mapper = &mmapper{ - active: make(map[*byte][]byte), - mmap: mmap, - munmap: munmap, -} - -func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { - return mapper.Mmap(fd, offset, length, prot, flags) -} - -func Munmap(b []byte) (err error) { - return mapper.Munmap(b) -} - -// A Signal is a number describing a process signal. -// It implements the os.Signal interface. -type Signal int - -func (s Signal) Signal() {} - -func Signame(s Signal) string - -func (s Signal) String() string { - return Signame(s) -} - -func Read(fd int, p []byte) (n int, err error) { - n, err = read(fd, p) - if raceenabled && err == nil { - raceAcquire(unsafe.Pointer(&ioSync)) - } - return -} - -func Write(fd int, p []byte) (n int, err error) { - if raceenabled { - raceReleaseMerge(unsafe.Pointer(&ioSync)) - } - return write(fd, p) -} - -var ioSync int64 diff --git a/gcc-4.8.1/libgo/go/syscall/wait.c b/gcc-4.8.1/libgo/go/syscall/wait.c deleted file mode 100644 index 8c3b53fa4..000000000 --- a/gcc-4.8.1/libgo/go/syscall/wait.c +++ /dev/null @@ -1,106 +0,0 @@ -/* wait.c -- functions for getting wait status values. - - Copyright 2011 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. - - We use C code to extract the wait status so that we can easily be - OS-independent. */ - -#include <stdint.h> -#include <sys/wait.h> - -#include "runtime.h" - -extern _Bool Exited (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.Exited.N18_syscall.WaitStatus"); - -_Bool -Exited (uint32_t *w) -{ - return WIFEXITED (*w) != 0; -} - -extern _Bool Signaled (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.Signaled.N18_syscall.WaitStatus"); - -_Bool -Signaled (uint32_t *w) -{ - return WIFSIGNALED (*w) != 0; -} - -extern _Bool Stopped (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.Stopped.N18_syscall.WaitStatus"); - -_Bool -Stopped (uint32_t *w) -{ - return WIFSTOPPED (*w) != 0; -} - -extern _Bool Continued (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.Continued.N18_syscall.WaitStatus"); - -_Bool -Continued (uint32_t *w) -{ - return WIFCONTINUED (*w) != 0; -} - -extern _Bool CoreDump (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.CoreDump.N18_syscall.WaitStatus"); - -_Bool -CoreDump (uint32_t *w) -{ - return WCOREDUMP (*w) != 0; -} - -extern int ExitStatus (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.ExitStatus.N18_syscall.WaitStatus"); - -int -ExitStatus (uint32_t *w) -{ - if (!WIFEXITED (*w)) - return -1; - return WEXITSTATUS (*w); -} - -extern int Signal (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.Signal.N18_syscall.WaitStatus"); - -int -Signal (uint32_t *w) -{ - if (!WIFSIGNALED (*w)) - return -1; - return WTERMSIG (*w); -} - -extern int StopSignal (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.StopSignal.N18_syscall.WaitStatus"); - -int -StopSignal (uint32_t *w) -{ - if (!WIFSTOPPED (*w)) - return -1; - return WSTOPSIG (*w); -} - -extern int TrapCause (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.TrapCause.N18_syscall.WaitStatus"); - -int -TrapCause (uint32_t *w __attribute__ ((unused))) -{ -#ifndef __linux__ - return -1; -#else - if (!WIFSTOPPED (*w) || WSTOPSIG (*w) != SIGTRAP) - return -1; - return *w >> 16; -#endif -} |