├── client
├── rebuild.sh
├── index.html
├── package.json
├── app.js
└── main.js
├── server
├── database
│ ├── database.go
│ ├── store.go
│ └── database_test.go
└── main.go
├── vendor
├── golang.org
│ └── x
│ │ └── sys
│ │ ├── unix
│ │ ├── asm.s
│ │ ├── constants.go
│ │ ├── syscall_no_getwd.go
│ │ ├── zsysnum_solaris_amd64.go
│ │ ├── env_unset.go
│ │ ├── syscall_linux_amd64_gc.go
│ │ ├── flock_linux_32bit.go
│ │ ├── asm_solaris_amd64.s
│ │ ├── gccgo_linux_sparc64.go
│ │ ├── gccgo_linux_amd64.go
│ │ ├── race0.go
│ │ ├── env_unix.go
│ │ ├── syscall_unix_gc.go
│ │ ├── asm_linux_arm64.s
│ │ ├── str.go
│ │ ├── race.go
│ │ ├── asm_linux_s390x.s
│ │ ├── asm_linux_ppc64x.s
│ │ ├── asm_linux_arm.s
│ │ ├── asm_linux_mips64x.s
│ │ ├── asm_freebsd_arm.s
│ │ ├── asm_netbsd_arm.s
│ │ ├── asm_darwin_386.s
│ │ ├── asm_freebsd_386.s
│ │ ├── asm_netbsd_386.s
│ │ ├── asm_openbsd_386.s
│ │ ├── asm_darwin_amd64.s
│ │ ├── asm_freebsd_amd64.s
│ │ ├── asm_linux_amd64.s
│ │ ├── asm_netbsd_amd64.s
│ │ ├── asm_openbsd_amd64.s
│ │ ├── asm_dragonfly_amd64.s
│ │ ├── asm_darwin_arm.s
│ │ ├── bluetooth_linux.go
│ │ ├── asm_darwin_arm64.s
│ │ ├── asm_linux_mipsx.s
│ │ ├── flock.go
│ │ ├── mksysnum_darwin.pl
│ │ ├── asm_linux_386.s
│ │ ├── syscall_solaris_amd64.go
│ │ ├── syscall_openbsd_amd64.go
│ │ ├── syscall_netbsd_386.go
│ │ ├── syscall_netbsd_arm.go
│ │ ├── syscall_netbsd_amd64.go
│ │ ├── syscall_openbsd_386.go
│ │ ├── gccgo_c.c
│ │ ├── sockcmsg_linux.go
│ │ ├── mksysnum_dragonfly.pl
│ │ ├── mksysnum_openbsd.pl
│ │ ├── mksysnum_netbsd.pl
│ │ ├── syscall_dragonfly_amd64.go
│ │ ├── syscall_freebsd_amd64.go
│ │ ├── syscall_freebsd_arm.go
│ │ ├── syscall_freebsd_386.go
│ │ ├── gccgo.go
│ │ ├── mksysnum_linux.pl
│ │ ├── mksysnum_freebsd.pl
│ │ ├── mkpost.go
│ │ ├── syscall_darwin_arm.go
│ │ ├── syscall_darwin_arm64.go
│ │ ├── syscall_darwin_386.go
│ │ ├── syscall_darwin_amd64.go
│ │ ├── syscall.go
│ │ ├── sockcmsg_unix.go
│ │ ├── syscall_linux_ppc64x.go
│ │ ├── types_netbsd.go
│ │ ├── syscall_linux_amd64.go
│ │ ├── types_dragonfly.go
│ │ ├── types_openbsd.go
│ │ ├── syscall_linux_sparc64.go
│ │ ├── types_darwin.go
│ │ ├── mksysctl_openbsd.pl
│ │ ├── types_solaris.go
│ │ ├── syscall_linux_arm64.go
│ │ ├── syscall_linux_mips64x.go
│ │ ├── ztypes_netbsd_386.go
│ │ ├── syscall_unix.go
│ │ ├── ztypes_netbsd_arm.go
│ │ ├── syscall_linux_mipsx.go
│ │ ├── ztypes_netbsd_amd64.go
│ │ ├── ztypes_solaris_amd64.go
│ │ └── mksyscall_solaris.pl
│ │ ├── PATENTS
│ │ └── LICENSE
└── vendor.json
├── demo
└── demo.proto
└── README.md
/client/rebuild.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | LDFLAGS=-L/usr/local/opt/openssl/lib CPPFLAGS=-I/usr/local/opt/openssl/include ./node_modules/.bin/electron-rebuild
4 |
5 |
--------------------------------------------------------------------------------
/server/database/database.go:
--------------------------------------------------------------------------------
1 | package database
2 |
3 | import (
4 | pb "github.com/iheanyi/go-electron-grpc/demo"
5 | )
6 |
7 | type Database interface {
8 | CreateTodo(todo *pb.Todo) (*pb.Todo, error)
9 | ListTodos() ([]*pb.Todo, error)
10 | }
11 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm.s:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | TEXT ·use(SB),NOSPLIT,$0
10 | RET
11 |
--------------------------------------------------------------------------------
/client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Hello World!
6 |
7 |
8 | No Reply Yet
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/constants.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris
6 |
7 | package unix
8 |
9 | const (
10 | R_OK = 0x4
11 | W_OK = 0x2
12 | X_OK = 0x1
13 | )
14 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_no_getwd.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build dragonfly freebsd netbsd openbsd
6 |
7 | package unix
8 |
9 | const ImplementsGetwd = false
10 |
11 | func Getwd() (string, error) { return "", ENOTSUP }
12 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64,solaris
6 |
7 | package unix
8 |
9 | // TODO(aram): remove these before Go 1.3.
10 | const (
11 | SYS_EXECVE = 59
12 | SYS_FCNTL = 62
13 | )
14 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/env_unset.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build go1.4
6 |
7 | package unix
8 |
9 | import "syscall"
10 |
11 | func Unsetenv(key string) error {
12 | // This was added in Go 1.4.
13 | return syscall.Unsetenv(key)
14 | }
15 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64,linux
6 | // +build !gccgo
7 |
8 | package unix
9 |
10 | import "syscall"
11 |
12 | //go:noescape
13 | func gettimeofday(tv *Timeval) (err syscall.Errno)
14 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/flock_linux_32bit.go:
--------------------------------------------------------------------------------
1 | // +build linux,386 linux,arm linux,mips linux,mipsle
2 |
3 | // Copyright 2014 The Go Authors. All rights reserved.
4 | // Use of this source code is governed by a BSD-style
5 | // license that can be found in the LICENSE file.
6 |
7 | package unix
8 |
9 | func init() {
10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's
11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL.
12 | fcntl64Syscall = SYS_FCNTL64
13 | }
14 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
11 | //
12 |
13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-64
14 | JMP syscall·sysvicall6(SB)
15 |
16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64
17 | JMP syscall·rawSysvicall6(SB)
18 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/gccgo_linux_sparc64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build gccgo,linux,sparc64
6 |
7 | package unix
8 |
9 | import "syscall"
10 |
11 | //extern sysconf
12 | func realSysconf(name int) int64
13 |
14 | func sysconf(name int) (n int64, err syscall.Errno) {
15 | r := realSysconf(name)
16 | if r < 0 {
17 | return 0, syscall.GetErrno()
18 | }
19 | return r, 0
20 | }
21 |
--------------------------------------------------------------------------------
/client/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "go-electron-grpc",
3 | "version": "1.0.0",
4 | "description": "Just a proof of concept for Electron + gRPC + GoLang",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "devDependencies": {
12 | "electron": "^1.4.15",
13 | "electron-rebuild": "^1.5.7",
14 | "grpc": "git+https://github.com/grpc/grpc.git#c84725fd02dc58a819c8c4e8acdc321e81f44764",
15 | "jquery": "^3.1.1"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build gccgo,linux,amd64
6 |
7 | package unix
8 |
9 | import "syscall"
10 |
11 | //extern gettimeofday
12 | func realGettimeofday(*Timeval, *byte) int32
13 |
14 | func gettimeofday(tv *Timeval) (err syscall.Errno) {
15 | r := realGettimeofday(tv, nil)
16 | if r < 0 {
17 | return syscall.GetErrno()
18 | }
19 | return 0
20 | }
21 |
--------------------------------------------------------------------------------
/vendor/vendor.json:
--------------------------------------------------------------------------------
1 | {
2 | "comment": "",
3 | "ignore": "test",
4 | "package": [
5 | {
6 | "checksumSHA1": "nBhBtI5wOm4+vOD4xZbWbE3FlZM=",
7 | "path": "github.com/boltdb/bolt",
8 | "revision": "a705895fdad108f053eae7ee011ed94a0541ee13",
9 | "revisionTime": "2016-12-28T23:26:56Z"
10 | },
11 | {
12 | "checksumSHA1": "uTQtOqR0ePMMcvuvAIksiIZxhqU=",
13 | "path": "golang.org/x/sys/unix",
14 | "revision": "d75a52659825e75fff6158388dddc6a5b04f9ba5",
15 | "revisionTime": "2016-12-14T18:38:57Z"
16 | }
17 | ],
18 | "rootPath": "github.com/iheanyi/go-electron-grpc"
19 | }
20 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/race0.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly
6 |
7 | package unix
8 |
9 | import (
10 | "unsafe"
11 | )
12 |
13 | const raceenabled = false
14 |
15 | func raceAcquire(addr unsafe.Pointer) {
16 | }
17 |
18 | func raceReleaseMerge(addr unsafe.Pointer) {
19 | }
20 |
21 | func raceReadRange(addr unsafe.Pointer, len int) {
22 | }
23 |
24 | func raceWriteRange(addr unsafe.Pointer, len int) {
25 | }
26 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/env_unix.go:
--------------------------------------------------------------------------------
1 | // Copyright 2010 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris
6 |
7 | // Unix environment variables.
8 |
9 | package unix
10 |
11 | import "syscall"
12 |
13 | func Getenv(key string) (value string, found bool) {
14 | return syscall.Getenv(key)
15 | }
16 |
17 | func Setenv(key, value string) error {
18 | return syscall.Setenv(key, value)
19 | }
20 |
21 | func Clearenv() {
22 | syscall.Clearenv()
23 | }
24 |
25 | func Environ() []string {
26 | return syscall.Environ()
27 | }
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_unix_gc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris
6 | // +build !gccgo
7 |
8 | package unix
9 |
10 | import "syscall"
11 |
12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)
13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno)
15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
16 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_arm64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 | // +build arm64
7 | // +build !gccgo
8 |
9 | #include "textflag.h"
10 |
11 | // Just jump to package syscall's implementation for all these functions.
12 | // The runtime may know about them.
13 |
14 | TEXT ·Syscall(SB),NOSPLIT,$0-56
15 | B syscall·Syscall(SB)
16 |
17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
18 | B syscall·Syscall6(SB)
19 |
20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
21 | B syscall·RawSyscall(SB)
22 |
23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
24 | B syscall·RawSyscall6(SB)
25 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/str.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris
6 |
7 | package unix
8 |
9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency
10 | if val < 0 {
11 | return "-" + uitoa(uint(-val))
12 | }
13 | return uitoa(uint(val))
14 | }
15 |
16 | func uitoa(val uint) string {
17 | var buf [32]byte // big enough for int64
18 | i := len(buf) - 1
19 | for val >= 10 {
20 | buf[i] = byte(val%10 + '0')
21 | i--
22 | val /= 10
23 | }
24 | buf[i] = byte(val + '0')
25 | return string(buf[i:])
26 | }
27 |
--------------------------------------------------------------------------------
/demo/demo.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package demo;
4 |
5 | service Greeter {
6 | rpc SayHello(HelloRequest) returns (HelloReply) {}
7 | rpc CreateTodo(CreateTodoRequest) returns (CreateTodoResponse) {}
8 | rpc ListTodos(ListTodosRequest) returns (ListTodosResponse) {}
9 | }
10 |
11 | message HelloRequest {
12 | string name = 1;
13 | }
14 |
15 | message HelloReply {
16 | string message = 1;
17 | }
18 |
19 | message CreateTodoRequest {
20 | Todo todo = 1;
21 | }
22 |
23 | message CreateTodoResponse {
24 | Todo todo = 1;
25 | }
26 |
27 | message Todo {
28 | uint64 id = 1;
29 | string description = 2;
30 | bool done = 3;
31 | }
32 |
33 | message ListTodosRequest {}
34 |
35 | message ListTodosResponse {
36 | repeated Todo todos = 1;
37 | }
38 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/race.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin,race linux,race freebsd,race
6 |
7 | package unix
8 |
9 | import (
10 | "runtime"
11 | "unsafe"
12 | )
13 |
14 | const raceenabled = true
15 |
16 | func raceAcquire(addr unsafe.Pointer) {
17 | runtime.RaceAcquire(addr)
18 | }
19 |
20 | func raceReleaseMerge(addr unsafe.Pointer) {
21 | runtime.RaceReleaseMerge(addr)
22 | }
23 |
24 | func raceReadRange(addr unsafe.Pointer, len int) {
25 | runtime.RaceReadRange(addr, len)
26 | }
27 |
28 | func raceWriteRange(addr unsafe.Pointer, len int) {
29 | runtime.RaceWriteRange(addr, len)
30 | }
31 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_s390x.s:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build s390x
6 | // +build linux
7 | // +build !gccgo
8 |
9 | #include "textflag.h"
10 |
11 | //
12 | // System calls for s390x, Linux
13 | //
14 |
15 | // Just jump to package syscall's implementation for all these functions.
16 | // The runtime may know about them.
17 |
18 | TEXT ·Syscall(SB),NOSPLIT,$0-56
19 | BR syscall·Syscall(SB)
20 |
21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
22 | BR syscall·Syscall6(SB)
23 |
24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
25 | BR syscall·RawSyscall(SB)
26 |
27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
28 | BR syscall·RawSyscall6(SB)
29 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 | // +build ppc64 ppc64le
7 | // +build !gccgo
8 |
9 | #include "textflag.h"
10 |
11 | //
12 | // System calls for ppc64, Linux
13 | //
14 |
15 | // Just jump to package syscall's implementation for all these functions.
16 | // The runtime may know about them.
17 |
18 | TEXT ·Syscall(SB),NOSPLIT,$0-56
19 | BR syscall·Syscall(SB)
20 |
21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
22 | BR syscall·Syscall6(SB)
23 |
24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
25 | BR syscall·RawSyscall(SB)
26 |
27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
28 | BR syscall·RawSyscall6(SB)
29 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_arm.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System calls for arm, Linux
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | B syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | B syscall·Syscall6(SB)
21 |
22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
23 | B syscall·RawSyscall(SB)
24 |
25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
26 | B syscall·RawSyscall6(SB)
27 |
28 | TEXT ·seek(SB),NOSPLIT,$0-32
29 | B syscall·seek(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 | // +build mips64 mips64le
7 | // +build !gccgo
8 |
9 | #include "textflag.h"
10 |
11 | //
12 | // System calls for mips64, Linux
13 | //
14 |
15 | // Just jump to package syscall's implementation for all these functions.
16 | // The runtime may know about them.
17 |
18 | TEXT ·Syscall(SB),NOSPLIT,$0-56
19 | JMP syscall·Syscall(SB)
20 |
21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
22 | JMP syscall·Syscall6(SB)
23 |
24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
25 | JMP syscall·RawSyscall(SB)
26 |
27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
28 | JMP syscall·RawSyscall6(SB)
29 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_freebsd_arm.s:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for ARM, FreeBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | B syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | B syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
23 | B syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26 | B syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
29 | B syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_netbsd_arm.s:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for ARM, NetBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | B syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | B syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
23 | B syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26 | B syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
29 | B syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_darwin_386.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for 386, Darwin
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_freebsd_386.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for 386, FreeBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_netbsd_386.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for 386, NetBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_openbsd_386.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for 386, OpenBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-28
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_darwin_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for AMD64, Darwin
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-56
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for AMD64, FreeBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-56
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System calls for AMD64, Linux
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-56
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
23 | JMP syscall·RawSyscall(SB)
24 |
25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
26 | JMP syscall·RawSyscall6(SB)
27 |
28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16
29 | JMP syscall·gettimeofday(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for AMD64, NetBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-56
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for AMD64, OpenBSD
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-56
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 |
7 | #include "textflag.h"
8 |
9 | //
10 | // System call support for AMD64, DragonFly
11 | //
12 |
13 | // Just jump to package syscall's implementation for all these functions.
14 | // The runtime may know about them.
15 |
16 | TEXT ·Syscall(SB),NOSPLIT,$0-64
17 | JMP syscall·Syscall(SB)
18 |
19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88
20 | JMP syscall·Syscall6(SB)
21 |
22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112
23 | JMP syscall·Syscall9(SB)
24 |
25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64
26 | JMP syscall·RawSyscall(SB)
27 |
28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88
29 | JMP syscall·RawSyscall6(SB)
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_darwin_arm.s:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 | // +build arm,darwin
7 |
8 | #include "textflag.h"
9 |
10 | //
11 | // System call support for ARM, Darwin
12 | //
13 |
14 | // Just jump to package syscall's implementation for all these functions.
15 | // The runtime may know about them.
16 |
17 | TEXT ·Syscall(SB),NOSPLIT,$0-28
18 | B syscall·Syscall(SB)
19 |
20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
21 | B syscall·Syscall6(SB)
22 |
23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
24 | B syscall·Syscall9(SB)
25 |
26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
27 | B syscall·RawSyscall(SB)
28 |
29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
30 | B syscall·RawSyscall6(SB)
31 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/bluetooth_linux.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Bluetooth sockets and messages
6 |
7 | package unix
8 |
9 | // Bluetooth Protocols
10 | const (
11 | BTPROTO_L2CAP = 0
12 | BTPROTO_HCI = 1
13 | BTPROTO_SCO = 2
14 | BTPROTO_RFCOMM = 3
15 | BTPROTO_BNEP = 4
16 | BTPROTO_CMTP = 5
17 | BTPROTO_HIDP = 6
18 | BTPROTO_AVDTP = 7
19 | )
20 |
21 | const (
22 | HCI_CHANNEL_RAW = 0
23 | HCI_CHANNEL_USER = 1
24 | HCI_CHANNEL_MONITOR = 2
25 | HCI_CHANNEL_CONTROL = 3
26 | )
27 |
28 | // Socketoption Level
29 | const (
30 | SOL_BLUETOOTH = 0x112
31 | SOL_HCI = 0x0
32 | SOL_L2CAP = 0x6
33 | SOL_RFCOMM = 0x12
34 | SOL_SCO = 0x11
35 | )
36 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_darwin_arm64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !gccgo
6 | // +build arm64,darwin
7 |
8 | #include "textflag.h"
9 |
10 | //
11 | // System call support for AMD64, Darwin
12 | //
13 |
14 | // Just jump to package syscall's implementation for all these functions.
15 | // The runtime may know about them.
16 |
17 | TEXT ·Syscall(SB),NOSPLIT,$0-56
18 | B syscall·Syscall(SB)
19 |
20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80
21 | B syscall·Syscall6(SB)
22 |
23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104
24 | B syscall·Syscall9(SB)
25 |
26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56
27 | B syscall·RawSyscall(SB)
28 |
29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
30 | B syscall·RawSyscall6(SB)
31 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 | // +build mips mipsle
7 | // +build !gccgo
8 |
9 | #include "textflag.h"
10 |
11 | //
12 | // System calls for mips, Linux
13 | //
14 |
15 | // Just jump to package syscall's implementation for all these functions.
16 | // The runtime may know about them.
17 |
18 | TEXT ·Syscall(SB),NOSPLIT,$0-28
19 | JMP syscall·Syscall(SB)
20 |
21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40
22 | JMP syscall·Syscall6(SB)
23 |
24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52
25 | JMP syscall·Syscall9(SB)
26 |
27 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28
28 | JMP syscall·RawSyscall(SB)
29 |
30 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
31 | JMP syscall·RawSyscall6(SB)
32 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/flock.go:
--------------------------------------------------------------------------------
1 | // +build linux darwin freebsd openbsd netbsd dragonfly
2 |
3 | // Copyright 2014 The Go Authors. All rights reserved.
4 | // Use of this source code is governed by a BSD-style
5 | // license that can be found in the LICENSE file.
6 |
7 | // +build darwin dragonfly freebsd linux netbsd openbsd
8 |
9 | package unix
10 |
11 | import "unsafe"
12 |
13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64.
15 | var fcntl64Syscall uintptr = SYS_FCNTL
16 |
17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
20 | if errno == 0 {
21 | return nil
22 | }
23 | return errno
24 | }
25 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/mksysnum_darwin.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 | # Copyright 2009 The Go Authors. All rights reserved.
3 | # Use of this source code is governed by a BSD-style
4 | # license that can be found in the LICENSE file.
5 | #
6 | # Generate system call table for Darwin from sys/syscall.h
7 |
8 | use strict;
9 |
10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
11 | print STDERR "GOARCH or GOOS not defined in environment\n";
12 | exit 1;
13 | }
14 |
15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV);
16 |
17 | print <){
29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){
30 | my $name = $1;
31 | my $num = $2;
32 | $name =~ y/a-z/A-Z/;
33 | print " SYS_$name = $num;"
34 | }
35 | }
36 |
37 | print < 0) {
15 | user = name;
16 | } else {
17 | user = 'world';
18 | }
19 |
20 | client.sayHello({name: user}, function(err, response) {
21 | window.alert("Greeting: " + response.message);
22 | $nameMessage.text(response.message);
23 | });
24 | });
25 |
26 | let todo = {
27 | todo: {
28 | description: "Get Electron Working",
29 | done: false
30 | }
31 | };
32 |
33 | client.listTodos({}, function(err, response) {
34 | if (err) {
35 | console.log("There was an error listing todos.");
36 | console.log(err);
37 | }
38 |
39 | console.log("Response from List Todos:");
40 | console.log(response);
41 | });
42 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64,openbsd
6 |
7 | package unix
8 |
9 | func Getpagesize() int { return 4096 }
10 |
11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
12 |
13 | func NsecToTimespec(nsec int64) (ts Timespec) {
14 | ts.Sec = nsec / 1e9
15 | ts.Nsec = nsec % 1e9
16 | return
17 | }
18 |
19 | func NsecToTimeval(nsec int64) (tv Timeval) {
20 | nsec += 999 // round up to microsecond
21 | tv.Usec = nsec % 1e9 / 1e3
22 | tv.Sec = nsec / 1e9
23 | return
24 | }
25 |
26 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
27 | k.Ident = uint64(fd)
28 | k.Filter = int16(mode)
29 | k.Flags = uint16(flags)
30 | }
31 |
32 | func (iov *Iovec) SetLen(length int) {
33 | iov.Len = uint64(length)
34 | }
35 |
36 | func (msghdr *Msghdr) SetControllen(length int) {
37 | msghdr.Controllen = uint32(length)
38 | }
39 |
40 | func (cmsg *Cmsghdr) SetLen(length int) {
41 | cmsg.Len = uint32(length)
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build 386,netbsd
6 |
7 | package unix
8 |
9 | func Getpagesize() int { return 4096 }
10 |
11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
12 |
13 | func NsecToTimespec(nsec int64) (ts Timespec) {
14 | ts.Sec = int64(nsec / 1e9)
15 | ts.Nsec = int32(nsec % 1e9)
16 | return
17 | }
18 |
19 | func NsecToTimeval(nsec int64) (tv Timeval) {
20 | nsec += 999 // round up to microsecond
21 | tv.Usec = int32(nsec % 1e9 / 1e3)
22 | tv.Sec = int64(nsec / 1e9)
23 | return
24 | }
25 |
26 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
27 | k.Ident = uint32(fd)
28 | k.Filter = uint32(mode)
29 | k.Flags = uint32(flags)
30 | }
31 |
32 | func (iov *Iovec) SetLen(length int) {
33 | iov.Len = uint32(length)
34 | }
35 |
36 | func (msghdr *Msghdr) SetControllen(length int) {
37 | msghdr.Controllen = uint32(length)
38 | }
39 |
40 | func (cmsg *Cmsghdr) SetLen(length int) {
41 | cmsg.Len = uint32(length)
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build arm,netbsd
6 |
7 | package unix
8 |
9 | func Getpagesize() int { return 4096 }
10 |
11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
12 |
13 | func NsecToTimespec(nsec int64) (ts Timespec) {
14 | ts.Sec = int64(nsec / 1e9)
15 | ts.Nsec = int32(nsec % 1e9)
16 | return
17 | }
18 |
19 | func NsecToTimeval(nsec int64) (tv Timeval) {
20 | nsec += 999 // round up to microsecond
21 | tv.Usec = int32(nsec % 1e9 / 1e3)
22 | tv.Sec = int64(nsec / 1e9)
23 | return
24 | }
25 |
26 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
27 | k.Ident = uint32(fd)
28 | k.Filter = uint32(mode)
29 | k.Flags = uint32(flags)
30 | }
31 |
32 | func (iov *Iovec) SetLen(length int) {
33 | iov.Len = uint32(length)
34 | }
35 |
36 | func (msghdr *Msghdr) SetControllen(length int) {
37 | msghdr.Controllen = uint32(length)
38 | }
39 |
40 | func (cmsg *Cmsghdr) SetLen(length int) {
41 | cmsg.Len = uint32(length)
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64,netbsd
6 |
7 | package unix
8 |
9 | func Getpagesize() int { return 4096 }
10 |
11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
12 |
13 | func NsecToTimespec(nsec int64) (ts Timespec) {
14 | ts.Sec = int64(nsec / 1e9)
15 | ts.Nsec = int64(nsec % 1e9)
16 | return
17 | }
18 |
19 | func NsecToTimeval(nsec int64) (tv Timeval) {
20 | nsec += 999 // round up to microsecond
21 | tv.Usec = int32(nsec % 1e9 / 1e3)
22 | tv.Sec = int64(nsec / 1e9)
23 | return
24 | }
25 |
26 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
27 | k.Ident = uint64(fd)
28 | k.Filter = uint32(mode)
29 | k.Flags = uint32(flags)
30 | }
31 |
32 | func (iov *Iovec) SetLen(length int) {
33 | iov.Len = uint64(length)
34 | }
35 |
36 | func (msghdr *Msghdr) SetControllen(length int) {
37 | msghdr.Controllen = uint32(length)
38 | }
39 |
40 | func (cmsg *Cmsghdr) SetLen(length int) {
41 | cmsg.Len = uint32(length)
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build 386,openbsd
6 |
7 | package unix
8 |
9 | func Getpagesize() int { return 4096 }
10 |
11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
12 |
13 | func NsecToTimespec(nsec int64) (ts Timespec) {
14 | ts.Sec = int64(nsec / 1e9)
15 | ts.Nsec = int32(nsec % 1e9)
16 | return
17 | }
18 |
19 | func NsecToTimeval(nsec int64) (tv Timeval) {
20 | nsec += 999 // round up to microsecond
21 | tv.Usec = int32(nsec % 1e9 / 1e3)
22 | tv.Sec = int64(nsec / 1e9)
23 | return
24 | }
25 |
26 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
27 | k.Ident = uint32(fd)
28 | k.Filter = int16(mode)
29 | k.Flags = uint16(flags)
30 | }
31 |
32 | func (iov *Iovec) SetLen(length int) {
33 | iov.Len = uint32(length)
34 | }
35 |
36 | func (msghdr *Msghdr) SetControllen(length int) {
37 | msghdr.Controllen = uint32(length)
38 | }
39 |
40 | func (cmsg *Cmsghdr) SetLen(length int) {
41 | cmsg.Len = uint32(length)
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/gccgo_c.c:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build gccgo
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | #define _STRINGIFY2_(x) #x
12 | #define _STRINGIFY_(x) _STRINGIFY2_(x)
13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
14 |
15 | // Call syscall from C code because the gccgo support for calling from
16 | // Go to C does not support varargs functions.
17 |
18 | struct ret {
19 | uintptr_t r;
20 | uintptr_t err;
21 | };
22 |
23 | struct ret
24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
25 | {
26 | struct ret r;
27 |
28 | errno = 0;
29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
30 | r.err = errno;
31 | return r;
32 | }
33 |
34 | // Define the use function in C so that it is not inlined.
35 |
36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline));
37 |
38 | void
39 | use(void *p __attribute__ ((unused)))
40 | {
41 | }
42 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/sockcmsg_linux.go:
--------------------------------------------------------------------------------
1 | // Copyright 2011 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Socket control messages
6 |
7 | package unix
8 |
9 | import "unsafe"
10 |
11 | // UnixCredentials encodes credentials into a socket control message
12 | // for sending to another process. This can be used for
13 | // authentication.
14 | func UnixCredentials(ucred *Ucred) []byte {
15 | b := make([]byte, CmsgSpace(SizeofUcred))
16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
17 | h.Level = SOL_SOCKET
18 | h.Type = SCM_CREDENTIALS
19 | h.SetLen(CmsgLen(SizeofUcred))
20 | *((*Ucred)(cmsgData(h))) = *ucred
21 | return b
22 | }
23 |
24 | // ParseUnixCredentials decodes a socket control message that contains
25 | // credentials in a Ucred structure. To receive such a message, the
26 | // SO_PASSCRED option must be enabled on the socket.
27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) {
28 | if m.Header.Level != SOL_SOCKET {
29 | return nil, EINVAL
30 | }
31 | if m.Header.Type != SCM_CREDENTIALS {
32 | return nil, EINVAL
33 | }
34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0]))
35 | return &ucred, nil
36 | }
37 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 | # Copyright 2009 The Go Authors. All rights reserved.
3 | # Use of this source code is governed by a BSD-style
4 | # license that can be found in the LICENSE file.
5 | #
6 | # Generate system call table for DragonFly from master list
7 | # (for example, /usr/src/sys/kern/syscalls.master).
8 |
9 | use strict;
10 |
11 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
12 | print STDERR "GOARCH or GOOS not defined in environment\n";
13 | exit 1;
14 | }
15 |
16 | my $command = "mksysnum_dragonfly.pl " . join(' ', @ARGV);
17 |
18 | print <){
30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){
31 | my $num = $1;
32 | my $proto = $2;
33 | my $name = "SYS_$3";
34 | $name =~ y/a-z/A-Z/;
35 |
36 | # There are multiple entries for enosys and nosys, so comment them out.
37 | if($name =~ /^SYS_E?NOSYS$/){
38 | $name = "// $name";
39 | }
40 | if($name eq 'SYS_SYS_EXIT'){
41 | $name = 'SYS_EXIT';
42 | }
43 |
44 | print " $name = $num; // $proto\n";
45 | }
46 | }
47 |
48 | print <){
30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){
31 | my $num = $1;
32 | my $proto = $3;
33 | my $name = $4;
34 | $name =~ y/a-z/A-Z/;
35 |
36 | # There are multiple entries for enosys and nosys, so comment them out.
37 | if($name =~ /^SYS_E?NOSYS$/){
38 | $name = "// $name";
39 | }
40 | if($name eq 'SYS_SYS_EXIT'){
41 | $name = 'SYS_EXIT';
42 | }
43 |
44 | print " $name = $num; // $proto\n";
45 | }
46 | }
47 |
48 | print < {
32 | // Dereference the window object, usually you would store windows
33 | // in an array if your app supports multi windows, this is the time
34 | // when you should delete the corresponding element.
35 | win = null;
36 | });
37 | }
38 |
39 | app.on('ready', createWindow)
40 |
41 | app.on('window-all-closed', () => {
42 | // On macOS it is common for applications and their menu bar
43 | // to stay active until the user quits explicitly with Cmd + Q
44 | //if (process.platform !== 'darwin') {
45 | app.quit()
46 | //}
47 | });
48 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 | # Copyright 2009 The Go Authors. All rights reserved.
3 | # Use of this source code is governed by a BSD-style
4 | # license that can be found in the LICENSE file.
5 | #
6 | # Generate system call table for OpenBSD from master list
7 | # (for example, /usr/src/sys/kern/syscalls.master).
8 |
9 | use strict;
10 |
11 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
12 | print STDERR "GOARCH or GOOS not defined in environment\n";
13 | exit 1;
14 | }
15 |
16 | my $command = "mksysnum_netbsd.pl " . join(' ', @ARGV);
17 |
18 | print <){
31 | if($line =~ /^(.*)\\$/) {
32 | # Handle continuation
33 | $line = $1;
34 | $_ =~ s/^\s+//;
35 | $line .= $_;
36 | } else {
37 | # New line
38 | $line = $_;
39 | }
40 | next if $line =~ /\\$/;
41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) {
42 | my $num = $1;
43 | my $proto = $6;
44 | my $compat = $8;
45 | my $name = "$7_$9";
46 |
47 | $name = "$7_$11" if $11 ne '';
48 | $name =~ y/a-z/A-Z/;
49 |
50 | if($compat eq '' || $compat eq '30' || $compat eq '50') {
51 | print " $name = $num; // $proto\n";
52 | }
53 | }
54 | }
55 |
56 | print <>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
52 |
53 | written = int(writtenOut)
54 |
55 | if e1 != 0 {
56 | err = e1
57 | }
58 | return
59 | }
60 |
61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
62 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build 386,freebsd
6 |
7 | package unix
8 |
9 | import (
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | func Getpagesize() int { return 4096 }
15 |
16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
17 |
18 | func NsecToTimespec(nsec int64) (ts Timespec) {
19 | ts.Sec = int32(nsec / 1e9)
20 | ts.Nsec = int32(nsec % 1e9)
21 | return
22 | }
23 |
24 | func NsecToTimeval(nsec int64) (tv Timeval) {
25 | nsec += 999 // round up to microsecond
26 | tv.Usec = int32(nsec % 1e9 / 1e3)
27 | tv.Sec = int32(nsec / 1e9)
28 | return
29 | }
30 |
31 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
32 | k.Ident = uint32(fd)
33 | k.Filter = int16(mode)
34 | k.Flags = uint16(flags)
35 | }
36 |
37 | func (iov *Iovec) SetLen(length int) {
38 | iov.Len = uint32(length)
39 | }
40 |
41 | func (msghdr *Msghdr) SetControllen(length int) {
42 | msghdr.Controllen = uint32(length)
43 | }
44 |
45 | func (cmsg *Cmsghdr) SetLen(length int) {
46 | cmsg.Len = uint32(length)
47 | }
48 |
49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
50 | var writtenOut uint64 = 0
51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0)
52 |
53 | written = int(writtenOut)
54 |
55 | if e1 != 0 {
56 | err = e1
57 | }
58 | return
59 | }
60 |
61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
62 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/gccgo.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build gccgo
6 |
7 | package unix
8 |
9 | import "syscall"
10 |
11 | // We can't use the gc-syntax .s files for gccgo. On the plus side
12 | // much of the functionality can be written directly in Go.
13 |
14 | //extern gccgoRealSyscall
15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
16 |
17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
18 | syscall.Entersyscall()
19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
20 | syscall.Exitsyscall()
21 | return r, 0, syscall.Errno(errno)
22 | }
23 |
24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
25 | syscall.Entersyscall()
26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
27 | syscall.Exitsyscall()
28 | return r, 0, syscall.Errno(errno)
29 | }
30 |
31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) {
32 | syscall.Entersyscall()
33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
34 | syscall.Exitsyscall()
35 | return r, 0, syscall.Errno(errno)
36 | }
37 |
38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
40 | return r, 0, syscall.Errno(errno)
41 | }
42 |
43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
45 | return r, 0, syscall.Errno(errno)
46 | }
47 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/mksysnum_linux.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 | # Copyright 2009 The Go Authors. All rights reserved.
3 | # Use of this source code is governed by a BSD-style
4 | # license that can be found in the LICENSE file.
5 |
6 | use strict;
7 |
8 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
9 | print STDERR "GOARCH or GOOS not defined in environment\n";
10 | exit 1;
11 | }
12 |
13 | my $command = "mksysnum_linux.pl ". join(' ', @ARGV);
14 |
15 | print < 999){
31 | # ignore deprecated syscalls that are no longer implemented
32 | # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716
33 | return;
34 | }
35 | $name =~ y/a-z/A-Z/;
36 | $num = $num + $offset;
37 | print " SYS_$name = $num;\n";
38 | }
39 |
40 | my $prev;
41 | open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc";
42 | while(){
43 | if(/^#define __NR_Linux\s+([0-9]+)/){
44 | # mips/mips64: extract offset
45 | $offset = $1;
46 | }
47 | elsif(/^#define __NR_syscalls\s+/) {
48 | # ignore redefinitions of __NR_syscalls
49 | }
50 | elsif(/^#define __NR_(\w+)\s+([0-9]+)/){
51 | $prev = $2;
52 | fmt($1, $2);
53 | }
54 | elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){
55 | $prev = $2;
56 | fmt($1, $2);
57 | }
58 | elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){
59 | fmt($1, $prev+$2)
60 | }
61 | elsif(/^#define __NR_(\w+)\s+\(__NR_Linux \+ ([0-9]+)/){
62 | fmt($1, $2);
63 | }
64 | }
65 |
66 | print <){
30 | if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){
31 | my $num = $1;
32 | my $proto = $2;
33 | my $name = "SYS_$3";
34 | $name =~ y/a-z/A-Z/;
35 |
36 | # There are multiple entries for enosys and nosys, so comment them out.
37 | if($name =~ /^SYS_E?NOSYS$/){
38 | $name = "// $name";
39 | }
40 | if($name eq 'SYS_SYS_EXIT'){
41 | $name = 'SYS_EXIT';
42 | }
43 | if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){
44 | next
45 | }
46 |
47 | print " $name = $num; // $proto\n";
48 |
49 | # We keep Capsicum syscall numbers for FreeBSD
50 | # 9-STABLE here because we are not sure whether they
51 | # are mature and stable.
52 | if($num == 513){
53 | print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n";
54 | print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n";
55 | print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n";
56 | print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n";
57 | }
58 | }
59 | }
60 |
61 | print <>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
62 |
63 | written = int(length)
64 |
65 | if e1 != 0 {
66 | err = e1
67 | }
68 | return
69 | }
70 |
71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
72 |
--------------------------------------------------------------------------------
/server/database/database_test.go:
--------------------------------------------------------------------------------
1 | package database
2 |
3 | import (
4 | "github.com/boltdb/bolt"
5 | pb "github.com/iheanyi/go-electron-grpc/demo"
6 | "os"
7 | "testing"
8 | )
9 |
10 | func TestCreateTodo(t *testing.T) {
11 | db, teardown, err := setupTestDatabase()
12 | if err != nil {
13 | t.Errorf("Error creating test database: %v", err)
14 | }
15 | defer teardown()
16 |
17 | store := NewStore(db)
18 | mock := &pb.Todo{
19 | Description: "Test this",
20 | Done: false,
21 | }
22 |
23 | output, err := store.CreateTodo(mock)
24 | if err != nil {
25 | t.Errorf("Error thrown by CreateTodo: %v", err)
26 | }
27 |
28 | if output.Description != mock.Description {
29 | t.Errorf("Got %v, want %v", output.Description, mock.Description)
30 | }
31 |
32 | if output.Done != mock.Done {
33 | t.Errorf("Got %v, want %v", output.Done, mock.Done)
34 | }
35 |
36 | if output.Id < 1 {
37 | t.Errorf("Expected Todo.Id to not be zero.")
38 | }
39 | }
40 |
41 | func TestListTodos(t *testing.T) {
42 | db, teardown, err := setupTestDatabase()
43 | if err != nil {
44 | t.Errorf("Error setting up test database: %v", err)
45 | }
46 | defer teardown()
47 |
48 | store := NewStore(db)
49 |
50 | store.CreateTodo(&pb.Todo{
51 | Description: "Test this.",
52 | Done: false,
53 | })
54 |
55 | store.CreateTodo(&pb.Todo{
56 | Description: "Another test.",
57 | Done: false,
58 | })
59 |
60 | store.CreateTodo(&pb.Todo{
61 | Description: "Last test.",
62 | Done: false,
63 | })
64 |
65 | output, err := store.ListTodos()
66 | if err != nil {
67 | t.Errorf("store.ListTodos returned err: %v", err)
68 | }
69 |
70 | if len(output) != 3 {
71 | t.Errorf("Expected output to be of length 3, got length: %v", len(output))
72 | }
73 | }
74 |
75 | func setupTestDatabase() (*bolt.DB, func(), error) {
76 | // Wipe the database before every single test.
77 | db, err := bolt.Open("test.db", 0600, nil)
78 | if err != nil {
79 | return nil, nil, err
80 | }
81 |
82 | return db, func() {
83 | db.Close()
84 | os.Remove("test.db")
85 | }, nil
86 | }
87 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build arm64,darwin
6 |
7 | package unix
8 |
9 | import (
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | func Getpagesize() int { return 16384 }
15 |
16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
17 |
18 | func NsecToTimespec(nsec int64) (ts Timespec) {
19 | ts.Sec = nsec / 1e9
20 | ts.Nsec = nsec % 1e9
21 | return
22 | }
23 |
24 | func NsecToTimeval(nsec int64) (tv Timeval) {
25 | nsec += 999 // round up to microsecond
26 | tv.Usec = int32(nsec % 1e9 / 1e3)
27 | tv.Sec = int64(nsec / 1e9)
28 | return
29 | }
30 |
31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
32 | func Gettimeofday(tv *Timeval) (err error) {
33 | // The tv passed to gettimeofday must be non-nil
34 | // but is otherwise unused. The answers come back
35 | // in the two registers.
36 | sec, usec, err := gettimeofday(tv)
37 | tv.Sec = sec
38 | tv.Usec = usec
39 | return err
40 | }
41 |
42 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
43 | k.Ident = uint64(fd)
44 | k.Filter = int16(mode)
45 | k.Flags = uint16(flags)
46 | }
47 |
48 | func (iov *Iovec) SetLen(length int) {
49 | iov.Len = uint64(length)
50 | }
51 |
52 | func (msghdr *Msghdr) SetControllen(length int) {
53 | msghdr.Controllen = uint32(length)
54 | }
55 |
56 | func (cmsg *Cmsghdr) SetLen(length int) {
57 | cmsg.Len = uint32(length)
58 | }
59 |
60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
61 | var length = uint64(count)
62 |
63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
64 |
65 | written = int(length)
66 |
67 | if e1 != 0 {
68 | err = e1
69 | }
70 | return
71 | }
72 |
73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
74 |
75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl.
77 | const SYS___SYSCTL = SYS_SYSCTL
78 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_darwin_386.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build 386,darwin
6 |
7 | package unix
8 |
9 | import (
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | func Getpagesize() int { return 4096 }
15 |
16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
17 |
18 | func NsecToTimespec(nsec int64) (ts Timespec) {
19 | ts.Sec = int32(nsec / 1e9)
20 | ts.Nsec = int32(nsec % 1e9)
21 | return
22 | }
23 |
24 | func NsecToTimeval(nsec int64) (tv Timeval) {
25 | nsec += 999 // round up to microsecond
26 | tv.Usec = int32(nsec % 1e9 / 1e3)
27 | tv.Sec = int32(nsec / 1e9)
28 | return
29 | }
30 |
31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
32 | func Gettimeofday(tv *Timeval) (err error) {
33 | // The tv passed to gettimeofday must be non-nil
34 | // but is otherwise unused. The answers come back
35 | // in the two registers.
36 | sec, usec, err := gettimeofday(tv)
37 | tv.Sec = int32(sec)
38 | tv.Usec = int32(usec)
39 | return err
40 | }
41 |
42 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
43 | k.Ident = uint32(fd)
44 | k.Filter = int16(mode)
45 | k.Flags = uint16(flags)
46 | }
47 |
48 | func (iov *Iovec) SetLen(length int) {
49 | iov.Len = uint32(length)
50 | }
51 |
52 | func (msghdr *Msghdr) SetControllen(length int) {
53 | msghdr.Controllen = uint32(length)
54 | }
55 |
56 | func (cmsg *Cmsghdr) SetLen(length int) {
57 | cmsg.Len = uint32(length)
58 | }
59 |
60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
61 | var length = uint64(count)
62 |
63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
64 |
65 | written = int(length)
66 |
67 | if e1 != 0 {
68 | err = e1
69 | }
70 | return
71 | }
72 |
73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
74 |
75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
76 | // of darwin/386 the syscall is called sysctl instead of __sysctl.
77 | const SYS___SYSCTL = SYS_SYSCTL
78 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64,darwin
6 |
7 | package unix
8 |
9 | import (
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
15 |
16 | func Getpagesize() int { return 4096 }
17 |
18 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
19 |
20 | func NsecToTimespec(nsec int64) (ts Timespec) {
21 | ts.Sec = nsec / 1e9
22 | ts.Nsec = nsec % 1e9
23 | return
24 | }
25 |
26 | func NsecToTimeval(nsec int64) (tv Timeval) {
27 | nsec += 999 // round up to microsecond
28 | tv.Usec = int32(nsec % 1e9 / 1e3)
29 | tv.Sec = int64(nsec / 1e9)
30 | return
31 | }
32 |
33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
34 | func Gettimeofday(tv *Timeval) (err error) {
35 | // The tv passed to gettimeofday must be non-nil
36 | // but is otherwise unused. The answers come back
37 | // in the two registers.
38 | sec, usec, err := gettimeofday(tv)
39 | tv.Sec = sec
40 | tv.Usec = usec
41 | return err
42 | }
43 |
44 | func SetKevent(k *Kevent_t, fd, mode, flags int) {
45 | k.Ident = uint64(fd)
46 | k.Filter = int16(mode)
47 | k.Flags = uint16(flags)
48 | }
49 |
50 | func (iov *Iovec) SetLen(length int) {
51 | iov.Len = uint64(length)
52 | }
53 |
54 | func (msghdr *Msghdr) SetControllen(length int) {
55 | msghdr.Controllen = uint32(length)
56 | }
57 |
58 | func (cmsg *Cmsghdr) SetLen(length int) {
59 | cmsg.Len = uint32(length)
60 | }
61 |
62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
63 | var length = uint64(count)
64 |
65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
66 |
67 | written = int(length)
68 |
69 | if e1 != 0 {
70 | err = e1
71 | }
72 | return
73 | }
74 |
75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
76 |
77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
78 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl.
79 | const SYS___SYSCTL = SYS_SYSCTL
80 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris
6 |
7 | // Package unix contains an interface to the low-level operating system
8 | // primitives. OS details vary depending on the underlying system, and
9 | // by default, godoc will display OS-specific documentation for the current
10 | // system. If you want godoc to display OS documentation for another
11 | // system, set $GOOS and $GOARCH to the desired system. For example, if
12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS
13 | // to freebsd and $GOARCH to arm.
14 | // The primary use of this package is inside other packages that provide a more
15 | // portable interface to the system, such as "os", "time" and "net". Use
16 | // those packages rather than this one if you can.
17 | // For details of the functions and data types in this package consult
18 | // the manuals for the appropriate operating system.
19 | // These calls return err == nil to indicate success; otherwise
20 | // err represents an operating system error describing the failure and
21 | // holds a value of type syscall.Errno.
22 | package unix // import "golang.org/x/sys/unix"
23 |
24 | import "unsafe"
25 |
26 | // ByteSliceFromString returns a NUL-terminated slice of bytes
27 | // containing the text of s. If s contains a NUL byte at any
28 | // location, it returns (nil, EINVAL).
29 | func ByteSliceFromString(s string) ([]byte, error) {
30 | for i := 0; i < len(s); i++ {
31 | if s[i] == 0 {
32 | return nil, EINVAL
33 | }
34 | }
35 | a := make([]byte, len(s)+1)
36 | copy(a, s)
37 | return a, nil
38 | }
39 |
40 | // BytePtrFromString returns a pointer to a NUL-terminated array of
41 | // bytes containing the text of s. If s contains a NUL byte at any
42 | // location, it returns (nil, EINVAL).
43 | func BytePtrFromString(s string) (*byte, error) {
44 | a, err := ByteSliceFromString(s)
45 | if err != nil {
46 | return nil, err
47 | }
48 | return &a[0], nil
49 | }
50 |
51 | // Single-word zero for use when we need a valid pointer to 0 bytes.
52 | // See mkunix.pl.
53 | var _zero uintptr
54 |
55 | func (ts *Timespec) Unix() (sec int64, nsec int64) {
56 | return int64(ts.Sec), int64(ts.Nsec)
57 | }
58 |
59 | func (tv *Timeval) Unix() (sec int64, nsec int64) {
60 | return int64(tv.Sec), int64(tv.Usec) * 1000
61 | }
62 |
63 | func (ts *Timespec) Nano() int64 {
64 | return int64(ts.Sec)*1e9 + int64(ts.Nsec)
65 | }
66 |
67 | func (tv *Timeval) Nano() int64 {
68 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
69 | }
70 |
71 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
72 |
73 | // use is a no-op, but the compiler cannot see that it is.
74 | // Calling use(p) ensures that p is kept live until that point.
75 | //go:noescape
76 | func use(p unsafe.Pointer)
77 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/sockcmsg_unix.go:
--------------------------------------------------------------------------------
1 | // Copyright 2011 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris
6 |
7 | // Socket control messages
8 |
9 | package unix
10 |
11 | import "unsafe"
12 |
13 | // Round the length of a raw sockaddr up to align it properly.
14 | func cmsgAlignOf(salen int) int {
15 | salign := sizeofPtr
16 | // NOTE: It seems like 64-bit Darwin and DragonFly BSD kernels
17 | // still require 32-bit aligned access to network subsystem.
18 | if darwin64Bit || dragonfly64Bit {
19 | salign = 4
20 | }
21 | return (salen + salign - 1) & ^(salign - 1)
22 | }
23 |
24 | // CmsgLen returns the value to store in the Len field of the Cmsghdr
25 | // structure, taking into account any necessary alignment.
26 | func CmsgLen(datalen int) int {
27 | return cmsgAlignOf(SizeofCmsghdr) + datalen
28 | }
29 |
30 | // CmsgSpace returns the number of bytes an ancillary element with
31 | // payload of the passed data length occupies.
32 | func CmsgSpace(datalen int) int {
33 | return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen)
34 | }
35 |
36 | func cmsgData(h *Cmsghdr) unsafe.Pointer {
37 | return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr)))
38 | }
39 |
40 | // SocketControlMessage represents a socket control message.
41 | type SocketControlMessage struct {
42 | Header Cmsghdr
43 | Data []byte
44 | }
45 |
46 | // ParseSocketControlMessage parses b as an array of socket control
47 | // messages.
48 | func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) {
49 | var msgs []SocketControlMessage
50 | i := 0
51 | for i+CmsgLen(0) <= len(b) {
52 | h, dbuf, err := socketControlMessageHeaderAndData(b[i:])
53 | if err != nil {
54 | return nil, err
55 | }
56 | m := SocketControlMessage{Header: *h, Data: dbuf}
57 | msgs = append(msgs, m)
58 | i += cmsgAlignOf(int(h.Len))
59 | }
60 | return msgs, nil
61 | }
62 |
63 | func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) {
64 | h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
65 | if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) {
66 | return nil, nil, EINVAL
67 | }
68 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil
69 | }
70 |
71 | // UnixRights encodes a set of open file descriptors into a socket
72 | // control message for sending to another process.
73 | func UnixRights(fds ...int) []byte {
74 | datalen := len(fds) * 4
75 | b := make([]byte, CmsgSpace(datalen))
76 | h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
77 | h.Level = SOL_SOCKET
78 | h.Type = SCM_RIGHTS
79 | h.SetLen(CmsgLen(datalen))
80 | data := cmsgData(h)
81 | for _, fd := range fds {
82 | *(*int32)(data) = int32(fd)
83 | data = unsafe.Pointer(uintptr(data) + 4)
84 | }
85 | return b
86 | }
87 |
88 | // ParseUnixRights decodes a socket control message that contains an
89 | // integer array of open file descriptors from another process.
90 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) {
91 | if m.Header.Level != SOL_SOCKET {
92 | return nil, EINVAL
93 | }
94 | if m.Header.Type != SCM_RIGHTS {
95 | return nil, EINVAL
96 | }
97 | fds := make([]int, len(m.Data)>>2)
98 | for i, j := 0, 0; i < len(m.Data); i += 4 {
99 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i])))
100 | j++
101 | }
102 | return fds, nil
103 | }
104 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 | // +build ppc64 ppc64le
7 |
8 | package unix
9 |
10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
11 | //sys Dup2(oldfd int, newfd int) (err error)
12 | //sys Fchown(fd int, uid int, gid int) (err error)
13 | //sys Fstat(fd int, stat *Stat_t) (err error)
14 | //sys Fstatfs(fd int, buf *Statfs_t) (err error)
15 | //sys Ftruncate(fd int, length int64) (err error)
16 | //sysnb Getegid() (egid int)
17 | //sysnb Geteuid() (euid int)
18 | //sysnb Getgid() (gid int)
19 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT
20 | //sysnb Getuid() (uid int)
21 | //sysnb InotifyInit() (fd int, err error)
22 | //sys Ioperm(from int, num int, on int) (err error)
23 | //sys Iopl(level int) (err error)
24 | //sys Lchown(path string, uid int, gid int) (err error)
25 | //sys Listen(s int, n int) (err error)
26 | //sys Lstat(path string, stat *Stat_t) (err error)
27 | //sys Pause() (err error)
28 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
29 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
30 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
31 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
32 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
33 | //sys Setfsgid(gid int) (err error)
34 | //sys Setfsuid(uid int) (err error)
35 | //sysnb Setregid(rgid int, egid int) (err error)
36 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
37 | //sysnb Setresuid(ruid int, euid int, suid int) (err error)
38 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
39 | //sysnb Setreuid(ruid int, euid int) (err error)
40 | //sys Shutdown(fd int, how int) (err error)
41 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
42 | //sys Stat(path string, stat *Stat_t) (err error)
43 | //sys Statfs(path string, buf *Statfs_t) (err error)
44 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2
45 | //sys Truncate(path string, length int64) (err error)
46 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
47 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
48 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
49 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
50 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
51 | //sysnb setgroups(n int, list *_Gid_t) (err error)
52 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
53 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
54 | //sysnb socket(domain int, typ int, proto int) (fd int, err error)
55 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
56 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
57 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
58 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
59 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
60 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
61 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
62 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
63 |
64 | func Getpagesize() int { return 65536 }
65 |
66 | //sysnb Gettimeofday(tv *Timeval) (err error)
67 | //sysnb Time(t *Time_t) (tt Time_t, err error)
68 |
69 | //sys Utime(path string, buf *Utimbuf) (err error)
70 |
71 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
72 |
73 | func NsecToTimespec(nsec int64) (ts Timespec) {
74 | ts.Sec = nsec / 1e9
75 | ts.Nsec = nsec % 1e9
76 | return
77 | }
78 |
79 | func NsecToTimeval(nsec int64) (tv Timeval) {
80 | nsec += 999 // round up to microsecond
81 | tv.Sec = nsec / 1e9
82 | tv.Usec = nsec % 1e9 / 1e3
83 | return
84 | }
85 |
86 | func (r *PtraceRegs) PC() uint64 { return r.Nip }
87 |
88 | func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc }
89 |
90 | func (iov *Iovec) SetLen(length int) {
91 | iov.Len = uint64(length)
92 | }
93 |
94 | func (msghdr *Msghdr) SetControllen(length int) {
95 | msghdr.Controllen = uint64(length)
96 | }
97 |
98 | func (cmsg *Cmsghdr) SetLen(length int) {
99 | cmsg.Len = uint64(length)
100 | }
101 |
102 | //sysnb pipe(p *[2]_C_int) (err error)
103 |
104 | func Pipe(p []int) (err error) {
105 | if len(p) != 2 {
106 | return EINVAL
107 | }
108 | var pp [2]_C_int
109 | err = pipe(&pp)
110 | p[0] = int(pp[0])
111 | p[1] = int(pp[1])
112 | return
113 | }
114 |
115 | //sysnb pipe2(p *[2]_C_int, flags int) (err error)
116 |
117 | func Pipe2(p []int, flags int) (err error) {
118 | if len(p) != 2 {
119 | return EINVAL
120 | }
121 | var pp [2]_C_int
122 | err = pipe2(&pp, flags)
123 | p[0] = int(pp[0])
124 | p[1] = int(pp[1])
125 | return
126 | }
127 |
128 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
129 |
130 | func Poll(fds []PollFd, timeout int) (n int, err error) {
131 | if len(fds) == 0 {
132 | return poll(nil, 0, timeout)
133 | }
134 | return poll(&fds[0], len(fds), timeout)
135 | }
136 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/types_netbsd.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build ignore
6 |
7 | /*
8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh
9 | */
10 |
11 | // +godefs map struct_in_addr [4]byte /* in_addr */
12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */
13 |
14 | package unix
15 |
16 | /*
17 | #define KERNEL
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 | #include
47 |
48 | enum {
49 | sizeofPtr = sizeof(void*),
50 | };
51 |
52 | union sockaddr_all {
53 | struct sockaddr s1; // this one gets used for fields
54 | struct sockaddr_in s2; // these pad it out
55 | struct sockaddr_in6 s3;
56 | struct sockaddr_un s4;
57 | struct sockaddr_dl s5;
58 | };
59 |
60 | struct sockaddr_any {
61 | struct sockaddr addr;
62 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
63 | };
64 |
65 | */
66 | import "C"
67 |
68 | // Machine characteristics; for internal use.
69 |
70 | const (
71 | sizeofPtr = C.sizeofPtr
72 | sizeofShort = C.sizeof_short
73 | sizeofInt = C.sizeof_int
74 | sizeofLong = C.sizeof_long
75 | sizeofLongLong = C.sizeof_longlong
76 | )
77 |
78 | // Basic types
79 |
80 | type (
81 | _C_short C.short
82 | _C_int C.int
83 | _C_long C.long
84 | _C_long_long C.longlong
85 | )
86 |
87 | // Time
88 |
89 | type Timespec C.struct_timespec
90 |
91 | type Timeval C.struct_timeval
92 |
93 | // Processes
94 |
95 | type Rusage C.struct_rusage
96 |
97 | type Rlimit C.struct_rlimit
98 |
99 | type _Gid_t C.gid_t
100 |
101 | // Files
102 |
103 | type Stat_t C.struct_stat
104 |
105 | type Statfs_t C.struct_statfs
106 |
107 | type Flock_t C.struct_flock
108 |
109 | type Dirent C.struct_dirent
110 |
111 | type Fsid C.fsid_t
112 |
113 | // Sockets
114 |
115 | type RawSockaddrInet4 C.struct_sockaddr_in
116 |
117 | type RawSockaddrInet6 C.struct_sockaddr_in6
118 |
119 | type RawSockaddrUnix C.struct_sockaddr_un
120 |
121 | type RawSockaddrDatalink C.struct_sockaddr_dl
122 |
123 | type RawSockaddr C.struct_sockaddr
124 |
125 | type RawSockaddrAny C.struct_sockaddr_any
126 |
127 | type _Socklen C.socklen_t
128 |
129 | type Linger C.struct_linger
130 |
131 | type Iovec C.struct_iovec
132 |
133 | type IPMreq C.struct_ip_mreq
134 |
135 | type IPv6Mreq C.struct_ipv6_mreq
136 |
137 | type Msghdr C.struct_msghdr
138 |
139 | type Cmsghdr C.struct_cmsghdr
140 |
141 | type Inet6Pktinfo C.struct_in6_pktinfo
142 |
143 | type IPv6MTUInfo C.struct_ip6_mtuinfo
144 |
145 | type ICMPv6Filter C.struct_icmp6_filter
146 |
147 | const (
148 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
149 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
150 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
151 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
152 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
153 | SizeofLinger = C.sizeof_struct_linger
154 | SizeofIPMreq = C.sizeof_struct_ip_mreq
155 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
156 | SizeofMsghdr = C.sizeof_struct_msghdr
157 | SizeofCmsghdr = C.sizeof_struct_cmsghdr
158 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
159 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
160 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
161 | )
162 |
163 | // Ptrace requests
164 |
165 | const (
166 | PTRACE_TRACEME = C.PT_TRACE_ME
167 | PTRACE_CONT = C.PT_CONTINUE
168 | PTRACE_KILL = C.PT_KILL
169 | )
170 |
171 | // Events (kqueue, kevent)
172 |
173 | type Kevent_t C.struct_kevent
174 |
175 | // Select
176 |
177 | type FdSet C.fd_set
178 |
179 | // Routing and interface messages
180 |
181 | const (
182 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr
183 | SizeofIfData = C.sizeof_struct_if_data
184 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
185 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
186 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
187 | SizeofRtMetrics = C.sizeof_struct_rt_metrics
188 | )
189 |
190 | type IfMsghdr C.struct_if_msghdr
191 |
192 | type IfData C.struct_if_data
193 |
194 | type IfaMsghdr C.struct_ifa_msghdr
195 |
196 | type IfAnnounceMsghdr C.struct_if_announcemsghdr
197 |
198 | type RtMsghdr C.struct_rt_msghdr
199 |
200 | type RtMetrics C.struct_rt_metrics
201 |
202 | type Mclpool C.struct_mclpool
203 |
204 | // Berkeley packet filter
205 |
206 | const (
207 | SizeofBpfVersion = C.sizeof_struct_bpf_version
208 | SizeofBpfStat = C.sizeof_struct_bpf_stat
209 | SizeofBpfProgram = C.sizeof_struct_bpf_program
210 | SizeofBpfInsn = C.sizeof_struct_bpf_insn
211 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr
212 | )
213 |
214 | type BpfVersion C.struct_bpf_version
215 |
216 | type BpfStat C.struct_bpf_stat
217 |
218 | type BpfProgram C.struct_bpf_program
219 |
220 | type BpfInsn C.struct_bpf_insn
221 |
222 | type BpfHdr C.struct_bpf_hdr
223 |
224 | type BpfTimeval C.struct_bpf_timeval
225 |
226 | // Terminal handling
227 |
228 | type Termios C.struct_termios
229 |
230 | // Sysctl
231 |
232 | type Sysctlnode C.struct_sysctlnode
233 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64,linux
6 |
7 | package unix
8 |
9 | //sys Dup2(oldfd int, newfd int) (err error)
10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
11 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
12 | //sys Fchown(fd int, uid int, gid int) (err error)
13 | //sys Fstat(fd int, stat *Stat_t) (err error)
14 | //sys Fstatfs(fd int, buf *Statfs_t) (err error)
15 | //sys Ftruncate(fd int, length int64) (err error)
16 | //sysnb Getegid() (egid int)
17 | //sysnb Geteuid() (euid int)
18 | //sysnb Getgid() (gid int)
19 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
20 | //sysnb Getuid() (uid int)
21 | //sysnb InotifyInit() (fd int, err error)
22 | //sys Ioperm(from int, num int, on int) (err error)
23 | //sys Iopl(level int) (err error)
24 | //sys Lchown(path string, uid int, gid int) (err error)
25 | //sys Listen(s int, n int) (err error)
26 | //sys Lstat(path string, stat *Stat_t) (err error)
27 | //sys Pause() (err error)
28 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
29 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
30 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
31 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
32 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
33 | //sys Setfsgid(gid int) (err error)
34 | //sys Setfsuid(uid int) (err error)
35 | //sysnb Setregid(rgid int, egid int) (err error)
36 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
37 | //sysnb Setresuid(ruid int, euid int, suid int) (err error)
38 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
39 | //sysnb Setreuid(ruid int, euid int) (err error)
40 | //sys Shutdown(fd int, how int) (err error)
41 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
42 | //sys Stat(path string, stat *Stat_t) (err error)
43 | //sys Statfs(path string, buf *Statfs_t) (err error)
44 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
45 | //sys Truncate(path string, length int64) (err error)
46 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
47 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
48 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
49 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
50 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
51 | //sysnb setgroups(n int, list *_Gid_t) (err error)
52 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
53 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
54 | //sysnb socket(domain int, typ int, proto int) (fd int, err error)
55 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
56 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
57 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
58 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
59 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
60 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
61 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
62 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
63 |
64 | func Gettimeofday(tv *Timeval) (err error) {
65 | errno := gettimeofday(tv)
66 | if errno != 0 {
67 | return errno
68 | }
69 | return nil
70 | }
71 |
72 | func Getpagesize() int { return 4096 }
73 |
74 | func Time(t *Time_t) (tt Time_t, err error) {
75 | var tv Timeval
76 | errno := gettimeofday(&tv)
77 | if errno != 0 {
78 | return 0, errno
79 | }
80 | if t != nil {
81 | *t = Time_t(tv.Sec)
82 | }
83 | return Time_t(tv.Sec), nil
84 | }
85 |
86 | //sys Utime(path string, buf *Utimbuf) (err error)
87 |
88 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
89 |
90 | func NsecToTimespec(nsec int64) (ts Timespec) {
91 | ts.Sec = nsec / 1e9
92 | ts.Nsec = nsec % 1e9
93 | return
94 | }
95 |
96 | func NsecToTimeval(nsec int64) (tv Timeval) {
97 | nsec += 999 // round up to microsecond
98 | tv.Sec = nsec / 1e9
99 | tv.Usec = nsec % 1e9 / 1e3
100 | return
101 | }
102 |
103 | //sysnb pipe(p *[2]_C_int) (err error)
104 |
105 | func Pipe(p []int) (err error) {
106 | if len(p) != 2 {
107 | return EINVAL
108 | }
109 | var pp [2]_C_int
110 | err = pipe(&pp)
111 | p[0] = int(pp[0])
112 | p[1] = int(pp[1])
113 | return
114 | }
115 |
116 | //sysnb pipe2(p *[2]_C_int, flags int) (err error)
117 |
118 | func Pipe2(p []int, flags int) (err error) {
119 | if len(p) != 2 {
120 | return EINVAL
121 | }
122 | var pp [2]_C_int
123 | err = pipe2(&pp, flags)
124 | p[0] = int(pp[0])
125 | p[1] = int(pp[1])
126 | return
127 | }
128 |
129 | func (r *PtraceRegs) PC() uint64 { return r.Rip }
130 |
131 | func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc }
132 |
133 | func (iov *Iovec) SetLen(length int) {
134 | iov.Len = uint64(length)
135 | }
136 |
137 | func (msghdr *Msghdr) SetControllen(length int) {
138 | msghdr.Controllen = uint64(length)
139 | }
140 |
141 | func (cmsg *Cmsghdr) SetLen(length int) {
142 | cmsg.Len = uint64(length)
143 | }
144 |
145 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
146 |
147 | func Poll(fds []PollFd, timeout int) (n int, err error) {
148 | if len(fds) == 0 {
149 | return poll(nil, 0, timeout)
150 | }
151 | return poll(&fds[0], len(fds), timeout)
152 | }
153 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/types_dragonfly.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build ignore
6 |
7 | /*
8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh
9 | */
10 |
11 | // +godefs map struct_in_addr [4]byte /* in_addr */
12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */
13 |
14 | package unix
15 |
16 | /*
17 | #define KERNEL
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 |
46 | enum {
47 | sizeofPtr = sizeof(void*),
48 | };
49 |
50 | union sockaddr_all {
51 | struct sockaddr s1; // this one gets used for fields
52 | struct sockaddr_in s2; // these pad it out
53 | struct sockaddr_in6 s3;
54 | struct sockaddr_un s4;
55 | struct sockaddr_dl s5;
56 | };
57 |
58 | struct sockaddr_any {
59 | struct sockaddr addr;
60 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
61 | };
62 |
63 | */
64 | import "C"
65 |
66 | // Machine characteristics; for internal use.
67 |
68 | const (
69 | sizeofPtr = C.sizeofPtr
70 | sizeofShort = C.sizeof_short
71 | sizeofInt = C.sizeof_int
72 | sizeofLong = C.sizeof_long
73 | sizeofLongLong = C.sizeof_longlong
74 | )
75 |
76 | // Basic types
77 |
78 | type (
79 | _C_short C.short
80 | _C_int C.int
81 | _C_long C.long
82 | _C_long_long C.longlong
83 | )
84 |
85 | // Time
86 |
87 | type Timespec C.struct_timespec
88 |
89 | type Timeval C.struct_timeval
90 |
91 | // Processes
92 |
93 | type Rusage C.struct_rusage
94 |
95 | type Rlimit C.struct_rlimit
96 |
97 | type _Gid_t C.gid_t
98 |
99 | // Files
100 |
101 | const ( // Directory mode bits
102 | S_IFMT = C.S_IFMT
103 | S_IFIFO = C.S_IFIFO
104 | S_IFCHR = C.S_IFCHR
105 | S_IFDIR = C.S_IFDIR
106 | S_IFBLK = C.S_IFBLK
107 | S_IFREG = C.S_IFREG
108 | S_IFLNK = C.S_IFLNK
109 | S_IFSOCK = C.S_IFSOCK
110 | S_ISUID = C.S_ISUID
111 | S_ISGID = C.S_ISGID
112 | S_ISVTX = C.S_ISVTX
113 | S_IRUSR = C.S_IRUSR
114 | S_IWUSR = C.S_IWUSR
115 | S_IXUSR = C.S_IXUSR
116 | )
117 |
118 | type Stat_t C.struct_stat
119 |
120 | type Statfs_t C.struct_statfs
121 |
122 | type Flock_t C.struct_flock
123 |
124 | type Dirent C.struct_dirent
125 |
126 | type Fsid C.struct_fsid
127 |
128 | // Sockets
129 |
130 | type RawSockaddrInet4 C.struct_sockaddr_in
131 |
132 | type RawSockaddrInet6 C.struct_sockaddr_in6
133 |
134 | type RawSockaddrUnix C.struct_sockaddr_un
135 |
136 | type RawSockaddrDatalink C.struct_sockaddr_dl
137 |
138 | type RawSockaddr C.struct_sockaddr
139 |
140 | type RawSockaddrAny C.struct_sockaddr_any
141 |
142 | type _Socklen C.socklen_t
143 |
144 | type Linger C.struct_linger
145 |
146 | type Iovec C.struct_iovec
147 |
148 | type IPMreq C.struct_ip_mreq
149 |
150 | type IPv6Mreq C.struct_ipv6_mreq
151 |
152 | type Msghdr C.struct_msghdr
153 |
154 | type Cmsghdr C.struct_cmsghdr
155 |
156 | type Inet6Pktinfo C.struct_in6_pktinfo
157 |
158 | type IPv6MTUInfo C.struct_ip6_mtuinfo
159 |
160 | type ICMPv6Filter C.struct_icmp6_filter
161 |
162 | const (
163 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
164 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
165 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
166 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
167 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
168 | SizeofLinger = C.sizeof_struct_linger
169 | SizeofIPMreq = C.sizeof_struct_ip_mreq
170 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
171 | SizeofMsghdr = C.sizeof_struct_msghdr
172 | SizeofCmsghdr = C.sizeof_struct_cmsghdr
173 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
174 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
175 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
176 | )
177 |
178 | // Ptrace requests
179 |
180 | const (
181 | PTRACE_TRACEME = C.PT_TRACE_ME
182 | PTRACE_CONT = C.PT_CONTINUE
183 | PTRACE_KILL = C.PT_KILL
184 | )
185 |
186 | // Events (kqueue, kevent)
187 |
188 | type Kevent_t C.struct_kevent
189 |
190 | // Select
191 |
192 | type FdSet C.fd_set
193 |
194 | // Routing and interface messages
195 |
196 | const (
197 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr
198 | SizeofIfData = C.sizeof_struct_if_data
199 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
200 | SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
201 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
202 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
203 | SizeofRtMetrics = C.sizeof_struct_rt_metrics
204 | )
205 |
206 | type IfMsghdr C.struct_if_msghdr
207 |
208 | type IfData C.struct_if_data
209 |
210 | type IfaMsghdr C.struct_ifa_msghdr
211 |
212 | type IfmaMsghdr C.struct_ifma_msghdr
213 |
214 | type IfAnnounceMsghdr C.struct_if_announcemsghdr
215 |
216 | type RtMsghdr C.struct_rt_msghdr
217 |
218 | type RtMetrics C.struct_rt_metrics
219 |
220 | // Berkeley packet filter
221 |
222 | const (
223 | SizeofBpfVersion = C.sizeof_struct_bpf_version
224 | SizeofBpfStat = C.sizeof_struct_bpf_stat
225 | SizeofBpfProgram = C.sizeof_struct_bpf_program
226 | SizeofBpfInsn = C.sizeof_struct_bpf_insn
227 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr
228 | )
229 |
230 | type BpfVersion C.struct_bpf_version
231 |
232 | type BpfStat C.struct_bpf_stat
233 |
234 | type BpfProgram C.struct_bpf_program
235 |
236 | type BpfInsn C.struct_bpf_insn
237 |
238 | type BpfHdr C.struct_bpf_hdr
239 |
240 | // Terminal handling
241 |
242 | type Termios C.struct_termios
243 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/types_openbsd.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build ignore
6 |
7 | /*
8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh
9 | */
10 |
11 | // +godefs map struct_in_addr [4]byte /* in_addr */
12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */
13 |
14 | package unix
15 |
16 | /*
17 | #define KERNEL
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 |
47 | enum {
48 | sizeofPtr = sizeof(void*),
49 | };
50 |
51 | union sockaddr_all {
52 | struct sockaddr s1; // this one gets used for fields
53 | struct sockaddr_in s2; // these pad it out
54 | struct sockaddr_in6 s3;
55 | struct sockaddr_un s4;
56 | struct sockaddr_dl s5;
57 | };
58 |
59 | struct sockaddr_any {
60 | struct sockaddr addr;
61 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
62 | };
63 |
64 | */
65 | import "C"
66 |
67 | // Machine characteristics; for internal use.
68 |
69 | const (
70 | sizeofPtr = C.sizeofPtr
71 | sizeofShort = C.sizeof_short
72 | sizeofInt = C.sizeof_int
73 | sizeofLong = C.sizeof_long
74 | sizeofLongLong = C.sizeof_longlong
75 | )
76 |
77 | // Basic types
78 |
79 | type (
80 | _C_short C.short
81 | _C_int C.int
82 | _C_long C.long
83 | _C_long_long C.longlong
84 | )
85 |
86 | // Time
87 |
88 | type Timespec C.struct_timespec
89 |
90 | type Timeval C.struct_timeval
91 |
92 | // Processes
93 |
94 | type Rusage C.struct_rusage
95 |
96 | type Rlimit C.struct_rlimit
97 |
98 | type _Gid_t C.gid_t
99 |
100 | // Files
101 |
102 | const ( // Directory mode bits
103 | S_IFMT = C.S_IFMT
104 | S_IFIFO = C.S_IFIFO
105 | S_IFCHR = C.S_IFCHR
106 | S_IFDIR = C.S_IFDIR
107 | S_IFBLK = C.S_IFBLK
108 | S_IFREG = C.S_IFREG
109 | S_IFLNK = C.S_IFLNK
110 | S_IFSOCK = C.S_IFSOCK
111 | S_ISUID = C.S_ISUID
112 | S_ISGID = C.S_ISGID
113 | S_ISVTX = C.S_ISVTX
114 | S_IRUSR = C.S_IRUSR
115 | S_IWUSR = C.S_IWUSR
116 | S_IXUSR = C.S_IXUSR
117 | )
118 |
119 | type Stat_t C.struct_stat
120 |
121 | type Statfs_t C.struct_statfs
122 |
123 | type Flock_t C.struct_flock
124 |
125 | type Dirent C.struct_dirent
126 |
127 | type Fsid C.fsid_t
128 |
129 | // Sockets
130 |
131 | type RawSockaddrInet4 C.struct_sockaddr_in
132 |
133 | type RawSockaddrInet6 C.struct_sockaddr_in6
134 |
135 | type RawSockaddrUnix C.struct_sockaddr_un
136 |
137 | type RawSockaddrDatalink C.struct_sockaddr_dl
138 |
139 | type RawSockaddr C.struct_sockaddr
140 |
141 | type RawSockaddrAny C.struct_sockaddr_any
142 |
143 | type _Socklen C.socklen_t
144 |
145 | type Linger C.struct_linger
146 |
147 | type Iovec C.struct_iovec
148 |
149 | type IPMreq C.struct_ip_mreq
150 |
151 | type IPv6Mreq C.struct_ipv6_mreq
152 |
153 | type Msghdr C.struct_msghdr
154 |
155 | type Cmsghdr C.struct_cmsghdr
156 |
157 | type Inet6Pktinfo C.struct_in6_pktinfo
158 |
159 | type IPv6MTUInfo C.struct_ip6_mtuinfo
160 |
161 | type ICMPv6Filter C.struct_icmp6_filter
162 |
163 | const (
164 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
165 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
166 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
167 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
168 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
169 | SizeofLinger = C.sizeof_struct_linger
170 | SizeofIPMreq = C.sizeof_struct_ip_mreq
171 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
172 | SizeofMsghdr = C.sizeof_struct_msghdr
173 | SizeofCmsghdr = C.sizeof_struct_cmsghdr
174 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
175 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
176 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
177 | )
178 |
179 | // Ptrace requests
180 |
181 | const (
182 | PTRACE_TRACEME = C.PT_TRACE_ME
183 | PTRACE_CONT = C.PT_CONTINUE
184 | PTRACE_KILL = C.PT_KILL
185 | )
186 |
187 | // Events (kqueue, kevent)
188 |
189 | type Kevent_t C.struct_kevent
190 |
191 | // Select
192 |
193 | type FdSet C.fd_set
194 |
195 | // Routing and interface messages
196 |
197 | const (
198 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr
199 | SizeofIfData = C.sizeof_struct_if_data
200 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
201 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
202 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
203 | SizeofRtMetrics = C.sizeof_struct_rt_metrics
204 | )
205 |
206 | type IfMsghdr C.struct_if_msghdr
207 |
208 | type IfData C.struct_if_data
209 |
210 | type IfaMsghdr C.struct_ifa_msghdr
211 |
212 | type IfAnnounceMsghdr C.struct_if_announcemsghdr
213 |
214 | type RtMsghdr C.struct_rt_msghdr
215 |
216 | type RtMetrics C.struct_rt_metrics
217 |
218 | type Mclpool C.struct_mclpool
219 |
220 | // Berkeley packet filter
221 |
222 | const (
223 | SizeofBpfVersion = C.sizeof_struct_bpf_version
224 | SizeofBpfStat = C.sizeof_struct_bpf_stat
225 | SizeofBpfProgram = C.sizeof_struct_bpf_program
226 | SizeofBpfInsn = C.sizeof_struct_bpf_insn
227 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr
228 | )
229 |
230 | type BpfVersion C.struct_bpf_version
231 |
232 | type BpfStat C.struct_bpf_stat
233 |
234 | type BpfProgram C.struct_bpf_program
235 |
236 | type BpfInsn C.struct_bpf_insn
237 |
238 | type BpfHdr C.struct_bpf_hdr
239 |
240 | type BpfTimeval C.struct_bpf_timeval
241 |
242 | // Terminal handling
243 |
244 | type Termios C.struct_termios
245 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build sparc64,linux
6 |
7 | package unix
8 |
9 | import (
10 | "sync/atomic"
11 | "syscall"
12 | )
13 |
14 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
15 | //sys Dup2(oldfd int, newfd int) (err error)
16 | //sys Fchown(fd int, uid int, gid int) (err error)
17 | //sys Fstat(fd int, stat *Stat_t) (err error)
18 | //sys Fstatfs(fd int, buf *Statfs_t) (err error)
19 | //sys Ftruncate(fd int, length int64) (err error)
20 | //sysnb Getegid() (egid int)
21 | //sysnb Geteuid() (euid int)
22 | //sysnb Getgid() (gid int)
23 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
24 | //sysnb Getuid() (uid int)
25 | //sysnb InotifyInit() (fd int, err error)
26 | //sys Lchown(path string, uid int, gid int) (err error)
27 | //sys Listen(s int, n int) (err error)
28 | //sys Lstat(path string, stat *Stat_t) (err error)
29 | //sys Pause() (err error)
30 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
31 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
32 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
33 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
34 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
35 | //sys Setfsgid(gid int) (err error)
36 | //sys Setfsuid(uid int) (err error)
37 | //sysnb Setregid(rgid int, egid int) (err error)
38 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
39 | //sysnb Setresuid(ruid int, euid int, suid int) (err error)
40 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
41 | //sysnb Setreuid(ruid int, euid int) (err error)
42 | //sys Shutdown(fd int, how int) (err error)
43 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
44 | //sys Stat(path string, stat *Stat_t) (err error)
45 | //sys Statfs(path string, buf *Statfs_t) (err error)
46 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
47 | //sys Truncate(path string, length int64) (err error)
48 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
49 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
50 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
51 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
52 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
53 | //sysnb setgroups(n int, list *_Gid_t) (err error)
54 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
55 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
56 | //sysnb socket(domain int, typ int, proto int) (fd int, err error)
57 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
58 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
59 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
60 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
61 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
62 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
63 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
64 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
65 |
66 | func sysconf(name int) (n int64, err syscall.Errno)
67 |
68 | // pageSize caches the value of Getpagesize, since it can't change
69 | // once the system is booted.
70 | var pageSize int64 // accessed atomically
71 |
72 | func Getpagesize() int {
73 | n := atomic.LoadInt64(&pageSize)
74 | if n == 0 {
75 | n, _ = sysconf(_SC_PAGESIZE)
76 | atomic.StoreInt64(&pageSize, n)
77 | }
78 | return int(n)
79 | }
80 |
81 | func Ioperm(from int, num int, on int) (err error) {
82 | return ENOSYS
83 | }
84 |
85 | func Iopl(level int) (err error) {
86 | return ENOSYS
87 | }
88 |
89 | //sysnb Gettimeofday(tv *Timeval) (err error)
90 |
91 | func Time(t *Time_t) (tt Time_t, err error) {
92 | var tv Timeval
93 | err = Gettimeofday(&tv)
94 | if err != nil {
95 | return 0, err
96 | }
97 | if t != nil {
98 | *t = Time_t(tv.Sec)
99 | }
100 | return Time_t(tv.Sec), nil
101 | }
102 |
103 | //sys Utime(path string, buf *Utimbuf) (err error)
104 |
105 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
106 |
107 | func NsecToTimespec(nsec int64) (ts Timespec) {
108 | ts.Sec = nsec / 1e9
109 | ts.Nsec = nsec % 1e9
110 | return
111 | }
112 |
113 | func NsecToTimeval(nsec int64) (tv Timeval) {
114 | nsec += 999 // round up to microsecond
115 | tv.Sec = nsec / 1e9
116 | tv.Usec = int32(nsec % 1e9 / 1e3)
117 | return
118 | }
119 |
120 | func (r *PtraceRegs) PC() uint64 { return r.Tpc }
121 |
122 | func (r *PtraceRegs) SetPC(pc uint64) { r.Tpc = pc }
123 |
124 | func (iov *Iovec) SetLen(length int) {
125 | iov.Len = uint64(length)
126 | }
127 |
128 | func (msghdr *Msghdr) SetControllen(length int) {
129 | msghdr.Controllen = uint64(length)
130 | }
131 |
132 | func (cmsg *Cmsghdr) SetLen(length int) {
133 | cmsg.Len = uint64(length)
134 | }
135 |
136 | //sysnb pipe(p *[2]_C_int) (err error)
137 |
138 | func Pipe(p []int) (err error) {
139 | if len(p) != 2 {
140 | return EINVAL
141 | }
142 | var pp [2]_C_int
143 | err = pipe(&pp)
144 | p[0] = int(pp[0])
145 | p[1] = int(pp[1])
146 | return
147 | }
148 |
149 | //sysnb pipe2(p *[2]_C_int, flags int) (err error)
150 |
151 | func Pipe2(p []int, flags int) (err error) {
152 | if len(p) != 2 {
153 | return EINVAL
154 | }
155 | var pp [2]_C_int
156 | err = pipe2(&pp, flags)
157 | p[0] = int(pp[0])
158 | p[1] = int(pp[1])
159 | return
160 | }
161 |
162 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
163 |
164 | func Poll(fds []PollFd, timeout int) (n int, err error) {
165 | if len(fds) == 0 {
166 | return poll(nil, 0, timeout)
167 | }
168 | return poll(&fds[0], len(fds), timeout)
169 | }
170 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/types_darwin.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build ignore
6 |
7 | /*
8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh
9 | */
10 |
11 | // +godefs map struct_in_addr [4]byte /* in_addr */
12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */
13 |
14 | package unix
15 |
16 | /*
17 | #define __DARWIN_UNIX03 0
18 | #define KERNEL
19 | #define _DARWIN_USE_64_BIT_INODE
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 | #include
47 | #include
48 | #include
49 | #include
50 |
51 | enum {
52 | sizeofPtr = sizeof(void*),
53 | };
54 |
55 | union sockaddr_all {
56 | struct sockaddr s1; // this one gets used for fields
57 | struct sockaddr_in s2; // these pad it out
58 | struct sockaddr_in6 s3;
59 | struct sockaddr_un s4;
60 | struct sockaddr_dl s5;
61 | };
62 |
63 | struct sockaddr_any {
64 | struct sockaddr addr;
65 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
66 | };
67 |
68 | */
69 | import "C"
70 |
71 | // Machine characteristics; for internal use.
72 |
73 | const (
74 | sizeofPtr = C.sizeofPtr
75 | sizeofShort = C.sizeof_short
76 | sizeofInt = C.sizeof_int
77 | sizeofLong = C.sizeof_long
78 | sizeofLongLong = C.sizeof_longlong
79 | )
80 |
81 | // Basic types
82 |
83 | type (
84 | _C_short C.short
85 | _C_int C.int
86 | _C_long C.long
87 | _C_long_long C.longlong
88 | )
89 |
90 | // Time
91 |
92 | type Timespec C.struct_timespec
93 |
94 | type Timeval C.struct_timeval
95 |
96 | type Timeval32 C.struct_timeval32
97 |
98 | // Processes
99 |
100 | type Rusage C.struct_rusage
101 |
102 | type Rlimit C.struct_rlimit
103 |
104 | type _Gid_t C.gid_t
105 |
106 | // Files
107 |
108 | type Stat_t C.struct_stat64
109 |
110 | type Statfs_t C.struct_statfs64
111 |
112 | type Flock_t C.struct_flock
113 |
114 | type Fstore_t C.struct_fstore
115 |
116 | type Radvisory_t C.struct_radvisory
117 |
118 | type Fbootstraptransfer_t C.struct_fbootstraptransfer
119 |
120 | type Log2phys_t C.struct_log2phys
121 |
122 | type Fsid C.struct_fsid
123 |
124 | type Dirent C.struct_dirent
125 |
126 | // Sockets
127 |
128 | type RawSockaddrInet4 C.struct_sockaddr_in
129 |
130 | type RawSockaddrInet6 C.struct_sockaddr_in6
131 |
132 | type RawSockaddrUnix C.struct_sockaddr_un
133 |
134 | type RawSockaddrDatalink C.struct_sockaddr_dl
135 |
136 | type RawSockaddr C.struct_sockaddr
137 |
138 | type RawSockaddrAny C.struct_sockaddr_any
139 |
140 | type _Socklen C.socklen_t
141 |
142 | type Linger C.struct_linger
143 |
144 | type Iovec C.struct_iovec
145 |
146 | type IPMreq C.struct_ip_mreq
147 |
148 | type IPv6Mreq C.struct_ipv6_mreq
149 |
150 | type Msghdr C.struct_msghdr
151 |
152 | type Cmsghdr C.struct_cmsghdr
153 |
154 | type Inet4Pktinfo C.struct_in_pktinfo
155 |
156 | type Inet6Pktinfo C.struct_in6_pktinfo
157 |
158 | type IPv6MTUInfo C.struct_ip6_mtuinfo
159 |
160 | type ICMPv6Filter C.struct_icmp6_filter
161 |
162 | const (
163 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
164 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
165 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
166 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
167 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
168 | SizeofLinger = C.sizeof_struct_linger
169 | SizeofIPMreq = C.sizeof_struct_ip_mreq
170 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
171 | SizeofMsghdr = C.sizeof_struct_msghdr
172 | SizeofCmsghdr = C.sizeof_struct_cmsghdr
173 | SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo
174 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
175 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
176 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
177 | )
178 |
179 | // Ptrace requests
180 |
181 | const (
182 | PTRACE_TRACEME = C.PT_TRACE_ME
183 | PTRACE_CONT = C.PT_CONTINUE
184 | PTRACE_KILL = C.PT_KILL
185 | )
186 |
187 | // Events (kqueue, kevent)
188 |
189 | type Kevent_t C.struct_kevent
190 |
191 | // Select
192 |
193 | type FdSet C.fd_set
194 |
195 | // Routing and interface messages
196 |
197 | const (
198 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr
199 | SizeofIfData = C.sizeof_struct_if_data
200 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
201 | SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
202 | SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2
203 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
204 | SizeofRtMetrics = C.sizeof_struct_rt_metrics
205 | )
206 |
207 | type IfMsghdr C.struct_if_msghdr
208 |
209 | type IfData C.struct_if_data
210 |
211 | type IfaMsghdr C.struct_ifa_msghdr
212 |
213 | type IfmaMsghdr C.struct_ifma_msghdr
214 |
215 | type IfmaMsghdr2 C.struct_ifma_msghdr2
216 |
217 | type RtMsghdr C.struct_rt_msghdr
218 |
219 | type RtMetrics C.struct_rt_metrics
220 |
221 | // Berkeley packet filter
222 |
223 | const (
224 | SizeofBpfVersion = C.sizeof_struct_bpf_version
225 | SizeofBpfStat = C.sizeof_struct_bpf_stat
226 | SizeofBpfProgram = C.sizeof_struct_bpf_program
227 | SizeofBpfInsn = C.sizeof_struct_bpf_insn
228 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr
229 | )
230 |
231 | type BpfVersion C.struct_bpf_version
232 |
233 | type BpfStat C.struct_bpf_stat
234 |
235 | type BpfProgram C.struct_bpf_program
236 |
237 | type BpfInsn C.struct_bpf_insn
238 |
239 | type BpfHdr C.struct_bpf_hdr
240 |
241 | // Terminal handling
242 |
243 | type Termios C.struct_termios
244 |
245 | // fchmodat-like syscalls.
246 |
247 | const (
248 | AT_FDCWD = C.AT_FDCWD
249 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
250 | )
251 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 |
3 | # Copyright 2011 The Go Authors. All rights reserved.
4 | # Use of this source code is governed by a BSD-style
5 | # license that can be found in the LICENSE file.
6 |
7 | #
8 | # Parse the header files for OpenBSD and generate a Go usable sysctl MIB.
9 | #
10 | # Build a MIB with each entry being an array containing the level, type and
11 | # a hash that will contain additional entries if the current entry is a node.
12 | # We then walk this MIB and create a flattened sysctl name to OID hash.
13 | #
14 |
15 | use strict;
16 |
17 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
18 | print STDERR "GOARCH or GOOS not defined in environment\n";
19 | exit 1;
20 | }
21 |
22 | my $debug = 0;
23 | my %ctls = ();
24 |
25 | my @headers = qw (
26 | sys/sysctl.h
27 | sys/socket.h
28 | sys/tty.h
29 | sys/malloc.h
30 | sys/mount.h
31 | sys/namei.h
32 | sys/sem.h
33 | sys/shm.h
34 | sys/vmmeter.h
35 | uvm/uvm_param.h
36 | uvm/uvm_swap_encrypt.h
37 | ddb/db_var.h
38 | net/if.h
39 | net/if_pfsync.h
40 | net/pipex.h
41 | netinet/in.h
42 | netinet/icmp_var.h
43 | netinet/igmp_var.h
44 | netinet/ip_ah.h
45 | netinet/ip_carp.h
46 | netinet/ip_divert.h
47 | netinet/ip_esp.h
48 | netinet/ip_ether.h
49 | netinet/ip_gre.h
50 | netinet/ip_ipcomp.h
51 | netinet/ip_ipip.h
52 | netinet/pim_var.h
53 | netinet/tcp_var.h
54 | netinet/udp_var.h
55 | netinet6/in6.h
56 | netinet6/ip6_divert.h
57 | netinet6/pim6_var.h
58 | netinet/icmp6.h
59 | netmpls/mpls.h
60 | );
61 |
62 | my @ctls = qw (
63 | kern
64 | vm
65 | fs
66 | net
67 | #debug # Special handling required
68 | hw
69 | #machdep # Arch specific
70 | user
71 | ddb
72 | #vfs # Special handling required
73 | fs.posix
74 | kern.forkstat
75 | kern.intrcnt
76 | kern.malloc
77 | kern.nchstats
78 | kern.seminfo
79 | kern.shminfo
80 | kern.timecounter
81 | kern.tty
82 | kern.watchdog
83 | net.bpf
84 | net.ifq
85 | net.inet
86 | net.inet.ah
87 | net.inet.carp
88 | net.inet.divert
89 | net.inet.esp
90 | net.inet.etherip
91 | net.inet.gre
92 | net.inet.icmp
93 | net.inet.igmp
94 | net.inet.ip
95 | net.inet.ip.ifq
96 | net.inet.ipcomp
97 | net.inet.ipip
98 | net.inet.mobileip
99 | net.inet.pfsync
100 | net.inet.pim
101 | net.inet.tcp
102 | net.inet.udp
103 | net.inet6
104 | net.inet6.divert
105 | net.inet6.ip6
106 | net.inet6.icmp6
107 | net.inet6.pim6
108 | net.inet6.tcp6
109 | net.inet6.udp6
110 | net.mpls
111 | net.mpls.ifq
112 | net.key
113 | net.pflow
114 | net.pfsync
115 | net.pipex
116 | net.rt
117 | vm.swapencrypt
118 | #vfsgenctl # Special handling required
119 | );
120 |
121 | # Node name "fixups"
122 | my %ctl_map = (
123 | "ipproto" => "net.inet",
124 | "net.inet.ipproto" => "net.inet",
125 | "net.inet6.ipv6proto" => "net.inet6",
126 | "net.inet6.ipv6" => "net.inet6.ip6",
127 | "net.inet.icmpv6" => "net.inet6.icmp6",
128 | "net.inet6.divert6" => "net.inet6.divert",
129 | "net.inet6.tcp6" => "net.inet.tcp",
130 | "net.inet6.udp6" => "net.inet.udp",
131 | "mpls" => "net.mpls",
132 | "swpenc" => "vm.swapencrypt"
133 | );
134 |
135 | # Node mappings
136 | my %node_map = (
137 | "net.inet.ip.ifq" => "net.ifq",
138 | "net.inet.pfsync" => "net.pfsync",
139 | "net.mpls.ifq" => "net.ifq"
140 | );
141 |
142 | my $ctlname;
143 | my %mib = ();
144 | my %sysctl = ();
145 | my $node;
146 |
147 | sub debug() {
148 | print STDERR "$_[0]\n" if $debug;
149 | }
150 |
151 | # Walk the MIB and build a sysctl name to OID mapping.
152 | sub build_sysctl() {
153 | my ($node, $name, $oid) = @_;
154 | my %node = %{$node};
155 | my @oid = @{$oid};
156 |
157 | foreach my $key (sort keys %node) {
158 | my @node = @{$node{$key}};
159 | my $nodename = $name.($name ne '' ? '.' : '').$key;
160 | my @nodeoid = (@oid, $node[0]);
161 | if ($node[1] eq 'CTLTYPE_NODE') {
162 | if (exists $node_map{$nodename}) {
163 | $node = \%mib;
164 | $ctlname = $node_map{$nodename};
165 | foreach my $part (split /\./, $ctlname) {
166 | $node = \%{@{$$node{$part}}[2]};
167 | }
168 | } else {
169 | $node = $node[2];
170 | }
171 | &build_sysctl($node, $nodename, \@nodeoid);
172 | } elsif ($node[1] ne '') {
173 | $sysctl{$nodename} = \@nodeoid;
174 | }
175 | }
176 | }
177 |
178 | foreach my $ctl (@ctls) {
179 | $ctls{$ctl} = $ctl;
180 | }
181 |
182 | # Build MIB
183 | foreach my $header (@headers) {
184 | &debug("Processing $header...");
185 | open HEADER, "/usr/include/$header" ||
186 | print STDERR "Failed to open $header\n";
187 | while () {
188 | if ($_ =~ /^#define\s+(CTL_NAMES)\s+{/ ||
189 | $_ =~ /^#define\s+(CTL_(.*)_NAMES)\s+{/ ||
190 | $_ =~ /^#define\s+((.*)CTL_NAMES)\s+{/) {
191 | if ($1 eq 'CTL_NAMES') {
192 | # Top level.
193 | $node = \%mib;
194 | } else {
195 | # Node.
196 | my $nodename = lc($2);
197 | if ($header =~ /^netinet\//) {
198 | $ctlname = "net.inet.$nodename";
199 | } elsif ($header =~ /^netinet6\//) {
200 | $ctlname = "net.inet6.$nodename";
201 | } elsif ($header =~ /^net\//) {
202 | $ctlname = "net.$nodename";
203 | } else {
204 | $ctlname = "$nodename";
205 | $ctlname =~ s/^(fs|net|kern)_/$1\./;
206 | }
207 | if (exists $ctl_map{$ctlname}) {
208 | $ctlname = $ctl_map{$ctlname};
209 | }
210 | if (not exists $ctls{$ctlname}) {
211 | &debug("Ignoring $ctlname...");
212 | next;
213 | }
214 |
215 | # Walk down from the top of the MIB.
216 | $node = \%mib;
217 | foreach my $part (split /\./, $ctlname) {
218 | if (not exists $$node{$part}) {
219 | &debug("Missing node $part");
220 | $$node{$part} = [ 0, '', {} ];
221 | }
222 | $node = \%{@{$$node{$part}}[2]};
223 | }
224 | }
225 |
226 | # Populate current node with entries.
227 | my $i = -1;
228 | while (defined($_) && $_ !~ /^}/) {
229 | $_ = ;
230 | $i++ if $_ =~ /{.*}/;
231 | next if $_ !~ /{\s+"(\w+)",\s+(CTLTYPE_[A-Z]+)\s+}/;
232 | $$node{$1} = [ $i, $2, {} ];
233 | }
234 | }
235 | }
236 | close HEADER;
237 | }
238 |
239 | &build_sysctl(\%mib, "", []);
240 |
241 | print <
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 | #include
47 | #include
48 | #include
49 | #include
50 | #include
51 | #include
52 | #include
53 | #include
54 | #include
55 |
56 | enum {
57 | sizeofPtr = sizeof(void*),
58 | };
59 |
60 | union sockaddr_all {
61 | struct sockaddr s1; // this one gets used for fields
62 | struct sockaddr_in s2; // these pad it out
63 | struct sockaddr_in6 s3;
64 | struct sockaddr_un s4;
65 | struct sockaddr_dl s5;
66 | };
67 |
68 | struct sockaddr_any {
69 | struct sockaddr addr;
70 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
71 | };
72 |
73 | */
74 | import "C"
75 |
76 | // Machine characteristics; for internal use.
77 |
78 | const (
79 | sizeofPtr = C.sizeofPtr
80 | sizeofShort = C.sizeof_short
81 | sizeofInt = C.sizeof_int
82 | sizeofLong = C.sizeof_long
83 | sizeofLongLong = C.sizeof_longlong
84 | PathMax = C.PATH_MAX
85 | MaxHostNameLen = C.MAXHOSTNAMELEN
86 | )
87 |
88 | // Basic types
89 |
90 | type (
91 | _C_short C.short
92 | _C_int C.int
93 | _C_long C.long
94 | _C_long_long C.longlong
95 | )
96 |
97 | // Time
98 |
99 | type Timespec C.struct_timespec
100 |
101 | type Timeval C.struct_timeval
102 |
103 | type Timeval32 C.struct_timeval32
104 |
105 | type Tms C.struct_tms
106 |
107 | type Utimbuf C.struct_utimbuf
108 |
109 | // Processes
110 |
111 | type Rusage C.struct_rusage
112 |
113 | type Rlimit C.struct_rlimit
114 |
115 | type _Gid_t C.gid_t
116 |
117 | // Files
118 |
119 | const ( // Directory mode bits
120 | S_IFMT = C.S_IFMT
121 | S_IFIFO = C.S_IFIFO
122 | S_IFCHR = C.S_IFCHR
123 | S_IFDIR = C.S_IFDIR
124 | S_IFBLK = C.S_IFBLK
125 | S_IFREG = C.S_IFREG
126 | S_IFLNK = C.S_IFLNK
127 | S_IFSOCK = C.S_IFSOCK
128 | S_ISUID = C.S_ISUID
129 | S_ISGID = C.S_ISGID
130 | S_ISVTX = C.S_ISVTX
131 | S_IRUSR = C.S_IRUSR
132 | S_IWUSR = C.S_IWUSR
133 | S_IXUSR = C.S_IXUSR
134 | )
135 |
136 | type Stat_t C.struct_stat
137 |
138 | type Flock_t C.struct_flock
139 |
140 | type Dirent C.struct_dirent
141 |
142 | // Sockets
143 |
144 | type RawSockaddrInet4 C.struct_sockaddr_in
145 |
146 | type RawSockaddrInet6 C.struct_sockaddr_in6
147 |
148 | type RawSockaddrUnix C.struct_sockaddr_un
149 |
150 | type RawSockaddrDatalink C.struct_sockaddr_dl
151 |
152 | type RawSockaddr C.struct_sockaddr
153 |
154 | type RawSockaddrAny C.struct_sockaddr_any
155 |
156 | type _Socklen C.socklen_t
157 |
158 | type Linger C.struct_linger
159 |
160 | type Iovec C.struct_iovec
161 |
162 | type IPMreq C.struct_ip_mreq
163 |
164 | type IPv6Mreq C.struct_ipv6_mreq
165 |
166 | type Msghdr C.struct_msghdr
167 |
168 | type Cmsghdr C.struct_cmsghdr
169 |
170 | type Inet6Pktinfo C.struct_in6_pktinfo
171 |
172 | type IPv6MTUInfo C.struct_ip6_mtuinfo
173 |
174 | type ICMPv6Filter C.struct_icmp6_filter
175 |
176 | const (
177 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
178 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
179 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
180 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
181 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
182 | SizeofLinger = C.sizeof_struct_linger
183 | SizeofIPMreq = C.sizeof_struct_ip_mreq
184 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
185 | SizeofMsghdr = C.sizeof_struct_msghdr
186 | SizeofCmsghdr = C.sizeof_struct_cmsghdr
187 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
188 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
189 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
190 | )
191 |
192 | // Select
193 |
194 | type FdSet C.fd_set
195 |
196 | // Misc
197 |
198 | type Utsname C.struct_utsname
199 |
200 | type Ustat_t C.struct_ustat
201 |
202 | const (
203 | AT_FDCWD = C.AT_FDCWD
204 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
205 | AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW
206 | AT_REMOVEDIR = C.AT_REMOVEDIR
207 | AT_EACCESS = C.AT_EACCESS
208 | )
209 |
210 | // Routing and interface messages
211 |
212 | const (
213 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr
214 | SizeofIfData = C.sizeof_struct_if_data
215 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
216 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
217 | SizeofRtMetrics = C.sizeof_struct_rt_metrics
218 | )
219 |
220 | type IfMsghdr C.struct_if_msghdr
221 |
222 | type IfData C.struct_if_data
223 |
224 | type IfaMsghdr C.struct_ifa_msghdr
225 |
226 | type RtMsghdr C.struct_rt_msghdr
227 |
228 | type RtMetrics C.struct_rt_metrics
229 |
230 | // Berkeley packet filter
231 |
232 | const (
233 | SizeofBpfVersion = C.sizeof_struct_bpf_version
234 | SizeofBpfStat = C.sizeof_struct_bpf_stat
235 | SizeofBpfProgram = C.sizeof_struct_bpf_program
236 | SizeofBpfInsn = C.sizeof_struct_bpf_insn
237 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr
238 | )
239 |
240 | type BpfVersion C.struct_bpf_version
241 |
242 | type BpfStat C.struct_bpf_stat
243 |
244 | type BpfProgram C.struct_bpf_program
245 |
246 | type BpfInsn C.struct_bpf_insn
247 |
248 | type BpfTimeval C.struct_bpf_timeval
249 |
250 | type BpfHdr C.struct_bpf_hdr
251 |
252 | // sysconf information
253 |
254 | const _SC_PAGESIZE = C._SC_PAGESIZE
255 |
256 | // Terminal handling
257 |
258 | type Termios C.struct_termios
259 |
260 | type Termio C.struct_termio
261 |
262 | type Winsize C.struct_winsize
263 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build arm64,linux
6 |
7 | package unix
8 |
9 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT
10 | //sys Fchown(fd int, uid int, gid int) (err error)
11 | //sys Fstat(fd int, stat *Stat_t) (err error)
12 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
13 | //sys Fstatfs(fd int, buf *Statfs_t) (err error)
14 | //sys Ftruncate(fd int, length int64) (err error)
15 | //sysnb Getegid() (egid int)
16 | //sysnb Geteuid() (euid int)
17 | //sysnb Getgid() (gid int)
18 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
19 | //sysnb Getuid() (uid int)
20 | //sys Listen(s int, n int) (err error)
21 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
22 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
23 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
24 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6
25 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
26 | //sys Setfsgid(gid int) (err error)
27 | //sys Setfsuid(uid int) (err error)
28 | //sysnb Setregid(rgid int, egid int) (err error)
29 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
30 | //sysnb Setresuid(ruid int, euid int, suid int) (err error)
31 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
32 | //sysnb Setreuid(ruid int, euid int) (err error)
33 | //sys Shutdown(fd int, how int) (err error)
34 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
35 |
36 | func Stat(path string, stat *Stat_t) (err error) {
37 | return Fstatat(AT_FDCWD, path, stat, 0)
38 | }
39 |
40 | func Lchown(path string, uid int, gid int) (err error) {
41 | return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW)
42 | }
43 |
44 | func Lstat(path string, stat *Stat_t) (err error) {
45 | return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW)
46 | }
47 |
48 | //sys Statfs(path string, buf *Statfs_t) (err error)
49 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
50 | //sys Truncate(path string, length int64) (err error)
51 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
52 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
53 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
54 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
55 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
56 | //sysnb setgroups(n int, list *_Gid_t) (err error)
57 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
58 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
59 | //sysnb socket(domain int, typ int, proto int) (fd int, err error)
60 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
61 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
62 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
63 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
64 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
65 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
66 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
67 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
68 |
69 | func Getpagesize() int { return 65536 }
70 |
71 | //sysnb Gettimeofday(tv *Timeval) (err error)
72 |
73 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
74 |
75 | func NsecToTimespec(nsec int64) (ts Timespec) {
76 | ts.Sec = nsec / 1e9
77 | ts.Nsec = nsec % 1e9
78 | return
79 | }
80 |
81 | func NsecToTimeval(nsec int64) (tv Timeval) {
82 | nsec += 999 // round up to microsecond
83 | tv.Sec = nsec / 1e9
84 | tv.Usec = nsec % 1e9 / 1e3
85 | return
86 | }
87 |
88 | func Time(t *Time_t) (Time_t, error) {
89 | var tv Timeval
90 | err := Gettimeofday(&tv)
91 | if err != nil {
92 | return 0, err
93 | }
94 | if t != nil {
95 | *t = Time_t(tv.Sec)
96 | }
97 | return Time_t(tv.Sec), nil
98 | }
99 |
100 | func Utime(path string, buf *Utimbuf) error {
101 | tv := []Timeval{
102 | {Sec: buf.Actime},
103 | {Sec: buf.Modtime},
104 | }
105 | return Utimes(path, tv)
106 | }
107 |
108 | func Pipe(p []int) (err error) {
109 | if len(p) != 2 {
110 | return EINVAL
111 | }
112 | var pp [2]_C_int
113 | err = pipe2(&pp, 0)
114 | p[0] = int(pp[0])
115 | p[1] = int(pp[1])
116 | return
117 | }
118 |
119 | //sysnb pipe2(p *[2]_C_int, flags int) (err error)
120 |
121 | func Pipe2(p []int, flags int) (err error) {
122 | if len(p) != 2 {
123 | return EINVAL
124 | }
125 | var pp [2]_C_int
126 | err = pipe2(&pp, flags)
127 | p[0] = int(pp[0])
128 | p[1] = int(pp[1])
129 | return
130 | }
131 |
132 | func (r *PtraceRegs) PC() uint64 { return r.Pc }
133 |
134 | func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
135 |
136 | func (iov *Iovec) SetLen(length int) {
137 | iov.Len = uint64(length)
138 | }
139 |
140 | func (msghdr *Msghdr) SetControllen(length int) {
141 | msghdr.Controllen = uint64(length)
142 | }
143 |
144 | func (cmsg *Cmsghdr) SetLen(length int) {
145 | cmsg.Len = uint64(length)
146 | }
147 |
148 | func InotifyInit() (fd int, err error) {
149 | return InotifyInit1(0)
150 | }
151 |
152 | func Dup2(oldfd int, newfd int) (err error) {
153 | return Dup3(oldfd, newfd, 0)
154 | }
155 |
156 | func Pause() (err error) {
157 | _, _, e1 := Syscall6(SYS_PPOLL, 0, 0, 0, 0, 0, 0)
158 | if e1 != 0 {
159 | err = errnoErr(e1)
160 | }
161 | return
162 | }
163 |
164 | // TODO(dfc): constants that should be in zsysnum_linux_arm64.go, remove
165 | // these when the deprecated syscalls that the syscall package relies on
166 | // are removed.
167 | const (
168 | SYS_GETPGRP = 1060
169 | SYS_UTIMES = 1037
170 | SYS_FUTIMESAT = 1066
171 | SYS_PAUSE = 1061
172 | SYS_USTAT = 1070
173 | SYS_UTIME = 1063
174 | SYS_LCHOWN = 1032
175 | SYS_TIME = 1062
176 | SYS_EPOLL_CREATE = 1042
177 | SYS_EPOLL_WAIT = 1069
178 | )
179 |
180 | func Poll(fds []PollFd, timeout int) (n int, err error) {
181 | var ts *Timespec
182 | if timeout >= 0 {
183 | ts = new(Timespec)
184 | *ts = NsecToTimespec(int64(timeout) * 1e6)
185 | }
186 | if len(fds) == 0 {
187 | return ppoll(nil, 0, ts, nil)
188 | }
189 | return ppoll(&fds[0], len(fds), ts, nil)
190 | }
191 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 | // +build mips64 mips64le
7 |
8 | package unix
9 |
10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
11 | //sys Fchown(fd int, uid int, gid int) (err error)
12 | //sys Fstatfs(fd int, buf *Statfs_t) (err error)
13 | //sys Ftruncate(fd int, length int64) (err error)
14 | //sysnb Getegid() (egid int)
15 | //sysnb Geteuid() (euid int)
16 | //sysnb Getgid() (gid int)
17 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
18 | //sysnb Getuid() (uid int)
19 | //sys Lchown(path string, uid int, gid int) (err error)
20 | //sys Listen(s int, n int) (err error)
21 | //sys Pause() (err error)
22 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
23 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
24 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
25 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6
26 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
27 | //sys Setfsgid(gid int) (err error)
28 | //sys Setfsuid(uid int) (err error)
29 | //sysnb Setregid(rgid int, egid int) (err error)
30 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
31 | //sysnb Setresuid(ruid int, euid int, suid int) (err error)
32 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
33 | //sysnb Setreuid(ruid int, euid int) (err error)
34 | //sys Shutdown(fd int, how int) (err error)
35 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
36 | //sys Statfs(path string, buf *Statfs_t) (err error)
37 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
38 | //sys Truncate(path string, length int64) (err error)
39 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
40 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
41 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
42 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
43 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
44 | //sysnb setgroups(n int, list *_Gid_t) (err error)
45 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
46 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
47 | //sysnb socket(domain int, typ int, proto int) (fd int, err error)
48 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
49 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
50 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
51 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
52 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
53 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
54 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
55 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
56 |
57 | func Getpagesize() int { return 65536 }
58 |
59 | //sysnb Gettimeofday(tv *Timeval) (err error)
60 |
61 | func Time(t *Time_t) (tt Time_t, err error) {
62 | var tv Timeval
63 | err = Gettimeofday(&tv)
64 | if err != nil {
65 | return 0, err
66 | }
67 | if t != nil {
68 | *t = Time_t(tv.Sec)
69 | }
70 | return Time_t(tv.Sec), nil
71 | }
72 |
73 | //sys Utime(path string, buf *Utimbuf) (err error)
74 |
75 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
76 |
77 | func NsecToTimespec(nsec int64) (ts Timespec) {
78 | ts.Sec = nsec / 1e9
79 | ts.Nsec = nsec % 1e9
80 | return
81 | }
82 |
83 | func NsecToTimeval(nsec int64) (tv Timeval) {
84 | nsec += 999 // round up to microsecond
85 | tv.Sec = nsec / 1e9
86 | tv.Usec = nsec % 1e9 / 1e3
87 | return
88 | }
89 |
90 | func Pipe(p []int) (err error) {
91 | if len(p) != 2 {
92 | return EINVAL
93 | }
94 | var pp [2]_C_int
95 | err = pipe2(&pp, 0)
96 | p[0] = int(pp[0])
97 | p[1] = int(pp[1])
98 | return
99 | }
100 |
101 | //sysnb pipe2(p *[2]_C_int, flags int) (err error)
102 |
103 | func Pipe2(p []int, flags int) (err error) {
104 | if len(p) != 2 {
105 | return EINVAL
106 | }
107 | var pp [2]_C_int
108 | err = pipe2(&pp, flags)
109 | p[0] = int(pp[0])
110 | p[1] = int(pp[1])
111 | return
112 | }
113 |
114 | func Ioperm(from int, num int, on int) (err error) {
115 | return ENOSYS
116 | }
117 |
118 | func Iopl(level int) (err error) {
119 | return ENOSYS
120 | }
121 |
122 | type stat_t struct {
123 | Dev uint32
124 | Pad0 [3]int32
125 | Ino uint64
126 | Mode uint32
127 | Nlink uint32
128 | Uid uint32
129 | Gid uint32
130 | Rdev uint32
131 | Pad1 [3]uint32
132 | Size int64
133 | Atime uint32
134 | Atime_nsec uint32
135 | Mtime uint32
136 | Mtime_nsec uint32
137 | Ctime uint32
138 | Ctime_nsec uint32
139 | Blksize uint32
140 | Pad2 uint32
141 | Blocks int64
142 | }
143 |
144 | //sys fstat(fd int, st *stat_t) (err error)
145 | //sys lstat(path string, st *stat_t) (err error)
146 | //sys stat(path string, st *stat_t) (err error)
147 |
148 | func Fstat(fd int, s *Stat_t) (err error) {
149 | st := &stat_t{}
150 | err = fstat(fd, st)
151 | fillStat_t(s, st)
152 | return
153 | }
154 |
155 | func Lstat(path string, s *Stat_t) (err error) {
156 | st := &stat_t{}
157 | err = lstat(path, st)
158 | fillStat_t(s, st)
159 | return
160 | }
161 |
162 | func Stat(path string, s *Stat_t) (err error) {
163 | st := &stat_t{}
164 | err = stat(path, st)
165 | fillStat_t(s, st)
166 | return
167 | }
168 |
169 | func fillStat_t(s *Stat_t, st *stat_t) {
170 | s.Dev = st.Dev
171 | s.Ino = st.Ino
172 | s.Mode = st.Mode
173 | s.Nlink = st.Nlink
174 | s.Uid = st.Uid
175 | s.Gid = st.Gid
176 | s.Rdev = st.Rdev
177 | s.Size = st.Size
178 | s.Atim = Timespec{int64(st.Atime), int64(st.Atime_nsec)}
179 | s.Mtim = Timespec{int64(st.Mtime), int64(st.Mtime_nsec)}
180 | s.Ctim = Timespec{int64(st.Ctime), int64(st.Ctime_nsec)}
181 | s.Blksize = st.Blksize
182 | s.Blocks = st.Blocks
183 | }
184 |
185 | func (r *PtraceRegs) PC() uint64 { return r.Regs[64] }
186 |
187 | func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = pc }
188 |
189 | func (iov *Iovec) SetLen(length int) {
190 | iov.Len = uint64(length)
191 | }
192 |
193 | func (msghdr *Msghdr) SetControllen(length int) {
194 | msghdr.Controllen = uint64(length)
195 | }
196 |
197 | func (cmsg *Cmsghdr) SetLen(length int) {
198 | cmsg.Len = uint64(length)
199 | }
200 |
201 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
202 |
203 | func Poll(fds []PollFd, timeout int) (n int, err error) {
204 | if len(fds) == 0 {
205 | return poll(nil, 0, timeout)
206 | }
207 | return poll(&fds[0], len(fds), timeout)
208 | }
209 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go:
--------------------------------------------------------------------------------
1 | // Created by cgo -godefs - DO NOT EDIT
2 | // cgo -godefs types_netbsd.go
3 |
4 | // +build 386,netbsd
5 |
6 | package unix
7 |
8 | const (
9 | sizeofPtr = 0x4
10 | sizeofShort = 0x2
11 | sizeofInt = 0x4
12 | sizeofLong = 0x4
13 | sizeofLongLong = 0x8
14 | )
15 |
16 | type (
17 | _C_short int16
18 | _C_int int32
19 | _C_long int32
20 | _C_long_long int64
21 | )
22 |
23 | type Timespec struct {
24 | Sec int64
25 | Nsec int32
26 | }
27 |
28 | type Timeval struct {
29 | Sec int64
30 | Usec int32
31 | }
32 |
33 | type Rusage struct {
34 | Utime Timeval
35 | Stime Timeval
36 | Maxrss int32
37 | Ixrss int32
38 | Idrss int32
39 | Isrss int32
40 | Minflt int32
41 | Majflt int32
42 | Nswap int32
43 | Inblock int32
44 | Oublock int32
45 | Msgsnd int32
46 | Msgrcv int32
47 | Nsignals int32
48 | Nvcsw int32
49 | Nivcsw int32
50 | }
51 |
52 | type Rlimit struct {
53 | Cur uint64
54 | Max uint64
55 | }
56 |
57 | type _Gid_t uint32
58 |
59 | type Stat_t struct {
60 | Dev uint64
61 | Mode uint32
62 | Ino uint64
63 | Nlink uint32
64 | Uid uint32
65 | Gid uint32
66 | Rdev uint64
67 | Atimespec Timespec
68 | Mtimespec Timespec
69 | Ctimespec Timespec
70 | Birthtimespec Timespec
71 | Size int64
72 | Blocks int64
73 | Blksize uint32
74 | Flags uint32
75 | Gen uint32
76 | Spare [2]uint32
77 | }
78 |
79 | type Statfs_t [0]byte
80 |
81 | type Flock_t struct {
82 | Start int64
83 | Len int64
84 | Pid int32
85 | Type int16
86 | Whence int16
87 | }
88 |
89 | type Dirent struct {
90 | Fileno uint64
91 | Reclen uint16
92 | Namlen uint16
93 | Type uint8
94 | Name [512]int8
95 | Pad_cgo_0 [3]byte
96 | }
97 |
98 | type Fsid struct {
99 | X__fsid_val [2]int32
100 | }
101 |
102 | type RawSockaddrInet4 struct {
103 | Len uint8
104 | Family uint8
105 | Port uint16
106 | Addr [4]byte /* in_addr */
107 | Zero [8]int8
108 | }
109 |
110 | type RawSockaddrInet6 struct {
111 | Len uint8
112 | Family uint8
113 | Port uint16
114 | Flowinfo uint32
115 | Addr [16]byte /* in6_addr */
116 | Scope_id uint32
117 | }
118 |
119 | type RawSockaddrUnix struct {
120 | Len uint8
121 | Family uint8
122 | Path [104]int8
123 | }
124 |
125 | type RawSockaddrDatalink struct {
126 | Len uint8
127 | Family uint8
128 | Index uint16
129 | Type uint8
130 | Nlen uint8
131 | Alen uint8
132 | Slen uint8
133 | Data [12]int8
134 | }
135 |
136 | type RawSockaddr struct {
137 | Len uint8
138 | Family uint8
139 | Data [14]int8
140 | }
141 |
142 | type RawSockaddrAny struct {
143 | Addr RawSockaddr
144 | Pad [92]int8
145 | }
146 |
147 | type _Socklen uint32
148 |
149 | type Linger struct {
150 | Onoff int32
151 | Linger int32
152 | }
153 |
154 | type Iovec struct {
155 | Base *byte
156 | Len uint32
157 | }
158 |
159 | type IPMreq struct {
160 | Multiaddr [4]byte /* in_addr */
161 | Interface [4]byte /* in_addr */
162 | }
163 |
164 | type IPv6Mreq struct {
165 | Multiaddr [16]byte /* in6_addr */
166 | Interface uint32
167 | }
168 |
169 | type Msghdr struct {
170 | Name *byte
171 | Namelen uint32
172 | Iov *Iovec
173 | Iovlen int32
174 | Control *byte
175 | Controllen uint32
176 | Flags int32
177 | }
178 |
179 | type Cmsghdr struct {
180 | Len uint32
181 | Level int32
182 | Type int32
183 | }
184 |
185 | type Inet6Pktinfo struct {
186 | Addr [16]byte /* in6_addr */
187 | Ifindex uint32
188 | }
189 |
190 | type IPv6MTUInfo struct {
191 | Addr RawSockaddrInet6
192 | Mtu uint32
193 | }
194 |
195 | type ICMPv6Filter struct {
196 | Filt [8]uint32
197 | }
198 |
199 | const (
200 | SizeofSockaddrInet4 = 0x10
201 | SizeofSockaddrInet6 = 0x1c
202 | SizeofSockaddrAny = 0x6c
203 | SizeofSockaddrUnix = 0x6a
204 | SizeofSockaddrDatalink = 0x14
205 | SizeofLinger = 0x8
206 | SizeofIPMreq = 0x8
207 | SizeofIPv6Mreq = 0x14
208 | SizeofMsghdr = 0x1c
209 | SizeofCmsghdr = 0xc
210 | SizeofInet6Pktinfo = 0x14
211 | SizeofIPv6MTUInfo = 0x20
212 | SizeofICMPv6Filter = 0x20
213 | )
214 |
215 | const (
216 | PTRACE_TRACEME = 0x0
217 | PTRACE_CONT = 0x7
218 | PTRACE_KILL = 0x8
219 | )
220 |
221 | type Kevent_t struct {
222 | Ident uint32
223 | Filter uint32
224 | Flags uint32
225 | Fflags uint32
226 | Data int64
227 | Udata int32
228 | }
229 |
230 | type FdSet struct {
231 | Bits [8]uint32
232 | }
233 |
234 | const (
235 | SizeofIfMsghdr = 0x98
236 | SizeofIfData = 0x84
237 | SizeofIfaMsghdr = 0x18
238 | SizeofIfAnnounceMsghdr = 0x18
239 | SizeofRtMsghdr = 0x78
240 | SizeofRtMetrics = 0x50
241 | )
242 |
243 | type IfMsghdr struct {
244 | Msglen uint16
245 | Version uint8
246 | Type uint8
247 | Addrs int32
248 | Flags int32
249 | Index uint16
250 | Pad_cgo_0 [2]byte
251 | Data IfData
252 | Pad_cgo_1 [4]byte
253 | }
254 |
255 | type IfData struct {
256 | Type uint8
257 | Addrlen uint8
258 | Hdrlen uint8
259 | Pad_cgo_0 [1]byte
260 | Link_state int32
261 | Mtu uint64
262 | Metric uint64
263 | Baudrate uint64
264 | Ipackets uint64
265 | Ierrors uint64
266 | Opackets uint64
267 | Oerrors uint64
268 | Collisions uint64
269 | Ibytes uint64
270 | Obytes uint64
271 | Imcasts uint64
272 | Omcasts uint64
273 | Iqdrops uint64
274 | Noproto uint64
275 | Lastchange Timespec
276 | }
277 |
278 | type IfaMsghdr struct {
279 | Msglen uint16
280 | Version uint8
281 | Type uint8
282 | Addrs int32
283 | Flags int32
284 | Metric int32
285 | Index uint16
286 | Pad_cgo_0 [6]byte
287 | }
288 |
289 | type IfAnnounceMsghdr struct {
290 | Msglen uint16
291 | Version uint8
292 | Type uint8
293 | Index uint16
294 | Name [16]int8
295 | What uint16
296 | }
297 |
298 | type RtMsghdr struct {
299 | Msglen uint16
300 | Version uint8
301 | Type uint8
302 | Index uint16
303 | Pad_cgo_0 [2]byte
304 | Flags int32
305 | Addrs int32
306 | Pid int32
307 | Seq int32
308 | Errno int32
309 | Use int32
310 | Inits int32
311 | Pad_cgo_1 [4]byte
312 | Rmx RtMetrics
313 | }
314 |
315 | type RtMetrics struct {
316 | Locks uint64
317 | Mtu uint64
318 | Hopcount uint64
319 | Recvpipe uint64
320 | Sendpipe uint64
321 | Ssthresh uint64
322 | Rtt uint64
323 | Rttvar uint64
324 | Expire int64
325 | Pksent int64
326 | }
327 |
328 | type Mclpool [0]byte
329 |
330 | const (
331 | SizeofBpfVersion = 0x4
332 | SizeofBpfStat = 0x80
333 | SizeofBpfProgram = 0x8
334 | SizeofBpfInsn = 0x8
335 | SizeofBpfHdr = 0x14
336 | )
337 |
338 | type BpfVersion struct {
339 | Major uint16
340 | Minor uint16
341 | }
342 |
343 | type BpfStat struct {
344 | Recv uint64
345 | Drop uint64
346 | Capt uint64
347 | Padding [13]uint64
348 | }
349 |
350 | type BpfProgram struct {
351 | Len uint32
352 | Insns *BpfInsn
353 | }
354 |
355 | type BpfInsn struct {
356 | Code uint16
357 | Jt uint8
358 | Jf uint8
359 | K uint32
360 | }
361 |
362 | type BpfHdr struct {
363 | Tstamp BpfTimeval
364 | Caplen uint32
365 | Datalen uint32
366 | Hdrlen uint16
367 | Pad_cgo_0 [2]byte
368 | }
369 |
370 | type BpfTimeval struct {
371 | Sec int32
372 | Usec int32
373 | }
374 |
375 | type Termios struct {
376 | Iflag uint32
377 | Oflag uint32
378 | Cflag uint32
379 | Lflag uint32
380 | Cc [20]uint8
381 | Ispeed int32
382 | Ospeed int32
383 | }
384 |
385 | type Sysctlnode struct {
386 | Flags uint32
387 | Num int32
388 | Name [32]int8
389 | Ver uint32
390 | X__rsvd uint32
391 | Un [16]byte
392 | X_sysctl_size [8]byte
393 | X_sysctl_func [8]byte
394 | X_sysctl_parent [8]byte
395 | X_sysctl_desc [8]byte
396 | }
397 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_unix.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris
6 |
7 | package unix
8 |
9 | import (
10 | "runtime"
11 | "sync"
12 | "syscall"
13 | "unsafe"
14 | )
15 |
16 | var (
17 | Stdin = 0
18 | Stdout = 1
19 | Stderr = 2
20 | )
21 |
22 | const (
23 | darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8
24 | dragonfly64Bit = runtime.GOOS == "dragonfly" && sizeofPtr == 8
25 | netbsd32Bit = runtime.GOOS == "netbsd" && sizeofPtr == 4
26 | )
27 |
28 | // Do the interface allocations only once for common
29 | // Errno values.
30 | var (
31 | errEAGAIN error = syscall.EAGAIN
32 | errEINVAL error = syscall.EINVAL
33 | errENOENT error = syscall.ENOENT
34 | )
35 |
36 | // errnoErr returns common boxed Errno values, to prevent
37 | // allocations at runtime.
38 | func errnoErr(e syscall.Errno) error {
39 | switch e {
40 | case 0:
41 | return nil
42 | case EAGAIN:
43 | return errEAGAIN
44 | case EINVAL:
45 | return errEINVAL
46 | case ENOENT:
47 | return errENOENT
48 | }
49 | return e
50 | }
51 |
52 | // Mmap manager, for use by operating system-specific implementations.
53 |
54 | type mmapper struct {
55 | sync.Mutex
56 | active map[*byte][]byte // active mappings; key is last byte in mapping
57 | mmap func(addr, length uintptr, prot, flags, fd int, offset int64) (uintptr, error)
58 | munmap func(addr uintptr, length uintptr) error
59 | }
60 |
61 | func (m *mmapper) Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
62 | if length <= 0 {
63 | return nil, EINVAL
64 | }
65 |
66 | // Map the requested memory.
67 | addr, errno := m.mmap(0, uintptr(length), prot, flags, fd, offset)
68 | if errno != nil {
69 | return nil, errno
70 | }
71 |
72 | // Slice memory layout
73 | var sl = struct {
74 | addr uintptr
75 | len int
76 | cap int
77 | }{addr, length, length}
78 |
79 | // Use unsafe to turn sl into a []byte.
80 | b := *(*[]byte)(unsafe.Pointer(&sl))
81 |
82 | // Register mapping in m and return it.
83 | p := &b[cap(b)-1]
84 | m.Lock()
85 | defer m.Unlock()
86 | m.active[p] = b
87 | return b, nil
88 | }
89 |
90 | func (m *mmapper) Munmap(data []byte) (err error) {
91 | if len(data) == 0 || len(data) != cap(data) {
92 | return EINVAL
93 | }
94 |
95 | // Find the base of the mapping.
96 | p := &data[cap(data)-1]
97 | m.Lock()
98 | defer m.Unlock()
99 | b := m.active[p]
100 | if b == nil || &b[0] != &data[0] {
101 | return EINVAL
102 | }
103 |
104 | // Unmap the memory and update m.
105 | if errno := m.munmap(uintptr(unsafe.Pointer(&b[0])), uintptr(len(b))); errno != nil {
106 | return errno
107 | }
108 | delete(m.active, p)
109 | return nil
110 | }
111 |
112 | func Read(fd int, p []byte) (n int, err error) {
113 | n, err = read(fd, p)
114 | if raceenabled {
115 | if n > 0 {
116 | raceWriteRange(unsafe.Pointer(&p[0]), n)
117 | }
118 | if err == nil {
119 | raceAcquire(unsafe.Pointer(&ioSync))
120 | }
121 | }
122 | return
123 | }
124 |
125 | func Write(fd int, p []byte) (n int, err error) {
126 | if raceenabled {
127 | raceReleaseMerge(unsafe.Pointer(&ioSync))
128 | }
129 | n, err = write(fd, p)
130 | if raceenabled && n > 0 {
131 | raceReadRange(unsafe.Pointer(&p[0]), n)
132 | }
133 | return
134 | }
135 |
136 | // For testing: clients can set this flag to force
137 | // creation of IPv6 sockets to return EAFNOSUPPORT.
138 | var SocketDisableIPv6 bool
139 |
140 | type Sockaddr interface {
141 | sockaddr() (ptr unsafe.Pointer, len _Socklen, err error) // lowercase; only we can define Sockaddrs
142 | }
143 |
144 | type SockaddrInet4 struct {
145 | Port int
146 | Addr [4]byte
147 | raw RawSockaddrInet4
148 | }
149 |
150 | type SockaddrInet6 struct {
151 | Port int
152 | ZoneId uint32
153 | Addr [16]byte
154 | raw RawSockaddrInet6
155 | }
156 |
157 | type SockaddrUnix struct {
158 | Name string
159 | raw RawSockaddrUnix
160 | }
161 |
162 | func Bind(fd int, sa Sockaddr) (err error) {
163 | ptr, n, err := sa.sockaddr()
164 | if err != nil {
165 | return err
166 | }
167 | return bind(fd, ptr, n)
168 | }
169 |
170 | func Connect(fd int, sa Sockaddr) (err error) {
171 | ptr, n, err := sa.sockaddr()
172 | if err != nil {
173 | return err
174 | }
175 | return connect(fd, ptr, n)
176 | }
177 |
178 | func Getpeername(fd int) (sa Sockaddr, err error) {
179 | var rsa RawSockaddrAny
180 | var len _Socklen = SizeofSockaddrAny
181 | if err = getpeername(fd, &rsa, &len); err != nil {
182 | return
183 | }
184 | return anyToSockaddr(&rsa)
185 | }
186 |
187 | func GetsockoptInt(fd, level, opt int) (value int, err error) {
188 | var n int32
189 | vallen := _Socklen(4)
190 | err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen)
191 | return int(n), err
192 | }
193 |
194 | func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) {
195 | var rsa RawSockaddrAny
196 | var len _Socklen = SizeofSockaddrAny
197 | if n, err = recvfrom(fd, p, flags, &rsa, &len); err != nil {
198 | return
199 | }
200 | if rsa.Addr.Family != AF_UNSPEC {
201 | from, err = anyToSockaddr(&rsa)
202 | }
203 | return
204 | }
205 |
206 | func Sendto(fd int, p []byte, flags int, to Sockaddr) (err error) {
207 | ptr, n, err := to.sockaddr()
208 | if err != nil {
209 | return err
210 | }
211 | return sendto(fd, p, flags, ptr, n)
212 | }
213 |
214 | func SetsockoptByte(fd, level, opt int, value byte) (err error) {
215 | return setsockopt(fd, level, opt, unsafe.Pointer(&value), 1)
216 | }
217 |
218 | func SetsockoptInt(fd, level, opt int, value int) (err error) {
219 | var n = int32(value)
220 | return setsockopt(fd, level, opt, unsafe.Pointer(&n), 4)
221 | }
222 |
223 | func SetsockoptInet4Addr(fd, level, opt int, value [4]byte) (err error) {
224 | return setsockopt(fd, level, opt, unsafe.Pointer(&value[0]), 4)
225 | }
226 |
227 | func SetsockoptIPMreq(fd, level, opt int, mreq *IPMreq) (err error) {
228 | return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPMreq)
229 | }
230 |
231 | func SetsockoptIPv6Mreq(fd, level, opt int, mreq *IPv6Mreq) (err error) {
232 | return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPv6Mreq)
233 | }
234 |
235 | func SetsockoptICMPv6Filter(fd, level, opt int, filter *ICMPv6Filter) error {
236 | return setsockopt(fd, level, opt, unsafe.Pointer(filter), SizeofICMPv6Filter)
237 | }
238 |
239 | func SetsockoptLinger(fd, level, opt int, l *Linger) (err error) {
240 | return setsockopt(fd, level, opt, unsafe.Pointer(l), SizeofLinger)
241 | }
242 |
243 | func SetsockoptString(fd, level, opt int, s string) (err error) {
244 | return setsockopt(fd, level, opt, unsafe.Pointer(&[]byte(s)[0]), uintptr(len(s)))
245 | }
246 |
247 | func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (err error) {
248 | return setsockopt(fd, level, opt, unsafe.Pointer(tv), unsafe.Sizeof(*tv))
249 | }
250 |
251 | func Socket(domain, typ, proto int) (fd int, err error) {
252 | if domain == AF_INET6 && SocketDisableIPv6 {
253 | return -1, EAFNOSUPPORT
254 | }
255 | fd, err = socket(domain, typ, proto)
256 | return
257 | }
258 |
259 | func Socketpair(domain, typ, proto int) (fd [2]int, err error) {
260 | var fdx [2]int32
261 | err = socketpair(domain, typ, proto, &fdx)
262 | if err == nil {
263 | fd[0] = int(fdx[0])
264 | fd[1] = int(fdx[1])
265 | }
266 | return
267 | }
268 |
269 | func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
270 | if raceenabled {
271 | raceReleaseMerge(unsafe.Pointer(&ioSync))
272 | }
273 | return sendfile(outfd, infd, offset, count)
274 | }
275 |
276 | var ioSync int64
277 |
278 | func CloseOnExec(fd int) { fcntl(fd, F_SETFD, FD_CLOEXEC) }
279 |
280 | func SetNonblock(fd int, nonblocking bool) (err error) {
281 | flag, err := fcntl(fd, F_GETFL, 0)
282 | if err != nil {
283 | return err
284 | }
285 | if nonblocking {
286 | flag |= O_NONBLOCK
287 | } else {
288 | flag &= ^O_NONBLOCK
289 | }
290 | _, err = fcntl(fd, F_SETFL, flag)
291 | return err
292 | }
293 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go:
--------------------------------------------------------------------------------
1 | // Created by cgo -godefs - DO NOT EDIT
2 | // cgo -godefs types_netbsd.go
3 |
4 | // +build arm,netbsd
5 |
6 | package unix
7 |
8 | const (
9 | sizeofPtr = 0x4
10 | sizeofShort = 0x2
11 | sizeofInt = 0x4
12 | sizeofLong = 0x4
13 | sizeofLongLong = 0x8
14 | )
15 |
16 | type (
17 | _C_short int16
18 | _C_int int32
19 | _C_long int32
20 | _C_long_long int64
21 | )
22 |
23 | type Timespec struct {
24 | Sec int64
25 | Nsec int32
26 | Pad_cgo_0 [4]byte
27 | }
28 |
29 | type Timeval struct {
30 | Sec int64
31 | Usec int32
32 | Pad_cgo_0 [4]byte
33 | }
34 |
35 | type Rusage struct {
36 | Utime Timeval
37 | Stime Timeval
38 | Maxrss int32
39 | Ixrss int32
40 | Idrss int32
41 | Isrss int32
42 | Minflt int32
43 | Majflt int32
44 | Nswap int32
45 | Inblock int32
46 | Oublock int32
47 | Msgsnd int32
48 | Msgrcv int32
49 | Nsignals int32
50 | Nvcsw int32
51 | Nivcsw int32
52 | }
53 |
54 | type Rlimit struct {
55 | Cur uint64
56 | Max uint64
57 | }
58 |
59 | type _Gid_t uint32
60 |
61 | type Stat_t struct {
62 | Dev uint64
63 | Mode uint32
64 | Pad_cgo_0 [4]byte
65 | Ino uint64
66 | Nlink uint32
67 | Uid uint32
68 | Gid uint32
69 | Pad_cgo_1 [4]byte
70 | Rdev uint64
71 | Atimespec Timespec
72 | Mtimespec Timespec
73 | Ctimespec Timespec
74 | Birthtimespec Timespec
75 | Size int64
76 | Blocks int64
77 | Blksize uint32
78 | Flags uint32
79 | Gen uint32
80 | Spare [2]uint32
81 | Pad_cgo_2 [4]byte
82 | }
83 |
84 | type Statfs_t [0]byte
85 |
86 | type Flock_t struct {
87 | Start int64
88 | Len int64
89 | Pid int32
90 | Type int16
91 | Whence int16
92 | }
93 |
94 | type Dirent struct {
95 | Fileno uint64
96 | Reclen uint16
97 | Namlen uint16
98 | Type uint8
99 | Name [512]int8
100 | Pad_cgo_0 [3]byte
101 | }
102 |
103 | type Fsid struct {
104 | X__fsid_val [2]int32
105 | }
106 |
107 | type RawSockaddrInet4 struct {
108 | Len uint8
109 | Family uint8
110 | Port uint16
111 | Addr [4]byte /* in_addr */
112 | Zero [8]int8
113 | }
114 |
115 | type RawSockaddrInet6 struct {
116 | Len uint8
117 | Family uint8
118 | Port uint16
119 | Flowinfo uint32
120 | Addr [16]byte /* in6_addr */
121 | Scope_id uint32
122 | }
123 |
124 | type RawSockaddrUnix struct {
125 | Len uint8
126 | Family uint8
127 | Path [104]int8
128 | }
129 |
130 | type RawSockaddrDatalink struct {
131 | Len uint8
132 | Family uint8
133 | Index uint16
134 | Type uint8
135 | Nlen uint8
136 | Alen uint8
137 | Slen uint8
138 | Data [12]int8
139 | }
140 |
141 | type RawSockaddr struct {
142 | Len uint8
143 | Family uint8
144 | Data [14]int8
145 | }
146 |
147 | type RawSockaddrAny struct {
148 | Addr RawSockaddr
149 | Pad [92]int8
150 | }
151 |
152 | type _Socklen uint32
153 |
154 | type Linger struct {
155 | Onoff int32
156 | Linger int32
157 | }
158 |
159 | type Iovec struct {
160 | Base *byte
161 | Len uint32
162 | }
163 |
164 | type IPMreq struct {
165 | Multiaddr [4]byte /* in_addr */
166 | Interface [4]byte /* in_addr */
167 | }
168 |
169 | type IPv6Mreq struct {
170 | Multiaddr [16]byte /* in6_addr */
171 | Interface uint32
172 | }
173 |
174 | type Msghdr struct {
175 | Name *byte
176 | Namelen uint32
177 | Iov *Iovec
178 | Iovlen int32
179 | Control *byte
180 | Controllen uint32
181 | Flags int32
182 | }
183 |
184 | type Cmsghdr struct {
185 | Len uint32
186 | Level int32
187 | Type int32
188 | }
189 |
190 | type Inet6Pktinfo struct {
191 | Addr [16]byte /* in6_addr */
192 | Ifindex uint32
193 | }
194 |
195 | type IPv6MTUInfo struct {
196 | Addr RawSockaddrInet6
197 | Mtu uint32
198 | }
199 |
200 | type ICMPv6Filter struct {
201 | Filt [8]uint32
202 | }
203 |
204 | const (
205 | SizeofSockaddrInet4 = 0x10
206 | SizeofSockaddrInet6 = 0x1c
207 | SizeofSockaddrAny = 0x6c
208 | SizeofSockaddrUnix = 0x6a
209 | SizeofSockaddrDatalink = 0x14
210 | SizeofLinger = 0x8
211 | SizeofIPMreq = 0x8
212 | SizeofIPv6Mreq = 0x14
213 | SizeofMsghdr = 0x1c
214 | SizeofCmsghdr = 0xc
215 | SizeofInet6Pktinfo = 0x14
216 | SizeofIPv6MTUInfo = 0x20
217 | SizeofICMPv6Filter = 0x20
218 | )
219 |
220 | const (
221 | PTRACE_TRACEME = 0x0
222 | PTRACE_CONT = 0x7
223 | PTRACE_KILL = 0x8
224 | )
225 |
226 | type Kevent_t struct {
227 | Ident uint32
228 | Filter uint32
229 | Flags uint32
230 | Fflags uint32
231 | Data int64
232 | Udata int32
233 | Pad_cgo_0 [4]byte
234 | }
235 |
236 | type FdSet struct {
237 | Bits [8]uint32
238 | }
239 |
240 | const (
241 | SizeofIfMsghdr = 0x98
242 | SizeofIfData = 0x88
243 | SizeofIfaMsghdr = 0x18
244 | SizeofIfAnnounceMsghdr = 0x18
245 | SizeofRtMsghdr = 0x78
246 | SizeofRtMetrics = 0x50
247 | )
248 |
249 | type IfMsghdr struct {
250 | Msglen uint16
251 | Version uint8
252 | Type uint8
253 | Addrs int32
254 | Flags int32
255 | Index uint16
256 | Pad_cgo_0 [2]byte
257 | Data IfData
258 | }
259 |
260 | type IfData struct {
261 | Type uint8
262 | Addrlen uint8
263 | Hdrlen uint8
264 | Pad_cgo_0 [1]byte
265 | Link_state int32
266 | Mtu uint64
267 | Metric uint64
268 | Baudrate uint64
269 | Ipackets uint64
270 | Ierrors uint64
271 | Opackets uint64
272 | Oerrors uint64
273 | Collisions uint64
274 | Ibytes uint64
275 | Obytes uint64
276 | Imcasts uint64
277 | Omcasts uint64
278 | Iqdrops uint64
279 | Noproto uint64
280 | Lastchange Timespec
281 | }
282 |
283 | type IfaMsghdr struct {
284 | Msglen uint16
285 | Version uint8
286 | Type uint8
287 | Addrs int32
288 | Flags int32
289 | Metric int32
290 | Index uint16
291 | Pad_cgo_0 [6]byte
292 | }
293 |
294 | type IfAnnounceMsghdr struct {
295 | Msglen uint16
296 | Version uint8
297 | Type uint8
298 | Index uint16
299 | Name [16]int8
300 | What uint16
301 | }
302 |
303 | type RtMsghdr struct {
304 | Msglen uint16
305 | Version uint8
306 | Type uint8
307 | Index uint16
308 | Pad_cgo_0 [2]byte
309 | Flags int32
310 | Addrs int32
311 | Pid int32
312 | Seq int32
313 | Errno int32
314 | Use int32
315 | Inits int32
316 | Pad_cgo_1 [4]byte
317 | Rmx RtMetrics
318 | }
319 |
320 | type RtMetrics struct {
321 | Locks uint64
322 | Mtu uint64
323 | Hopcount uint64
324 | Recvpipe uint64
325 | Sendpipe uint64
326 | Ssthresh uint64
327 | Rtt uint64
328 | Rttvar uint64
329 | Expire int64
330 | Pksent int64
331 | }
332 |
333 | type Mclpool [0]byte
334 |
335 | const (
336 | SizeofBpfVersion = 0x4
337 | SizeofBpfStat = 0x80
338 | SizeofBpfProgram = 0x8
339 | SizeofBpfInsn = 0x8
340 | SizeofBpfHdr = 0x14
341 | )
342 |
343 | type BpfVersion struct {
344 | Major uint16
345 | Minor uint16
346 | }
347 |
348 | type BpfStat struct {
349 | Recv uint64
350 | Drop uint64
351 | Capt uint64
352 | Padding [13]uint64
353 | }
354 |
355 | type BpfProgram struct {
356 | Len uint32
357 | Insns *BpfInsn
358 | }
359 |
360 | type BpfInsn struct {
361 | Code uint16
362 | Jt uint8
363 | Jf uint8
364 | K uint32
365 | }
366 |
367 | type BpfHdr struct {
368 | Tstamp BpfTimeval
369 | Caplen uint32
370 | Datalen uint32
371 | Hdrlen uint16
372 | Pad_cgo_0 [2]byte
373 | }
374 |
375 | type BpfTimeval struct {
376 | Sec int32
377 | Usec int32
378 | }
379 |
380 | type Termios struct {
381 | Iflag uint32
382 | Oflag uint32
383 | Cflag uint32
384 | Lflag uint32
385 | Cc [20]uint8
386 | Ispeed int32
387 | Ospeed int32
388 | }
389 |
390 | type Sysctlnode struct {
391 | Flags uint32
392 | Num int32
393 | Name [32]int8
394 | Ver uint32
395 | X__rsvd uint32
396 | Un [16]byte
397 | X_sysctl_size [8]byte
398 | X_sysctl_func [8]byte
399 | X_sysctl_parent [8]byte
400 | X_sysctl_desc [8]byte
401 | }
402 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 | // +build mips mipsle
7 |
8 | package unix
9 |
10 | import (
11 | "syscall"
12 | "unsafe"
13 | )
14 |
15 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
16 |
17 | //sys Dup2(oldfd int, newfd int) (err error)
18 | //sys Fchown(fd int, uid int, gid int) (err error)
19 | //sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64
20 | //sysnb Getegid() (egid int)
21 | //sysnb Geteuid() (euid int)
22 | //sysnb Getgid() (gid int)
23 | //sysnb Getuid() (uid int)
24 | //sys Lchown(path string, uid int, gid int) (err error)
25 | //sys Listen(s int, n int) (err error)
26 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
27 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
28 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT
29 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64
30 | //sys Setfsgid(gid int) (err error)
31 | //sys Setfsuid(uid int) (err error)
32 | //sysnb Setregid(rgid int, egid int) (err error)
33 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
34 | //sysnb Setresuid(ruid int, euid int, suid int) (err error)
35 |
36 | //sysnb Setreuid(ruid int, euid int) (err error)
37 | //sys Shutdown(fd int, how int) (err error)
38 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
39 |
40 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
41 | //sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64
42 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
43 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
44 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
45 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
46 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
47 | //sysnb setgroups(n int, list *_Gid_t) (err error)
48 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
49 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
50 | //sysnb socket(domain int, typ int, proto int) (fd int, err error)
51 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
52 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
53 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
54 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
55 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
56 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
57 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
58 |
59 | //sysnb InotifyInit() (fd int, err error)
60 | //sys Ioperm(from int, num int, on int) (err error)
61 | //sys Iopl(level int) (err error)
62 |
63 | //sysnb Gettimeofday(tv *Timeval) (err error)
64 | //sysnb Time(t *Time_t) (tt Time_t, err error)
65 |
66 | //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
67 | //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
68 | //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
69 |
70 | //sys Utime(path string, buf *Utimbuf) (err error)
71 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
72 | //sys Pause() (err error)
73 |
74 | func Fstatfs(fd int, buf *Statfs_t) (err error) {
75 | _, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
76 | use(unsafe.Pointer(buf))
77 | if e != 0 {
78 | err = errnoErr(e)
79 | }
80 | return
81 | }
82 |
83 | func Statfs(path string, buf *Statfs_t) (err error) {
84 | p, err := BytePtrFromString(path)
85 | if err != nil {
86 | return err
87 | }
88 | _, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(p)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
89 | use(unsafe.Pointer(p))
90 | if e != 0 {
91 | err = errnoErr(e)
92 | }
93 | return
94 | }
95 |
96 | func Seek(fd int, offset int64, whence int) (off int64, err error) {
97 | _, _, e := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offset>>32), uintptr(offset), uintptr(unsafe.Pointer(&off)), uintptr(whence), 0)
98 | if e != 0 {
99 | err = errnoErr(e)
100 | }
101 | return
102 | }
103 |
104 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
105 |
106 | func NsecToTimespec(nsec int64) (ts Timespec) {
107 | ts.Sec = int32(nsec / 1e9)
108 | ts.Nsec = int32(nsec % 1e9)
109 | return
110 | }
111 |
112 | func NsecToTimeval(nsec int64) (tv Timeval) {
113 | nsec += 999 // round up to microsecond
114 | tv.Sec = int32(nsec / 1e9)
115 | tv.Usec = int32(nsec % 1e9 / 1e3)
116 | return
117 | }
118 |
119 | //sysnb pipe2(p *[2]_C_int, flags int) (err error)
120 |
121 | func Pipe2(p []int, flags int) (err error) {
122 | if len(p) != 2 {
123 | return EINVAL
124 | }
125 | var pp [2]_C_int
126 | err = pipe2(&pp, flags)
127 | p[0] = int(pp[0])
128 | p[1] = int(pp[1])
129 | return
130 | }
131 |
132 | func Pipe(p []int) (err error) {
133 | if len(p) != 2 {
134 | return EINVAL
135 | }
136 | var pp [2]_C_int
137 | err = pipe2(&pp, 0)
138 | p[0] = int(pp[0])
139 | p[1] = int(pp[1])
140 | return
141 | }
142 |
143 | //sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error)
144 |
145 | func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
146 | page := uintptr(offset / 4096)
147 | if offset != int64(page)*4096 {
148 | return 0, EINVAL
149 | }
150 | return mmap2(addr, length, prot, flags, fd, page)
151 | }
152 |
153 | const rlimInf32 = ^uint32(0)
154 | const rlimInf64 = ^uint64(0)
155 |
156 | type rlimit32 struct {
157 | Cur uint32
158 | Max uint32
159 | }
160 |
161 | //sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_GETRLIMIT
162 |
163 | func Getrlimit(resource int, rlim *Rlimit) (err error) {
164 | err = prlimit(0, resource, nil, rlim)
165 | if err != ENOSYS {
166 | return err
167 | }
168 |
169 | rl := rlimit32{}
170 | err = getrlimit(resource, &rl)
171 | if err != nil {
172 | return
173 | }
174 |
175 | if rl.Cur == rlimInf32 {
176 | rlim.Cur = rlimInf64
177 | } else {
178 | rlim.Cur = uint64(rl.Cur)
179 | }
180 |
181 | if rl.Max == rlimInf32 {
182 | rlim.Max = rlimInf64
183 | } else {
184 | rlim.Max = uint64(rl.Max)
185 | }
186 | return
187 | }
188 |
189 | //sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT
190 |
191 | func Setrlimit(resource int, rlim *Rlimit) (err error) {
192 | err = prlimit(0, resource, rlim, nil)
193 | if err != ENOSYS {
194 | return err
195 | }
196 |
197 | rl := rlimit32{}
198 | if rlim.Cur == rlimInf64 {
199 | rl.Cur = rlimInf32
200 | } else if rlim.Cur < uint64(rlimInf32) {
201 | rl.Cur = uint32(rlim.Cur)
202 | } else {
203 | return EINVAL
204 | }
205 | if rlim.Max == rlimInf64 {
206 | rl.Max = rlimInf32
207 | } else if rlim.Max < uint64(rlimInf32) {
208 | rl.Max = uint32(rlim.Max)
209 | } else {
210 | return EINVAL
211 | }
212 |
213 | return setrlimit(resource, &rl)
214 | }
215 |
216 | func (r *PtraceRegs) PC() uint64 { return uint64(r.Regs[64]) }
217 |
218 | func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = uint32(pc) }
219 |
220 | func (iov *Iovec) SetLen(length int) {
221 | iov.Len = uint32(length)
222 | }
223 |
224 | func (msghdr *Msghdr) SetControllen(length int) {
225 | msghdr.Controllen = uint32(length)
226 | }
227 |
228 | func (cmsg *Cmsghdr) SetLen(length int) {
229 | cmsg.Len = uint32(length)
230 | }
231 |
232 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
233 |
234 | func Poll(fds []PollFd, timeout int) (n int, err error) {
235 | if len(fds) == 0 {
236 | return poll(nil, 0, timeout)
237 | }
238 | return poll(&fds[0], len(fds), timeout)
239 | }
240 |
241 | func Getpagesize() int { return 4096 }
242 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go:
--------------------------------------------------------------------------------
1 | // Created by cgo -godefs - DO NOT EDIT
2 | // cgo -godefs types_netbsd.go
3 |
4 | // +build amd64,netbsd
5 |
6 | package unix
7 |
8 | const (
9 | sizeofPtr = 0x8
10 | sizeofShort = 0x2
11 | sizeofInt = 0x4
12 | sizeofLong = 0x8
13 | sizeofLongLong = 0x8
14 | )
15 |
16 | type (
17 | _C_short int16
18 | _C_int int32
19 | _C_long int64
20 | _C_long_long int64
21 | )
22 |
23 | type Timespec struct {
24 | Sec int64
25 | Nsec int64
26 | }
27 |
28 | type Timeval struct {
29 | Sec int64
30 | Usec int32
31 | Pad_cgo_0 [4]byte
32 | }
33 |
34 | type Rusage struct {
35 | Utime Timeval
36 | Stime Timeval
37 | Maxrss int64
38 | Ixrss int64
39 | Idrss int64
40 | Isrss int64
41 | Minflt int64
42 | Majflt int64
43 | Nswap int64
44 | Inblock int64
45 | Oublock int64
46 | Msgsnd int64
47 | Msgrcv int64
48 | Nsignals int64
49 | Nvcsw int64
50 | Nivcsw int64
51 | }
52 |
53 | type Rlimit struct {
54 | Cur uint64
55 | Max uint64
56 | }
57 |
58 | type _Gid_t uint32
59 |
60 | type Stat_t struct {
61 | Dev uint64
62 | Mode uint32
63 | Pad_cgo_0 [4]byte
64 | Ino uint64
65 | Nlink uint32
66 | Uid uint32
67 | Gid uint32
68 | Pad_cgo_1 [4]byte
69 | Rdev uint64
70 | Atimespec Timespec
71 | Mtimespec Timespec
72 | Ctimespec Timespec
73 | Birthtimespec Timespec
74 | Size int64
75 | Blocks int64
76 | Blksize uint32
77 | Flags uint32
78 | Gen uint32
79 | Spare [2]uint32
80 | Pad_cgo_2 [4]byte
81 | }
82 |
83 | type Statfs_t [0]byte
84 |
85 | type Flock_t struct {
86 | Start int64
87 | Len int64
88 | Pid int32
89 | Type int16
90 | Whence int16
91 | }
92 |
93 | type Dirent struct {
94 | Fileno uint64
95 | Reclen uint16
96 | Namlen uint16
97 | Type uint8
98 | Name [512]int8
99 | Pad_cgo_0 [3]byte
100 | }
101 |
102 | type Fsid struct {
103 | X__fsid_val [2]int32
104 | }
105 |
106 | type RawSockaddrInet4 struct {
107 | Len uint8
108 | Family uint8
109 | Port uint16
110 | Addr [4]byte /* in_addr */
111 | Zero [8]int8
112 | }
113 |
114 | type RawSockaddrInet6 struct {
115 | Len uint8
116 | Family uint8
117 | Port uint16
118 | Flowinfo uint32
119 | Addr [16]byte /* in6_addr */
120 | Scope_id uint32
121 | }
122 |
123 | type RawSockaddrUnix struct {
124 | Len uint8
125 | Family uint8
126 | Path [104]int8
127 | }
128 |
129 | type RawSockaddrDatalink struct {
130 | Len uint8
131 | Family uint8
132 | Index uint16
133 | Type uint8
134 | Nlen uint8
135 | Alen uint8
136 | Slen uint8
137 | Data [12]int8
138 | }
139 |
140 | type RawSockaddr struct {
141 | Len uint8
142 | Family uint8
143 | Data [14]int8
144 | }
145 |
146 | type RawSockaddrAny struct {
147 | Addr RawSockaddr
148 | Pad [92]int8
149 | }
150 |
151 | type _Socklen uint32
152 |
153 | type Linger struct {
154 | Onoff int32
155 | Linger int32
156 | }
157 |
158 | type Iovec struct {
159 | Base *byte
160 | Len uint64
161 | }
162 |
163 | type IPMreq struct {
164 | Multiaddr [4]byte /* in_addr */
165 | Interface [4]byte /* in_addr */
166 | }
167 |
168 | type IPv6Mreq struct {
169 | Multiaddr [16]byte /* in6_addr */
170 | Interface uint32
171 | }
172 |
173 | type Msghdr struct {
174 | Name *byte
175 | Namelen uint32
176 | Pad_cgo_0 [4]byte
177 | Iov *Iovec
178 | Iovlen int32
179 | Pad_cgo_1 [4]byte
180 | Control *byte
181 | Controllen uint32
182 | Flags int32
183 | }
184 |
185 | type Cmsghdr struct {
186 | Len uint32
187 | Level int32
188 | Type int32
189 | }
190 |
191 | type Inet6Pktinfo struct {
192 | Addr [16]byte /* in6_addr */
193 | Ifindex uint32
194 | }
195 |
196 | type IPv6MTUInfo struct {
197 | Addr RawSockaddrInet6
198 | Mtu uint32
199 | }
200 |
201 | type ICMPv6Filter struct {
202 | Filt [8]uint32
203 | }
204 |
205 | const (
206 | SizeofSockaddrInet4 = 0x10
207 | SizeofSockaddrInet6 = 0x1c
208 | SizeofSockaddrAny = 0x6c
209 | SizeofSockaddrUnix = 0x6a
210 | SizeofSockaddrDatalink = 0x14
211 | SizeofLinger = 0x8
212 | SizeofIPMreq = 0x8
213 | SizeofIPv6Mreq = 0x14
214 | SizeofMsghdr = 0x30
215 | SizeofCmsghdr = 0xc
216 | SizeofInet6Pktinfo = 0x14
217 | SizeofIPv6MTUInfo = 0x20
218 | SizeofICMPv6Filter = 0x20
219 | )
220 |
221 | const (
222 | PTRACE_TRACEME = 0x0
223 | PTRACE_CONT = 0x7
224 | PTRACE_KILL = 0x8
225 | )
226 |
227 | type Kevent_t struct {
228 | Ident uint64
229 | Filter uint32
230 | Flags uint32
231 | Fflags uint32
232 | Pad_cgo_0 [4]byte
233 | Data int64
234 | Udata int64
235 | }
236 |
237 | type FdSet struct {
238 | Bits [8]uint32
239 | }
240 |
241 | const (
242 | SizeofIfMsghdr = 0x98
243 | SizeofIfData = 0x88
244 | SizeofIfaMsghdr = 0x18
245 | SizeofIfAnnounceMsghdr = 0x18
246 | SizeofRtMsghdr = 0x78
247 | SizeofRtMetrics = 0x50
248 | )
249 |
250 | type IfMsghdr struct {
251 | Msglen uint16
252 | Version uint8
253 | Type uint8
254 | Addrs int32
255 | Flags int32
256 | Index uint16
257 | Pad_cgo_0 [2]byte
258 | Data IfData
259 | }
260 |
261 | type IfData struct {
262 | Type uint8
263 | Addrlen uint8
264 | Hdrlen uint8
265 | Pad_cgo_0 [1]byte
266 | Link_state int32
267 | Mtu uint64
268 | Metric uint64
269 | Baudrate uint64
270 | Ipackets uint64
271 | Ierrors uint64
272 | Opackets uint64
273 | Oerrors uint64
274 | Collisions uint64
275 | Ibytes uint64
276 | Obytes uint64
277 | Imcasts uint64
278 | Omcasts uint64
279 | Iqdrops uint64
280 | Noproto uint64
281 | Lastchange Timespec
282 | }
283 |
284 | type IfaMsghdr struct {
285 | Msglen uint16
286 | Version uint8
287 | Type uint8
288 | Addrs int32
289 | Flags int32
290 | Metric int32
291 | Index uint16
292 | Pad_cgo_0 [6]byte
293 | }
294 |
295 | type IfAnnounceMsghdr struct {
296 | Msglen uint16
297 | Version uint8
298 | Type uint8
299 | Index uint16
300 | Name [16]int8
301 | What uint16
302 | }
303 |
304 | type RtMsghdr struct {
305 | Msglen uint16
306 | Version uint8
307 | Type uint8
308 | Index uint16
309 | Pad_cgo_0 [2]byte
310 | Flags int32
311 | Addrs int32
312 | Pid int32
313 | Seq int32
314 | Errno int32
315 | Use int32
316 | Inits int32
317 | Pad_cgo_1 [4]byte
318 | Rmx RtMetrics
319 | }
320 |
321 | type RtMetrics struct {
322 | Locks uint64
323 | Mtu uint64
324 | Hopcount uint64
325 | Recvpipe uint64
326 | Sendpipe uint64
327 | Ssthresh uint64
328 | Rtt uint64
329 | Rttvar uint64
330 | Expire int64
331 | Pksent int64
332 | }
333 |
334 | type Mclpool [0]byte
335 |
336 | const (
337 | SizeofBpfVersion = 0x4
338 | SizeofBpfStat = 0x80
339 | SizeofBpfProgram = 0x10
340 | SizeofBpfInsn = 0x8
341 | SizeofBpfHdr = 0x20
342 | )
343 |
344 | type BpfVersion struct {
345 | Major uint16
346 | Minor uint16
347 | }
348 |
349 | type BpfStat struct {
350 | Recv uint64
351 | Drop uint64
352 | Capt uint64
353 | Padding [13]uint64
354 | }
355 |
356 | type BpfProgram struct {
357 | Len uint32
358 | Pad_cgo_0 [4]byte
359 | Insns *BpfInsn
360 | }
361 |
362 | type BpfInsn struct {
363 | Code uint16
364 | Jt uint8
365 | Jf uint8
366 | K uint32
367 | }
368 |
369 | type BpfHdr struct {
370 | Tstamp BpfTimeval
371 | Caplen uint32
372 | Datalen uint32
373 | Hdrlen uint16
374 | Pad_cgo_0 [6]byte
375 | }
376 |
377 | type BpfTimeval struct {
378 | Sec int64
379 | Usec int64
380 | }
381 |
382 | type Termios struct {
383 | Iflag uint32
384 | Oflag uint32
385 | Cflag uint32
386 | Lflag uint32
387 | Cc [20]uint8
388 | Ispeed int32
389 | Ospeed int32
390 | }
391 |
392 | type Sysctlnode struct {
393 | Flags uint32
394 | Num int32
395 | Name [32]int8
396 | Ver uint32
397 | X__rsvd uint32
398 | Un [16]byte
399 | X_sysctl_size [8]byte
400 | X_sysctl_func [8]byte
401 | X_sysctl_parent [8]byte
402 | X_sysctl_desc [8]byte
403 | }
404 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go:
--------------------------------------------------------------------------------
1 | // +build amd64,solaris
2 | // Created by cgo -godefs - DO NOT EDIT
3 | // cgo -godefs types_solaris.go | go run mkpost.go
4 |
5 | package unix
6 |
7 | const (
8 | sizeofPtr = 0x8
9 | sizeofShort = 0x2
10 | sizeofInt = 0x4
11 | sizeofLong = 0x8
12 | sizeofLongLong = 0x8
13 | PathMax = 0x400
14 | MaxHostNameLen = 0x100
15 | )
16 |
17 | type (
18 | _C_short int16
19 | _C_int int32
20 | _C_long int64
21 | _C_long_long int64
22 | )
23 |
24 | type Timespec struct {
25 | Sec int64
26 | Nsec int64
27 | }
28 |
29 | type Timeval struct {
30 | Sec int64
31 | Usec int64
32 | }
33 |
34 | type Timeval32 struct {
35 | Sec int32
36 | Usec int32
37 | }
38 |
39 | type Tms struct {
40 | Utime int64
41 | Stime int64
42 | Cutime int64
43 | Cstime int64
44 | }
45 |
46 | type Utimbuf struct {
47 | Actime int64
48 | Modtime int64
49 | }
50 |
51 | type Rusage struct {
52 | Utime Timeval
53 | Stime Timeval
54 | Maxrss int64
55 | Ixrss int64
56 | Idrss int64
57 | Isrss int64
58 | Minflt int64
59 | Majflt int64
60 | Nswap int64
61 | Inblock int64
62 | Oublock int64
63 | Msgsnd int64
64 | Msgrcv int64
65 | Nsignals int64
66 | Nvcsw int64
67 | Nivcsw int64
68 | }
69 |
70 | type Rlimit struct {
71 | Cur uint64
72 | Max uint64
73 | }
74 |
75 | type _Gid_t uint32
76 |
77 | const (
78 | S_IFMT = 0xf000
79 | S_IFIFO = 0x1000
80 | S_IFCHR = 0x2000
81 | S_IFDIR = 0x4000
82 | S_IFBLK = 0x6000
83 | S_IFREG = 0x8000
84 | S_IFLNK = 0xa000
85 | S_IFSOCK = 0xc000
86 | S_ISUID = 0x800
87 | S_ISGID = 0x400
88 | S_ISVTX = 0x200
89 | S_IRUSR = 0x100
90 | S_IWUSR = 0x80
91 | S_IXUSR = 0x40
92 | )
93 |
94 | type Stat_t struct {
95 | Dev uint64
96 | Ino uint64
97 | Mode uint32
98 | Nlink uint32
99 | Uid uint32
100 | Gid uint32
101 | Rdev uint64
102 | Size int64
103 | Atim Timespec
104 | Mtim Timespec
105 | Ctim Timespec
106 | Blksize int32
107 | Pad_cgo_0 [4]byte
108 | Blocks int64
109 | Fstype [16]int8
110 | }
111 |
112 | type Flock_t struct {
113 | Type int16
114 | Whence int16
115 | Pad_cgo_0 [4]byte
116 | Start int64
117 | Len int64
118 | Sysid int32
119 | Pid int32
120 | Pad [4]int64
121 | }
122 |
123 | type Dirent struct {
124 | Ino uint64
125 | Off int64
126 | Reclen uint16
127 | Name [1]int8
128 | Pad_cgo_0 [5]byte
129 | }
130 |
131 | type RawSockaddrInet4 struct {
132 | Family uint16
133 | Port uint16
134 | Addr [4]byte /* in_addr */
135 | Zero [8]int8
136 | }
137 |
138 | type RawSockaddrInet6 struct {
139 | Family uint16
140 | Port uint16
141 | Flowinfo uint32
142 | Addr [16]byte /* in6_addr */
143 | Scope_id uint32
144 | X__sin6_src_id uint32
145 | }
146 |
147 | type RawSockaddrUnix struct {
148 | Family uint16
149 | Path [108]int8
150 | }
151 |
152 | type RawSockaddrDatalink struct {
153 | Family uint16
154 | Index uint16
155 | Type uint8
156 | Nlen uint8
157 | Alen uint8
158 | Slen uint8
159 | Data [244]int8
160 | }
161 |
162 | type RawSockaddr struct {
163 | Family uint16
164 | Data [14]int8
165 | }
166 |
167 | type RawSockaddrAny struct {
168 | Addr RawSockaddr
169 | Pad [236]int8
170 | }
171 |
172 | type _Socklen uint32
173 |
174 | type Linger struct {
175 | Onoff int32
176 | Linger int32
177 | }
178 |
179 | type Iovec struct {
180 | Base *int8
181 | Len uint64
182 | }
183 |
184 | type IPMreq struct {
185 | Multiaddr [4]byte /* in_addr */
186 | Interface [4]byte /* in_addr */
187 | }
188 |
189 | type IPv6Mreq struct {
190 | Multiaddr [16]byte /* in6_addr */
191 | Interface uint32
192 | }
193 |
194 | type Msghdr struct {
195 | Name *byte
196 | Namelen uint32
197 | Pad_cgo_0 [4]byte
198 | Iov *Iovec
199 | Iovlen int32
200 | Pad_cgo_1 [4]byte
201 | Accrights *int8
202 | Accrightslen int32
203 | Pad_cgo_2 [4]byte
204 | }
205 |
206 | type Cmsghdr struct {
207 | Len uint32
208 | Level int32
209 | Type int32
210 | }
211 |
212 | type Inet6Pktinfo struct {
213 | Addr [16]byte /* in6_addr */
214 | Ifindex uint32
215 | }
216 |
217 | type IPv6MTUInfo struct {
218 | Addr RawSockaddrInet6
219 | Mtu uint32
220 | }
221 |
222 | type ICMPv6Filter struct {
223 | X__icmp6_filt [8]uint32
224 | }
225 |
226 | const (
227 | SizeofSockaddrInet4 = 0x10
228 | SizeofSockaddrInet6 = 0x20
229 | SizeofSockaddrAny = 0xfc
230 | SizeofSockaddrUnix = 0x6e
231 | SizeofSockaddrDatalink = 0xfc
232 | SizeofLinger = 0x8
233 | SizeofIPMreq = 0x8
234 | SizeofIPv6Mreq = 0x14
235 | SizeofMsghdr = 0x30
236 | SizeofCmsghdr = 0xc
237 | SizeofInet6Pktinfo = 0x14
238 | SizeofIPv6MTUInfo = 0x24
239 | SizeofICMPv6Filter = 0x20
240 | )
241 |
242 | type FdSet struct {
243 | Bits [1024]int64
244 | }
245 |
246 | type Utsname struct {
247 | Sysname [257]int8
248 | Nodename [257]int8
249 | Release [257]int8
250 | Version [257]int8
251 | Machine [257]int8
252 | }
253 |
254 | type Ustat_t struct {
255 | Tfree int64
256 | Tinode uint64
257 | Fname [6]int8
258 | Fpack [6]int8
259 | Pad_cgo_0 [4]byte
260 | }
261 |
262 | const (
263 | AT_FDCWD = 0xffd19553
264 | AT_SYMLINK_NOFOLLOW = 0x1000
265 | AT_SYMLINK_FOLLOW = 0x2000
266 | AT_REMOVEDIR = 0x1
267 | AT_EACCESS = 0x4
268 | )
269 |
270 | const (
271 | SizeofIfMsghdr = 0x54
272 | SizeofIfData = 0x44
273 | SizeofIfaMsghdr = 0x14
274 | SizeofRtMsghdr = 0x4c
275 | SizeofRtMetrics = 0x28
276 | )
277 |
278 | type IfMsghdr struct {
279 | Msglen uint16
280 | Version uint8
281 | Type uint8
282 | Addrs int32
283 | Flags int32
284 | Index uint16
285 | Pad_cgo_0 [2]byte
286 | Data IfData
287 | }
288 |
289 | type IfData struct {
290 | Type uint8
291 | Addrlen uint8
292 | Hdrlen uint8
293 | Pad_cgo_0 [1]byte
294 | Mtu uint32
295 | Metric uint32
296 | Baudrate uint32
297 | Ipackets uint32
298 | Ierrors uint32
299 | Opackets uint32
300 | Oerrors uint32
301 | Collisions uint32
302 | Ibytes uint32
303 | Obytes uint32
304 | Imcasts uint32
305 | Omcasts uint32
306 | Iqdrops uint32
307 | Noproto uint32
308 | Lastchange Timeval32
309 | }
310 |
311 | type IfaMsghdr struct {
312 | Msglen uint16
313 | Version uint8
314 | Type uint8
315 | Addrs int32
316 | Flags int32
317 | Index uint16
318 | Pad_cgo_0 [2]byte
319 | Metric int32
320 | }
321 |
322 | type RtMsghdr struct {
323 | Msglen uint16
324 | Version uint8
325 | Type uint8
326 | Index uint16
327 | Pad_cgo_0 [2]byte
328 | Flags int32
329 | Addrs int32
330 | Pid int32
331 | Seq int32
332 | Errno int32
333 | Use int32
334 | Inits uint32
335 | Rmx RtMetrics
336 | }
337 |
338 | type RtMetrics struct {
339 | Locks uint32
340 | Mtu uint32
341 | Hopcount uint32
342 | Expire uint32
343 | Recvpipe uint32
344 | Sendpipe uint32
345 | Ssthresh uint32
346 | Rtt uint32
347 | Rttvar uint32
348 | Pksent uint32
349 | }
350 |
351 | const (
352 | SizeofBpfVersion = 0x4
353 | SizeofBpfStat = 0x80
354 | SizeofBpfProgram = 0x10
355 | SizeofBpfInsn = 0x8
356 | SizeofBpfHdr = 0x14
357 | )
358 |
359 | type BpfVersion struct {
360 | Major uint16
361 | Minor uint16
362 | }
363 |
364 | type BpfStat struct {
365 | Recv uint64
366 | Drop uint64
367 | Capt uint64
368 | Padding [13]uint64
369 | }
370 |
371 | type BpfProgram struct {
372 | Len uint32
373 | Pad_cgo_0 [4]byte
374 | Insns *BpfInsn
375 | }
376 |
377 | type BpfInsn struct {
378 | Code uint16
379 | Jt uint8
380 | Jf uint8
381 | K uint32
382 | }
383 |
384 | type BpfTimeval struct {
385 | Sec int32
386 | Usec int32
387 | }
388 |
389 | type BpfHdr struct {
390 | Tstamp BpfTimeval
391 | Caplen uint32
392 | Datalen uint32
393 | Hdrlen uint16
394 | Pad_cgo_0 [2]byte
395 | }
396 |
397 | const _SC_PAGESIZE = 0xb
398 |
399 | type Termios struct {
400 | Iflag uint32
401 | Oflag uint32
402 | Cflag uint32
403 | Lflag uint32
404 | Cc [19]uint8
405 | Pad_cgo_0 [1]byte
406 | }
407 |
408 | type Termio struct {
409 | Iflag uint16
410 | Oflag uint16
411 | Cflag uint16
412 | Lflag uint16
413 | Line int8
414 | Cc [8]uint8
415 | Pad_cgo_0 [1]byte
416 | }
417 |
418 | type Winsize struct {
419 | Row uint16
420 | Col uint16
421 | Xpixel uint16
422 | Ypixel uint16
423 | }
424 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/unix/mksyscall_solaris.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 | # Copyright 2009 The Go Authors. All rights reserved.
3 | # Use of this source code is governed by a BSD-style
4 | # license that can be found in the LICENSE file.
5 |
6 | # This program reads a file containing function prototypes
7 | # (like syscall_solaris.go) and generates system call bodies.
8 | # The prototypes are marked by lines beginning with "//sys"
9 | # and read like func declarations if //sys is replaced by func, but:
10 | # * The parameter lists must give a name for each argument.
11 | # This includes return parameters.
12 | # * The parameter lists must give a type for each argument:
13 | # the (x, y, z int) shorthand is not allowed.
14 | # * If the return parameter is an error number, it must be named err.
15 | # * If go func name needs to be different than its libc name,
16 | # * or the function is not in libc, name could be specified
17 | # * at the end, after "=" sign, like
18 | # //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
19 |
20 | use strict;
21 |
22 | my $cmdline = "mksyscall_solaris.pl " . join(' ', @ARGV);
23 | my $errors = 0;
24 | my $_32bit = "";
25 |
26 | binmode STDOUT;
27 |
28 | if($ARGV[0] eq "-b32") {
29 | $_32bit = "big-endian";
30 | shift;
31 | } elsif($ARGV[0] eq "-l32") {
32 | $_32bit = "little-endian";
33 | shift;
34 | }
35 |
36 | if($ARGV[0] =~ /^-/) {
37 | print STDERR "usage: mksyscall_solaris.pl [-b32 | -l32] [file ...]\n";
38 | exit 1;
39 | }
40 |
41 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
42 | print STDERR "GOARCH or GOOS not defined in environment\n";
43 | exit 1;
44 | }
45 |
46 | sub parseparamlist($) {
47 | my ($list) = @_;
48 | $list =~ s/^\s*//;
49 | $list =~ s/\s*$//;
50 | if($list eq "") {
51 | return ();
52 | }
53 | return split(/\s*,\s*/, $list);
54 | }
55 |
56 | sub parseparam($) {
57 | my ($p) = @_;
58 | if($p !~ /^(\S*) (\S*)$/) {
59 | print STDERR "$ARGV:$.: malformed parameter: $p\n";
60 | $errors = 1;
61 | return ("xx", "int");
62 | }
63 | return ($1, $2);
64 | }
65 |
66 | my $package = "";
67 | my $text = "";
68 | my $dynimports = "";
69 | my $linknames = "";
70 | my @vars = ();
71 | while(<>) {
72 | chomp;
73 | s/\s+/ /g;
74 | s/^\s+//;
75 | s/\s+$//;
76 | $package = $1 if !$package && /^package (\S+)$/;
77 | my $nonblock = /^\/\/sysnb /;
78 | next if !/^\/\/sys / && !$nonblock;
79 |
80 | # Line must be of the form
81 | # func Open(path string, mode int, perm int) (fd int, err error)
82 | # Split into name, in params, out params.
83 | if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$/) {
84 | print STDERR "$ARGV:$.: malformed //sys declaration\n";
85 | $errors = 1;
86 | next;
87 | }
88 | my ($nb, $func, $in, $out, $modname, $sysname) = ($1, $2, $3, $4, $5, $6);
89 |
90 | # Split argument lists on comma.
91 | my @in = parseparamlist($in);
92 | my @out = parseparamlist($out);
93 |
94 | # So file name.
95 | if($modname eq "") {
96 | $modname = "libc";
97 | }
98 |
99 | # System call name.
100 | if($sysname eq "") {
101 | $sysname = "$func";
102 | }
103 |
104 | # System call pointer variable name.
105 | my $sysvarname = "proc$sysname";
106 |
107 | my $strconvfunc = "BytePtrFromString";
108 | my $strconvtype = "*byte";
109 |
110 | $sysname =~ y/A-Z/a-z/; # All libc functions are lowercase.
111 |
112 | # Runtime import of function to allow cross-platform builds.
113 | $dynimports .= "//go:cgo_import_dynamic libc_${sysname} ${sysname} \"$modname.so\"\n";
114 | # Link symbol to proc address variable.
115 | $linknames .= "//go:linkname ${sysvarname} libc_${sysname}\n";
116 | # Library proc address variable.
117 | push @vars, $sysvarname;
118 |
119 | # Go function header.
120 | $out = join(', ', @out);
121 | if($out ne "") {
122 | $out = " ($out)";
123 | }
124 | if($text ne "") {
125 | $text .= "\n"
126 | }
127 | $text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out;
128 |
129 | # Check if err return available
130 | my $errvar = "";
131 | foreach my $p (@out) {
132 | my ($name, $type) = parseparam($p);
133 | if($type eq "error") {
134 | $errvar = $name;
135 | last;
136 | }
137 | }
138 |
139 | # Prepare arguments to Syscall.
140 | my @args = ();
141 | my @uses = ();
142 | my $n = 0;
143 | foreach my $p (@in) {
144 | my ($name, $type) = parseparam($p);
145 | if($type =~ /^\*/) {
146 | push @args, "uintptr(unsafe.Pointer($name))";
147 | } elsif($type eq "string" && $errvar ne "") {
148 | $text .= "\tvar _p$n $strconvtype\n";
149 | $text .= "\t_p$n, $errvar = $strconvfunc($name)\n";
150 | $text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
151 | push @args, "uintptr(unsafe.Pointer(_p$n))";
152 | push @uses, "use(unsafe.Pointer(_p$n))";
153 | $n++;
154 | } elsif($type eq "string") {
155 | print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
156 | $text .= "\tvar _p$n $strconvtype\n";
157 | $text .= "\t_p$n, _ = $strconvfunc($name)\n";
158 | push @args, "uintptr(unsafe.Pointer(_p$n))";
159 | push @uses, "use(unsafe.Pointer(_p$n))";
160 | $n++;
161 | } elsif($type =~ /^\[\](.*)/) {
162 | # Convert slice into pointer, length.
163 | # Have to be careful not to take address of &a[0] if len == 0:
164 | # pass nil in that case.
165 | $text .= "\tvar _p$n *$1\n";
166 | $text .= "\tif len($name) > 0 {\n\t\t_p$n = \&$name\[0]\n\t}\n";
167 | push @args, "uintptr(unsafe.Pointer(_p$n))", "uintptr(len($name))";
168 | $n++;
169 | } elsif($type eq "int64" && $_32bit ne "") {
170 | if($_32bit eq "big-endian") {
171 | push @args, "uintptr($name >> 32)", "uintptr($name)";
172 | } else {
173 | push @args, "uintptr($name)", "uintptr($name >> 32)";
174 | }
175 | } elsif($type eq "bool") {
176 | $text .= "\tvar _p$n uint32\n";
177 | $text .= "\tif $name {\n\t\t_p$n = 1\n\t} else {\n\t\t_p$n = 0\n\t}\n";
178 | push @args, "uintptr(_p$n)";
179 | $n++;
180 | } else {
181 | push @args, "uintptr($name)";
182 | }
183 | }
184 | my $nargs = @args;
185 |
186 | # Determine which form to use; pad args with zeros.
187 | my $asm = "sysvicall6";
188 | if ($nonblock) {
189 | $asm = "rawSysvicall6";
190 | }
191 | if(@args <= 6) {
192 | while(@args < 6) {
193 | push @args, "0";
194 | }
195 | } else {
196 | print STDERR "$ARGV:$.: too many arguments to system call\n";
197 | }
198 |
199 | # Actual call.
200 | my $args = join(', ', @args);
201 | my $call = "$asm(uintptr(unsafe.Pointer(&$sysvarname)), $nargs, $args)";
202 |
203 | # Assign return values.
204 | my $body = "";
205 | my $failexpr = "";
206 | my @ret = ("_", "_", "_");
207 | my @pout= ();
208 | my $do_errno = 0;
209 | for(my $i=0; $i<@out; $i++) {
210 | my $p = $out[$i];
211 | my ($name, $type) = parseparam($p);
212 | my $reg = "";
213 | if($name eq "err") {
214 | $reg = "e1";
215 | $ret[2] = $reg;
216 | $do_errno = 1;
217 | } else {
218 | $reg = sprintf("r%d", $i);
219 | $ret[$i] = $reg;
220 | }
221 | if($type eq "bool") {
222 | $reg = "$reg != 0";
223 | }
224 | if($type eq "int64" && $_32bit ne "") {
225 | # 64-bit number in r1:r0 or r0:r1.
226 | if($i+2 > @out) {
227 | print STDERR "$ARGV:$.: not enough registers for int64 return\n";
228 | }
229 | if($_32bit eq "big-endian") {
230 | $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1);
231 | } else {
232 | $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i);
233 | }
234 | $ret[$i] = sprintf("r%d", $i);
235 | $ret[$i+1] = sprintf("r%d", $i+1);
236 | }
237 | if($reg ne "e1") {
238 | $body .= "\t$name = $type($reg)\n";
239 | }
240 | }
241 | if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
242 | $text .= "\t$call\n";
243 | } else {
244 | $text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
245 | }
246 | foreach my $use (@uses) {
247 | $text .= "\t$use\n";
248 | }
249 | $text .= $body;
250 |
251 | if ($do_errno) {
252 | $text .= "\tif e1 != 0 {\n";
253 | $text .= "\t\terr = e1\n";
254 | $text .= "\t}\n";
255 | }
256 | $text .= "\treturn\n";
257 | $text .= "}\n";
258 | }
259 |
260 | if($errors) {
261 | exit 1;
262 | }
263 |
264 | print <