├── .travis.yml ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── README.md ├── doc.go ├── examples └── main.go ├── formatter.go ├── formatters ├── json_formatter.go ├── text_formatter.go ├── util_fileline.go └── util_terminal.go ├── level.go ├── level_test.go ├── log.go ├── log_interface.go ├── logger.go ├── logger_test.go ├── vendor └── golang.org │ └── x │ ├── crypto │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ └── ssh │ │ └── terminal │ │ ├── terminal.go │ │ ├── util.go │ │ ├── util_bsd.go │ │ ├── util_linux.go │ │ ├── util_plan9.go │ │ ├── util_solaris.go │ │ └── util_windows.go │ └── sys │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ ├── unix │ ├── affinity_linux.go │ ├── asm_darwin_386.s │ ├── asm_darwin_amd64.s │ ├── asm_darwin_arm.s │ ├── asm_darwin_arm64.s │ ├── asm_dragonfly_amd64.s │ ├── asm_freebsd_386.s │ ├── asm_freebsd_amd64.s │ ├── asm_freebsd_arm.s │ ├── asm_linux_386.s │ ├── asm_linux_amd64.s │ ├── asm_linux_arm.s │ ├── asm_linux_arm64.s │ ├── asm_linux_mips64x.s │ ├── asm_linux_mipsx.s │ ├── asm_linux_ppc64x.s │ ├── asm_linux_s390x.s │ ├── asm_netbsd_386.s │ ├── asm_netbsd_amd64.s │ ├── asm_netbsd_arm.s │ ├── asm_openbsd_386.s │ ├── asm_openbsd_amd64.s │ ├── asm_openbsd_arm.s │ ├── asm_solaris_amd64.s │ ├── bluetooth_linux.go │ ├── cap_freebsd.go │ ├── constants.go │ ├── dev_darwin.go │ ├── dev_dragonfly.go │ ├── dev_freebsd.go │ ├── dev_linux.go │ ├── dev_netbsd.go │ ├── dev_openbsd.go │ ├── dirent.go │ ├── endian_big.go │ ├── endian_little.go │ ├── env_unix.go │ ├── errors_freebsd_386.go │ ├── errors_freebsd_amd64.go │ ├── errors_freebsd_arm.go │ ├── fcntl.go │ ├── fcntl_linux_32bit.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── mkpost.go │ ├── openbsd_pledge.go │ ├── pagesize_unix.go │ ├── race.go │ ├── race0.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── str.go │ ├── syscall.go │ ├── syscall_bsd.go │ ├── syscall_darwin.go │ ├── syscall_darwin_386.go │ ├── syscall_darwin_amd64.go │ ├── syscall_darwin_arm.go │ ├── syscall_darwin_arm64.go │ ├── syscall_dragonfly.go │ ├── syscall_dragonfly_amd64.go │ ├── syscall_freebsd.go │ ├── syscall_freebsd_386.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_freebsd_arm.go │ ├── syscall_linux.go │ ├── syscall_linux_386.go │ ├── syscall_linux_amd64.go │ ├── syscall_linux_amd64_gc.go │ ├── syscall_linux_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_gc.go │ ├── syscall_linux_gccgo.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_mipsx.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_linux_s390x.go │ ├── syscall_linux_sparc64.go │ ├── syscall_netbsd.go │ ├── syscall_netbsd_386.go │ ├── syscall_netbsd_amd64.go │ ├── syscall_netbsd_arm.go │ ├── syscall_openbsd.go │ ├── syscall_openbsd_386.go │ ├── syscall_openbsd_amd64.go │ ├── syscall_openbsd_arm.go │ ├── syscall_solaris.go │ ├── syscall_solaris_amd64.go │ ├── syscall_unix.go │ ├── syscall_unix_gc.go │ ├── timestruct.go │ ├── types_darwin.go │ ├── types_dragonfly.go │ ├── types_freebsd.go │ ├── types_netbsd.go │ ├── types_openbsd.go │ ├── types_solaris.go │ ├── zerrors_darwin_386.go │ ├── zerrors_darwin_amd64.go │ ├── zerrors_darwin_arm.go │ ├── zerrors_darwin_arm64.go │ ├── zerrors_dragonfly_amd64.go │ ├── zerrors_freebsd_386.go │ ├── zerrors_freebsd_amd64.go │ ├── zerrors_freebsd_arm.go │ ├── zerrors_linux_386.go │ ├── zerrors_linux_amd64.go │ ├── zerrors_linux_arm.go │ ├── zerrors_linux_arm64.go │ ├── zerrors_linux_mips.go │ ├── zerrors_linux_mips64.go │ ├── zerrors_linux_mips64le.go │ ├── zerrors_linux_mipsle.go │ ├── zerrors_linux_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_linux_s390x.go │ ├── zerrors_linux_sparc64.go │ ├── zerrors_netbsd_386.go │ ├── zerrors_netbsd_amd64.go │ ├── zerrors_netbsd_arm.go │ ├── zerrors_openbsd_386.go │ ├── zerrors_openbsd_amd64.go │ ├── zerrors_openbsd_arm.go │ ├── zerrors_solaris_amd64.go │ ├── zptrace386_linux.go │ ├── zptracearm_linux.go │ ├── zptracemips_linux.go │ ├── zptracemipsle_linux.go │ ├── zsyscall_darwin_386.go │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_arm.go │ ├── zsyscall_darwin_arm64.go │ ├── zsyscall_dragonfly_amd64.go │ ├── zsyscall_freebsd_386.go │ ├── zsyscall_freebsd_amd64.go │ ├── zsyscall_freebsd_arm.go │ ├── zsyscall_linux_386.go │ ├── zsyscall_linux_amd64.go │ ├── zsyscall_linux_arm.go │ ├── zsyscall_linux_arm64.go │ ├── zsyscall_linux_mips.go │ ├── zsyscall_linux_mips64.go │ ├── zsyscall_linux_mips64le.go │ ├── zsyscall_linux_mipsle.go │ ├── zsyscall_linux_ppc64.go │ ├── zsyscall_linux_ppc64le.go │ ├── zsyscall_linux_s390x.go │ ├── zsyscall_linux_sparc64.go │ ├── zsyscall_netbsd_386.go │ ├── zsyscall_netbsd_amd64.go │ ├── zsyscall_netbsd_arm.go │ ├── zsyscall_openbsd_386.go │ ├── zsyscall_openbsd_amd64.go │ ├── zsyscall_openbsd_arm.go │ ├── zsyscall_solaris_amd64.go │ ├── zsysctl_openbsd_386.go │ ├── zsysctl_openbsd_amd64.go │ ├── zsysctl_openbsd_arm.go │ ├── zsysnum_darwin_386.go │ ├── zsysnum_darwin_amd64.go │ ├── zsysnum_darwin_arm.go │ ├── zsysnum_darwin_arm64.go │ ├── zsysnum_dragonfly_amd64.go │ ├── zsysnum_freebsd_386.go │ ├── zsysnum_freebsd_amd64.go │ ├── zsysnum_freebsd_arm.go │ ├── zsysnum_linux_386.go │ ├── zsysnum_linux_amd64.go │ ├── zsysnum_linux_arm.go │ ├── zsysnum_linux_arm64.go │ ├── zsysnum_linux_mips.go │ ├── zsysnum_linux_mips64.go │ ├── zsysnum_linux_mips64le.go │ ├── zsysnum_linux_mipsle.go │ ├── zsysnum_linux_ppc64.go │ ├── zsysnum_linux_ppc64le.go │ ├── zsysnum_linux_s390x.go │ ├── zsysnum_linux_sparc64.go │ ├── zsysnum_netbsd_386.go │ ├── zsysnum_netbsd_amd64.go │ ├── zsysnum_netbsd_arm.go │ ├── zsysnum_openbsd_386.go │ ├── zsysnum_openbsd_amd64.go │ ├── zsysnum_openbsd_arm.go │ ├── ztypes_darwin_386.go │ ├── ztypes_darwin_amd64.go │ ├── ztypes_darwin_arm.go │ ├── ztypes_darwin_arm64.go │ ├── ztypes_dragonfly_amd64.go │ ├── ztypes_freebsd_386.go │ ├── ztypes_freebsd_amd64.go │ ├── ztypes_freebsd_arm.go │ ├── ztypes_linux_386.go │ ├── ztypes_linux_amd64.go │ ├── ztypes_linux_arm.go │ ├── ztypes_linux_arm64.go │ ├── ztypes_linux_mips.go │ ├── ztypes_linux_mips64.go │ ├── ztypes_linux_mips64le.go │ ├── ztypes_linux_mipsle.go │ ├── ztypes_linux_ppc64.go │ ├── ztypes_linux_ppc64le.go │ ├── ztypes_linux_s390x.go │ ├── ztypes_linux_sparc64.go │ ├── ztypes_netbsd_386.go │ ├── ztypes_netbsd_amd64.go │ ├── ztypes_netbsd_arm.go │ ├── ztypes_openbsd_386.go │ ├── ztypes_openbsd_amd64.go │ ├── ztypes_openbsd_arm.go │ └── ztypes_solaris_amd64.go │ └── windows │ ├── asm_windows_386.s │ ├── asm_windows_amd64.s │ ├── dll_windows.go │ ├── env_windows.go │ ├── eventlog.go │ ├── exec_windows.go │ ├── memory_windows.go │ ├── mksyscall.go │ ├── race.go │ ├── race0.go │ ├── security_windows.go │ ├── service.go │ ├── str.go │ ├── syscall.go │ ├── syscall_windows.go │ ├── types_windows.go │ ├── types_windows_386.go │ ├── types_windows_amd64.go │ └── zsyscall_windows.go └── writers ├── always_new_file_writer.go ├── daily_file_writer.go └── fixed_size_file_writer.go /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - "1.9" 5 | - "1.10" 6 | 7 | before_install: 8 | - go get github.com/mattn/goveralls 9 | 10 | script: 11 | - $GOPATH/bin/goveralls -v -service=travis-ci -package=github.com/subchen/go-log 12 | -------------------------------------------------------------------------------- /Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | branch = "master" 6 | name = "golang.org/x/crypto" 7 | packages = ["ssh/terminal"] 8 | revision = "1a580b3eff7814fc9b40602fd35256c63b50f491" 9 | 10 | [[projects]] 11 | branch = "master" 12 | name = "golang.org/x/sys" 13 | packages = [ 14 | "unix", 15 | "windows" 16 | ] 17 | revision = "7c87d13f8e835d2fb3a70a2912c811ed0c1d241b" 18 | 19 | [solve-meta] 20 | analyzer-name = "dep" 21 | analyzer-version = 1 22 | inputs-digest = "5d23260104de1fc6bee0a07cb064f1b57081935b7958acdb627d18dd9c80ce02" 23 | solver-name = "gps-cdcl" 24 | solver-version = 1 25 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Gopkg.toml example 2 | # 3 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 4 | # for detailed Gopkg.toml documentation. 5 | # 6 | # required = ["github.com/user/thing/cmd/thing"] 7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 8 | # 9 | # [[constraint]] 10 | # name = "github.com/user/project" 11 | # version = "1.0.0" 12 | # 13 | # [[constraint]] 14 | # name = "github.com/user/project2" 15 | # branch = "dev" 16 | # source = "github.com/myfork/project2" 17 | # 18 | # [[override]] 19 | # name = "github.com/x/y" 20 | # version = "2.4.0" 21 | # 22 | # [prune] 23 | # non-go = false 24 | # go-tests = true 25 | # unused-packages = true 26 | 27 | 28 | [[constraint]] 29 | name = "golang.org/x/crypto" 30 | branch = "master" 31 | 32 | [prune] 33 | non-go = true 34 | go-tests = true 35 | unused-packages = true 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | go-log 2 | ================ 3 | 4 | [![GoDoc](https://godoc.org/github.com/subchen/go-log?status.svg)](https://godoc.org/github.com/subchen/go-log) 5 | [![Build Status](https://travis-ci.org/subchen/go-log.svg?branch=master)](https://travis-ci.org/subchen/go-log) 6 | [![Coverage Status](https://coveralls.io/repos/github/subchen/go-log/badge.svg?branch=master)](https://coveralls.io/github/subchen/go-log?branch=master) 7 | [![Go Report Card](https://goreportcard.com/badge/github.com/subchen/go-log)](https://goreportcard.com/report/github.com/subchen/go-log) 8 | [![License](http://img.shields.io/badge/License-Apache_2-red.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) 9 | 10 | Logging package similar to log4j for the Golang. 11 | 12 | - Support dynamic log level 13 | - Support customized formatter 14 | - TextFormatter 15 | - JSONFormatter 16 | - Support multiple rolling file writers 17 | - FixedSizeFileWriter 18 | - DailyFileWriter 19 | - AlwaysNewFileWriter 20 | 21 | Installation 22 | --------------- 23 | 24 | ```bash 25 | $ go get github.com/subchen/go-log 26 | ``` 27 | 28 | Usage 29 | --------------- 30 | 31 | ```go 32 | package main 33 | 34 | import ( 35 | "os" 36 | "errors" 37 | "github.com/subchen/go-log" 38 | ) 39 | 40 | func main() { 41 | log.Debugf("app = %s", os.Args[0]) 42 | log.Errorf("error = %v", errors.New("some error")) 43 | 44 | // dynamic set level 45 | log.Default.Level = log.WARN 46 | 47 | log.Debug("cannot output debug message") 48 | log.Errorln("can output error message", errors.New("some error")) 49 | } 50 | ``` 51 | 52 | ### Output 53 | 54 | Default log to console, you can set `Logger.Out` to set a file writer into log. 55 | 56 | ```go 57 | import ( 58 | "github.com/subchen/go-log" 59 | "github.com/subchen/go-log/writers" 60 | ) 61 | 62 | log.Default.Out = &writers.FixedSizeFileWriter{ 63 | Name: "/tmp/test.log", 64 | MaxSize: 10 * 1024 * 1024, // 10m 65 | MaxCount: 10, 66 | }) 67 | ``` 68 | 69 | Three builtin writers for use 70 | 71 | ```go 72 | // Create log file if file size large than fixed size (10m) 73 | // files: /tmp/test.log.0 .. test.log.10 74 | &writers.FixedSizeFileWriter{ 75 | Name: "/tmp/test.log", 76 | MaxSize: 10 * 1024 * 1024, // 10m 77 | MaxCount: 10, 78 | } 79 | 80 | // Create log file every day. 81 | // files: /tmp/test.log.20160102 82 | &writers.DailyFileWriter{ 83 | Name: "/tmp/test.log", 84 | MaxCount: 10, 85 | } 86 | 87 | // Create log file every process. 88 | // files: /tmp/test.log.20160102_150405 89 | &writers.AlwaysNewFileWriter{ 90 | Name: "/tmp/test.log", 91 | MaxCount: 10, 92 | } 93 | 94 | // Output to multiple writes 95 | io.MultiWriter( 96 | os.Stdout, 97 | &writers.DailyFileWriter{ 98 | Name: "/tmp/test.log", 99 | MaxCount: 10, 100 | } 101 | //... 102 | ) 103 | ``` 104 | 105 | ### Formatter 106 | 107 | ```go 108 | import ( 109 | "github.com/subchen/go-log" 110 | "github.com/subchen/go-log/formatters" 111 | ) 112 | 113 | log.Default.Formatter = new(formatters.TextFormatter) 114 | ``` 115 | 116 | 117 | ### New Logger instance 118 | 119 | ```go 120 | import ( 121 | "github.com/subchen/go-log" 122 | ) 123 | 124 | func main() { 125 | logger := &log.Logger{ 126 | Level: log.INFO, 127 | Formatter: new(formatters.JSONFormatter), 128 | Out: os.Stdout, 129 | } 130 | 131 | logger.Infof("i = %d", 99) 132 | } 133 | ``` 134 | 135 | ## LICENSE 136 | 137 | Apache 2.0 138 | -------------------------------------------------------------------------------- /doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package log is a simple and configurable Logging in Go, with level, formatters and writers. 3 | 4 | It is completely API compatible with the standard library logger. 5 | 6 | The simplest way to use log is simply the package-level exported logger: 7 | 8 | package main 9 | 10 | import ( 11 | "os" 12 | "github.com/subchen/go-log" 13 | ) 14 | 15 | func main() { 16 | log.Print("some message") 17 | log.Infof("$HOME = %v", os.Getenv("HOME")) 18 | log.Errorln("Got err:", os.ErrPermission) 19 | } 20 | 21 | Output: 22 | 23 | 07:34:23.039 INFO some message 24 | 07:34:23.039 INFO $HOME = /home/subchen 25 | 07:34:23.039 ERROR Got err: permission denied 26 | 27 | 28 | You also can config `log.Default` or new `log.Logger` to customize formatter and writer. 29 | 30 | package main 31 | 32 | import ( 33 | "os" 34 | "github.com/subchen/go-log" 35 | "github.com/subchen/go-log/formatters" 36 | "github.com/subchen/go-log/writers" 37 | ) 38 | 39 | func main() { 40 | logger := &log.Logger{ 41 | Level: log.INFO, 42 | Formatter: new(formatters.TextFormatter), 43 | Out: &writers.FixedSizeFileWriter{ 44 | Name: "/tmp/test.log", 45 | MaxSize: 10 * 1024 * 1024, // 10m 46 | MaxCount: 10, 47 | }, 48 | } 49 | 50 | logger.Info("some message") 51 | } 52 | 53 | 54 | 55 | Output log in `/tmp/test.log`: 56 | 57 | 2018-05-19T07:49:05.979+0000 INFO devbox main 9981 example/main.go:17 some message 58 | 59 | 60 | For a full guide visit https://github.com/subchen/go-log 61 | 62 | */ 63 | package log 64 | -------------------------------------------------------------------------------- /examples/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/subchen/go-log" 7 | "github.com/subchen/go-log/formatters" 8 | ) 9 | 10 | func main() { 11 | log.Info("hello", 123) 12 | log.Warn("hello", 123) 13 | 14 | log.Default.Formatter = new(formatters.TextFormatter) 15 | log.Infoln("hello", "world") 16 | log.Warnln("hello", "world") 17 | 18 | newLog := &log.Logger{ 19 | Level: log.INFO, 20 | Formatter: new(formatters.JSONFormatter), 21 | Out: os.Stdout, 22 | } 23 | newLog.Infof("hello %v", 123) 24 | newLog.Warnf("hello %v", 123) 25 | } 26 | -------------------------------------------------------------------------------- /formatter.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | // Formatter is a interface used to implement a custom Formatter 9 | type Formatter interface { 10 | Format(level Level, msg string, logger *Logger) []byte 11 | } 12 | 13 | // simpleFormatter is default formmatter 14 | type simpleFormatter struct { 15 | } 16 | 17 | // Format implements log.Formatter 18 | func (f *simpleFormatter) Format(level Level, msg string, logger *Logger) []byte { 19 | time := time.Now().Format("15:04:05.000") 20 | return []byte(fmt.Sprintf("%s %s %s\n", time, level.String(), msg)) 21 | } 22 | -------------------------------------------------------------------------------- /formatters/json_formatter.go: -------------------------------------------------------------------------------- 1 | package formatters 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "fmt" 7 | "os" 8 | "path/filepath" 9 | "sync" 10 | "time" 11 | 12 | "github.com/subchen/go-log" 13 | ) 14 | 15 | // JSONFormatter is a json formatter 16 | type JSONFormatter struct { 17 | AppName string 18 | TimeFormat string 19 | 20 | init sync.Once 21 | host string 22 | pid int 23 | } 24 | 25 | // Format implements log.Formatter 26 | func (f *JSONFormatter) Format(level log.Level, msg string, logger *log.Logger) []byte { 27 | // output fields: time level host app pid file line msg 28 | 29 | f.init.Do(func() { 30 | if f.AppName == "" { 31 | f.AppName = filepath.Base(os.Args[0]) 32 | } 33 | if f.TimeFormat == "" { 34 | f.TimeFormat = "2006-01-02T15:04:05.000-0700" 35 | } 36 | 37 | f.host, _ = os.Hostname() 38 | f.pid = os.Getpid() 39 | }) 40 | 41 | data := make(map[string]interface{}, 8) 42 | 43 | // file, line 44 | file, line := FilelineCaller(5) 45 | 46 | data["time"] = time.Now().Format(f.TimeFormat) 47 | data["level"] = level.String() 48 | data["host"] = f.host 49 | data["app"] = f.AppName 50 | data["pid"] = f.pid 51 | data["file"] = file 52 | data["line"] = line 53 | data["msg"] = msg 54 | 55 | serialized, err := marshal(data) 56 | if err != nil { 57 | fmt.Fprintf(os.Stderr, "Failed to marshal json, %v\n", err) 58 | } 59 | return serialized 60 | } 61 | 62 | func marshal(v interface{}) ([]byte, error) { 63 | var buf bytes.Buffer 64 | encoder := json.NewEncoder(&buf) 65 | encoder.SetEscapeHTML(false) 66 | err := encoder.Encode(v) 67 | if err != nil { 68 | return nil, err 69 | } 70 | return buf.Bytes(), nil 71 | } 72 | -------------------------------------------------------------------------------- /formatters/text_formatter.go: -------------------------------------------------------------------------------- 1 | package formatters 2 | 3 | import ( 4 | "bytes" 5 | "os" 6 | "path/filepath" 7 | "strconv" 8 | "sync" 9 | "time" 10 | 11 | "github.com/subchen/go-log" 12 | ) 13 | 14 | var ( 15 | fmtBuffer = sync.Pool{ 16 | New: func() interface{} { 17 | return new(bytes.Buffer) 18 | }, 19 | } 20 | ) 21 | 22 | // TextFormatter is a text line formatter 23 | type TextFormatter struct { 24 | AppName string 25 | TimeFormat string 26 | 27 | init sync.Once 28 | host []byte 29 | app []byte 30 | pid []byte 31 | isterm bool 32 | } 33 | 34 | // Format implements log.Formatter 35 | func (f *TextFormatter) Format(level log.Level, msg string, logger *log.Logger) []byte { 36 | // output format: DATE LEVEL HOST APP PID file:line message 37 | // 2001-10-10T12:00:00,000+0800 INFO web-1 app 1234 main/main.go:1234 message ... 38 | 39 | f.init.Do(func() { 40 | if f.AppName == "" { 41 | f.AppName = filepath.Base(os.Args[0]) 42 | } 43 | f.app = []byte(f.AppName) 44 | 45 | if f.TimeFormat == "" { 46 | f.TimeFormat = "2006-01-02T15:04:05.000-0700" 47 | } 48 | 49 | f.isterm = IsTerminal(logger.Out) 50 | 51 | host, _ := os.Hostname() 52 | f.host = []byte(host) 53 | 54 | f.pid = []byte(strconv.Itoa(os.Getpid())) 55 | }) 56 | 57 | buf := fmtBuffer.Get().(*bytes.Buffer) 58 | buf.Reset() 59 | defer fmtBuffer.Put(buf) 60 | 61 | // timestamp 62 | timeStr := time.Now().Format(f.TimeFormat) 63 | buf.WriteString(timeStr) 64 | 65 | // level 66 | buf.WriteByte(' ') 67 | if f.isterm { 68 | buf.WriteString(level.ColorString()) 69 | } else { 70 | buf.WriteString(level.String()) 71 | } 72 | 73 | // host 74 | buf.WriteByte(' ') 75 | buf.Write(f.host) 76 | 77 | // name 78 | buf.WriteByte(' ') 79 | buf.Write(f.app) 80 | 81 | // pid 82 | buf.WriteByte(' ') 83 | buf.Write(f.pid) 84 | 85 | // file, line 86 | file, line := FilelineCaller(5) 87 | buf.WriteByte(' ') 88 | buf.WriteString(file) 89 | buf.WriteByte(':') 90 | buf.WriteString(strconv.Itoa(line)) 91 | 92 | // msg 93 | buf.WriteByte(' ') 94 | buf.WriteString(msg) 95 | 96 | // newline 97 | buf.WriteByte('\n') 98 | 99 | return buf.Bytes() 100 | } 101 | -------------------------------------------------------------------------------- /formatters/util_fileline.go: -------------------------------------------------------------------------------- 1 | package formatters 2 | 3 | import ( 4 | "runtime" 5 | "strings" 6 | ) 7 | 8 | // FilelineCaller returns file and line for caller 9 | func FilelineCaller(skip int) (file string, line int) { 10 | for i := 0; i < 10; i++ { 11 | _, file, line, ok := runtime.Caller(skip + i) 12 | if !ok { 13 | return "???", 0 14 | } 15 | 16 | // file = pkg/file.go 17 | n := 0 18 | for i := len(file) - 1; i > 0; i-- { 19 | if file[i] == '/' { 20 | n++ 21 | if n >= 2 { 22 | file = file[i+1:] 23 | break 24 | } 25 | } 26 | } 27 | 28 | if !strings.HasPrefix(file, "go-log/") { 29 | return file, line 30 | } 31 | } 32 | 33 | return "???", 0 34 | } 35 | -------------------------------------------------------------------------------- /formatters/util_terminal.go: -------------------------------------------------------------------------------- 1 | package formatters 2 | 3 | import ( 4 | "io" 5 | "os" 6 | 7 | "golang.org/x/crypto/ssh/terminal" 8 | ) 9 | 10 | // IsTerminal returns whether is a valid tty for io.Writer 11 | func IsTerminal(w io.Writer) bool { 12 | switch v := w.(type) { 13 | case *os.File: 14 | return terminal.IsTerminal(int(v.Fd())) 15 | default: 16 | return false 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /level.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // Level type 9 | type Level uint32 10 | 11 | // These are the different logging levels 12 | const ( 13 | OFF Level = iota 14 | FATAL 15 | PANIC 16 | ERROR 17 | WARN 18 | INFO 19 | DEBUG 20 | ) 21 | 22 | // String converts the Level to a string 23 | func (level Level) String() string { 24 | switch level { 25 | case OFF: 26 | return "OFF" 27 | case FATAL: 28 | return "FATAL" 29 | case PANIC: 30 | return "PANIC" 31 | case ERROR: 32 | return "ERROR" 33 | case WARN: 34 | return "WARN" 35 | case INFO: 36 | return "INFO" 37 | case DEBUG: 38 | return "DEBUG" 39 | default: 40 | return "UNKNOWN" 41 | } 42 | } 43 | 44 | // ColorString converts the Level to a string with term colorful 45 | func (level Level) ColorString() string { 46 | switch level { 47 | case OFF: 48 | return "OFF" 49 | case FATAL: 50 | return "\033[35mFATAL\033[0m" 51 | case PANIC: 52 | return "\033[35mPANIC\033[0m" 53 | case ERROR: 54 | return "\033[31mERROR\033[0m" 55 | case WARN: 56 | return "\033[33mWARN\033[0m" 57 | case INFO: 58 | return "\033[32mINFO\033[0m" 59 | case DEBUG: 60 | return "\033[34mDEBUG\033[0m" 61 | default: 62 | return "UNKNOWN" 63 | } 64 | } 65 | 66 | // ParseLevel takes a string level and returns the log level constant. 67 | func ParseLevel(name string) (Level, error) { 68 | switch strings.ToUpper(name) { 69 | case "OFF": 70 | return OFF, nil 71 | case "FATAL": 72 | return FATAL, nil 73 | case "PANIC": 74 | return PANIC, nil 75 | case "ERROR": 76 | return ERROR, nil 77 | case "WARN": 78 | return WARN, nil 79 | case "INFO": 80 | return INFO, nil 81 | case "DEBUG": 82 | return DEBUG, nil 83 | } 84 | 85 | return 0, fmt.Errorf("invalid log.Level: %q", name) 86 | } 87 | -------------------------------------------------------------------------------- /level_test.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "strings" 5 | "testing" 6 | ) 7 | 8 | func TestLevelToString(t *testing.T) { 9 | tests := []struct { 10 | level Level 11 | wantOut string 12 | }{ 13 | {level: DEBUG, wantOut: "DEBUG"}, 14 | {level: INFO, wantOut: "INFO"}, 15 | {level: WARN, wantOut: "WARN"}, 16 | {level: ERROR, wantOut: "ERROR"}, 17 | {level: PANIC, wantOut: "PANIC"}, 18 | {level: FATAL, wantOut: "FATAL"}, 19 | {level: OFF, wantOut: "OFF"}, 20 | } 21 | 22 | for _, tt := range tests { 23 | got := tt.level.String() 24 | if got != tt.wantOut { 25 | t.Errorf("%v.String() output = %v, want %v", tt.level, got, tt.wantOut) 26 | } 27 | 28 | gotColor := tt.level.ColorString() 29 | if !strings.Contains(gotColor, tt.wantOut) { 30 | t.Errorf("%v.ColorString() output = %v, want %v", tt.level, gotColor, tt.wantOut) 31 | } 32 | } 33 | } 34 | 35 | func TestParseLevel(t *testing.T) { 36 | tests := []struct { 37 | name string 38 | wantOut Level 39 | wantErr bool 40 | }{ 41 | {name: "debug", wantOut: DEBUG}, 42 | {name: "Info", wantOut: INFO}, 43 | {name: "WARN", wantOut: WARN}, 44 | {name: "error", wantOut: ERROR}, 45 | {name: "panic", wantOut: PANIC}, 46 | {name: "FATAL", wantOut: FATAL}, 47 | {name: "Off", wantOut: OFF}, 48 | {name: "xxxx", wantOut: 0, wantErr: true}, 49 | } 50 | for _, tt := range tests { 51 | got, err := ParseLevel(tt.name) 52 | if (err != nil) != tt.wantErr { 53 | t.Errorf("ParseLevel(%q) error = %v, wantErr %v", tt.name, err, tt.wantErr) 54 | return 55 | } 56 | if got != tt.wantOut { 57 | t.Errorf("ParseLevel(%q) output = %v, want %v", tt.name, got, tt.wantOut) 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /log.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | // Default is a default Logger instance 4 | var Default = New() 5 | 6 | // IsDebugEnabled indicates whether output message 7 | func IsDebugEnabled() bool { 8 | return Default.IsDebugEnabled() 9 | } 10 | 11 | // IsInfoEnabled indicates whether output message 12 | func IsInfoEnabled() bool { 13 | return Default.IsInfoEnabled() 14 | } 15 | 16 | // IsPrintEnabled indicates whether output message 17 | func IsPrintEnabled() bool { 18 | return Default.IsPrintEnabled() 19 | } 20 | 21 | // IsWarnEnabled indicates whether output message 22 | func IsWarnEnabled() bool { 23 | return Default.IsWarnEnabled() 24 | } 25 | 26 | // IsErrorEnabled indicates whether output message 27 | func IsErrorEnabled() bool { 28 | return Default.IsErrorEnabled() 29 | } 30 | 31 | // IsPanicEnabled indicates whether output message 32 | func IsPanicEnabled() bool { 33 | return Default.IsPanicEnabled() 34 | } 35 | 36 | // IsFatalEnabled indicates whether output message 37 | func IsFatalEnabled() bool { 38 | return Default.IsFatalEnabled() 39 | } 40 | 41 | // IsDisabled indicates whether output message 42 | func IsDisabled() bool { 43 | return Default.IsDisabled() 44 | } 45 | 46 | // Debug outputs message, Arguments are handled by fmt.Sprint 47 | func Debug(obj ...interface{}) { 48 | Default.Debug(obj...) 49 | } 50 | 51 | // Info outputs message, Arguments are handled by fmt.Sprint 52 | func Info(obj ...interface{}) { 53 | Default.Info(obj...) 54 | } 55 | 56 | // Print outputs message, Arguments are handled by fmt.Sprint 57 | func Print(obj ...interface{}) { 58 | Default.Print(obj...) 59 | } 60 | 61 | // Warn outputs message, Arguments are handled by fmt.Sprint 62 | func Warn(obj ...interface{}) { 63 | Default.Warn(obj...) 64 | } 65 | 66 | // Error outputs message, Arguments are handled by fmt.Sprint 67 | func Error(obj ...interface{}) { 68 | Default.Error(obj...) 69 | } 70 | 71 | // Panic outputs message, and followed by a call to panic() Arguments are handled by fmt.Sprint 72 | func Panic(obj ...interface{}) { 73 | Default.Panic(obj...) 74 | } 75 | 76 | // Fatal outputs message, and followed by a call to os.Exit(1) Arguments are handled by fmt.Sprint 77 | func Fatal(obj ...interface{}) { 78 | Default.Fatal(obj...) 79 | } 80 | 81 | // Debugln outputs message, Arguments are handled by fmt.Sprintln 82 | func Debugln(obj ...interface{}) { 83 | Default.Debugln(obj...) 84 | } 85 | 86 | // Infoln outputs message, Arguments are handled by fmt.Sprintln 87 | func Infoln(obj ...interface{}) { 88 | Default.Infoln(obj...) 89 | } 90 | 91 | // Println outputs message, Arguments are handled by fmt.Sprintln 92 | func Println(obj ...interface{}) { 93 | Default.Println(obj...) 94 | } 95 | 96 | // Warnln outputs message, Arguments are handled by fmt.Sprintln 97 | func Warnln(obj ...interface{}) { 98 | Default.Warnln(obj...) 99 | } 100 | 101 | // Errorln outputs message, Arguments are handled by fmt.Sprintln 102 | func Errorln(obj ...interface{}) { 103 | Default.Errorln(obj...) 104 | } 105 | 106 | // Panicln outputs message and followed by a call to panic(), Arguments are handled by fmt.Sprintln 107 | func Panicln(obj ...interface{}) { 108 | Default.Panicln(obj...) 109 | } 110 | 111 | // Fatalln outputs message and followed by a call to os.Exit(1), Arguments are handled by fmt.Sprintln 112 | func Fatalln(obj ...interface{}) { 113 | Default.Fatalln(obj...) 114 | } 115 | 116 | // Debugf outputs message, Arguments are handled by fmt.Sprintf 117 | func Debugf(msg string, args ...interface{}) { 118 | Default.Debugf(msg, args...) 119 | } 120 | 121 | // Infof outputs message, Arguments are handled by fmt.Sprintf 122 | func Infof(msg string, args ...interface{}) { 123 | Default.Infof(msg, args...) 124 | } 125 | 126 | // Printf outputs message, Arguments are handled by fmt.Sprintf 127 | func Printf(msg string, args ...interface{}) { 128 | Default.Printf(msg, args...) 129 | } 130 | 131 | // Warnf outputs message, Arguments are handled by fmt.Sprintf 132 | func Warnf(msg string, args ...interface{}) { 133 | Default.Warnf(msg, args...) 134 | } 135 | 136 | // Errorf outputs message, Arguments are handled by fmt.Sprintf 137 | func Errorf(msg string, args ...interface{}) { 138 | Default.Errorf(msg, args...) 139 | } 140 | 141 | // Panicf outputs message and followed by a call to panic(), Arguments are handled by fmt.Sprintf 142 | func Panicf(msg string, args ...interface{}) { 143 | Default.Panicf(msg, args...) 144 | } 145 | 146 | // Fatalf outputs message and followed by a call to os.Exit(1), Arguments are handled by fmt.Sprintf 147 | func Fatalf(msg string, args ...interface{}) { 148 | Default.Fatalf(msg, args...) 149 | } 150 | -------------------------------------------------------------------------------- /log_interface.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | // Won't compile if LogInterface can't be realized by a log.Logger 4 | var ( 5 | _ StdLog = Default 6 | _ LogInterface = Default 7 | ) 8 | 9 | // StdLog is interface for builtin log 10 | type StdLog interface { 11 | Print(...interface{}) 12 | Printf(string, ...interface{}) 13 | Println(...interface{}) 14 | 15 | Fatal(...interface{}) 16 | Fatalf(string, ...interface{}) 17 | Fatalln(...interface{}) 18 | 19 | Panic(...interface{}) 20 | Panicf(string, ...interface{}) 21 | Panicln(...interface{}) 22 | } 23 | 24 | // LogInterface is interface for this logger 25 | type LogInterface interface { 26 | Debug(...interface{}) 27 | Info(...interface{}) 28 | Print(...interface{}) 29 | Warn(...interface{}) 30 | Error(...interface{}) 31 | Panic(...interface{}) 32 | Fatal(...interface{}) 33 | 34 | Debugln(...interface{}) 35 | Infoln(...interface{}) 36 | Println(...interface{}) 37 | Warnln(...interface{}) 38 | Errorln(...interface{}) 39 | Panicln(...interface{}) 40 | Fatalln(...interface{}) 41 | 42 | Debugf(string, ...interface{}) 43 | Infof(string, ...interface{}) 44 | Printf(string, ...interface{}) 45 | Warnf(string, ...interface{}) 46 | Errorf(string, ...interface{}) 47 | Panicf(string, ...interface{}) 48 | Fatalf(string, ...interface{}) 49 | } 50 | -------------------------------------------------------------------------------- /logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | "sync" 8 | ) 9 | 10 | // Exit is equals os.Exit 11 | var Exit = os.Exit 12 | 13 | // Logger is represents an active logging object 14 | type Logger struct { 15 | m sync.Mutex 16 | Level Level 17 | Formatter Formatter 18 | Out io.Writer 19 | } 20 | 21 | // New creates a new Logger 22 | func New() *Logger { 23 | return &Logger{ 24 | Level: INFO, 25 | Formatter: new(simpleFormatter), 26 | Out: os.Stdout, 27 | } 28 | } 29 | 30 | // IsDebugEnabled indicates whether output message 31 | func (l *Logger) IsDebugEnabled() bool { 32 | return l.Level >= DEBUG 33 | } 34 | 35 | // IsInfoEnabled indicates whether output message 36 | func (l *Logger) IsInfoEnabled() bool { 37 | return l.Level >= INFO 38 | } 39 | 40 | // IsPrintEnabled indicates whether output message 41 | func (l *Logger) IsPrintEnabled() bool { 42 | return l.Level > OFF 43 | } 44 | 45 | // IsWarnEnabled indicates whether output message 46 | func (l *Logger) IsWarnEnabled() bool { 47 | return l.Level >= WARN 48 | } 49 | 50 | // IsErrorEnabled indicates whether output message 51 | func (l *Logger) IsErrorEnabled() bool { 52 | return l.Level >= ERROR 53 | } 54 | 55 | // IsPanicEnabled indicates whether output message 56 | func (l *Logger) IsPanicEnabled() bool { 57 | return l.Level >= PANIC 58 | } 59 | 60 | // IsFatalEnabled indicates whether output message 61 | func (l *Logger) IsFatalEnabled() bool { 62 | return l.Level >= FATAL 63 | } 64 | 65 | // IsDisabled indicates whether output message 66 | func (l *Logger) IsDisabled() bool { 67 | return l.Level <= OFF 68 | } 69 | 70 | // Debug outputs message, Arguments are handled by fmt.Sprint 71 | func (l *Logger) Debug(obj ...interface{}) { 72 | if l.Level >= DEBUG { 73 | l.log(DEBUG, fmt.Sprint(obj...)) 74 | } 75 | } 76 | 77 | // Info outputs message, Arguments are handled by fmt.Sprint 78 | func (l *Logger) Info(obj ...interface{}) { 79 | if l.Level >= INFO { 80 | l.log(INFO, fmt.Sprint(obj...)) 81 | } 82 | } 83 | 84 | // Print outputs message, Arguments are handled by fmt.Sprint 85 | func (l *Logger) Print(obj ...interface{}) { 86 | if l.Level != OFF { 87 | l.log(INFO, fmt.Sprint(obj...)) 88 | } 89 | } 90 | 91 | // Warn outputs message, Arguments are handled by fmt.Sprint 92 | func (l *Logger) Warn(obj ...interface{}) { 93 | if l.Level >= WARN { 94 | l.log(WARN, fmt.Sprint(obj...)) 95 | } 96 | } 97 | 98 | // Error outputs message, Arguments are handled by fmt.Sprint 99 | func (l *Logger) Error(obj ...interface{}) { 100 | if l.Level >= ERROR { 101 | l.log(ERROR, fmt.Sprint(obj...)) 102 | } 103 | } 104 | 105 | // Panic outputs message, and followed by a call to panic() Arguments are handled by fmt.Sprint 106 | func (l *Logger) Panic(obj ...interface{}) { 107 | if l.Level >= PANIC { 108 | l.log(PANIC, fmt.Sprint(obj...)) 109 | } 110 | panic(fmt.Sprint(obj...)) 111 | } 112 | 113 | // Fatal outputs message and followed by a call to os.Exit(1), Arguments are handled by fmt.Sprint 114 | func (l *Logger) Fatal(obj ...interface{}) { 115 | if l.Level >= FATAL { 116 | l.log(FATAL, fmt.Sprint(obj...)) 117 | } 118 | Exit(1) 119 | } 120 | 121 | // Debugln outputs message, Arguments are handled by fmt.Sprintln 122 | func (l *Logger) Debugln(obj ...interface{}) { 123 | if l.Level >= DEBUG { 124 | l.log(DEBUG, vsprintln(obj...)) 125 | } 126 | } 127 | 128 | // Infoln outputs message, Arguments are handled by fmt.Sprintln 129 | func (l *Logger) Infoln(obj ...interface{}) { 130 | if l.Level >= INFO { 131 | l.log(INFO, vsprintln(obj...)) 132 | } 133 | } 134 | 135 | // Println outputs message, Arguments are handled by fmt.Sprintln 136 | func (l *Logger) Println(obj ...interface{}) { 137 | if l.Level != OFF { 138 | l.log(INFO, vsprintln(obj...)) 139 | } 140 | } 141 | 142 | // Warnln outputs message, Arguments are handled by fmt.Sprintln 143 | func (l *Logger) Warnln(obj ...interface{}) { 144 | if l.Level >= WARN { 145 | l.log(WARN, vsprintln(obj...)) 146 | } 147 | } 148 | 149 | // Errorln outputs message, Arguments are handled by fmt.Sprintln 150 | func (l *Logger) Errorln(obj ...interface{}) { 151 | if l.Level >= ERROR { 152 | l.log(ERROR, vsprintln(obj...)) 153 | } 154 | } 155 | 156 | // Panicln outputs message and followed by a call to panic(), Arguments are handled by fmt.Sprintln 157 | func (l *Logger) Panicln(obj ...interface{}) { 158 | if l.Level >= PANIC { 159 | l.log(PANIC, vsprintln(obj...)) 160 | } 161 | panic(vsprintln(obj...)) 162 | } 163 | 164 | // Fatalln outputs message and followed by a call to os.Exit(1), Arguments are handled by fmt.Sprintln 165 | func (l *Logger) Fatalln(obj ...interface{}) { 166 | if l.Level >= FATAL { 167 | l.log(FATAL, vsprintln(obj...)) 168 | } 169 | Exit(1) 170 | } 171 | 172 | // Debugf outputs message, Arguments are handles by fmt.Sprintf 173 | func (l *Logger) Debugf(msg string, args ...interface{}) { 174 | if l.Level >= DEBUG { 175 | l.log(DEBUG, fmt.Sprintf(msg, args...)) 176 | } 177 | } 178 | 179 | // Infof outputs message, Arguments are handles by fmt.Sprintf 180 | func (l *Logger) Infof(msg string, args ...interface{}) { 181 | if l.Level >= INFO { 182 | l.log(INFO, fmt.Sprintf(msg, args...)) 183 | } 184 | } 185 | 186 | // Printf outputs message, Arguments are handles by fmt.Sprintf 187 | func (l *Logger) Printf(msg string, args ...interface{}) { 188 | if l.Level != OFF { 189 | l.log(INFO, fmt.Sprintf(msg, args...)) 190 | } 191 | } 192 | 193 | // Warnf outputs message, Arguments are handles by fmt.Sprintf 194 | func (l *Logger) Warnf(msg string, args ...interface{}) { 195 | if l.Level >= WARN { 196 | l.log(WARN, fmt.Sprintf(msg, args...)) 197 | } 198 | } 199 | 200 | // Errorf outputs message, Arguments are handles by fmt.Sprintf 201 | func (l *Logger) Errorf(msg string, args ...interface{}) { 202 | if l.Level >= ERROR { 203 | l.log(ERROR, fmt.Sprintf(msg, args...)) 204 | } 205 | } 206 | 207 | // Panicf outputs message and followed by a call to panic(), Arguments are handles by fmt.Sprintf 208 | func (l *Logger) Panicf(msg string, args ...interface{}) { 209 | if l.Level >= PANIC { 210 | l.log(PANIC, fmt.Sprintf(msg, args...)) 211 | } 212 | panic(fmt.Sprintf(msg, args...)) 213 | } 214 | 215 | // Fatalf outputs message and followed by a call to os.Exit(1), Arguments are handles by fmt.Sprintf 216 | func (l *Logger) Fatalf(msg string, args ...interface{}) { 217 | if l.Level >= FATAL { 218 | l.log(FATAL, fmt.Sprintf(msg, args...)) 219 | } 220 | Exit(1) 221 | } 222 | 223 | func (l *Logger) log(level Level, msg string) { 224 | line := l.Formatter.Format(level, msg, l) 225 | 226 | l.m.Lock() 227 | defer l.m.Unlock() 228 | 229 | _, err := l.Out.Write(line) 230 | if err != nil { 231 | fmt.Fprintf(os.Stderr, "Failed to write log, %v\n", err) 232 | } 233 | } 234 | 235 | // vsprintln => spaces are always added between operands 236 | func vsprintln(obj ...interface{}) string { 237 | msg := fmt.Sprintln(obj...) 238 | return msg[:len(msg)-1] 239 | } 240 | -------------------------------------------------------------------------------- /logger_test.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | ) 7 | 8 | var ( 9 | logHits int 10 | exitHits int 11 | ) 12 | 13 | type hitsFormatter struct{} 14 | 15 | func (f *hitsFormatter) Format(level Level, msg string, logger *Logger) []byte { 16 | logHits++ 17 | return []byte(msg) 18 | } 19 | 20 | func init() { 21 | Default.Formatter = new(hitsFormatter) 22 | Default.Out = new(bytes.Buffer) 23 | 24 | Exit = func(code int) { 25 | exitHits++ 26 | } 27 | } 28 | 29 | func TestLogOnLevel(t *testing.T) { 30 | type fns struct { 31 | fn0 func() bool 32 | fn1 func(...interface{}) 33 | fn2 func(...interface{}) 34 | fn3 func(string, ...interface{}) 35 | ispanic bool 36 | isexit bool 37 | } 38 | debugFns := fns{IsDebugEnabled, Debug, Debugln, Debugf, false, false} 39 | infoFns := fns{IsInfoEnabled, Info, Infoln, Infof, false, false} 40 | printFns := fns{IsPrintEnabled, Print, Println, Printf, false, false} 41 | warnFns := fns{IsWarnEnabled, Warn, Warnln, Warnf, false, false} 42 | errorFns := fns{IsErrorEnabled, Error, Errorln, Errorf, false, false} 43 | panicFns := fns{IsPanicEnabled, Panic, Panicln, Panicf, true, false} 44 | fatalFns := fns{IsFatalEnabled, Fatal, Fatalln, Fatalf, false, true} 45 | 46 | tests := []struct { 47 | level Level 48 | fns fns 49 | hits int 50 | }{ 51 | // 0 52 | {level: DEBUG, fns: debugFns, hits: 1}, 53 | {level: DEBUG, fns: infoFns, hits: 1}, 54 | {level: DEBUG, fns: printFns, hits: 1}, 55 | {level: DEBUG, fns: warnFns, hits: 1}, 56 | {level: DEBUG, fns: errorFns, hits: 1}, 57 | {level: DEBUG, fns: panicFns, hits: 1}, 58 | {level: DEBUG, fns: fatalFns, hits: 1}, 59 | // 7 60 | {level: INFO, fns: debugFns, hits: 0}, 61 | {level: INFO, fns: infoFns, hits: 1}, 62 | {level: INFO, fns: printFns, hits: 1}, 63 | {level: INFO, fns: warnFns, hits: 1}, 64 | {level: INFO, fns: errorFns, hits: 1}, 65 | {level: INFO, fns: panicFns, hits: 1}, 66 | {level: INFO, fns: fatalFns, hits: 1}, 67 | // 14 68 | {level: WARN, fns: debugFns, hits: 0}, 69 | {level: WARN, fns: infoFns, hits: 0}, 70 | {level: WARN, fns: printFns, hits: 1}, 71 | {level: WARN, fns: warnFns, hits: 1}, 72 | {level: WARN, fns: errorFns, hits: 1}, 73 | {level: WARN, fns: panicFns, hits: 1}, 74 | {level: WARN, fns: fatalFns, hits: 1}, 75 | // 21 76 | {level: ERROR, fns: debugFns, hits: 0}, 77 | {level: ERROR, fns: infoFns, hits: 0}, 78 | {level: ERROR, fns: printFns, hits: 1}, 79 | {level: ERROR, fns: warnFns, hits: 0}, 80 | {level: ERROR, fns: errorFns, hits: 1}, 81 | {level: ERROR, fns: panicFns, hits: 1}, 82 | {level: ERROR, fns: fatalFns, hits: 1}, 83 | // 28 84 | {level: PANIC, fns: debugFns, hits: 0}, 85 | {level: PANIC, fns: infoFns, hits: 0}, 86 | {level: PANIC, fns: printFns, hits: 1}, 87 | {level: PANIC, fns: warnFns, hits: 0}, 88 | {level: PANIC, fns: errorFns, hits: 0}, 89 | {level: PANIC, fns: panicFns, hits: 1}, 90 | {level: PANIC, fns: fatalFns, hits: 1}, 91 | // 35 92 | {level: FATAL, fns: debugFns, hits: 0}, 93 | {level: FATAL, fns: infoFns, hits: 0}, 94 | {level: FATAL, fns: printFns, hits: 1}, 95 | {level: FATAL, fns: warnFns, hits: 0}, 96 | {level: FATAL, fns: errorFns, hits: 0}, 97 | {level: FATAL, fns: panicFns, hits: 0}, 98 | {level: FATAL, fns: fatalFns, hits: 1}, 99 | // 42 100 | {level: OFF, fns: debugFns, hits: 0}, 101 | {level: OFF, fns: infoFns, hits: 0}, 102 | {level: OFF, fns: printFns, hits: 0}, 103 | {level: OFF, fns: warnFns, hits: 0}, 104 | {level: OFF, fns: errorFns, hits: 0}, 105 | {level: OFF, fns: panicFns, hits: 0}, 106 | {level: OFF, fns: fatalFns, hits: 0}, 107 | } 108 | 109 | for i, tt := range tests { 110 | func() { 111 | defer func() { 112 | // check panic hits 113 | if err := recover(); err != nil { 114 | if !tt.fns.ispanic { 115 | t.Errorf("Case %d, got panic", i) 116 | } 117 | } else { 118 | if tt.fns.ispanic { 119 | t.Errorf("Case %d, no panic found", i) 120 | } 121 | } 122 | }() 123 | 124 | // reset 125 | logHits = 0 126 | exitHits = 0 127 | Default.Level = tt.level 128 | 129 | // run 130 | tt.fns.fn1("message") 131 | tt.fns.fn2("message") 132 | tt.fns.fn3("message") 133 | 134 | // check is enabled 135 | if tt.fns.fn0() { 136 | if logHits == 0 { 137 | t.Errorf("Case %d, IsEnabled, but no log hits", i) 138 | } 139 | } else { 140 | if logHits != 0 { 141 | t.Errorf("Case %d, not IsEnabled, but found log hits=%v", i, logHits) 142 | } 143 | } 144 | 145 | // check log hits 146 | if logHits != tt.hits*3 { 147 | t.Errorf("Case %d, fn hits on level %v, got %v, want %v", i, tt.level, logHits, tt.hits) 148 | } 149 | 150 | // check exit hits 151 | if tt.fns.isexit { 152 | if exitHits != 3 { 153 | t.Errorf("Case %d, no exits hits", i) 154 | } 155 | } 156 | }() 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at https://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at https://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util.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,!appengine netbsd openbsd 6 | 7 | // Package terminal provides support functions for dealing with terminals, as 8 | // commonly found on UNIX systems. 9 | // 10 | // Putting a terminal into raw mode is the most common requirement: 11 | // 12 | // oldState, err := terminal.MakeRaw(0) 13 | // if err != nil { 14 | // panic(err) 15 | // } 16 | // defer terminal.Restore(0, oldState) 17 | package terminal // import "golang.org/x/crypto/ssh/terminal" 18 | 19 | import ( 20 | "golang.org/x/sys/unix" 21 | ) 22 | 23 | // State contains the state of a terminal. 24 | type State struct { 25 | termios unix.Termios 26 | } 27 | 28 | // IsTerminal returns true if the given file descriptor is a terminal. 29 | func IsTerminal(fd int) bool { 30 | _, err := unix.IoctlGetTermios(fd, ioctlReadTermios) 31 | return err == nil 32 | } 33 | 34 | // MakeRaw put the terminal connected to the given file descriptor into raw 35 | // mode and returns the previous state of the terminal so that it can be 36 | // restored. 37 | func MakeRaw(fd int) (*State, error) { 38 | termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios) 39 | if err != nil { 40 | return nil, err 41 | } 42 | 43 | oldState := State{termios: *termios} 44 | 45 | // This attempts to replicate the behaviour documented for cfmakeraw in 46 | // the termios(3) manpage. 47 | termios.Iflag &^= unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON 48 | termios.Oflag &^= unix.OPOST 49 | termios.Lflag &^= unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN 50 | termios.Cflag &^= unix.CSIZE | unix.PARENB 51 | termios.Cflag |= unix.CS8 52 | termios.Cc[unix.VMIN] = 1 53 | termios.Cc[unix.VTIME] = 0 54 | if err := unix.IoctlSetTermios(fd, ioctlWriteTermios, termios); err != nil { 55 | return nil, err 56 | } 57 | 58 | return &oldState, nil 59 | } 60 | 61 | // GetState returns the current state of a terminal which may be useful to 62 | // restore the terminal after a signal. 63 | func GetState(fd int) (*State, error) { 64 | termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios) 65 | if err != nil { 66 | return nil, err 67 | } 68 | 69 | return &State{termios: *termios}, nil 70 | } 71 | 72 | // Restore restores the terminal connected to the given file descriptor to a 73 | // previous state. 74 | func Restore(fd int, state *State) error { 75 | return unix.IoctlSetTermios(fd, ioctlWriteTermios, &state.termios) 76 | } 77 | 78 | // GetSize returns the dimensions of the given terminal. 79 | func GetSize(fd int) (width, height int, err error) { 80 | ws, err := unix.IoctlGetWinsize(fd, unix.TIOCGWINSZ) 81 | if err != nil { 82 | return -1, -1, err 83 | } 84 | return int(ws.Col), int(ws.Row), nil 85 | } 86 | 87 | // passwordReader is an io.Reader that reads from a specific file descriptor. 88 | type passwordReader int 89 | 90 | func (r passwordReader) Read(buf []byte) (int, error) { 91 | return unix.Read(int(r), buf) 92 | } 93 | 94 | // ReadPassword reads a line of input from a terminal without local echo. This 95 | // is commonly used for inputting passwords and other sensitive data. The slice 96 | // returned does not include the \n. 97 | func ReadPassword(fd int) ([]byte, error) { 98 | termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios) 99 | if err != nil { 100 | return nil, err 101 | } 102 | 103 | newState := *termios 104 | newState.Lflag &^= unix.ECHO 105 | newState.Lflag |= unix.ICANON | unix.ISIG 106 | newState.Iflag |= unix.ICRNL 107 | if err := unix.IoctlSetTermios(fd, ioctlWriteTermios, &newState); err != nil { 108 | return nil, err 109 | } 110 | 111 | defer unix.IoctlSetTermios(fd, ioctlWriteTermios, termios) 112 | 113 | return readPasswordLine(passwordReader(fd)) 114 | } 115 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_bsd.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 darwin dragonfly freebsd netbsd openbsd 6 | 7 | package terminal 8 | 9 | import "golang.org/x/sys/unix" 10 | 11 | const ioctlReadTermios = unix.TIOCGETA 12 | const ioctlWriteTermios = unix.TIOCSETA 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_linux.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 | package terminal 6 | 7 | import "golang.org/x/sys/unix" 8 | 9 | const ioctlReadTermios = unix.TCGETS 10 | const ioctlWriteTermios = unix.TCSETS 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_plan9.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 | // Package terminal provides support functions for dealing with terminals, as 6 | // commonly found on UNIX systems. 7 | // 8 | // Putting a terminal into raw mode is the most common requirement: 9 | // 10 | // oldState, err := terminal.MakeRaw(0) 11 | // if err != nil { 12 | // panic(err) 13 | // } 14 | // defer terminal.Restore(0, oldState) 15 | package terminal 16 | 17 | import ( 18 | "fmt" 19 | "runtime" 20 | ) 21 | 22 | type State struct{} 23 | 24 | // IsTerminal returns true if the given file descriptor is a terminal. 25 | func IsTerminal(fd int) bool { 26 | return false 27 | } 28 | 29 | // MakeRaw put the terminal connected to the given file descriptor into raw 30 | // mode and returns the previous state of the terminal so that it can be 31 | // restored. 32 | func MakeRaw(fd int) (*State, error) { 33 | return nil, fmt.Errorf("terminal: MakeRaw not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 34 | } 35 | 36 | // GetState returns the current state of a terminal which may be useful to 37 | // restore the terminal after a signal. 38 | func GetState(fd int) (*State, error) { 39 | return nil, fmt.Errorf("terminal: GetState not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 40 | } 41 | 42 | // Restore restores the terminal connected to the given file descriptor to a 43 | // previous state. 44 | func Restore(fd int, state *State) error { 45 | return fmt.Errorf("terminal: Restore not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 46 | } 47 | 48 | // GetSize returns the dimensions of the given terminal. 49 | func GetSize(fd int) (width, height int, err error) { 50 | return 0, 0, fmt.Errorf("terminal: GetSize not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 51 | } 52 | 53 | // ReadPassword reads a line of input from a terminal without local echo. This 54 | // is commonly used for inputting passwords and other sensitive data. The slice 55 | // returned does not include the \n. 56 | func ReadPassword(fd int) ([]byte, error) { 57 | return nil, fmt.Errorf("terminal: ReadPassword not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 58 | } 59 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_solaris.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 solaris 6 | 7 | package terminal // import "golang.org/x/crypto/ssh/terminal" 8 | 9 | import ( 10 | "golang.org/x/sys/unix" 11 | "io" 12 | "syscall" 13 | ) 14 | 15 | // State contains the state of a terminal. 16 | type State struct { 17 | termios unix.Termios 18 | } 19 | 20 | // IsTerminal returns true if the given file descriptor is a terminal. 21 | func IsTerminal(fd int) bool { 22 | _, err := unix.IoctlGetTermio(fd, unix.TCGETA) 23 | return err == nil 24 | } 25 | 26 | // ReadPassword reads a line of input from a terminal without local echo. This 27 | // is commonly used for inputting passwords and other sensitive data. The slice 28 | // returned does not include the \n. 29 | func ReadPassword(fd int) ([]byte, error) { 30 | // see also: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libast/common/uwin/getpass.c 31 | val, err := unix.IoctlGetTermios(fd, unix.TCGETS) 32 | if err != nil { 33 | return nil, err 34 | } 35 | oldState := *val 36 | 37 | newState := oldState 38 | newState.Lflag &^= syscall.ECHO 39 | newState.Lflag |= syscall.ICANON | syscall.ISIG 40 | newState.Iflag |= syscall.ICRNL 41 | err = unix.IoctlSetTermios(fd, unix.TCSETS, &newState) 42 | if err != nil { 43 | return nil, err 44 | } 45 | 46 | defer unix.IoctlSetTermios(fd, unix.TCSETS, &oldState) 47 | 48 | var buf [16]byte 49 | var ret []byte 50 | for { 51 | n, err := syscall.Read(fd, buf[:]) 52 | if err != nil { 53 | return nil, err 54 | } 55 | if n == 0 { 56 | if len(ret) == 0 { 57 | return nil, io.EOF 58 | } 59 | break 60 | } 61 | if buf[n-1] == '\n' { 62 | n-- 63 | } 64 | ret = append(ret, buf[:n]...) 65 | if n < len(buf) { 66 | break 67 | } 68 | } 69 | 70 | return ret, nil 71 | } 72 | 73 | // MakeRaw puts the terminal connected to the given file descriptor into raw 74 | // mode and returns the previous state of the terminal so that it can be 75 | // restored. 76 | // see http://cr.illumos.org/~webrev/andy_js/1060/ 77 | func MakeRaw(fd int) (*State, error) { 78 | termios, err := unix.IoctlGetTermios(fd, unix.TCGETS) 79 | if err != nil { 80 | return nil, err 81 | } 82 | 83 | oldState := State{termios: *termios} 84 | 85 | termios.Iflag &^= unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON 86 | termios.Oflag &^= unix.OPOST 87 | termios.Lflag &^= unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN 88 | termios.Cflag &^= unix.CSIZE | unix.PARENB 89 | termios.Cflag |= unix.CS8 90 | termios.Cc[unix.VMIN] = 1 91 | termios.Cc[unix.VTIME] = 0 92 | 93 | if err := unix.IoctlSetTermios(fd, unix.TCSETS, termios); err != nil { 94 | return nil, err 95 | } 96 | 97 | return &oldState, nil 98 | } 99 | 100 | // Restore restores the terminal connected to the given file descriptor to a 101 | // previous state. 102 | func Restore(fd int, oldState *State) error { 103 | return unix.IoctlSetTermios(fd, unix.TCSETS, &oldState.termios) 104 | } 105 | 106 | // GetState returns the current state of a terminal which may be useful to 107 | // restore the terminal after a signal. 108 | func GetState(fd int) (*State, error) { 109 | termios, err := unix.IoctlGetTermios(fd, unix.TCGETS) 110 | if err != nil { 111 | return nil, err 112 | } 113 | 114 | return &State{termios: *termios}, nil 115 | } 116 | 117 | // GetSize returns the dimensions of the given terminal. 118 | func GetSize(fd int) (width, height int, err error) { 119 | ws, err := unix.IoctlGetWinsize(fd, unix.TIOCGWINSZ) 120 | if err != nil { 121 | return 0, 0, err 122 | } 123 | return int(ws.Col), int(ws.Row), nil 124 | } 125 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_windows.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 windows 6 | 7 | // Package terminal provides support functions for dealing with terminals, as 8 | // commonly found on UNIX systems. 9 | // 10 | // Putting a terminal into raw mode is the most common requirement: 11 | // 12 | // oldState, err := terminal.MakeRaw(0) 13 | // if err != nil { 14 | // panic(err) 15 | // } 16 | // defer terminal.Restore(0, oldState) 17 | package terminal 18 | 19 | import ( 20 | "os" 21 | 22 | "golang.org/x/sys/windows" 23 | ) 24 | 25 | type State struct { 26 | mode uint32 27 | } 28 | 29 | // IsTerminal returns true if the given file descriptor is a terminal. 30 | func IsTerminal(fd int) bool { 31 | var st uint32 32 | err := windows.GetConsoleMode(windows.Handle(fd), &st) 33 | return err == nil 34 | } 35 | 36 | // MakeRaw put the terminal connected to the given file descriptor into raw 37 | // mode and returns the previous state of the terminal so that it can be 38 | // restored. 39 | func MakeRaw(fd int) (*State, error) { 40 | var st uint32 41 | if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil { 42 | return nil, err 43 | } 44 | raw := st &^ (windows.ENABLE_ECHO_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT) 45 | if err := windows.SetConsoleMode(windows.Handle(fd), raw); err != nil { 46 | return nil, err 47 | } 48 | return &State{st}, nil 49 | } 50 | 51 | // GetState returns the current state of a terminal which may be useful to 52 | // restore the terminal after a signal. 53 | func GetState(fd int) (*State, error) { 54 | var st uint32 55 | if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil { 56 | return nil, err 57 | } 58 | return &State{st}, nil 59 | } 60 | 61 | // Restore restores the terminal connected to the given file descriptor to a 62 | // previous state. 63 | func Restore(fd int, state *State) error { 64 | return windows.SetConsoleMode(windows.Handle(fd), state.mode) 65 | } 66 | 67 | // GetSize returns the dimensions of the given terminal. 68 | func GetSize(fd int) (width, height int, err error) { 69 | var info windows.ConsoleScreenBufferInfo 70 | if err := windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info); err != nil { 71 | return 0, 0, err 72 | } 73 | return int(info.Size.X), int(info.Size.Y), nil 74 | } 75 | 76 | // ReadPassword reads a line of input from a terminal without local echo. This 77 | // is commonly used for inputting passwords and other sensitive data. The slice 78 | // returned does not include the \n. 79 | func ReadPassword(fd int) ([]byte, error) { 80 | var st uint32 81 | if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil { 82 | return nil, err 83 | } 84 | old := st 85 | 86 | st &^= (windows.ENABLE_ECHO_INPUT) 87 | st |= (windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT) 88 | if err := windows.SetConsoleMode(windows.Handle(fd), st); err != nil { 89 | return nil, err 90 | } 91 | 92 | defer windows.SetConsoleMode(windows.Handle(fd), old) 93 | 94 | var h windows.Handle 95 | p, _ := windows.GetCurrentProcess() 96 | if err := windows.DuplicateHandle(p, windows.Handle(fd), p, &h, 0, false, windows.DUPLICATE_SAME_ACCESS); err != nil { 97 | return nil, err 98 | } 99 | 100 | f := os.NewFile(uintptr(h), "stdin") 101 | defer f.Close() 102 | return readPasswordLine(f) 103 | } 104 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/affinity_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | // CPU affinity functions 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const cpuSetSize = _CPU_SETSIZE / _NCPUBITS 14 | 15 | // CPUSet represents a CPU affinity mask. 16 | type CPUSet [cpuSetSize]cpuMask 17 | 18 | func schedAffinity(trap uintptr, pid int, set *CPUSet) error { 19 | _, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(*set)), uintptr(unsafe.Pointer(set))) 20 | if e != 0 { 21 | return errnoErr(e) 22 | } 23 | return nil 24 | } 25 | 26 | // SchedGetaffinity gets the CPU affinity mask of the thread specified by pid. 27 | // If pid is 0 the calling thread is used. 28 | func SchedGetaffinity(pid int, set *CPUSet) error { 29 | return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set) 30 | } 31 | 32 | // SchedSetaffinity sets the CPU affinity mask of the thread specified by pid. 33 | // If pid is 0 the calling thread is used. 34 | func SchedSetaffinity(pid int, set *CPUSet) error { 35 | return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set) 36 | } 37 | 38 | // Zero clears the set s, so that it contains no CPUs. 39 | func (s *CPUSet) Zero() { 40 | for i := range s { 41 | s[i] = 0 42 | } 43 | } 44 | 45 | func cpuBitsIndex(cpu int) int { 46 | return cpu / _NCPUBITS 47 | } 48 | 49 | func cpuBitsMask(cpu int) cpuMask { 50 | return cpuMask(1 << (uint(cpu) % _NCPUBITS)) 51 | } 52 | 53 | // Set adds cpu to the set s. 54 | func (s *CPUSet) Set(cpu int) { 55 | i := cpuBitsIndex(cpu) 56 | if i < len(s) { 57 | s[i] |= cpuBitsMask(cpu) 58 | } 59 | } 60 | 61 | // Clear removes cpu from the set s. 62 | func (s *CPUSet) Clear(cpu int) { 63 | i := cpuBitsIndex(cpu) 64 | if i < len(s) { 65 | s[i] &^= cpuBitsMask(cpu) 66 | } 67 | } 68 | 69 | // IsSet reports whether cpu is in the set s. 70 | func (s *CPUSet) IsSet(cpu int) bool { 71 | i := cpuBitsIndex(cpu) 72 | if i < len(s) { 73 | return s[i]&cpuBitsMask(cpu) != 0 74 | } 75 | return false 76 | } 77 | 78 | // Count returns the number of CPUs in the set s. 79 | func (s *CPUSet) Count() int { 80 | c := 0 81 | for _, b := range s { 82 | c += onesCount64(uint64(b)) 83 | } 84 | return c 85 | } 86 | 87 | // onesCount64 is a copy of Go 1.9's math/bits.OnesCount64. 88 | // Once this package can require Go 1.9, we can delete this 89 | // and update the caller to use bits.OnesCount64. 90 | func onesCount64(x uint64) int { 91 | const m0 = 0x5555555555555555 // 01010101 ... 92 | const m1 = 0x3333333333333333 // 00110011 ... 93 | const m2 = 0x0f0f0f0f0f0f0f0f // 00001111 ... 94 | const m3 = 0x00ff00ff00ff00ff // etc. 95 | const m4 = 0x0000ffff0000ffff 96 | 97 | // Implementation: Parallel summing of adjacent bits. 98 | // See "Hacker's Delight", Chap. 5: Counting Bits. 99 | // The following pattern shows the general approach: 100 | // 101 | // x = x>>1&(m0&m) + x&(m0&m) 102 | // x = x>>2&(m1&m) + x&(m1&m) 103 | // x = x>>4&(m2&m) + x&(m2&m) 104 | // x = x>>8&(m3&m) + x&(m3&m) 105 | // x = x>>16&(m4&m) + x&(m4&m) 106 | // x = x>>32&(m5&m) + x&(m5&m) 107 | // return int(x) 108 | // 109 | // Masking (& operations) can be left away when there's no 110 | // danger that a field's sum will carry over into the next 111 | // field: Since the result cannot be > 64, 8 bits is enough 112 | // and we can ignore the masks for the shifts by 8 and up. 113 | // Per "Hacker's Delight", the first line can be simplified 114 | // more, but it saves at best one instruction, so we leave 115 | // it alone for clarity. 116 | const m = 1<<64 - 1 117 | x = x>>1&(m0&m) + x&(m0&m) 118 | x = x>>2&(m1&m) + x&(m1&m) 119 | x = (x>>4 + x) & (m2 & m) 120 | x += x >> 8 121 | x += x >> 16 122 | x += x >> 32 123 | return int(x) & (1<<7 - 1) 124 | } 125 | -------------------------------------------------------------------------------- /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_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_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/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_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-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_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_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_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_linux_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 calls for 386, Linux 11 | // 12 | 13 | // See ../runtime/sys_linux_386.s for the reason why we always use int 0x80 14 | // instead of the glibc-specific "CALL 0x10(GS)". 15 | #define INVOKE_SYSCALL INT $0x80 16 | 17 | // Just jump to package syscall's implementation for all these functions. 18 | // The runtime may know about them. 19 | 20 | TEXT ·Syscall(SB),NOSPLIT,$0-28 21 | JMP syscall·Syscall(SB) 22 | 23 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 24 | JMP syscall·Syscall6(SB) 25 | 26 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 27 | CALL runtime·entersyscall(SB) 28 | MOVL trap+0(FP), AX // syscall entry 29 | MOVL a1+4(FP), BX 30 | MOVL a2+8(FP), CX 31 | MOVL a3+12(FP), DX 32 | MOVL $0, SI 33 | MOVL $0, DI 34 | INVOKE_SYSCALL 35 | MOVL AX, r1+16(FP) 36 | MOVL DX, r2+20(FP) 37 | CALL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVL trap+0(FP), AX // syscall entry 48 | MOVL a1+4(FP), BX 49 | MOVL a2+8(FP), CX 50 | MOVL a3+12(FP), DX 51 | MOVL $0, SI 52 | MOVL $0, DI 53 | INVOKE_SYSCALL 54 | MOVL AX, r1+16(FP) 55 | MOVL DX, r2+20(FP) 56 | RET 57 | 58 | TEXT ·socketcall(SB),NOSPLIT,$0-36 59 | JMP syscall·socketcall(SB) 60 | 61 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 62 | JMP syscall·rawsocketcall(SB) 63 | 64 | TEXT ·seek(SB),NOSPLIT,$0-28 65 | JMP syscall·seek(SB) 66 | -------------------------------------------------------------------------------- /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 ·SyscallNoError(SB),NOSPLIT,$0-48 23 | CALL runtime·entersyscall(SB) 24 | MOVQ a1+8(FP), DI 25 | MOVQ a2+16(FP), SI 26 | MOVQ a3+24(FP), DX 27 | MOVQ $0, R10 28 | MOVQ $0, R8 29 | MOVQ $0, R9 30 | MOVQ trap+0(FP), AX // syscall entry 31 | SYSCALL 32 | MOVQ AX, r1+32(FP) 33 | MOVQ DX, r2+40(FP) 34 | CALL runtime·exitsyscall(SB) 35 | RET 36 | 37 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 38 | JMP syscall·RawSyscall(SB) 39 | 40 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 41 | JMP syscall·RawSyscall6(SB) 42 | 43 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 44 | MOVQ a1+8(FP), DI 45 | MOVQ a2+16(FP), SI 46 | MOVQ a3+24(FP), DX 47 | MOVQ $0, R10 48 | MOVQ $0, R8 49 | MOVQ $0, R9 50 | MOVQ trap+0(FP), AX // syscall entry 51 | SYSCALL 52 | MOVQ AX, r1+32(FP) 53 | MOVQ DX, r2+40(FP) 54 | RET 55 | 56 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 57 | JMP syscall·gettimeofday(SB) 58 | -------------------------------------------------------------------------------- /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 ·SyscallNoError(SB),NOSPLIT,$0-24 23 | BL runtime·entersyscall(SB) 24 | MOVW trap+0(FP), R7 25 | MOVW a1+4(FP), R0 26 | MOVW a2+8(FP), R1 27 | MOVW a3+12(FP), R2 28 | MOVW $0, R3 29 | MOVW $0, R4 30 | MOVW $0, R5 31 | SWI $0 32 | MOVW R0, r1+16(FP) 33 | MOVW $0, R0 34 | MOVW R0, r2+20(FP) 35 | BL runtime·exitsyscall(SB) 36 | RET 37 | 38 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 39 | B syscall·RawSyscall(SB) 40 | 41 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 42 | B syscall·RawSyscall6(SB) 43 | 44 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 45 | MOVW trap+0(FP), R7 // syscall entry 46 | MOVW a1+4(FP), R0 47 | MOVW a2+8(FP), R1 48 | MOVW a3+12(FP), R2 49 | SWI $0 50 | MOVW R0, r1+16(FP) 51 | MOVW $0, R0 52 | MOVW R0, r2+20(FP) 53 | RET 54 | 55 | TEXT ·seek(SB),NOSPLIT,$0-28 56 | B syscall·seek(SB) 57 | -------------------------------------------------------------------------------- /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 ·SyscallNoError(SB),NOSPLIT,$0-48 21 | BL runtime·entersyscall(SB) 22 | MOVD a1+8(FP), R0 23 | MOVD a2+16(FP), R1 24 | MOVD a3+24(FP), R2 25 | MOVD $0, R3 26 | MOVD $0, R4 27 | MOVD $0, R5 28 | MOVD trap+0(FP), R8 // syscall entry 29 | SVC 30 | MOVD R0, r1+32(FP) // r1 31 | MOVD R1, r2+40(FP) // r2 32 | BL runtime·exitsyscall(SB) 33 | RET 34 | 35 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 36 | B syscall·RawSyscall(SB) 37 | 38 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 39 | B syscall·RawSyscall6(SB) 40 | 41 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 42 | MOVD a1+8(FP), R0 43 | MOVD a2+16(FP), R1 44 | MOVD a3+24(FP), R2 45 | MOVD $0, R3 46 | MOVD $0, R4 47 | MOVD $0, R5 48 | MOVD trap+0(FP), R8 // syscall entry 49 | SVC 50 | MOVD R0, r1+32(FP) 51 | MOVD R1, r2+40(FP) 52 | RET 53 | -------------------------------------------------------------------------------- /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 ·SyscallNoError(SB),NOSPLIT,$0-48 25 | JAL runtime·entersyscall(SB) 26 | MOVV a1+8(FP), R4 27 | MOVV a2+16(FP), R5 28 | MOVV a3+24(FP), R6 29 | MOVV R0, R7 30 | MOVV R0, R8 31 | MOVV R0, R9 32 | MOVV trap+0(FP), R2 // syscall entry 33 | SYSCALL 34 | MOVV R2, r1+32(FP) 35 | MOVV R3, r2+40(FP) 36 | JAL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | JMP syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | JMP syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVV a1+8(FP), R4 47 | MOVV a2+16(FP), R5 48 | MOVV a3+24(FP), R6 49 | MOVV R0, R7 50 | MOVV R0, R8 51 | MOVV R0, R9 52 | MOVV trap+0(FP), R2 // syscall entry 53 | SYSCALL 54 | MOVV R2, r1+32(FP) 55 | MOVV R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /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 ·SyscallNoError(SB),NOSPLIT,$0-24 28 | JAL runtime·entersyscall(SB) 29 | MOVW a1+4(FP), R4 30 | MOVW a2+8(FP), R5 31 | MOVW a3+12(FP), R6 32 | MOVW R0, R7 33 | MOVW trap+0(FP), R2 // syscall entry 34 | SYSCALL 35 | MOVW R2, r1+16(FP) // r1 36 | MOVW R3, r2+20(FP) // r2 37 | JAL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVW a1+4(FP), R4 48 | MOVW a2+8(FP), R5 49 | MOVW a3+12(FP), R6 50 | MOVW trap+0(FP), R2 // syscall entry 51 | SYSCALL 52 | MOVW R2, r1+16(FP) 53 | MOVW R3, r2+20(FP) 54 | RET 55 | -------------------------------------------------------------------------------- /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 ·SyscallNoError(SB),NOSPLIT,$0-48 25 | BL runtime·entersyscall(SB) 26 | MOVD a1+8(FP), R3 27 | MOVD a2+16(FP), R4 28 | MOVD a3+24(FP), R5 29 | MOVD R0, R6 30 | MOVD R0, R7 31 | MOVD R0, R8 32 | MOVD trap+0(FP), R9 // syscall entry 33 | SYSCALL R9 34 | MOVD R3, r1+32(FP) 35 | MOVD R4, r2+40(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | BR syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | BR syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVD a1+8(FP), R3 47 | MOVD a2+16(FP), R4 48 | MOVD a3+24(FP), R5 49 | MOVD R0, R6 50 | MOVD R0, R7 51 | MOVD R0, R8 52 | MOVD trap+0(FP), R9 // syscall entry 53 | SYSCALL R9 54 | MOVD R3, r1+32(FP) 55 | MOVD R4, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /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 ·SyscallNoError(SB),NOSPLIT,$0-48 25 | BL runtime·entersyscall(SB) 26 | MOVD a1+8(FP), R2 27 | MOVD a2+16(FP), R3 28 | MOVD a3+24(FP), R4 29 | MOVD $0, R5 30 | MOVD $0, R6 31 | MOVD $0, R7 32 | MOVD trap+0(FP), R1 // syscall entry 33 | SYSCALL 34 | MOVD R2, r1+32(FP) 35 | MOVD R3, r2+40(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | BR syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | BR syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVD a1+8(FP), R2 47 | MOVD a2+16(FP), R3 48 | MOVD a3+24(FP), R4 49 | MOVD $0, R5 50 | MOVD $0, R6 51 | MOVD $0, R7 52 | MOVD trap+0(FP), R1 // syscall entry 53 | SYSCALL 54 | MOVD R2, r1+32(FP) 55 | MOVD R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /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_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_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_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_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_openbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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, 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 | 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_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-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /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/cap_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "errors" 11 | "fmt" 12 | ) 13 | 14 | // Go implementation of C mostly found in /usr/src/sys/kern/subr_capability.c 15 | 16 | const ( 17 | // This is the version of CapRights this package understands. See C implementation for parallels. 18 | capRightsGoVersion = CAP_RIGHTS_VERSION_00 19 | capArSizeMin = CAP_RIGHTS_VERSION_00 + 2 20 | capArSizeMax = capRightsGoVersion + 2 21 | ) 22 | 23 | var ( 24 | bit2idx = []int{ 25 | -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 26 | 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27 | } 28 | ) 29 | 30 | func capidxbit(right uint64) int { 31 | return int((right >> 57) & 0x1f) 32 | } 33 | 34 | func rightToIndex(right uint64) (int, error) { 35 | idx := capidxbit(right) 36 | if idx < 0 || idx >= len(bit2idx) { 37 | return -2, fmt.Errorf("index for right 0x%x out of range", right) 38 | } 39 | return bit2idx[idx], nil 40 | } 41 | 42 | func caprver(right uint64) int { 43 | return int(right >> 62) 44 | } 45 | 46 | func capver(rights *CapRights) int { 47 | return caprver(rights.Rights[0]) 48 | } 49 | 50 | func caparsize(rights *CapRights) int { 51 | return capver(rights) + 2 52 | } 53 | 54 | // CapRightsSet sets the permissions in setrights in rights. 55 | func CapRightsSet(rights *CapRights, setrights []uint64) error { 56 | // This is essentially a copy of cap_rights_vset() 57 | if capver(rights) != CAP_RIGHTS_VERSION_00 { 58 | return fmt.Errorf("bad rights version %d", capver(rights)) 59 | } 60 | 61 | n := caparsize(rights) 62 | if n < capArSizeMin || n > capArSizeMax { 63 | return errors.New("bad rights size") 64 | } 65 | 66 | for _, right := range setrights { 67 | if caprver(right) != CAP_RIGHTS_VERSION_00 { 68 | return errors.New("bad right version") 69 | } 70 | i, err := rightToIndex(right) 71 | if err != nil { 72 | return err 73 | } 74 | if i >= n { 75 | return errors.New("index overflow") 76 | } 77 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 78 | return errors.New("index mismatch") 79 | } 80 | rights.Rights[i] |= right 81 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 82 | return errors.New("index mismatch (after assign)") 83 | } 84 | } 85 | 86 | return nil 87 | } 88 | 89 | // CapRightsClear clears the permissions in clearrights from rights. 90 | func CapRightsClear(rights *CapRights, clearrights []uint64) error { 91 | // This is essentially a copy of cap_rights_vclear() 92 | if capver(rights) != CAP_RIGHTS_VERSION_00 { 93 | return fmt.Errorf("bad rights version %d", capver(rights)) 94 | } 95 | 96 | n := caparsize(rights) 97 | if n < capArSizeMin || n > capArSizeMax { 98 | return errors.New("bad rights size") 99 | } 100 | 101 | for _, right := range clearrights { 102 | if caprver(right) != CAP_RIGHTS_VERSION_00 { 103 | return errors.New("bad right version") 104 | } 105 | i, err := rightToIndex(right) 106 | if err != nil { 107 | return err 108 | } 109 | if i >= n { 110 | return errors.New("index overflow") 111 | } 112 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 113 | return errors.New("index mismatch") 114 | } 115 | rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF) 116 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 117 | return errors.New("index mismatch (after assign)") 118 | } 119 | } 120 | 121 | return nil 122 | } 123 | 124 | // CapRightsIsSet checks whether all the permissions in setrights are present in rights. 125 | func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) { 126 | // This is essentially a copy of cap_rights_is_vset() 127 | if capver(rights) != CAP_RIGHTS_VERSION_00 { 128 | return false, fmt.Errorf("bad rights version %d", capver(rights)) 129 | } 130 | 131 | n := caparsize(rights) 132 | if n < capArSizeMin || n > capArSizeMax { 133 | return false, errors.New("bad rights size") 134 | } 135 | 136 | for _, right := range setrights { 137 | if caprver(right) != CAP_RIGHTS_VERSION_00 { 138 | return false, errors.New("bad right version") 139 | } 140 | i, err := rightToIndex(right) 141 | if err != nil { 142 | return false, err 143 | } 144 | if i >= n { 145 | return false, errors.New("index overflow") 146 | } 147 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 148 | return false, errors.New("index mismatch") 149 | } 150 | if (rights.Rights[i] & right) != right { 151 | return false, nil 152 | } 153 | } 154 | 155 | return true, nil 156 | } 157 | 158 | func capright(idx uint64, bit uint64) uint64 { 159 | return ((1 << (57 + idx)) | bit) 160 | } 161 | 162 | // CapRightsInit returns a pointer to an initialised CapRights structure filled with rights. 163 | // See man cap_rights_init(3) and rights(4). 164 | func CapRightsInit(rights []uint64) (*CapRights, error) { 165 | var r CapRights 166 | r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0) 167 | r.Rights[1] = capright(1, 0) 168 | 169 | err := CapRightsSet(&r, rights) 170 | if err != nil { 171 | return nil, err 172 | } 173 | return &r, nil 174 | } 175 | 176 | // CapRightsLimit reduces the operations permitted on fd to at most those contained in rights. 177 | // The capability rights on fd can never be increased by CapRightsLimit. 178 | // See man cap_rights_limit(2) and rights(4). 179 | func CapRightsLimit(fd uintptr, rights *CapRights) error { 180 | return capRightsLimit(int(fd), rights) 181 | } 182 | 183 | // CapRightsGet returns a CapRights structure containing the operations permitted on fd. 184 | // See man cap_rights_get(3) and rights(4). 185 | func CapRightsGet(fd uintptr) (*CapRights, error) { 186 | r, err := CapRightsInit(nil) 187 | if err != nil { 188 | return nil, err 189 | } 190 | err = capRightsGet(capRightsGoVersion, int(fd), r) 191 | if err != nil { 192 | return nil, err 193 | } 194 | return r, nil 195 | } 196 | -------------------------------------------------------------------------------- /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/dev_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Darwin's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a Darwin device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev >> 24) & 0xff) 13 | } 14 | 15 | // Minor returns the minor component of a Darwin device number. 16 | func Minor(dev uint64) uint32 { 17 | return uint32(dev & 0xffffff) 18 | } 19 | 20 | // Mkdev returns a Darwin device number generated from the given major and minor 21 | // components. 22 | func Mkdev(major, minor uint32) uint64 { 23 | return (uint64(major) << 24) | uint64(minor) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Dragonfly's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a DragonFlyBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a DragonFlyBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a DragonFlyBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in FreeBSD's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a FreeBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a FreeBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a FreeBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used by the Linux kernel and glibc. 7 | // 8 | // The information below is extracted and adapted from bits/sysmacros.h in the 9 | // glibc sources: 10 | // 11 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's 12 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major 13 | // number and m is a hex digit of the minor number. This is backward compatible 14 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also 15 | // backward compatible with the Linux kernel, which for some architectures uses 16 | // 32-bit dev_t, encoded as mmmM MMmm. 17 | 18 | package unix 19 | 20 | // Major returns the major component of a Linux device number. 21 | func Major(dev uint64) uint32 { 22 | major := uint32((dev & 0x00000000000fff00) >> 8) 23 | major |= uint32((dev & 0xfffff00000000000) >> 32) 24 | return major 25 | } 26 | 27 | // Minor returns the minor component of a Linux device number. 28 | func Minor(dev uint64) uint32 { 29 | minor := uint32((dev & 0x00000000000000ff) >> 0) 30 | minor |= uint32((dev & 0x00000ffffff00000) >> 12) 31 | return minor 32 | } 33 | 34 | // Mkdev returns a Linux device number generated from the given major and minor 35 | // components. 36 | func Mkdev(major, minor uint32) uint64 { 37 | dev := (uint64(major) & 0x00000fff) << 8 38 | dev |= (uint64(major) & 0xfffff000) << 32 39 | dev |= (uint64(minor) & 0x000000ff) << 0 40 | dev |= (uint64(minor) & 0xffffff00) << 12 41 | return dev 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in NetBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a NetBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x000fff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of a NetBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xfff00000) >> 12) 19 | return minor 20 | } 21 | 22 | // Mkdev returns a NetBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x000fff00 26 | dev |= (uint64(minor) << 12) & 0xfff00000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in OpenBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of an OpenBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x0000ff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of an OpenBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xffff0000) >> 8) 19 | return minor 20 | } 21 | 22 | // Mkdev returns an OpenBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x0000ff00 26 | dev |= (uint64(minor) << 8) & 0xffff0000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dirent.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 nacl netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // ParseDirent parses up to max directory entries in buf, 12 | // appending the names to names. It returns the number of 13 | // bytes consumed from buf, the number of entries added 14 | // to names, and the new names slice. 15 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { 16 | return syscall.ParseDirent(buf, max, names) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.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 ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.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 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /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 | 29 | func Unsetenv(key string) error { 30 | return syscall.Unsetenv(key) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl.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 darwin dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 16 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 17 | valptr, _, err := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg)) 18 | return int(valptr), err 19 | } 20 | 21 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 22 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 23 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 24 | if errno == 0 { 25 | return nil 26 | } 27 | return errno 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl_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/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 gccgoRealSyscallNoError 15 | func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr) 16 | 17 | //extern gccgoRealSyscall 18 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 19 | 20 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 21 | syscall.Entersyscall() 22 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 23 | syscall.Exitsyscall() 24 | return r, 0 25 | } 26 | 27 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 28 | syscall.Entersyscall() 29 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 30 | syscall.Exitsyscall() 31 | return r, 0, syscall.Errno(errno) 32 | } 33 | 34 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 35 | syscall.Entersyscall() 36 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 37 | syscall.Exitsyscall() 38 | return r, 0, syscall.Errno(errno) 39 | } 40 | 41 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 42 | syscall.Entersyscall() 43 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 44 | syscall.Exitsyscall() 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | 48 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 49 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 50 | return r, 0 51 | } 52 | 53 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 54 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 55 | return r, 0, syscall.Errno(errno) 56 | } 57 | 58 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 59 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 60 | return r, 0, syscall.Errno(errno) 61 | } 62 | -------------------------------------------------------------------------------- /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 | uintptr_t 35 | gccgoRealSyscallNoError(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) 36 | { 37 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 38 | } 39 | 40 | // Define the use function in C so that it is not inlined. 41 | 42 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 43 | 44 | void 45 | use(void *p __attribute__ ((unused))) 46 | { 47 | } 48 | -------------------------------------------------------------------------------- /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/golang.org/x/sys/unix/mkpost.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 ignore 6 | 7 | // mkpost processes the output of cgo -godefs to 8 | // modify the generated types. It is used to clean up 9 | // the sys API in an architecture specific manner. 10 | // 11 | // mkpost is run after cgo -godefs; see README.md. 12 | package main 13 | 14 | import ( 15 | "bytes" 16 | "fmt" 17 | "go/format" 18 | "io/ioutil" 19 | "log" 20 | "os" 21 | "regexp" 22 | ) 23 | 24 | func main() { 25 | // Get the OS and architecture (using GOARCH_TARGET if it exists) 26 | goos := os.Getenv("GOOS") 27 | goarch := os.Getenv("GOARCH_TARGET") 28 | if goarch == "" { 29 | goarch = os.Getenv("GOARCH") 30 | } 31 | // Check that we are using the new build system if we should be. 32 | if goos == "linux" && goarch != "sparc64" { 33 | if os.Getenv("GOLANG_SYS_BUILD") != "docker" { 34 | os.Stderr.WriteString("In the new build system, mkpost should not be called directly.\n") 35 | os.Stderr.WriteString("See README.md\n") 36 | os.Exit(1) 37 | } 38 | } 39 | 40 | b, err := ioutil.ReadAll(os.Stdin) 41 | if err != nil { 42 | log.Fatal(err) 43 | } 44 | 45 | // Intentionally export __val fields in Fsid and Sigset_t 46 | valRegex := regexp.MustCompile(`type (Fsid|Sigset_t) struct {(\s+)X__val(\s+\S+\s+)}`) 47 | b = valRegex.ReplaceAll(b, []byte("type $1 struct {${2}Val$3}")) 48 | 49 | // If we have empty Ptrace structs, we should delete them. Only s390x emits 50 | // nonempty Ptrace structs. 51 | ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`) 52 | b = ptraceRexexp.ReplaceAll(b, nil) 53 | 54 | // Replace the control_regs union with a blank identifier for now. 55 | controlRegsRegex := regexp.MustCompile(`(Control_regs)\s+\[0\]uint64`) 56 | b = controlRegsRegex.ReplaceAll(b, []byte("_ [0]uint64")) 57 | 58 | // Remove fields that are added by glibc 59 | // Note that this is unstable as the identifers are private. 60 | removeFieldsRegex := regexp.MustCompile(`X__glibc\S*`) 61 | b = removeFieldsRegex.ReplaceAll(b, []byte("_")) 62 | 63 | // Convert [65]int8 to [65]byte in Utsname members to simplify 64 | // conversion to string; see golang.org/issue/20753 65 | convertUtsnameRegex := regexp.MustCompile(`((Sys|Node|Domain)name|Release|Version|Machine)(\s+)\[(\d+)\]u?int8`) 66 | b = convertUtsnameRegex.ReplaceAll(b, []byte("$1$3[$4]byte")) 67 | 68 | // Remove spare fields (e.g. in Statx_t) 69 | spareFieldsRegex := regexp.MustCompile(`X__spare\S*`) 70 | b = spareFieldsRegex.ReplaceAll(b, []byte("_")) 71 | 72 | // Remove cgo padding fields 73 | removePaddingFieldsRegex := regexp.MustCompile(`Pad_cgo_\d+`) 74 | b = removePaddingFieldsRegex.ReplaceAll(b, []byte("_")) 75 | 76 | // Remove padding, hidden, or unused fields 77 | removeFieldsRegex = regexp.MustCompile(`\b(X_\S+|Padding)`) 78 | b = removeFieldsRegex.ReplaceAll(b, []byte("_")) 79 | 80 | // Remove the first line of warning from cgo 81 | b = b[bytes.IndexByte(b, '\n')+1:] 82 | // Modify the command in the header to include: 83 | // mkpost, our own warning, and a build tag. 84 | replacement := fmt.Sprintf(`$1 | go run mkpost.go 85 | // Code generated by the command above; see README.md. DO NOT EDIT. 86 | 87 | // +build %s,%s`, goarch, goos) 88 | cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`) 89 | b = cgoCommandRegex.ReplaceAll(b, []byte(replacement)) 90 | 91 | // gofmt 92 | b, err = format.Source(b) 93 | if err != nil { 94 | log.Fatal(err) 95 | } 96 | 97 | os.Stdout.Write(b) 98 | } 99 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/openbsd_pledge.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 openbsd 6 | // +build 386 amd64 arm 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | const ( 16 | SYS_PLEDGE = 108 17 | ) 18 | 19 | // Pledge implements the pledge syscall. For more information see pledge(2). 20 | func Pledge(promises string, paths []string) error { 21 | promisesPtr, err := syscall.BytePtrFromString(promises) 22 | if err != nil { 23 | return err 24 | } 25 | promisesUnsafe, pathsUnsafe := unsafe.Pointer(promisesPtr), unsafe.Pointer(nil) 26 | if paths != nil { 27 | var pathsPtr []*byte 28 | if pathsPtr, err = syscall.SlicePtrFromStrings(paths); err != nil { 29 | return err 30 | } 31 | pathsUnsafe = unsafe.Pointer(&pathsPtr[0]) 32 | } 33 | _, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(promisesUnsafe), uintptr(pathsUnsafe), 0) 34 | if e != 0 { 35 | return e 36 | } 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/pagesize_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | // For Unix, get the pagesize from the runtime. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getpagesize() int { 14 | return syscall.Getpagesize() 15 | } 16 | -------------------------------------------------------------------------------- /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/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/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/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, DragonFly BSD and 17 | // Solaris kernels still require 32-bit aligned access to 18 | // network subsystem. 19 | if darwin64Bit || dragonfly64Bit || solaris64Bit { 20 | salign = 4 21 | } 22 | return (salen + salign - 1) & ^(salign - 1) 23 | } 24 | 25 | // CmsgLen returns the value to store in the Len field of the Cmsghdr 26 | // structure, taking into account any necessary alignment. 27 | func CmsgLen(datalen int) int { 28 | return cmsgAlignOf(SizeofCmsghdr) + datalen 29 | } 30 | 31 | // CmsgSpace returns the number of bytes an ancillary element with 32 | // payload of the passed data length occupies. 33 | func CmsgSpace(datalen int) int { 34 | return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) 35 | } 36 | 37 | func cmsgData(h *Cmsghdr) unsafe.Pointer { 38 | return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr))) 39 | } 40 | 41 | // SocketControlMessage represents a socket control message. 42 | type SocketControlMessage struct { 43 | Header Cmsghdr 44 | Data []byte 45 | } 46 | 47 | // ParseSocketControlMessage parses b as an array of socket control 48 | // messages. 49 | func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { 50 | var msgs []SocketControlMessage 51 | i := 0 52 | for i+CmsgLen(0) <= len(b) { 53 | h, dbuf, err := socketControlMessageHeaderAndData(b[i:]) 54 | if err != nil { 55 | return nil, err 56 | } 57 | m := SocketControlMessage{Header: *h, Data: dbuf} 58 | msgs = append(msgs, m) 59 | i += cmsgAlignOf(int(h.Len)) 60 | } 61 | return msgs, nil 62 | } 63 | 64 | func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) { 65 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 66 | if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) { 67 | return nil, nil, EINVAL 68 | } 69 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 70 | } 71 | 72 | // UnixRights encodes a set of open file descriptors into a socket 73 | // control message for sending to another process. 74 | func UnixRights(fds ...int) []byte { 75 | datalen := len(fds) * 4 76 | b := make([]byte, CmsgSpace(datalen)) 77 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 78 | h.Level = SOL_SOCKET 79 | h.Type = SCM_RIGHTS 80 | h.SetLen(CmsgLen(datalen)) 81 | data := cmsgData(h) 82 | for _, fd := range fds { 83 | *(*int32)(data) = int32(fd) 84 | data = unsafe.Pointer(uintptr(data) + 4) 85 | } 86 | return b 87 | } 88 | 89 | // ParseUnixRights decodes a socket control message that contains an 90 | // integer array of open file descriptors from another process. 91 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 92 | if m.Header.Level != SOL_SOCKET { 93 | return nil, EINVAL 94 | } 95 | if m.Header.Type != SCM_RIGHTS { 96 | return nil, EINVAL 97 | } 98 | fds := make([]int, len(m.Data)>>2) 99 | for i, j := 0, 0; i < len(m.Data); i += 4 { 100 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 101 | j++ 102 | } 103 | return fds, nil 104 | } 105 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | // 15 | // The primary use of this package is inside other packages that provide a more 16 | // portable interface to the system, such as "os", "time" and "net". Use 17 | // those packages rather than this one if you can. 18 | // 19 | // For details of the functions and data types in this package consult 20 | // the manuals for the appropriate operating system. 21 | // 22 | // These calls return err == nil to indicate success; otherwise 23 | // err represents an operating system error describing the failure and 24 | // holds a value of type syscall.Errno. 25 | package unix // import "golang.org/x/sys/unix" 26 | 27 | import "strings" 28 | 29 | // ByteSliceFromString returns a NUL-terminated slice of bytes 30 | // containing the text of s. If s contains a NUL byte at any 31 | // location, it returns (nil, EINVAL). 32 | func ByteSliceFromString(s string) ([]byte, error) { 33 | if strings.IndexByte(s, 0) != -1 { 34 | return nil, EINVAL 35 | } 36 | a := make([]byte, len(s)+1) 37 | copy(a, s) 38 | return a, nil 39 | } 40 | 41 | // BytePtrFromString returns a pointer to a NUL-terminated array of 42 | // bytes containing the text of s. If s contains a NUL byte at any 43 | // location, it returns (nil, EINVAL). 44 | func BytePtrFromString(s string) (*byte, error) { 45 | a, err := ByteSliceFromString(s) 46 | if err != nil { 47 | return nil, err 48 | } 49 | return &a[0], nil 50 | } 51 | 52 | // Single-word zero for use when we need a valid pointer to 0 bytes. 53 | // See mkunix.pl. 54 | var _zero uintptr 55 | -------------------------------------------------------------------------------- /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 setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = int32(sec) 29 | tv.Usec = int32(usec) 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint32(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint32(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /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 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = sec 29 | tv.Usec = usec 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.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 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func setTimespec(sec, nsec int64) Timespec { 13 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 14 | } 15 | 16 | func setTimeval(sec, usec int64) Timeval { 17 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 18 | } 19 | 20 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 21 | func Gettimeofday(tv *Timeval) (err error) { 22 | // The tv passed to gettimeofday must be non-nil 23 | // but is otherwise unused. The answers come back 24 | // in the two registers. 25 | sec, usec, err := gettimeofday(tv) 26 | tv.Sec = int32(sec) 27 | tv.Usec = int32(usec) 28 | return err 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 length = uint64(count) 51 | 52 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 53 | 54 | written = int(length) 55 | 56 | if e1 != 0 { 57 | err = e1 58 | } 59 | return 60 | } 61 | 62 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 63 | 64 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 65 | // of darwin/arm the syscall is called sysctl instead of __sysctl. 66 | const SYS___SYSCTL = SYS_SYSCTL 67 | -------------------------------------------------------------------------------- /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 setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = sec 29 | tv.Usec = usec 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_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,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /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 setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_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,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.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 arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /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 Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT 15 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 16 | //sys Ftruncate(fd int, length int64) (err error) 17 | //sysnb Getegid() (egid int) 18 | //sysnb Geteuid() (euid int) 19 | //sysnb Getgid() (gid int) 20 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 21 | //sysnb Getuid() (uid int) 22 | //sysnb InotifyInit() (fd int, err error) 23 | //sys Ioperm(from int, num int, on int) (err error) 24 | //sys Iopl(level int) (err error) 25 | //sys Lchown(path string, uid int, gid int) (err error) 26 | //sys Listen(s int, n int) (err error) 27 | //sys Lstat(path string, stat *Stat_t) (err error) 28 | //sys Pause() (err error) 29 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 30 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 31 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 32 | 33 | func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { 34 | var ts *Timespec 35 | if timeout != nil { 36 | ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000} 37 | } 38 | return Pselect(nfd, r, w, e, ts, nil) 39 | } 40 | 41 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 42 | //sys Setfsgid(gid int) (err error) 43 | //sys Setfsuid(uid int) (err error) 44 | //sysnb Setregid(rgid int, egid int) (err error) 45 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 46 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 47 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 48 | //sysnb Setreuid(ruid int, euid int) (err error) 49 | //sys Shutdown(fd int, how int) (err error) 50 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 51 | 52 | func Stat(path string, stat *Stat_t) (err error) { 53 | // Use fstatat, because Android's seccomp policy blocks stat. 54 | return Fstatat(AT_FDCWD, path, stat, 0) 55 | } 56 | 57 | //sys Statfs(path string, buf *Statfs_t) (err error) 58 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 59 | //sys Truncate(path string, length int64) (err error) 60 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 61 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 62 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 63 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 64 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 65 | //sysnb setgroups(n int, list *_Gid_t) (err error) 66 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 67 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 68 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 69 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 70 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 71 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 72 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 73 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 74 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 75 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 76 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 77 | 78 | func Gettimeofday(tv *Timeval) (err error) { 79 | errno := gettimeofday(tv) 80 | if errno != 0 { 81 | return errno 82 | } 83 | return nil 84 | } 85 | 86 | func Time(t *Time_t) (tt Time_t, err error) { 87 | var tv Timeval 88 | errno := gettimeofday(&tv) 89 | if errno != 0 { 90 | return 0, errno 91 | } 92 | if t != nil { 93 | *t = Time_t(tv.Sec) 94 | } 95 | return Time_t(tv.Sec), nil 96 | } 97 | 98 | //sys Utime(path string, buf *Utimbuf) (err error) 99 | 100 | func setTimespec(sec, nsec int64) Timespec { 101 | return Timespec{Sec: sec, Nsec: nsec} 102 | } 103 | 104 | func setTimeval(sec, usec int64) Timeval { 105 | return Timeval{Sec: sec, Usec: usec} 106 | } 107 | 108 | //sysnb pipe(p *[2]_C_int) (err error) 109 | 110 | func Pipe(p []int) (err error) { 111 | if len(p) != 2 { 112 | return EINVAL 113 | } 114 | var pp [2]_C_int 115 | err = pipe(&pp) 116 | p[0] = int(pp[0]) 117 | p[1] = int(pp[1]) 118 | return 119 | } 120 | 121 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 122 | 123 | func Pipe2(p []int, flags int) (err error) { 124 | if len(p) != 2 { 125 | return EINVAL 126 | } 127 | var pp [2]_C_int 128 | err = pipe2(&pp, flags) 129 | p[0] = int(pp[0]) 130 | p[1] = int(pp[1]) 131 | return 132 | } 133 | 134 | func (r *PtraceRegs) PC() uint64 { return r.Rip } 135 | 136 | func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc } 137 | 138 | func (iov *Iovec) SetLen(length int) { 139 | iov.Len = uint64(length) 140 | } 141 | 142 | func (msghdr *Msghdr) SetControllen(length int) { 143 | msghdr.Controllen = uint64(length) 144 | } 145 | 146 | func (cmsg *Cmsghdr) SetLen(length int) { 147 | cmsg.Len = uint64(length) 148 | } 149 | 150 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 151 | 152 | func Poll(fds []PollFd, timeout int) (n int, err error) { 153 | if len(fds) == 0 { 154 | return poll(nil, 0, timeout) 155 | } 156 | return poll(&fds[0], len(fds), timeout) 157 | } 158 | -------------------------------------------------------------------------------- /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/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 Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 11 | //sys Fchown(fd int, uid int, gid int) (err error) 12 | //sys Fstat(fd int, stat *Stat_t) (err error) 13 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (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 | //sys Listen(s int, n int) (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 | 26 | func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { 27 | var ts *Timespec 28 | if timeout != nil { 29 | ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000} 30 | } 31 | return Pselect(nfd, r, w, e, ts, nil) 32 | } 33 | 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 | 45 | func Stat(path string, stat *Stat_t) (err error) { 46 | return Fstatat(AT_FDCWD, path, stat, 0) 47 | } 48 | 49 | func Lchown(path string, uid int, gid int) (err error) { 50 | return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW) 51 | } 52 | 53 | func Lstat(path string, stat *Stat_t) (err error) { 54 | return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW) 55 | } 56 | 57 | //sys Statfs(path string, buf *Statfs_t) (err error) 58 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 59 | //sys Truncate(path string, length int64) (err error) 60 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 61 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 62 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 63 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 64 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 65 | //sysnb setgroups(n int, list *_Gid_t) (err error) 66 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 67 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 68 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 69 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 70 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 71 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 72 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 73 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 74 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 75 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 76 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 77 | 78 | //sysnb Gettimeofday(tv *Timeval) (err error) 79 | 80 | func setTimespec(sec, nsec int64) Timespec { 81 | return Timespec{Sec: sec, Nsec: nsec} 82 | } 83 | 84 | func setTimeval(sec, usec int64) Timeval { 85 | return Timeval{Sec: sec, Usec: usec} 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_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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,!gccgo 6 | 7 | package unix 8 | 9 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail. 10 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 11 | 12 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't 13 | // fail. 14 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 gccgo 7 | // +build 386 arm 8 | 9 | package unix 10 | 11 | import ( 12 | "syscall" 13 | "unsafe" 14 | ) 15 | 16 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) { 17 | offsetLow := uint32(offset & 0xffffffff) 18 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 19 | _, _, err = Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 20 | return newoffset, err 21 | } 22 | -------------------------------------------------------------------------------- /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 Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 13 | //sys Fchown(fd int, uid int, gid int) (err error) 14 | //sys Fstat(fd int, stat *Stat_t) (err error) 15 | //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT 16 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 17 | //sys Ftruncate(fd int, length int64) (err error) 18 | //sysnb Getegid() (egid int) 19 | //sysnb Geteuid() (euid int) 20 | //sysnb Getgid() (gid int) 21 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT 22 | //sysnb Getuid() (uid int) 23 | //sysnb InotifyInit() (fd int, err error) 24 | //sys Ioperm(from int, num int, on int) (err error) 25 | //sys Iopl(level 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) = SYS__NEWSELECT 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) = SYS_SYNC_FILE_RANGE2 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 | //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 setTimespec(sec, nsec int64) Timespec { 72 | return Timespec{Sec: sec, Nsec: nsec} 73 | } 74 | 75 | func setTimeval(sec, usec int64) Timeval { 76 | return Timeval{Sec: sec, Usec: usec} 77 | } 78 | 79 | func (r *PtraceRegs) PC() uint64 { return r.Nip } 80 | 81 | func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc } 82 | 83 | func (iov *Iovec) SetLen(length int) { 84 | iov.Len = uint64(length) 85 | } 86 | 87 | func (msghdr *Msghdr) SetControllen(length int) { 88 | msghdr.Controllen = uint64(length) 89 | } 90 | 91 | func (cmsg *Cmsghdr) SetLen(length int) { 92 | cmsg.Len = uint64(length) 93 | } 94 | 95 | //sysnb pipe(p *[2]_C_int) (err error) 96 | 97 | func Pipe(p []int) (err error) { 98 | if len(p) != 2 { 99 | return EINVAL 100 | } 101 | var pp [2]_C_int 102 | err = pipe(&pp) 103 | p[0] = int(pp[0]) 104 | p[1] = int(pp[1]) 105 | return 106 | } 107 | 108 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 109 | 110 | func Pipe2(p []int, flags int) (err error) { 111 | if len(p) != 2 { 112 | return EINVAL 113 | } 114 | var pp [2]_C_int 115 | err = pipe2(&pp, flags) 116 | p[0] = int(pp[0]) 117 | p[1] = int(pp[1]) 118 | return 119 | } 120 | 121 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 122 | 123 | func Poll(fds []PollFd, timeout int) (n int, err error) { 124 | if len(fds) == 0 { 125 | return poll(nil, 0, timeout) 126 | } 127 | return poll(&fds[0], len(fds), timeout) 128 | } 129 | -------------------------------------------------------------------------------- /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 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 10 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 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 Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 15 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 16 | //sys Ftruncate(fd int, length int64) (err error) 17 | //sysnb Getegid() (egid int) 18 | //sysnb Geteuid() (euid int) 19 | //sysnb Getgid() (gid int) 20 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 21 | //sysnb Getuid() (uid int) 22 | //sysnb InotifyInit() (fd int, err error) 23 | //sys Lchown(path string, uid int, gid int) (err error) 24 | //sys Listen(s int, n int) (err error) 25 | //sys Lstat(path string, stat *Stat_t) (err error) 26 | //sys Pause() (err error) 27 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 28 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 29 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 30 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 31 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 32 | //sys Setfsgid(gid int) (err error) 33 | //sys Setfsuid(uid int) (err error) 34 | //sysnb Setregid(rgid int, egid int) (err error) 35 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 36 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 37 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 38 | //sysnb Setreuid(ruid int, euid int) (err error) 39 | //sys Shutdown(fd int, how int) (err error) 40 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 41 | //sys Stat(path string, stat *Stat_t) (err error) 42 | //sys Statfs(path string, buf *Statfs_t) (err error) 43 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 44 | //sys Truncate(path string, length int64) (err error) 45 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 46 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 47 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 48 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 49 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 50 | //sysnb setgroups(n int, list *_Gid_t) (err error) 51 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 52 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 53 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 54 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 55 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 56 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 57 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 58 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 59 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 60 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 61 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 62 | 63 | func Ioperm(from int, num int, on int) (err error) { 64 | return ENOSYS 65 | } 66 | 67 | func Iopl(level int) (err error) { 68 | return ENOSYS 69 | } 70 | 71 | //sysnb Gettimeofday(tv *Timeval) (err error) 72 | 73 | func Time(t *Time_t) (tt Time_t, err error) { 74 | var tv Timeval 75 | err = Gettimeofday(&tv) 76 | if err != nil { 77 | return 0, err 78 | } 79 | if t != nil { 80 | *t = Time_t(tv.Sec) 81 | } 82 | return Time_t(tv.Sec), nil 83 | } 84 | 85 | //sys Utime(path string, buf *Utimbuf) (err error) 86 | 87 | func setTimespec(sec, nsec int64) Timespec { 88 | return Timespec{Sec: sec, Nsec: nsec} 89 | } 90 | 91 | func setTimeval(sec, usec int64) Timeval { 92 | return Timeval{Sec: sec, Usec: int32(usec)} 93 | } 94 | 95 | func (r *PtraceRegs) PC() uint64 { return r.Tpc } 96 | 97 | func (r *PtraceRegs) SetPC(pc uint64) { r.Tpc = pc } 98 | 99 | func (iov *Iovec) SetLen(length int) { 100 | iov.Len = uint64(length) 101 | } 102 | 103 | func (msghdr *Msghdr) SetControllen(length int) { 104 | msghdr.Controllen = uint64(length) 105 | } 106 | 107 | func (cmsg *Cmsghdr) SetLen(length int) { 108 | cmsg.Len = uint64(length) 109 | } 110 | 111 | //sysnb pipe(p *[2]_C_int) (err error) 112 | 113 | func Pipe(p []int) (err error) { 114 | if len(p) != 2 { 115 | return EINVAL 116 | } 117 | var pp [2]_C_int 118 | err = pipe(&pp) 119 | p[0] = int(pp[0]) 120 | p[1] = int(pp[1]) 121 | return 122 | } 123 | 124 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 125 | 126 | func Pipe2(p []int, flags int) (err error) { 127 | if len(p) != 2 { 128 | return EINVAL 129 | } 130 | var pp [2]_C_int 131 | err = pipe2(&pp, flags) 132 | p[0] = int(pp[0]) 133 | p[1] = int(pp[1]) 134 | return 135 | } 136 | 137 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 138 | 139 | func Poll(fds []PollFd, timeout int) (n int, err error) { 140 | if len(fds) == 0 { 141 | return poll(nil, 0, timeout) 142 | } 143 | return poll(&fds[0], len(fds), timeout) 144 | } 145 | -------------------------------------------------------------------------------- /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 setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /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 setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /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 setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /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 setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /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 setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_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,solaris 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func (iov *Iovec) SetLen(length int) { 18 | iov.Len = uint64(length) 19 | } 20 | 21 | func (cmsg *Cmsghdr) SetLen(length int) { 22 | cmsg.Len = uint32(length) 23 | } 24 | -------------------------------------------------------------------------------- /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/timestruct.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 "time" 10 | 11 | // TimespecToNsec converts a Timespec value into a number of 12 | // nanoseconds since the Unix epoch. 13 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 14 | 15 | // NsecToTimespec takes a number of nanoseconds since the Unix epoch 16 | // and returns the corresponding Timespec value. 17 | func NsecToTimespec(nsec int64) Timespec { 18 | sec := nsec / 1e9 19 | nsec = nsec % 1e9 20 | if nsec < 0 { 21 | nsec += 1e9 22 | sec-- 23 | } 24 | return setTimespec(sec, nsec) 25 | } 26 | 27 | // TimeToTimespec converts t into a Timespec. 28 | // On some 32-bit systems the range of valid Timespec values are smaller 29 | // than that of time.Time values. So if t is out of the valid range of 30 | // Timespec, it returns a zero Timespec and ERANGE. 31 | func TimeToTimespec(t time.Time) (Timespec, error) { 32 | sec := t.Unix() 33 | nsec := int64(t.Nanosecond()) 34 | ts := setTimespec(sec, nsec) 35 | 36 | // Currently all targets have either int32 or int64 for Timespec.Sec. 37 | // If there were a new target with floating point type for it, we have 38 | // to consider the rounding error. 39 | if int64(ts.Sec) != sec { 40 | return Timespec{}, ERANGE 41 | } 42 | return ts, nil 43 | } 44 | 45 | // TimevalToNsec converts a Timeval value into a number of nanoseconds 46 | // since the Unix epoch. 47 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 48 | 49 | // NsecToTimeval takes a number of nanoseconds since the Unix epoch 50 | // and returns the corresponding Timeval value. 51 | func NsecToTimeval(nsec int64) Timeval { 52 | nsec += 999 // round up to microsecond 53 | usec := nsec % 1e9 / 1e3 54 | sec := nsec / 1e9 55 | if usec < 0 { 56 | usec += 1e6 57 | sec-- 58 | } 59 | return setTimeval(sec, usec) 60 | } 61 | 62 | // Unix returns ts as the number of seconds and nanoseconds elapsed since the 63 | // Unix epoch. 64 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 65 | return int64(ts.Sec), int64(ts.Nsec) 66 | } 67 | 68 | // Unix returns tv as the number of seconds and nanoseconds elapsed since the 69 | // Unix epoch. 70 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 71 | return int64(tv.Sec), int64(tv.Usec) * 1000 72 | } 73 | 74 | // Nano returns ts as the number of nanoseconds elapsed since the Unix epoch. 75 | func (ts *Timespec) Nano() int64 { 76 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 77 | } 78 | 79 | // Nano returns tv as the number of nanoseconds elapsed since the Unix epoch. 80 | func (tv *Timeval) Nano() int64 { 81 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 82 | } 83 | -------------------------------------------------------------------------------- /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 README.md 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 | const ( // Directory mode bits 104 | S_IFMT = C.S_IFMT 105 | S_IFIFO = C.S_IFIFO 106 | S_IFCHR = C.S_IFCHR 107 | S_IFDIR = C.S_IFDIR 108 | S_IFBLK = C.S_IFBLK 109 | S_IFREG = C.S_IFREG 110 | S_IFLNK = C.S_IFLNK 111 | S_IFSOCK = C.S_IFSOCK 112 | S_ISUID = C.S_ISUID 113 | S_ISGID = C.S_ISGID 114 | S_ISVTX = C.S_ISVTX 115 | S_IRUSR = C.S_IRUSR 116 | S_IWUSR = C.S_IWUSR 117 | S_IXUSR = C.S_IXUSR 118 | ) 119 | 120 | type Stat_t C.struct_stat 121 | 122 | type Statfs_t C.struct_statfs 123 | 124 | type Flock_t C.struct_flock 125 | 126 | type Dirent C.struct_dirent 127 | 128 | type Fsid C.struct_fsid 129 | 130 | // File system limits 131 | 132 | const ( 133 | PathMax = C.PATH_MAX 134 | ) 135 | 136 | // Sockets 137 | 138 | type RawSockaddrInet4 C.struct_sockaddr_in 139 | 140 | type RawSockaddrInet6 C.struct_sockaddr_in6 141 | 142 | type RawSockaddrUnix C.struct_sockaddr_un 143 | 144 | type RawSockaddrDatalink C.struct_sockaddr_dl 145 | 146 | type RawSockaddr C.struct_sockaddr 147 | 148 | type RawSockaddrAny C.struct_sockaddr_any 149 | 150 | type _Socklen C.socklen_t 151 | 152 | type Linger C.struct_linger 153 | 154 | type Iovec C.struct_iovec 155 | 156 | type IPMreq C.struct_ip_mreq 157 | 158 | type IPv6Mreq C.struct_ipv6_mreq 159 | 160 | type Msghdr C.struct_msghdr 161 | 162 | type Cmsghdr C.struct_cmsghdr 163 | 164 | type Inet6Pktinfo C.struct_in6_pktinfo 165 | 166 | type IPv6MTUInfo C.struct_ip6_mtuinfo 167 | 168 | type ICMPv6Filter C.struct_icmp6_filter 169 | 170 | const ( 171 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 172 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 173 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 174 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 175 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 176 | SizeofLinger = C.sizeof_struct_linger 177 | SizeofIPMreq = C.sizeof_struct_ip_mreq 178 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 179 | SizeofMsghdr = C.sizeof_struct_msghdr 180 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 181 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 182 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 183 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 184 | ) 185 | 186 | // Ptrace requests 187 | 188 | const ( 189 | PTRACE_TRACEME = C.PT_TRACE_ME 190 | PTRACE_CONT = C.PT_CONTINUE 191 | PTRACE_KILL = C.PT_KILL 192 | ) 193 | 194 | // Events (kqueue, kevent) 195 | 196 | type Kevent_t C.struct_kevent 197 | 198 | // Select 199 | 200 | type FdSet C.fd_set 201 | 202 | // Routing and interface messages 203 | 204 | const ( 205 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 206 | SizeofIfData = C.sizeof_struct_if_data 207 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 208 | SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr 209 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 210 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 211 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 212 | ) 213 | 214 | type IfMsghdr C.struct_if_msghdr 215 | 216 | type IfData C.struct_if_data 217 | 218 | type IfaMsghdr C.struct_ifa_msghdr 219 | 220 | type IfmaMsghdr C.struct_ifma_msghdr 221 | 222 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 223 | 224 | type RtMsghdr C.struct_rt_msghdr 225 | 226 | type RtMetrics C.struct_rt_metrics 227 | 228 | // Berkeley packet filter 229 | 230 | const ( 231 | SizeofBpfVersion = C.sizeof_struct_bpf_version 232 | SizeofBpfStat = C.sizeof_struct_bpf_stat 233 | SizeofBpfProgram = C.sizeof_struct_bpf_program 234 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 235 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 236 | ) 237 | 238 | type BpfVersion C.struct_bpf_version 239 | 240 | type BpfStat C.struct_bpf_stat 241 | 242 | type BpfProgram C.struct_bpf_program 243 | 244 | type BpfInsn C.struct_bpf_insn 245 | 246 | type BpfHdr C.struct_bpf_hdr 247 | 248 | // Terminal handling 249 | 250 | type Termios C.struct_termios 251 | 252 | type Winsize C.struct_winsize 253 | 254 | // fchmodat-like syscalls. 255 | 256 | const ( 257 | AT_FDCWD = C.AT_FDCWD 258 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 259 | ) 260 | 261 | // poll 262 | 263 | type PollFd C.struct_pollfd 264 | 265 | const ( 266 | POLLERR = C.POLLERR 267 | POLLHUP = C.POLLHUP 268 | POLLIN = C.POLLIN 269 | POLLNVAL = C.POLLNVAL 270 | POLLOUT = C.POLLOUT 271 | POLLPRI = C.POLLPRI 272 | POLLRDBAND = C.POLLRDBAND 273 | POLLRDNORM = C.POLLRDNORM 274 | POLLWRBAND = C.POLLWRBAND 275 | POLLWRNORM = C.POLLWRNORM 276 | ) 277 | 278 | // Uname 279 | 280 | type Utsname C.struct_utsname 281 | -------------------------------------------------------------------------------- /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 README.md 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 | #include 48 | #include 49 | 50 | enum { 51 | sizeofPtr = sizeof(void*), 52 | }; 53 | 54 | union sockaddr_all { 55 | struct sockaddr s1; // this one gets used for fields 56 | struct sockaddr_in s2; // these pad it out 57 | struct sockaddr_in6 s3; 58 | struct sockaddr_un s4; 59 | struct sockaddr_dl s5; 60 | }; 61 | 62 | struct sockaddr_any { 63 | struct sockaddr addr; 64 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 65 | }; 66 | 67 | */ 68 | import "C" 69 | 70 | // Machine characteristics; for internal use. 71 | 72 | const ( 73 | sizeofPtr = C.sizeofPtr 74 | sizeofShort = C.sizeof_short 75 | sizeofInt = C.sizeof_int 76 | sizeofLong = C.sizeof_long 77 | sizeofLongLong = C.sizeof_longlong 78 | ) 79 | 80 | // Basic types 81 | 82 | type ( 83 | _C_short C.short 84 | _C_int C.int 85 | _C_long C.long 86 | _C_long_long C.longlong 87 | ) 88 | 89 | // Time 90 | 91 | type Timespec C.struct_timespec 92 | 93 | type Timeval C.struct_timeval 94 | 95 | // Processes 96 | 97 | type Rusage C.struct_rusage 98 | 99 | type Rlimit C.struct_rlimit 100 | 101 | type _Gid_t C.gid_t 102 | 103 | // Files 104 | 105 | type Stat_t C.struct_stat 106 | 107 | type Statfs_t C.struct_statfs 108 | 109 | type Flock_t C.struct_flock 110 | 111 | type Dirent C.struct_dirent 112 | 113 | type Fsid C.fsid_t 114 | 115 | // File system limits 116 | 117 | const ( 118 | PathMax = C.PATH_MAX 119 | ) 120 | 121 | // Advice to Fadvise 122 | 123 | const ( 124 | FADV_NORMAL = C.POSIX_FADV_NORMAL 125 | FADV_RANDOM = C.POSIX_FADV_RANDOM 126 | FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL 127 | FADV_WILLNEED = C.POSIX_FADV_WILLNEED 128 | FADV_DONTNEED = C.POSIX_FADV_DONTNEED 129 | FADV_NOREUSE = C.POSIX_FADV_NOREUSE 130 | ) 131 | 132 | // Sockets 133 | 134 | type RawSockaddrInet4 C.struct_sockaddr_in 135 | 136 | type RawSockaddrInet6 C.struct_sockaddr_in6 137 | 138 | type RawSockaddrUnix C.struct_sockaddr_un 139 | 140 | type RawSockaddrDatalink C.struct_sockaddr_dl 141 | 142 | type RawSockaddr C.struct_sockaddr 143 | 144 | type RawSockaddrAny C.struct_sockaddr_any 145 | 146 | type _Socklen C.socklen_t 147 | 148 | type Linger C.struct_linger 149 | 150 | type Iovec C.struct_iovec 151 | 152 | type IPMreq C.struct_ip_mreq 153 | 154 | type IPv6Mreq C.struct_ipv6_mreq 155 | 156 | type Msghdr C.struct_msghdr 157 | 158 | type Cmsghdr C.struct_cmsghdr 159 | 160 | type Inet6Pktinfo C.struct_in6_pktinfo 161 | 162 | type IPv6MTUInfo C.struct_ip6_mtuinfo 163 | 164 | type ICMPv6Filter C.struct_icmp6_filter 165 | 166 | const ( 167 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 168 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 169 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 170 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 171 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 172 | SizeofLinger = C.sizeof_struct_linger 173 | SizeofIPMreq = C.sizeof_struct_ip_mreq 174 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 175 | SizeofMsghdr = C.sizeof_struct_msghdr 176 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 177 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 178 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 179 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 180 | ) 181 | 182 | // Ptrace requests 183 | 184 | const ( 185 | PTRACE_TRACEME = C.PT_TRACE_ME 186 | PTRACE_CONT = C.PT_CONTINUE 187 | PTRACE_KILL = C.PT_KILL 188 | ) 189 | 190 | // Events (kqueue, kevent) 191 | 192 | type Kevent_t C.struct_kevent 193 | 194 | // Select 195 | 196 | type FdSet C.fd_set 197 | 198 | // Routing and interface messages 199 | 200 | const ( 201 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 202 | SizeofIfData = C.sizeof_struct_if_data 203 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 204 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 205 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 206 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 207 | ) 208 | 209 | type IfMsghdr C.struct_if_msghdr 210 | 211 | type IfData C.struct_if_data 212 | 213 | type IfaMsghdr C.struct_ifa_msghdr 214 | 215 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 216 | 217 | type RtMsghdr C.struct_rt_msghdr 218 | 219 | type RtMetrics C.struct_rt_metrics 220 | 221 | type Mclpool C.struct_mclpool 222 | 223 | // Berkeley packet filter 224 | 225 | const ( 226 | SizeofBpfVersion = C.sizeof_struct_bpf_version 227 | SizeofBpfStat = C.sizeof_struct_bpf_stat 228 | SizeofBpfProgram = C.sizeof_struct_bpf_program 229 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 230 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 231 | ) 232 | 233 | type BpfVersion C.struct_bpf_version 234 | 235 | type BpfStat C.struct_bpf_stat 236 | 237 | type BpfProgram C.struct_bpf_program 238 | 239 | type BpfInsn C.struct_bpf_insn 240 | 241 | type BpfHdr C.struct_bpf_hdr 242 | 243 | type BpfTimeval C.struct_bpf_timeval 244 | 245 | // Terminal handling 246 | 247 | type Termios C.struct_termios 248 | 249 | type Winsize C.struct_winsize 250 | 251 | // fchmodat-like syscalls. 252 | 253 | const ( 254 | AT_FDCWD = C.AT_FDCWD 255 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 256 | ) 257 | 258 | // poll 259 | 260 | type PollFd C.struct_pollfd 261 | 262 | const ( 263 | POLLERR = C.POLLERR 264 | POLLHUP = C.POLLHUP 265 | POLLIN = C.POLLIN 266 | POLLNVAL = C.POLLNVAL 267 | POLLOUT = C.POLLOUT 268 | POLLPRI = C.POLLPRI 269 | POLLRDBAND = C.POLLRDBAND 270 | POLLRDNORM = C.POLLRDNORM 271 | POLLWRBAND = C.POLLWRBAND 272 | POLLWRNORM = C.POLLWRNORM 273 | ) 274 | 275 | // Sysctl 276 | 277 | type Sysctlnode C.struct_sysctlnode 278 | 279 | // Uname 280 | 281 | type Utsname C.struct_utsname 282 | -------------------------------------------------------------------------------- /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 README.md 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 | #include 48 | 49 | enum { 50 | sizeofPtr = sizeof(void*), 51 | }; 52 | 53 | union sockaddr_all { 54 | struct sockaddr s1; // this one gets used for fields 55 | struct sockaddr_in s2; // these pad it out 56 | struct sockaddr_in6 s3; 57 | struct sockaddr_un s4; 58 | struct sockaddr_dl s5; 59 | }; 60 | 61 | struct sockaddr_any { 62 | struct sockaddr addr; 63 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 64 | }; 65 | 66 | */ 67 | import "C" 68 | 69 | // Machine characteristics; for internal use. 70 | 71 | const ( 72 | sizeofPtr = C.sizeofPtr 73 | sizeofShort = C.sizeof_short 74 | sizeofInt = C.sizeof_int 75 | sizeofLong = C.sizeof_long 76 | sizeofLongLong = C.sizeof_longlong 77 | ) 78 | 79 | // Basic types 80 | 81 | type ( 82 | _C_short C.short 83 | _C_int C.int 84 | _C_long C.long 85 | _C_long_long C.longlong 86 | ) 87 | 88 | // Time 89 | 90 | type Timespec C.struct_timespec 91 | 92 | type Timeval C.struct_timeval 93 | 94 | // Processes 95 | 96 | type Rusage C.struct_rusage 97 | 98 | type Rlimit C.struct_rlimit 99 | 100 | type _Gid_t C.gid_t 101 | 102 | // Files 103 | 104 | const ( // Directory mode bits 105 | S_IFMT = C.S_IFMT 106 | S_IFIFO = C.S_IFIFO 107 | S_IFCHR = C.S_IFCHR 108 | S_IFDIR = C.S_IFDIR 109 | S_IFBLK = C.S_IFBLK 110 | S_IFREG = C.S_IFREG 111 | S_IFLNK = C.S_IFLNK 112 | S_IFSOCK = C.S_IFSOCK 113 | S_ISUID = C.S_ISUID 114 | S_ISGID = C.S_ISGID 115 | S_ISVTX = C.S_ISVTX 116 | S_IRUSR = C.S_IRUSR 117 | S_IWUSR = C.S_IWUSR 118 | S_IXUSR = C.S_IXUSR 119 | ) 120 | 121 | type Stat_t C.struct_stat 122 | 123 | type Statfs_t C.struct_statfs 124 | 125 | type Flock_t C.struct_flock 126 | 127 | type Dirent C.struct_dirent 128 | 129 | type Fsid C.fsid_t 130 | 131 | // File system limits 132 | 133 | const ( 134 | PathMax = C.PATH_MAX 135 | ) 136 | 137 | // Sockets 138 | 139 | type RawSockaddrInet4 C.struct_sockaddr_in 140 | 141 | type RawSockaddrInet6 C.struct_sockaddr_in6 142 | 143 | type RawSockaddrUnix C.struct_sockaddr_un 144 | 145 | type RawSockaddrDatalink C.struct_sockaddr_dl 146 | 147 | type RawSockaddr C.struct_sockaddr 148 | 149 | type RawSockaddrAny C.struct_sockaddr_any 150 | 151 | type _Socklen C.socklen_t 152 | 153 | type Linger C.struct_linger 154 | 155 | type Iovec C.struct_iovec 156 | 157 | type IPMreq C.struct_ip_mreq 158 | 159 | type IPv6Mreq C.struct_ipv6_mreq 160 | 161 | type Msghdr C.struct_msghdr 162 | 163 | type Cmsghdr C.struct_cmsghdr 164 | 165 | type Inet6Pktinfo C.struct_in6_pktinfo 166 | 167 | type IPv6MTUInfo C.struct_ip6_mtuinfo 168 | 169 | type ICMPv6Filter C.struct_icmp6_filter 170 | 171 | const ( 172 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 173 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 174 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 175 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 176 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 177 | SizeofLinger = C.sizeof_struct_linger 178 | SizeofIPMreq = C.sizeof_struct_ip_mreq 179 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 180 | SizeofMsghdr = C.sizeof_struct_msghdr 181 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 182 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 183 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 184 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 185 | ) 186 | 187 | // Ptrace requests 188 | 189 | const ( 190 | PTRACE_TRACEME = C.PT_TRACE_ME 191 | PTRACE_CONT = C.PT_CONTINUE 192 | PTRACE_KILL = C.PT_KILL 193 | ) 194 | 195 | // Events (kqueue, kevent) 196 | 197 | type Kevent_t C.struct_kevent 198 | 199 | // Select 200 | 201 | type FdSet C.fd_set 202 | 203 | // Routing and interface messages 204 | 205 | const ( 206 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 207 | SizeofIfData = C.sizeof_struct_if_data 208 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 209 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 210 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 211 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 212 | ) 213 | 214 | type IfMsghdr C.struct_if_msghdr 215 | 216 | type IfData C.struct_if_data 217 | 218 | type IfaMsghdr C.struct_ifa_msghdr 219 | 220 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 221 | 222 | type RtMsghdr C.struct_rt_msghdr 223 | 224 | type RtMetrics C.struct_rt_metrics 225 | 226 | type Mclpool C.struct_mclpool 227 | 228 | // Berkeley packet filter 229 | 230 | const ( 231 | SizeofBpfVersion = C.sizeof_struct_bpf_version 232 | SizeofBpfStat = C.sizeof_struct_bpf_stat 233 | SizeofBpfProgram = C.sizeof_struct_bpf_program 234 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 235 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 236 | ) 237 | 238 | type BpfVersion C.struct_bpf_version 239 | 240 | type BpfStat C.struct_bpf_stat 241 | 242 | type BpfProgram C.struct_bpf_program 243 | 244 | type BpfInsn C.struct_bpf_insn 245 | 246 | type BpfHdr C.struct_bpf_hdr 247 | 248 | type BpfTimeval C.struct_bpf_timeval 249 | 250 | // Terminal handling 251 | 252 | type Termios C.struct_termios 253 | 254 | type Winsize C.struct_winsize 255 | 256 | // fchmodat-like syscalls. 257 | 258 | const ( 259 | AT_FDCWD = C.AT_FDCWD 260 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 261 | ) 262 | 263 | // poll 264 | 265 | type PollFd C.struct_pollfd 266 | 267 | const ( 268 | POLLERR = C.POLLERR 269 | POLLHUP = C.POLLHUP 270 | POLLIN = C.POLLIN 271 | POLLNVAL = C.POLLNVAL 272 | POLLOUT = C.POLLOUT 273 | POLLPRI = C.POLLPRI 274 | POLLRDBAND = C.POLLRDBAND 275 | POLLRDNORM = C.POLLRDNORM 276 | POLLWRBAND = C.POLLWRBAND 277 | POLLWRNORM = C.POLLWRNORM 278 | ) 279 | 280 | // Uname 281 | 282 | type Utsname C.struct_utsname 283 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace386_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(386, amd64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build 386 amd64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegs386 is the registers used by 386 binaries. 11 | type PtraceRegs386 struct { 12 | Ebx int32 13 | Ecx int32 14 | Edx int32 15 | Esi int32 16 | Edi int32 17 | Ebp int32 18 | Eax int32 19 | Xds int32 20 | Xes int32 21 | Xfs int32 22 | Xgs int32 23 | Orig_eax int32 24 | Eip int32 25 | Xcs int32 26 | Eflags int32 27 | Esp int32 28 | Xss int32 29 | } 30 | 31 | // PtraceGetRegs386 fetches the registers used by 386 binaries. 32 | func PtraceGetRegs386(pid int, regsout *PtraceRegs386) error { 33 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 34 | } 35 | 36 | // PtraceSetRegs386 sets the registers used by 386 binaries. 37 | func PtraceSetRegs386(pid int, regs *PtraceRegs386) error { 38 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 39 | } 40 | 41 | // PtraceRegsAmd64 is the registers used by amd64 binaries. 42 | type PtraceRegsAmd64 struct { 43 | R15 uint64 44 | R14 uint64 45 | R13 uint64 46 | R12 uint64 47 | Rbp uint64 48 | Rbx uint64 49 | R11 uint64 50 | R10 uint64 51 | R9 uint64 52 | R8 uint64 53 | Rax uint64 54 | Rcx uint64 55 | Rdx uint64 56 | Rsi uint64 57 | Rdi uint64 58 | Orig_rax uint64 59 | Rip uint64 60 | Cs uint64 61 | Eflags uint64 62 | Rsp uint64 63 | Ss uint64 64 | Fs_base uint64 65 | Gs_base uint64 66 | Ds uint64 67 | Es uint64 68 | Fs uint64 69 | Gs uint64 70 | } 71 | 72 | // PtraceGetRegsAmd64 fetches the registers used by amd64 binaries. 73 | func PtraceGetRegsAmd64(pid int, regsout *PtraceRegsAmd64) error { 74 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 75 | } 76 | 77 | // PtraceSetRegsAmd64 sets the registers used by amd64 binaries. 78 | func PtraceSetRegsAmd64(pid int, regs *PtraceRegsAmd64) error { 79 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 80 | } 81 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracearm_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(arm, arm64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build arm arm64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsArm is the registers used by arm binaries. 11 | type PtraceRegsArm struct { 12 | Uregs [18]uint32 13 | } 14 | 15 | // PtraceGetRegsArm fetches the registers used by arm binaries. 16 | func PtraceGetRegsArm(pid int, regsout *PtraceRegsArm) error { 17 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 18 | } 19 | 20 | // PtraceSetRegsArm sets the registers used by arm binaries. 21 | func PtraceSetRegsArm(pid int, regs *PtraceRegsArm) error { 22 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 23 | } 24 | 25 | // PtraceRegsArm64 is the registers used by arm64 binaries. 26 | type PtraceRegsArm64 struct { 27 | Regs [31]uint64 28 | Sp uint64 29 | Pc uint64 30 | Pstate uint64 31 | } 32 | 33 | // PtraceGetRegsArm64 fetches the registers used by arm64 binaries. 34 | func PtraceGetRegsArm64(pid int, regsout *PtraceRegsArm64) error { 35 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 36 | } 37 | 38 | // PtraceSetRegsArm64 sets the registers used by arm64 binaries. 39 | func PtraceSetRegsArm64(pid int, regs *PtraceRegsArm64) error { 40 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracemips_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(mips, mips64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build mips mips64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsMips is the registers used by mips binaries. 11 | type PtraceRegsMips struct { 12 | Regs [32]uint64 13 | Lo uint64 14 | Hi uint64 15 | Epc uint64 16 | Badvaddr uint64 17 | Status uint64 18 | Cause uint64 19 | } 20 | 21 | // PtraceGetRegsMips fetches the registers used by mips binaries. 22 | func PtraceGetRegsMips(pid int, regsout *PtraceRegsMips) error { 23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 24 | } 25 | 26 | // PtraceSetRegsMips sets the registers used by mips binaries. 27 | func PtraceSetRegsMips(pid int, regs *PtraceRegsMips) error { 28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 29 | } 30 | 31 | // PtraceRegsMips64 is the registers used by mips64 binaries. 32 | type PtraceRegsMips64 struct { 33 | Regs [32]uint64 34 | Lo uint64 35 | Hi uint64 36 | Epc uint64 37 | Badvaddr uint64 38 | Status uint64 39 | Cause uint64 40 | } 41 | 42 | // PtraceGetRegsMips64 fetches the registers used by mips64 binaries. 43 | func PtraceGetRegsMips64(pid int, regsout *PtraceRegsMips64) error { 44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 45 | } 46 | 47 | // PtraceSetRegsMips64 sets the registers used by mips64 binaries. 48 | func PtraceSetRegsMips64(pid int, regs *PtraceRegsMips64) error { 49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracemipsle_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(mipsle, mips64le). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build mipsle mips64le 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsMipsle is the registers used by mipsle binaries. 11 | type PtraceRegsMipsle struct { 12 | Regs [32]uint64 13 | Lo uint64 14 | Hi uint64 15 | Epc uint64 16 | Badvaddr uint64 17 | Status uint64 18 | Cause uint64 19 | } 20 | 21 | // PtraceGetRegsMipsle fetches the registers used by mipsle binaries. 22 | func PtraceGetRegsMipsle(pid int, regsout *PtraceRegsMipsle) error { 23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 24 | } 25 | 26 | // PtraceSetRegsMipsle sets the registers used by mipsle binaries. 27 | func PtraceSetRegsMipsle(pid int, regs *PtraceRegsMipsle) error { 28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 29 | } 30 | 31 | // PtraceRegsMips64le is the registers used by mips64le binaries. 32 | type PtraceRegsMips64le struct { 33 | Regs [32]uint64 34 | Lo uint64 35 | Hi uint64 36 | Epc uint64 37 | Badvaddr uint64 38 | Status uint64 39 | Cause uint64 40 | } 41 | 42 | // PtraceGetRegsMips64le fetches the registers used by mips64le binaries. 43 | func PtraceGetRegsMips64le(pid int, regsout *PtraceRegsMips64le) error { 44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 45 | } 46 | 47 | // PtraceSetRegsMips64le sets the registers used by mips64le binaries. 48 | func PtraceSetRegsMips64le(pid int, regs *PtraceRegsMips64le) error { 49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/asm_windows_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 | // 6 | // System calls for 386, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-16 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-12 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/asm_windows_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 | // 6 | // System calls for amd64, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-32 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-8 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/env_windows.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 | // Windows environment variables. 6 | 7 | package windows 8 | 9 | import "syscall" 10 | 11 | func Getenv(key string) (value string, found bool) { 12 | return syscall.Getenv(key) 13 | } 14 | 15 | func Setenv(key, value string) error { 16 | return syscall.Setenv(key, value) 17 | } 18 | 19 | func Clearenv() { 20 | syscall.Clearenv() 21 | } 22 | 23 | func Environ() []string { 24 | return syscall.Environ() 25 | } 26 | 27 | func Unsetenv(key string) error { 28 | return syscall.Unsetenv(key) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/eventlog.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 windows 6 | 7 | package windows 8 | 9 | const ( 10 | EVENTLOG_SUCCESS = 0 11 | EVENTLOG_ERROR_TYPE = 1 12 | EVENTLOG_WARNING_TYPE = 2 13 | EVENTLOG_INFORMATION_TYPE = 4 14 | EVENTLOG_AUDIT_SUCCESS = 8 15 | EVENTLOG_AUDIT_FAILURE = 16 16 | ) 17 | 18 | //sys RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) [failretval==0] = advapi32.RegisterEventSourceW 19 | //sys DeregisterEventSource(handle Handle) (err error) = advapi32.DeregisterEventSource 20 | //sys ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) = advapi32.ReportEventW 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/exec_windows.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 | // Fork, exec, wait, etc. 6 | 7 | package windows 8 | 9 | // EscapeArg rewrites command line argument s as prescribed 10 | // in http://msdn.microsoft.com/en-us/library/ms880421. 11 | // This function returns "" (2 double quotes) if s is empty. 12 | // Alternatively, these transformations are done: 13 | // - every back slash (\) is doubled, but only if immediately 14 | // followed by double quote ("); 15 | // - every double quote (") is escaped by back slash (\); 16 | // - finally, s is wrapped with double quotes (arg -> "arg"), 17 | // but only if there is space or tab inside s. 18 | func EscapeArg(s string) string { 19 | if len(s) == 0 { 20 | return "\"\"" 21 | } 22 | n := len(s) 23 | hasSpace := false 24 | for i := 0; i < len(s); i++ { 25 | switch s[i] { 26 | case '"', '\\': 27 | n++ 28 | case ' ', '\t': 29 | hasSpace = true 30 | } 31 | } 32 | if hasSpace { 33 | n += 2 34 | } 35 | if n == len(s) { 36 | return s 37 | } 38 | 39 | qs := make([]byte, n) 40 | j := 0 41 | if hasSpace { 42 | qs[j] = '"' 43 | j++ 44 | } 45 | slashes := 0 46 | for i := 0; i < len(s); i++ { 47 | switch s[i] { 48 | default: 49 | slashes = 0 50 | qs[j] = s[i] 51 | case '\\': 52 | slashes++ 53 | qs[j] = s[i] 54 | case '"': 55 | for ; slashes > 0; slashes-- { 56 | qs[j] = '\\' 57 | j++ 58 | } 59 | qs[j] = '\\' 60 | j++ 61 | qs[j] = s[i] 62 | } 63 | j++ 64 | } 65 | if hasSpace { 66 | for ; slashes > 0; slashes-- { 67 | qs[j] = '\\' 68 | j++ 69 | } 70 | qs[j] = '"' 71 | j++ 72 | } 73 | return string(qs[:j]) 74 | } 75 | 76 | func CloseOnExec(fd Handle) { 77 | SetHandleInformation(Handle(fd), HANDLE_FLAG_INHERIT, 0) 78 | } 79 | 80 | // FullPath retrieves the full path of the specified file. 81 | func FullPath(name string) (path string, err error) { 82 | p, err := UTF16PtrFromString(name) 83 | if err != nil { 84 | return "", err 85 | } 86 | n := uint32(100) 87 | for { 88 | buf := make([]uint16, n) 89 | n, err = GetFullPathName(p, uint32(len(buf)), &buf[0], nil) 90 | if err != nil { 91 | return "", err 92 | } 93 | if n <= uint32(len(buf)) { 94 | return UTF16ToString(buf[:n]), nil 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/memory_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | package windows 6 | 7 | const ( 8 | MEM_COMMIT = 0x00001000 9 | MEM_RESERVE = 0x00002000 10 | MEM_DECOMMIT = 0x00004000 11 | MEM_RELEASE = 0x00008000 12 | MEM_RESET = 0x00080000 13 | MEM_TOP_DOWN = 0x00100000 14 | MEM_WRITE_WATCH = 0x00200000 15 | MEM_PHYSICAL = 0x00400000 16 | MEM_RESET_UNDO = 0x01000000 17 | MEM_LARGE_PAGES = 0x20000000 18 | 19 | PAGE_NOACCESS = 0x01 20 | PAGE_READONLY = 0x02 21 | PAGE_READWRITE = 0x04 22 | PAGE_WRITECOPY = 0x08 23 | PAGE_EXECUTE_READ = 0x20 24 | PAGE_EXECUTE_READWRITE = 0x40 25 | PAGE_EXECUTE_WRITECOPY = 0x80 26 | ) 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/mksyscall.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 | package windows 6 | 7 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go 8 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/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 windows,race 6 | 7 | package windows 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/windows/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 windows,!race 6 | 7 | package windows 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/windows/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 windows 6 | 7 | package windows 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + itoa(-val) 12 | } 13 | var buf [32]byte // big enough for int64 14 | i := len(buf) - 1 15 | for val >= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/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 windows 6 | 7 | // Package windows 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 the OS-specific documentation for the current 10 | // system. If you want godoc to display syscall 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 | // 15 | // The primary use of this package is inside other packages that provide a more 16 | // portable interface to the system, such as "os", "time" and "net". Use 17 | // those packages rather than this one if you can. 18 | // 19 | // For details of the functions and data types in this package consult 20 | // the manuals for the appropriate operating system. 21 | // 22 | // These calls return err == nil to indicate success; otherwise 23 | // err represents an operating system error describing the failure and 24 | // holds a value of type syscall.Errno. 25 | package windows // import "golang.org/x/sys/windows" 26 | 27 | import ( 28 | "syscall" 29 | ) 30 | 31 | // ByteSliceFromString returns a NUL-terminated slice of bytes 32 | // containing the text of s. If s contains a NUL byte at any 33 | // location, it returns (nil, syscall.EINVAL). 34 | func ByteSliceFromString(s string) ([]byte, error) { 35 | for i := 0; i < len(s); i++ { 36 | if s[i] == 0 { 37 | return nil, syscall.EINVAL 38 | } 39 | } 40 | a := make([]byte, len(s)+1) 41 | copy(a, s) 42 | return a, nil 43 | } 44 | 45 | // BytePtrFromString returns a pointer to a NUL-terminated array of 46 | // bytes containing the text of s. If s contains a NUL byte at any 47 | // location, it returns (nil, syscall.EINVAL). 48 | func BytePtrFromString(s string) (*byte, error) { 49 | a, err := ByteSliceFromString(s) 50 | if err != nil { 51 | return nil, err 52 | } 53 | return &a[0], nil 54 | } 55 | 56 | // Single-word zero for use when we need a valid pointer to 0 bytes. 57 | // See mksyscall.pl. 58 | var _zero uintptr 59 | 60 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 61 | return int64(ts.Sec), int64(ts.Nsec) 62 | } 63 | 64 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 65 | return int64(tv.Sec), int64(tv.Usec) * 1000 66 | } 67 | 68 | func (ts *Timespec) Nano() int64 { 69 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 70 | } 71 | 72 | func (tv *Timeval) Nano() int64 { 73 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 74 | } 75 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/types_windows_386.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 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/types_windows_amd64.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 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | MaxSockets uint16 11 | MaxUdpDg uint16 12 | VendorInfo *byte 13 | Description [WSADESCRIPTION_LEN + 1]byte 14 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Proto *byte 21 | Port uint16 22 | } 23 | -------------------------------------------------------------------------------- /writers/always_new_file_writer.go: -------------------------------------------------------------------------------- 1 | package writers 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | "path" 8 | "path/filepath" 9 | "sort" 10 | "strings" 11 | "time" 12 | ) 13 | 14 | // AlwaysNewFileWriter create new log for every process 15 | type AlwaysNewFileWriter struct { 16 | Name string 17 | MaxCount int 18 | 19 | file *os.File 20 | } 21 | 22 | // Write implements io.Writer 23 | func (w *AlwaysNewFileWriter) Write(p []byte) (n int, err error) { 24 | if w.file == nil { 25 | w.openFile() 26 | } 27 | 28 | return w.file.Write(p) 29 | } 30 | 31 | func (w *AlwaysNewFileWriter) openFile() (err error) { 32 | name := fmt.Sprintf("%s.%s", w.Name, time.Now().Format("20060102_150405")) 33 | 34 | // remove symbol link if exist 35 | os.Remove(w.Name) 36 | 37 | // create symbol 38 | err = os.Symlink(path.Base(name), w.Name) 39 | if err != nil { 40 | return err 41 | } 42 | 43 | w.file, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0644) 44 | if err != nil { 45 | return err 46 | } 47 | 48 | if w.MaxCount > 0 { 49 | go w.cleanFiles() 50 | } 51 | 52 | return nil 53 | } 54 | 55 | // clean old files 56 | func (w *AlwaysNewFileWriter) cleanFiles() { 57 | dir := path.Dir(w.Name) 58 | 59 | fileList, err := ioutil.ReadDir(dir) 60 | if err != nil { 61 | return 62 | } 63 | 64 | prefix := path.Base(w.Name) + "." 65 | 66 | var matches []string 67 | for _, f := range fileList { 68 | if !f.IsDir() && strings.HasPrefix(f.Name(), prefix) { 69 | matches = append(matches, f.Name()) 70 | } 71 | } 72 | 73 | if len(matches) > w.MaxCount { 74 | sort.Sort(sort.Reverse(sort.StringSlice(matches))) 75 | fmt.Println(matches) 76 | 77 | for _, f := range matches[w.MaxCount:] { 78 | file := filepath.Join(dir, f) 79 | os.Remove(file) 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /writers/daily_file_writer.go: -------------------------------------------------------------------------------- 1 | package writers 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | "path" 8 | "path/filepath" 9 | "sort" 10 | "strings" 11 | "time" 12 | ) 13 | 14 | // DailyFileWriter create new log for every day 15 | type DailyFileWriter struct { 16 | Name string 17 | MaxCount int 18 | 19 | file *os.File 20 | nextDayTime int64 21 | } 22 | 23 | // Write implements io.Writer 24 | func (w *DailyFileWriter) Write(p []byte) (n int, err error) { 25 | now := time.Now() 26 | 27 | if w.file == nil { 28 | w.openFile(&now) 29 | } else if now.Unix() >= w.nextDayTime { 30 | w.file.Close() 31 | w.openFile(&now) 32 | } 33 | 34 | return w.file.Write(p) 35 | } 36 | 37 | func (w *DailyFileWriter) openFile(now *time.Time) (err error) { 38 | name := fmt.Sprintf("%s.%s", w.Name, now.Format("20060102")) 39 | 40 | // remove symbol link if exist 41 | os.Remove(w.Name) 42 | 43 | // create symbol 44 | err = os.Symlink(path.Base(name), w.Name) 45 | if err != nil { 46 | return err 47 | } 48 | 49 | w.file, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) 50 | if err != nil { 51 | return err 52 | } 53 | 54 | year, month, day := now.Date() 55 | w.nextDayTime = time.Date(year, month, day+1, 0, 0, 0, 0, now.Location()).Unix() 56 | 57 | if w.MaxCount > 0 { 58 | go w.cleanFiles() 59 | } 60 | 61 | return nil 62 | } 63 | 64 | // clean old files 65 | func (w *DailyFileWriter) cleanFiles() { 66 | dir := path.Dir(w.Name) 67 | 68 | fileList, err := ioutil.ReadDir(dir) 69 | if err != nil { 70 | return 71 | } 72 | 73 | prefix := path.Base(w.Name) + "." 74 | 75 | var matches []string 76 | for _, f := range fileList { 77 | if !f.IsDir() && strings.HasPrefix(f.Name(), prefix) { 78 | matches = append(matches, f.Name()) 79 | } 80 | } 81 | 82 | if len(matches) > w.MaxCount { 83 | sort.Sort(sort.Reverse(sort.StringSlice(matches))) 84 | 85 | for _, f := range matches[w.MaxCount:] { 86 | file := filepath.Join(dir, f) 87 | os.Remove(file) 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /writers/fixed_size_file_writer.go: -------------------------------------------------------------------------------- 1 | package writers 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | "os" 7 | "path" 8 | ) 9 | 10 | // FixedSizeFileWriter create new log if log size exceed 11 | type FixedSizeFileWriter struct { 12 | Name string 13 | MaxSize int64 14 | MaxCount int 15 | 16 | file *os.File 17 | currentSize int64 18 | } 19 | 20 | // Write implements io.Writer 21 | func (w *FixedSizeFileWriter) Write(p []byte) (n int, err error) { 22 | if w.file == nil { 23 | w.openCurrentFile() 24 | } else if w.currentSize > w.MaxSize { 25 | w.file.Close() 26 | w.openNextFile() 27 | } 28 | 29 | w.currentSize += int64(len(p)) 30 | 31 | return w.file.Write(p) 32 | } 33 | 34 | func (w *FixedSizeFileWriter) openCurrentFile() error { 35 | name, err := os.Readlink(w.Name) 36 | if err != nil { 37 | name = w.getAvailableFileName() 38 | 39 | // create a symlink 40 | err = os.Symlink(path.Base(name), w.Name) 41 | if err != nil { 42 | return err 43 | } 44 | } else { 45 | // convert to abs path 46 | name = path.Join(path.Dir(w.Name), name) 47 | } 48 | 49 | w.file, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) 50 | if err != nil { 51 | return err 52 | } 53 | 54 | stat, err := w.file.Stat() 55 | if err != nil { 56 | return err 57 | } 58 | w.currentSize = stat.Size() 59 | 60 | return nil 61 | } 62 | 63 | func (w *FixedSizeFileWriter) openNextFile() (err error) { 64 | name := w.getAvailableFileName() 65 | 66 | // remove symbol link 67 | err = os.Remove(w.Name) 68 | if err != nil { 69 | return err 70 | } 71 | 72 | // create symbol 73 | err = os.Symlink(path.Base(name), w.Name) 74 | if err != nil { 75 | return err 76 | } 77 | 78 | w.file, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644) 79 | if err != nil { 80 | return err 81 | } 82 | 83 | w.currentSize = 0 84 | 85 | return nil 86 | } 87 | 88 | // get available file or oldest file 89 | func (w *FixedSizeFileWriter) getAvailableFileName() string { 90 | var oldestTime int64 = math.MaxInt64 91 | var oldestName string 92 | 93 | for i := 0; i < w.MaxCount; i++ { 94 | name := fmt.Sprintf("%s.%d", w.Name, i) 95 | stat, err := os.Stat(name) 96 | if err != nil { 97 | return name 98 | } 99 | 100 | if fTime := stat.ModTime().Unix(); fTime < oldestTime { 101 | oldestTime = fTime 102 | oldestName = name 103 | } 104 | } 105 | 106 | return oldestName 107 | } 108 | --------------------------------------------------------------------------------