├── .gitignore ├── .golangci.yml ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── _doc └── wiki.1 ├── cmd └── wiki │ └── main.go ├── doc.go ├── go.mod ├── go.sum ├── integration-tests.sh ├── request.go ├── request_test.go ├── response.go └── vendor ├── github.com ├── kr │ └── text │ │ ├── License │ │ ├── Readme │ │ ├── doc.go │ │ ├── go.mod │ │ ├── indent.go │ │ └── wrap.go └── mattn │ ├── go-colorable │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── colorable_appengine.go │ ├── colorable_others.go │ ├── colorable_windows.go │ ├── go.mod │ ├── go.sum │ └── noncolorable.go │ └── go-isatty │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── doc.go │ ├── go.mod │ ├── go.sum │ ├── isatty_android.go │ ├── isatty_bsd.go │ ├── isatty_others.go │ ├── isatty_solaris.go │ ├── isatty_tcgets.go │ └── isatty_windows.go ├── golang.org └── x │ └── sys │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ └── unix │ ├── .gitignore │ ├── README.md │ ├── affinity_linux.go │ ├── aliases.go │ ├── asm_aix_ppc64.s │ ├── 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_freebsd_arm64.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_netbsd_arm64.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_aix_ppc.go │ ├── dev_aix_ppc64.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_darwin.go │ ├── fcntl_linux_32bit.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── ioctl.go │ ├── mkall.sh │ ├── mkerrors.sh │ ├── mksysctl_openbsd.pl │ ├── openbsd_pledge.go │ ├── openbsd_unveil.go │ ├── pagesize_unix.go │ ├── race.go │ ├── race0.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── str.go │ ├── syscall.go │ ├── syscall_aix.go │ ├── syscall_aix_ppc.go │ ├── syscall_aix_ppc64.go │ ├── syscall_bsd.go │ ├── syscall_darwin.go │ ├── syscall_darwin_386.go │ ├── syscall_darwin_amd64.go │ ├── syscall_darwin_arm.go │ ├── syscall_darwin_arm64.go │ ├── syscall_darwin_libSystem.go │ ├── syscall_dragonfly.go │ ├── syscall_dragonfly_amd64.go │ ├── syscall_freebsd.go │ ├── syscall_freebsd_386.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_freebsd_arm.go │ ├── syscall_freebsd_arm64.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_gc_386.go │ ├── syscall_linux_gccgo_386.go │ ├── syscall_linux_gccgo_arm.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_mipsx.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_linux_riscv64.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_netbsd_arm64.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 │ ├── syscall_unix_gc_ppc64x.go │ ├── timestruct.go │ ├── xattr_bsd.go │ ├── zerrors_aix_ppc.go │ ├── zerrors_aix_ppc64.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_freebsd_arm64.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_riscv64.go │ ├── zerrors_linux_s390x.go │ ├── zerrors_linux_sparc64.go │ ├── zerrors_netbsd_386.go │ ├── zerrors_netbsd_amd64.go │ ├── zerrors_netbsd_arm.go │ ├── zerrors_netbsd_arm64.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_aix_ppc.go │ ├── zsyscall_aix_ppc64.go │ ├── zsyscall_aix_ppc64_gc.go │ ├── zsyscall_aix_ppc64_gccgo.go │ ├── zsyscall_darwin_386.1_11.go │ ├── zsyscall_darwin_386.go │ ├── zsyscall_darwin_386.s │ ├── zsyscall_darwin_amd64.1_11.go │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_amd64.s │ ├── zsyscall_darwin_arm.1_11.go │ ├── zsyscall_darwin_arm.go │ ├── zsyscall_darwin_arm.s │ ├── zsyscall_darwin_arm64.1_11.go │ ├── zsyscall_darwin_arm64.go │ ├── zsyscall_darwin_arm64.s │ ├── zsyscall_dragonfly_amd64.go │ ├── zsyscall_freebsd_386.go │ ├── zsyscall_freebsd_amd64.go │ ├── zsyscall_freebsd_arm.go │ ├── zsyscall_freebsd_arm64.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_riscv64.go │ ├── zsyscall_linux_s390x.go │ ├── zsyscall_linux_sparc64.go │ ├── zsyscall_netbsd_386.go │ ├── zsyscall_netbsd_amd64.go │ ├── zsyscall_netbsd_arm.go │ ├── zsyscall_netbsd_arm64.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_freebsd_arm64.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_riscv64.go │ ├── zsysnum_linux_s390x.go │ ├── zsysnum_linux_sparc64.go │ ├── zsysnum_netbsd_386.go │ ├── zsysnum_netbsd_amd64.go │ ├── zsysnum_netbsd_arm.go │ ├── zsysnum_netbsd_arm64.go │ ├── zsysnum_openbsd_386.go │ ├── zsysnum_openbsd_amd64.go │ ├── zsysnum_openbsd_arm.go │ ├── ztypes_aix_ppc.go │ ├── ztypes_aix_ppc64.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_freebsd_arm64.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_riscv64.go │ ├── ztypes_linux_s390x.go │ ├── ztypes_linux_sparc64.go │ ├── ztypes_netbsd_386.go │ ├── ztypes_netbsd_amd64.go │ ├── ztypes_netbsd_arm.go │ ├── ztypes_netbsd_arm64.go │ ├── ztypes_openbsd_386.go │ ├── ztypes_openbsd_amd64.go │ ├── ztypes_openbsd_arm.go │ └── ztypes_solaris_amd64.go └── modules.txt /.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /cmd/wiki/wiki 3 | /wiki* 4 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | run: 2 | deadline: 60s 3 | 4 | linters: 5 | enable-all: true 6 | 7 | linters-settings: 8 | goimports: 9 | local-prefixes: github.com/walle/wiki 10 | maligned: 11 | suggest-new: true 12 | dupl: 13 | threshold: 400 14 | lll: 15 | line-length: 80 16 | gocyclo: 17 | min-complexity: 15 18 | golint: 19 | min-confidence: 0.85 -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - "1.13" 5 | 6 | install: 7 | - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b ${GOPATH}/bin v1.19.1 8 | 9 | script: 10 | - make lint 11 | - make test 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | This project adheres to [Semantic Versioning](http://semver.org/). 5 | 6 | ## [1.4.1] - 2017-01-28 7 | ### Changes 8 | - Vendor dependencies and use `go mod`. 9 | 10 | ## [1.4.0] - 2017-01-28 11 | ### Changes 12 | - Add support for `-w` flag to wrap the output at a given width. 13 | 14 | ## [1.3.0] - 2015-10-09 15 | ### Changes 16 | - Add support for the `WIKI_LANG` and `WIKI_URL` environment variables. 17 | - Add support for colored output on Windows. 18 | 19 | ## [1.2.0] - 2015-10-07 20 | ### Changes 21 | - Add the `-short` flag to output only the first sentence of the excerpt. 22 | - Urldecode the link to page in output. 23 | - Remove the automatic capitalization of the query. 24 | 25 | ## [1.1.0] - 2015-10-07 26 | ### Changes 27 | - Add the `-no-check-certificate` flag for bypassing SSL certificate check. 28 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Issues 4 | 5 | When opening issues, try to be as clear as possible when describing the bug or 6 | feature request. Tag the issue accordingly. 7 | 8 | ## Pull Requests 9 | 10 | ### Hack on wiki 11 | 12 | 1. Install as usual (`go get github.com/walle/wiki`) 13 | 2. Write code and tests for your new feature 14 | 3. Ensure everything works and the tests pass (see below) 15 | 4. Consider contributing your code upstream 16 | 17 | ### Contribute upstream 18 | 19 | 1. Fork wiki on GitHub 20 | 2. Add your fork (`git remote add fork git@github.com:myuser/wiki.git`) 21 | 3. Checkout your fork (`git checkout -t fork/master`) 22 | 4. Create your feature branch (`git checkout -b my-new-feature`) 23 | 5. Write code and tests for your new feature 24 | 6. Rebase against upstream to get changes (`git fetch origin && git rebase origin/master`) 25 | 7. Ensure everything works and the tests pass (see below) 26 | 8. Commit your changes 27 | 9. Push the branch to github (`git push fork my-new-feature`) 28 | 10. Create a new Pull Request on GitHub 29 | 30 | Notice: Always use the original import path by installing with `go get`. 31 | 32 | ## Testing 33 | 34 | To run the test suite use the command 35 | 36 | ```shell 37 | $ make test 38 | ``` 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Fredrik Wallgren 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TARGET = wiki 2 | PREFIX ?= /usr/local 3 | MANPREFIX ?= "$(PREFIX)/share/man/man1" 4 | VERSION="1.4.1" 5 | BUILD_DIR="build" 6 | BUILD_TARGET="$(BUILD_DIR)/$(TARGET)" 7 | DIST="$(TARGET)-$(VERSION)" 8 | DIST_TARGET="$(DIST).tar.gz" 9 | DIST_SRC="$(TARGET)-src-$(VERSION)" 10 | DIST_SRC_TARGET="$(DIST_SRC).tar.gz" 11 | 12 | .PHONY: default all install lint uninstall dist dist-src clean 13 | 14 | default: $(BUILD_TARGET) 15 | all: clean test dist dist-src 16 | 17 | $(BUILD_TARGET): 18 | CGO_ENABLED=0 go build -mod=vendor -ldflags "-w -X main.Version=${VERSION}" -o $(BUILD_TARGET) cmd/wiki/*.go 19 | 20 | clean: 21 | -rm -r $(BUILD_DIR) 22 | -rm -r $(DIST) 23 | -rm -r $(DIST_TARGET) 24 | -rm -r $(DIST_SRC) 25 | -rm -r $(DIST_SRC_TARGET) 26 | 27 | lint: 28 | golangci-lint run ./... 29 | 30 | test: $(BUILD_TARGET) 31 | go test -mod=vendor -cover 32 | ./integration-tests.sh 33 | 34 | install: 35 | go install -mod=vendor github.com/walle/wiki/cmd/wiki 36 | install _doc/wiki.1 $(MANPREFIX) 37 | 38 | uninstall: 39 | which $(TARGET) | xargs rm 40 | -rm -f $(MANPREFIX)/wiki.1 41 | 42 | dist: $(BUILD_TARGET) 43 | mkdir $(DIST) 44 | cp -r $(BUILD_TARGET) LICENSE README.md _doc $(DIST) 45 | tar cfz $(DIST_TARGET) $(DIST) 46 | 47 | dist-src: 48 | mkdir $(DIST_SRC) 49 | cp -r _doc cmd LICENSE README.md *.go integration-tests.sh Makefile $(DIST_SRC) 50 | tar cfz $(DIST_SRC_TARGET) $(DIST_SRC) 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://img.shields.io/travis/walle/wiki.svg?style=flat)](https://travis-ci.org/walle/wiki) 2 | [![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/walle/wiki) 3 | [![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/walle/wiki/master/LICENSE) 4 | [![Go Report Card](https://goreportcard.com/badge/walle/wiki)](http:/goreportcard.com/report/walle/wiki) 5 | 6 | # wiki 7 | 8 | Command line tool to get Wikipedia summaries. 9 | 10 | The tool can fetch summaries from any MediaWiki wiki with the API active, but 11 | defaults to the English Wikipedia. 12 | 13 | ## Installation 14 | 15 | To be able to install with `go get` requires you to have your `$GOPATH` setup 16 | and your `$GOPATH/bin` added to path as described here 17 | http://golang.org/doc/code.html#GOPATH. 18 | 19 | If you don't want the man file you can just install it with `go get`. 20 | 21 | ```shell 22 | $ go get github.com/walle/wiki/cmd/wiki 23 | ``` 24 | 25 | If you want to install the man file you can install with `go get`, 26 | but then use the `make install` command from the source directory. 27 | 28 | ```shell 29 | $ go get github.com/walle/wiki 30 | $ cd $GOPATH/src/github.com/walle/wiki 31 | $ make install 32 | ``` 33 | 34 | or just copy the man file in `_doc/wiki.1` to `/usr/local/share/man/man1` or 35 | where you keep your man files. 36 | 37 | ## Usage 38 | 39 | To get a summary from Wikipedia in English just invoke the tool with a query. 40 | 41 | ```shell 42 | $ wiki golang 43 | Redirected from Golang to Go (programming language) 44 | 45 | Go, also commonly referred to as golang, is a programming language developed at Google in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. It is a statically typed language with syntax loosely derived from that of C, adding garbage collection, type safety, some structural typing capabilities, additional built-in types such as variable-length arrays & key-value maps, and a large standard library. 46 | The language was announced in November 2009 and is now used in some of Google's production systems. Go's "gc" compiler targets the Linux, OS X, FreeBSD, NetBSD, OpenBSD, Plan 9, DragonFly BSD, Solaris, and Windows operating systems and the i386, Amd64, ARM and IBM POWER processor architectures. A second compiler, gccgo, is a GCC frontend. 47 | Android support was added in version 1.4, which has since been ported to also run on iOS. 48 | 49 | Read more: https://en.wikipedia.org/wiki/Go_(programming_language) 50 | ``` 51 | 52 | To get a localized result, e.g. in Swedish use the -l flag. 53 | 54 | ```shell 55 | $ wiki -l sv ruby 56 | ``` 57 | 58 | or using System Environment: 59 | 60 | ```shell 61 | $ WIKI_LANG="sv" wiki ruby 62 | ``` 63 | 64 | Use the -h flag to see all options (or `man wiki` if you have it installed) 65 | 66 | ```shell 67 | $wiki -h 68 | wiki is a tool used to fetch exerpts from wikipedia 69 | Usage: wiki [options...] query 70 | Options: 71 | 72 | -h Print help information and exit. 73 | -l string 74 | The language to use (default "en") 75 | -n If the output should not be colorized 76 | -no-check-certificate 77 | Skip verification of certificates 78 | -s If simple output should be used 79 | -short 80 | If short output should be used 81 | -u string 82 | The api url (default "https://%s.wikipedia.org/w/api.php") 83 | -version 84 | Print version information and exit. 85 | -w int 86 | The width text should be wrapped at. 0 is no wrap. 87 | ``` 88 | 89 | ### Use another wiki 90 | 91 | To get excerpts from another wiki use the -u flag to give another url to the 92 | API to use. 93 | 94 | ```shell 95 | $ wiki -u https://en.wikiversity.org/w/api.php physics 96 | ``` 97 | 98 | This gives the excerpt from the wiki at wikiversity.org instead of Wikipedia. 99 | 100 | #### Advice 101 | 102 | If you frequently use the tool to fetch data from a custom url, add an alias. 103 | E.g. for bash. Add an alias to your `.bash_profile` or `.bashrc` file. 104 | 105 | ```bash 106 | alias uwiki='wiki -u https://en.wikiversity.org/w/api.php ' 107 | ``` 108 | And call it using 109 | 110 | ```shell 111 | $ uwiki physics 112 | ``` 113 | 114 | or using System Environment in your `.bash_profile` or `.bashrc`file. 115 | 116 | ```bash 117 | echo "export WIKI_URL=https://en.wikiversity.org/w/api.php" >> .bashrc 118 | # reload shell / source .bashrc 119 | wiki physics 120 | ``` 121 | 122 | ## Testing 123 | 124 | Run the tests using the make target test `make test`, this runs both the unit and 125 | the integration tests. For running only one type of tests use `go test -cover` 126 | and `./integration-tests.sh` respectively. 127 | 128 | ```shell 129 | $ make test 130 | ``` 131 | 132 | ## Contributing 133 | 134 | All contributions are welcome! See [CONTRIBUTING](CONTRIBUTING.md) for more 135 | info. 136 | 137 | ## License 138 | 139 | The code is under the MIT license. See [LICENSE](LICENSE) for more 140 | information. 141 | -------------------------------------------------------------------------------- /_doc/wiki.1: -------------------------------------------------------------------------------- 1 | .\" Manpage for wiki. 2 | .\" Contact fredrik.wallgren@gmail.com to correct errors or typos. 3 | .TH man 1 "09 Oct 2015" "1.3.0" "wiki man page" 4 | .SH NAME 5 | wiki \- get excerpts from MediaWiki wikis e.g. Wikipedia 6 | .SH SYNOPSIS 7 | .B wiki 8 | [OPTIONS] query 9 | .SH DESCRIPTION 10 | .B wiki 11 | get excerpts from MediaWiki wikis that has the API running. 12 | Default wiki is Wikipedia. 13 | Use the language flag `-l` to get excerpts in any language 14 | supported by the wiki. Default language is English (en). 15 | .SH OPTIONS 16 | .TP 17 | .BR \-l " " \fR \fILANGUAGE\fR 18 | Fetch articles in language. The language is added to the URL of the API. 19 | For Wikipedia the language string used is the ISO 639-1 code. 20 | For Swedish it is sv and for English en and so on. 21 | .TP 22 | .BR \-n 23 | Disables the color in output. 24 | .TP 25 | .BR \-w " " \fR \fIWRAP_WIDTH\fR 26 | Sets the width to wrap text at. Default is 0, no wrapping. 27 | .TP 28 | .BR \-no-check-certificate 29 | Disables the security check of certificates. 30 | You can use this to bypass self signed certificates on your wiki. 31 | .TP 32 | .BR \-s 33 | Simple output. Only the excerpt is outputted, no information about 34 | redirects or a link to the page is outputted. 35 | .TP 36 | .BR \-short 37 | Short output. Only the first line of the excerpt is outputted, no information 38 | about redirects or a link to the page is outputted. 39 | .TP 40 | .BR \-u " " \fR \fIURL\fR 41 | The URL to the API. Defaults to Wikipedias API URL. 42 | The language selected with the -l flag can be interpolated in the URL by 43 | supplying a `%s` in the url. 44 | E.g. https://%s.wikipedia.org/w/api.php The %s is substituted with 45 | the language selected with the -l flag. 46 | .TP 47 | .BR \-h 48 | Outputs help information and exists 49 | .TP 50 | .BR \-version " 51 | Outputs version information and exists 52 | .SH ENVIRONMENT 53 | Setting any of this variables will override the default application values. 54 | .TP 55 | .BR WIKI_LANG 56 | Override default LANGUAGE 57 | .TP 58 | .BR WIKI_URL 59 | Override default URL 60 | .SH EXAMPLES 61 | WIKI_LANG=sv wiki Software 62 | 63 | WIKI_URL=https://wiki.secret-stuff.com/w/api.php wiki SecretSystem 64 | .SH AUTHOR 65 | Fredrik Wallgren (fredrik.wallgren@gmail.com) 66 | -------------------------------------------------------------------------------- /cmd/wiki/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "flag" 6 | "fmt" 7 | "io" 8 | "os" 9 | "strings" 10 | 11 | "github.com/kr/text" 12 | "github.com/mattn/go-colorable" 13 | 14 | "github.com/walle/wiki" 15 | ) 16 | 17 | var Version = "1.4.1" // nolint:gochecknoglobals 18 | 19 | // Exit statuses for the tool. 20 | const ( 21 | UsageErrorExitStatus = 1 22 | NoSuchPageExitStatus = 2 23 | RequestErrorExitStatus = 3 24 | ParsingErrorExitStatus = 4 25 | SuccessExitStatus = 0 26 | ) 27 | 28 | func main() { 29 | flag.Usage = func() { 30 | fmt.Fprintln(os.Stderr, `wiki is a tool used to fetch excerpts from wikipedia 31 | Usage: wiki [options...] query 32 | Options:`) 33 | flag.PrintDefaults() 34 | } 35 | 36 | defLang, defURL := handleDefaults() 37 | 38 | language := flag.String("l", defLang, "The language to use") 39 | url := flag.String("u", defURL, "The api url") 40 | noColor := flag.Bool("n", false, "If the output should not be colorized") 41 | simple := flag.Bool("s", false, "If simple output should be used") 42 | short := flag.Bool("short", false, "If short output should be used") 43 | wrap := flag.Int("w", 0, "The width text should be wrapped at. 0 is no wrap.") 44 | noCheckCert := flag.Bool( 45 | "no-check-certificate", 46 | false, 47 | "Skip verification of certificates", 48 | ) 49 | help := flag.Bool("h", false, "Print help information and exit.") 50 | version := flag.Bool("version", false, "Print version information and exit.") 51 | 52 | flag.Parse() 53 | 54 | handleFlags(version, help) 55 | 56 | page := getPage(url, language, noCheckCert) 57 | 58 | if page.Content == "" { 59 | fmt.Fprintln(os.Stderr, "No such page") 60 | if !*simple { 61 | fmt.Printf("Create it on: %s\n", page.URL) 62 | } 63 | os.Exit(NoSuchPageExitStatus) 64 | } 65 | 66 | var buf bytes.Buffer 67 | switch { 68 | case *simple: 69 | printPageSimple(page, &buf) 70 | case *short: 71 | printPageShort(page, &buf) 72 | case *noColor: 73 | printPagePlain(page, &buf) 74 | default: 75 | printPageColor(page, &buf) 76 | } 77 | 78 | out := colorable.NewColorableStdout() 79 | if *wrap > 0 { 80 | paragraphs := strings.Split(buf.String(), "\n\n") 81 | for _, p := range paragraphs { 82 | fmt.Fprintln(out, text.Wrap(p, *wrap)) 83 | } 84 | os.Exit(SuccessExitStatus) 85 | } 86 | 87 | fmt.Fprintln(out, buf.String()) 88 | os.Exit(SuccessExitStatus) 89 | } 90 | 91 | func handleDefaults() (string, string) { 92 | defLang := os.Getenv("WIKI_LANG") 93 | defURL := os.Getenv("WIKI_URL") 94 | if defLang == "" { 95 | defLang = "en" 96 | } 97 | if defURL == "" { 98 | defURL = "https://%s.wikipedia.org/w/api.php" 99 | } 100 | return defLang, defURL 101 | } 102 | 103 | func handleFlags(version *bool, help *bool) { 104 | if *version { 105 | fmt.Fprintf(os.Stdout, "wiki %s\n", Version) 106 | os.Exit(SuccessExitStatus) 107 | } 108 | 109 | if *help { 110 | flag.Usage() 111 | os.Exit(SuccessExitStatus) 112 | } 113 | 114 | if flag.NArg() == 0 { 115 | flag.Usage() 116 | os.Exit(UsageErrorExitStatus) 117 | } 118 | } 119 | 120 | func getPage(url, language *string, noCheckCert *bool) *wiki.Page { 121 | query := strings.Join(flag.Args(), " ") 122 | req, err := wiki.NewRequest(*url, query, *language) 123 | if err != nil { 124 | fmt.Fprintf(os.Stderr, "Could not create request %s\n", err) 125 | os.Exit(RequestErrorExitStatus) 126 | } 127 | 128 | resp, err := req.Execute(*noCheckCert) 129 | if err != nil { 130 | fmt.Fprintf(os.Stderr, "Could not execute request %s\n", err) 131 | os.Exit(RequestErrorExitStatus) 132 | } 133 | 134 | page, err := resp.Page() 135 | if err != nil { 136 | fmt.Fprintf(os.Stderr, "Could not parse data %s\n", err) 137 | os.Exit(ParsingErrorExitStatus) 138 | } 139 | 140 | return page 141 | } 142 | 143 | func printPagePlain(page *wiki.Page, w io.Writer) { 144 | if page.Redirect != nil { 145 | fmt.Fprintf(w, "Redirected from %s to %s\n\n", 146 | page.Redirect.From, 147 | page.Redirect.To, 148 | ) 149 | } 150 | fmt.Fprintln(w, page.Content) 151 | fmt.Fprintf(w, "\nRead more: %s\n", page.URL) 152 | } 153 | 154 | func printPageSimple(page *wiki.Page, w io.Writer) { 155 | fmt.Fprintln(w, page.Content) 156 | } 157 | 158 | func printPageShort(page *wiki.Page, w io.Writer) { 159 | fmt.Fprintln(w, page.Content[:strings.Index(page.Content, ".")+1]) 160 | } 161 | 162 | func printPageColor(page *wiki.Page, w io.Writer) { 163 | if page.Redirect != nil { 164 | fmt.Fprintf(w, 165 | "\x1b[31m"+ 166 | "Redirected from "+ 167 | "\x1b[41;37m%s\x1b[49;31m to \x1b[41;37m%s"+ 168 | "\x1b[0m"+ 169 | "\n\n", 170 | page.Redirect.From, 171 | page.Redirect.To, 172 | ) 173 | } 174 | fmt.Fprintln(w, page.Content) 175 | fmt.Fprintf(w, "\n\x1b[32mRead more: %s\x1b[0m\n", page.URL) 176 | } 177 | -------------------------------------------------------------------------------- /doc.go: -------------------------------------------------------------------------------- 1 | // Package wiki contains functionality to fetch extracts from a MediaWiki api. 2 | package wiki 3 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/walle/wiki 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/kr/text v0.1.0 7 | github.com/mattn/go-colorable v0.1.4 8 | ) 9 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 2 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 3 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 4 | github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= 5 | github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= 6 | github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= 7 | github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 8 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8= 9 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 10 | -------------------------------------------------------------------------------- /integration-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Keep track of failures 4 | FAILED=0 5 | 6 | # Output a fail message 7 | fail() { 8 | echo '' 9 | echo 'FAIL' 10 | echo $1 11 | let "FAILED += 1" 12 | } 13 | 14 | # Show progress when tests pass 15 | pass() { 16 | echo -n '.' 17 | } 18 | 19 | # Output a message and return with no error when all tests has passed 20 | finished() { 21 | echo '' 22 | if [[ $FAILED -ne 0 ]]; then 23 | echo 'There were failed integration tests' 24 | else 25 | echo 'All integration tests passed' 26 | fi 27 | exit $FAILED 28 | } 29 | 30 | # Bin to use in tests 31 | BIN=./build/wiki 32 | 33 | # Test that error message and usage is printed if no query 34 | $BIN > /dev/null 2>&1 35 | STATUS=$? 36 | if [[ $STATUS -ne 1 ]]; then 37 | fail 'Error message and usage not printed if no output' 38 | exit 1 39 | fi 40 | pass 41 | 42 | # Test that standard usage prints a link to page 43 | OUTPUT="$($BIN golang)" 44 | STATUS=$? 45 | if [[ $STATUS -ne 0 ]]; then 46 | fail 'Did not get success exit code' 47 | exit 1 48 | fi 49 | echo "$OUTPUT" | grep -q "Read more: https://en.wikipedia.org/wiki/Go" 50 | if [ $? -ne 0 ];then 51 | fail 'Standard usage did not output link to page' 52 | fi 53 | pass 54 | 55 | # Test that short flag does not print a link to page 56 | OUTPUT="$($BIN -s golang)" 57 | STATUS=$? 58 | if [[ $STATUS -ne 0 ]]; then 59 | fail 'Did not get success exit code' 60 | exit 1 61 | fi 62 | echo "$OUTPUT" | grep -q "Read more: https://en.wikipedia.org/wiki/Go" 63 | if [ $? -eq 0 ];then 64 | fail 'Short flag did output link to page' 65 | fi 66 | pass 67 | 68 | # Test that language flag works 69 | OUTPUT="$($BIN -l sv c++)" 70 | STATUS=$? 71 | if [[ $STATUS -ne 0 ]]; then 72 | fail 'Did not get success exit code' 73 | exit 1 74 | fi 75 | echo "$OUTPUT" | grep -q "Read more: https://sv.wikipedia.org/wiki/C" 76 | if [ $? -ne 0 ];then 77 | fail 'Language flag did not work' 78 | fi 79 | pass 80 | 81 | # Test that language enviroment works 82 | OUTPUT="$(WIKI_LANG=sv $BIN c++)" 83 | STATUS=$? 84 | if [[ $STATUS -ne 0 ]]; then 85 | fail 'Did not get success exit code' 86 | exit 1 87 | fi 88 | echo "$OUTPUT" | grep -q "Read more: https://sv.wikipedia.org/wiki/C" 89 | if [ $? -ne 0 ];then 90 | fail 'Language flag did not work' 91 | fi 92 | pass 93 | 94 | # Test that no color flag works 95 | OUTPUT="$($BIN -n golang)" 96 | STATUS=$? 97 | if [[ $STATUS -ne 0 ]]; then 98 | fail 'Did not get success exit code' 99 | exit 1 100 | fi 101 | echo "$OUTPUT" | grep -q "\[32m" 102 | if [ $? -eq 0 ];then 103 | fail 'No color flag did not work' 104 | fi 105 | pass 106 | 107 | # Test that url flag works 108 | OUTPUT="$($BIN -u http://localhost:8080/w/api.php golang 2>&1)" 109 | STATUS=$? 110 | if [[ $STATUS -eq 0 ]]; then 111 | fail 'Got success exit code' 112 | exit 1 113 | fi 114 | echo "$OUTPUT" | grep -q "Could not execute request Get http://localhost:8080" 115 | if [ $? -ne 0 ];then 116 | fail 'Url flag did not work' 117 | fi 118 | pass 119 | 120 | #Test URL passed as enviroment 121 | OUTPUT="$(WIKI_URL=http://localhost:8080/w/api.php $BIN golang 2>&1)" 122 | STATUS=$? 123 | if [[ $STATUS -eq 0 ]]; then 124 | fail 'Got success exit code' 125 | exit 1 126 | fi 127 | echo "$OUTPUT" | grep -q "Could not execute request Get http://localhost:8080" 128 | if [ $? -ne 0 ];then 129 | fail 'Url flag did not work' 130 | fi 131 | pass 132 | 133 | # Test that no-check-certificate flag works 134 | OUTPUT="$($BIN -no-check-certificate golang)" 135 | STATUS=$? 136 | if [[ $STATUS -ne 0 ]]; then 137 | fail 'Did not get success exit code' 138 | exit 1 139 | fi 140 | echo "$OUTPUT" | grep -q "Read more: https://en.wikipedia.org/wiki/Go" 141 | if [ $? -ne 0 ];then 142 | fail 'Standard usage did not output link to page' 143 | fi 144 | pass 145 | 146 | # Test that short flag works 147 | OUTPUT="$($BIN -short golang)" 148 | STATUS=$? 149 | if [[ $STATUS -ne 0 ]]; then 150 | fail 'Did not get success exit code' 151 | exit 1 152 | fi 153 | OUTPUT2="$(echo $OUTPUT | grep -c '.')" 154 | if [ $OUTPUT2 -ne 1 ];then 155 | fail 'Short flag did not work' 156 | fi 157 | pass 158 | 159 | # Test that wrap flag works 160 | OUTPUT="$($BIN -w 80 golang)" 161 | STATUS=$? 162 | if [[ $STATUS -ne 0 ]]; then 163 | fail 'Did not get success exit code' 164 | exit 1 165 | fi 166 | OUTPUT2="$(echo $OUTPUT | grep -c '.')" 167 | if [ $OUTPUT2 -ne 1 ];then 168 | fail 'Wrap flag did not work' 169 | fi 170 | pass 171 | 172 | finished 173 | -------------------------------------------------------------------------------- /request.go: -------------------------------------------------------------------------------- 1 | package wiki 2 | 3 | import ( 4 | "crypto/tls" 5 | "encoding/json" 6 | "fmt" 7 | "net/http" 8 | "net/url" 9 | "strings" 10 | ) 11 | 12 | // Request sets up the request against the api with the correct parameters 13 | // and has functionality to fetch the data and convert it to a response. 14 | type Request struct { 15 | *url.URL 16 | } 17 | 18 | // NewRequest creates a new request against baseURL for language. 19 | // Language is interpolated in the baseURL if asked, if not it is ignored. 20 | // Query is the title of the page to fetch. 21 | // Returns an error if the URL can not be parsed. 22 | func NewRequest(baseURL, query, language string) (*Request, error) { 23 | if strings.Contains(baseURL, "%s") { 24 | baseURL = fmt.Sprintf(baseURL, language) 25 | } 26 | url, err := url.Parse(baseURL) 27 | if err != nil { 28 | return nil, err 29 | } 30 | v := url.Query() 31 | v.Set("action", "query") 32 | v.Set("prop", "extracts|info") 33 | v.Set("format", "json") 34 | v.Set("exintro", "") 35 | v.Set("explaintext", "") 36 | v.Set("inprop", "url") 37 | v.Set("redirects", "") 38 | v.Set("converttitles", "") 39 | v.Set("titles", query) 40 | url.RawQuery = v.Encode() 41 | 42 | return &Request{url}, nil 43 | } 44 | 45 | // Execute fetches the data and decodes it into a Response. 46 | // Returns an error if the data could not be retrieved or the decoding fails. 47 | func (r *Request) Execute(noCheckCert bool) (*Response, error) { 48 | client := &http.Client{} 49 | 50 | if noCheckCert { 51 | tr := &http.Transport{ 52 | TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec 53 | } 54 | client = &http.Client{Transport: tr} 55 | } 56 | 57 | response, err := client.Get(r.String()) 58 | if err != nil { 59 | return nil, err 60 | } 61 | defer response.Body.Close() 62 | 63 | d := json.NewDecoder(response.Body) 64 | resp := &Response{} 65 | err = d.Decode(resp) 66 | if err != nil { 67 | return nil, err 68 | } 69 | 70 | return resp, nil 71 | } 72 | -------------------------------------------------------------------------------- /request_test.go: -------------------------------------------------------------------------------- 1 | package wiki_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/walle/wiki" 7 | ) 8 | 9 | func Test_NewRequestLanguageInterpolation(t *testing.T) { 10 | r, err := wiki.NewRequest("example.com", "Test", "sv") 11 | if err != nil { 12 | t.Errorf("Could not create request: %s\n", err) 13 | } 14 | 15 | expected := "example.com?action=query&converttitles=&exintro=&explaintext=" + 16 | "&format=json&inprop=url&prop=extracts%7Cinfo&redirects=&titles=Test" 17 | if r.String() != expected { 18 | t.Errorf("Expected %s got %s", expected, r.String()) 19 | } 20 | 21 | r, err = wiki.NewRequest("%s.example.com", "Test", "sv") 22 | if err != nil { 23 | t.Errorf("Could not create request: %s\n", err) 24 | } 25 | 26 | expected = "sv.example.com?action=query&converttitles=&exintro=" + 27 | "&explaintext=&format=json&inprop=url&prop=extracts%7Cinfo" + 28 | "&redirects=&titles=Test" 29 | if r.String() != expected { 30 | t.Errorf("Expected %s got %s", expected, r.String()) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /response.go: -------------------------------------------------------------------------------- 1 | package wiki 2 | 3 | import ( 4 | "net/url" 5 | "strings" 6 | "time" 7 | ) 8 | 9 | // Page contains the parsed data. 10 | type Page struct { 11 | ID int 12 | Title string 13 | Content string 14 | Language string 15 | URL string 16 | Redirect *redirect 17 | } 18 | 19 | // Response contains the raw data the API returns. 20 | type Response struct { 21 | Batchcomplete string 22 | Query query 23 | } 24 | 25 | // Page parses the raw data and returns a Page with the relevant data. 26 | func (r *Response) Page() (*Page, error) { 27 | page := &Page{} 28 | 29 | if len(r.Query.Redirects) > 0 { 30 | page.Redirect = &r.Query.Redirects[0] 31 | } 32 | 33 | for _, p := range r.Query.Pages { 34 | url, err := url.QueryUnescape(p.Canonicalurl) 35 | if err != nil { 36 | url = p.Canonicalurl 37 | } 38 | page.ID = p.Pageid 39 | page.Title = p.Title 40 | page.Content = strings.Replace(p.Extract, "\n", "\n\n", -1) 41 | page.Language = p.Pagelanguage 42 | page.URL = url 43 | 44 | break 45 | } 46 | 47 | return page, nil 48 | } 49 | 50 | type query struct { 51 | Redirects []redirect 52 | Pages map[string]page 53 | } 54 | 55 | type redirect struct { 56 | From string 57 | To string 58 | } 59 | 60 | type page struct { 61 | Pageid int 62 | Ns int 63 | Title string 64 | Extract string 65 | Contentmodel string 66 | Pagelanguage string 67 | Touched time.Time 68 | Fullurl string 69 | Canonicalurl string 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/kr/text/License: -------------------------------------------------------------------------------- 1 | Copyright 2012 Keith Rarick 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/github.com/kr/text/Readme: -------------------------------------------------------------------------------- 1 | This is a Go package for manipulating paragraphs of text. 2 | 3 | See http://go.pkgdoc.org/github.com/kr/text for full documentation. 4 | -------------------------------------------------------------------------------- /vendor/github.com/kr/text/doc.go: -------------------------------------------------------------------------------- 1 | // Package text provides rudimentary functions for manipulating text in 2 | // paragraphs. 3 | package text 4 | -------------------------------------------------------------------------------- /vendor/github.com/kr/text/go.mod: -------------------------------------------------------------------------------- 1 | module "github.com/kr/text" 2 | 3 | require "github.com/kr/pty" v1.1.1 4 | -------------------------------------------------------------------------------- /vendor/github.com/kr/text/indent.go: -------------------------------------------------------------------------------- 1 | package text 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | // Indent inserts prefix at the beginning of each non-empty line of s. The 8 | // end-of-line marker is NL. 9 | func Indent(s, prefix string) string { 10 | return string(IndentBytes([]byte(s), []byte(prefix))) 11 | } 12 | 13 | // IndentBytes inserts prefix at the beginning of each non-empty line of b. 14 | // The end-of-line marker is NL. 15 | func IndentBytes(b, prefix []byte) []byte { 16 | var res []byte 17 | bol := true 18 | for _, c := range b { 19 | if bol && c != '\n' { 20 | res = append(res, prefix...) 21 | } 22 | res = append(res, c) 23 | bol = c == '\n' 24 | } 25 | return res 26 | } 27 | 28 | // Writer indents each line of its input. 29 | type indentWriter struct { 30 | w io.Writer 31 | bol bool 32 | pre [][]byte 33 | sel int 34 | off int 35 | } 36 | 37 | // NewIndentWriter makes a new write filter that indents the input 38 | // lines. Each line is prefixed in order with the corresponding 39 | // element of pre. If there are more lines than elements, the last 40 | // element of pre is repeated for each subsequent line. 41 | func NewIndentWriter(w io.Writer, pre ...[]byte) io.Writer { 42 | return &indentWriter{ 43 | w: w, 44 | pre: pre, 45 | bol: true, 46 | } 47 | } 48 | 49 | // The only errors returned are from the underlying indentWriter. 50 | func (w *indentWriter) Write(p []byte) (n int, err error) { 51 | for _, c := range p { 52 | if w.bol { 53 | var i int 54 | i, err = w.w.Write(w.pre[w.sel][w.off:]) 55 | w.off += i 56 | if err != nil { 57 | return n, err 58 | } 59 | } 60 | _, err = w.w.Write([]byte{c}) 61 | if err != nil { 62 | return n, err 63 | } 64 | n++ 65 | w.bol = c == '\n' 66 | if w.bol { 67 | w.off = 0 68 | if w.sel < len(w.pre)-1 { 69 | w.sel++ 70 | } 71 | } 72 | } 73 | return n, nil 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/kr/text/wrap.go: -------------------------------------------------------------------------------- 1 | package text 2 | 3 | import ( 4 | "bytes" 5 | "math" 6 | ) 7 | 8 | var ( 9 | nl = []byte{'\n'} 10 | sp = []byte{' '} 11 | ) 12 | 13 | const defaultPenalty = 1e5 14 | 15 | // Wrap wraps s into a paragraph of lines of length lim, with minimal 16 | // raggedness. 17 | func Wrap(s string, lim int) string { 18 | return string(WrapBytes([]byte(s), lim)) 19 | } 20 | 21 | // WrapBytes wraps b into a paragraph of lines of length lim, with minimal 22 | // raggedness. 23 | func WrapBytes(b []byte, lim int) []byte { 24 | words := bytes.Split(bytes.Replace(bytes.TrimSpace(b), nl, sp, -1), sp) 25 | var lines [][]byte 26 | for _, line := range WrapWords(words, 1, lim, defaultPenalty) { 27 | lines = append(lines, bytes.Join(line, sp)) 28 | } 29 | return bytes.Join(lines, nl) 30 | } 31 | 32 | // WrapWords is the low-level line-breaking algorithm, useful if you need more 33 | // control over the details of the text wrapping process. For most uses, either 34 | // Wrap or WrapBytes will be sufficient and more convenient. 35 | // 36 | // WrapWords splits a list of words into lines with minimal "raggedness", 37 | // treating each byte as one unit, accounting for spc units between adjacent 38 | // words on each line, and attempting to limit lines to lim units. Raggedness 39 | // is the total error over all lines, where error is the square of the 40 | // difference of the length of the line and lim. Too-long lines (which only 41 | // happen when a single word is longer than lim units) have pen penalty units 42 | // added to the error. 43 | func WrapWords(words [][]byte, spc, lim, pen int) [][][]byte { 44 | n := len(words) 45 | 46 | length := make([][]int, n) 47 | for i := 0; i < n; i++ { 48 | length[i] = make([]int, n) 49 | length[i][i] = len(words[i]) 50 | for j := i + 1; j < n; j++ { 51 | length[i][j] = length[i][j-1] + spc + len(words[j]) 52 | } 53 | } 54 | 55 | nbrk := make([]int, n) 56 | cost := make([]int, n) 57 | for i := range cost { 58 | cost[i] = math.MaxInt32 59 | } 60 | for i := n - 1; i >= 0; i-- { 61 | if length[i][n-1] <= lim || i == n-1 { 62 | cost[i] = 0 63 | nbrk[i] = n 64 | } else { 65 | for j := i + 1; j < n; j++ { 66 | d := lim - length[i][j-1] 67 | c := d*d + cost[j] 68 | if length[i][j-1] > lim { 69 | c += pen // too-long lines get a worse penalty 70 | } 71 | if c < cost[i] { 72 | cost[i] = c 73 | nbrk[i] = j 74 | } 75 | } 76 | } 77 | } 78 | 79 | var lines [][][]byte 80 | i := 0 81 | for i < n { 82 | lines = append(lines, words[i:nbrk[i]]) 83 | i = nbrk[i] 84 | } 85 | return lines 86 | } 87 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - tip 4 | 5 | before_install: 6 | - go get github.com/mattn/goveralls 7 | - go get golang.org/x/tools/cmd/cover 8 | script: 9 | - $HOME/gopath/bin/goveralls -repotoken xnXqRGwgW3SXIguzxf90ZSK1GPYZPaGrw 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/README.md: -------------------------------------------------------------------------------- 1 | # go-colorable 2 | 3 | [![Godoc Reference](https://godoc.org/github.com/mattn/go-colorable?status.svg)](http://godoc.org/github.com/mattn/go-colorable) 4 | [![Build Status](https://travis-ci.org/mattn/go-colorable.svg?branch=master)](https://travis-ci.org/mattn/go-colorable) 5 | [![Coverage Status](https://coveralls.io/repos/github/mattn/go-colorable/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-colorable?branch=master) 6 | [![Go Report Card](https://goreportcard.com/badge/mattn/go-colorable)](https://goreportcard.com/report/mattn/go-colorable) 7 | 8 | Colorable writer for windows. 9 | 10 | For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.) 11 | This package is possible to handle escape sequence for ansi color on windows. 12 | 13 | ## Too Bad! 14 | 15 | ![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/bad.png) 16 | 17 | 18 | ## So Good! 19 | 20 | ![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/good.png) 21 | 22 | ## Usage 23 | 24 | ```go 25 | logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true}) 26 | logrus.SetOutput(colorable.NewColorableStdout()) 27 | 28 | logrus.Info("succeeded") 29 | logrus.Warn("not correct") 30 | logrus.Error("something error") 31 | logrus.Fatal("panic") 32 | ``` 33 | 34 | You can compile above code on non-windows OSs. 35 | 36 | ## Installation 37 | 38 | ``` 39 | $ go get github.com/mattn/go-colorable 40 | ``` 41 | 42 | # License 43 | 44 | MIT 45 | 46 | # Author 47 | 48 | Yasuhiro Matsumoto (a.k.a mattn) 49 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package colorable 4 | 5 | import ( 6 | "io" 7 | "os" 8 | 9 | _ "github.com/mattn/go-isatty" 10 | ) 11 | 12 | // NewColorable returns new instance of Writer which handles escape sequence. 13 | func NewColorable(file *os.File) io.Writer { 14 | if file == nil { 15 | panic("nil passed instead of *os.File to NewColorable()") 16 | } 17 | 18 | return file 19 | } 20 | 21 | // NewColorableStdout returns new instance of Writer which handles escape sequence for stdout. 22 | func NewColorableStdout() io.Writer { 23 | return os.Stdout 24 | } 25 | 26 | // NewColorableStderr returns new instance of Writer which handles escape sequence for stderr. 27 | func NewColorableStderr() io.Writer { 28 | return os.Stderr 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package colorable 5 | 6 | import ( 7 | "io" 8 | "os" 9 | 10 | _ "github.com/mattn/go-isatty" 11 | ) 12 | 13 | // NewColorable returns new instance of Writer which handles escape sequence. 14 | func NewColorable(file *os.File) io.Writer { 15 | if file == nil { 16 | panic("nil passed instead of *os.File to NewColorable()") 17 | } 18 | 19 | return file 20 | } 21 | 22 | // NewColorableStdout returns new instance of Writer which handles escape sequence for stdout. 23 | func NewColorableStdout() io.Writer { 24 | return os.Stdout 25 | } 26 | 27 | // NewColorableStderr returns new instance of Writer which handles escape sequence for stderr. 28 | func NewColorableStderr() io.Writer { 29 | return os.Stderr 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/mattn/go-colorable 2 | 3 | require github.com/mattn/go-isatty v0.0.8 4 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/go.sum: -------------------------------------------------------------------------------- 1 | github.com/mattn/go-isatty v0.0.5 h1:tHXDdz1cpzGaovsTB+TVB8q90WEokoVmfMqoVcrLUgw= 2 | github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 3 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8= 4 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 5 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/noncolorable.go: -------------------------------------------------------------------------------- 1 | package colorable 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | ) 7 | 8 | // NonColorable holds writer but removes escape sequence. 9 | type NonColorable struct { 10 | out io.Writer 11 | } 12 | 13 | // NewNonColorable returns new instance of Writer which removes escape sequence from Writer. 14 | func NewNonColorable(w io.Writer) io.Writer { 15 | return &NonColorable{out: w} 16 | } 17 | 18 | // Write writes data on console 19 | func (w *NonColorable) Write(data []byte) (n int, err error) { 20 | er := bytes.NewReader(data) 21 | var bw [1]byte 22 | loop: 23 | for { 24 | c1, err := er.ReadByte() 25 | if err != nil { 26 | break loop 27 | } 28 | if c1 != 0x1b { 29 | bw[0] = c1 30 | w.out.Write(bw[:]) 31 | continue 32 | } 33 | c2, err := er.ReadByte() 34 | if err != nil { 35 | break loop 36 | } 37 | if c2 != 0x5b { 38 | continue 39 | } 40 | 41 | var buf bytes.Buffer 42 | for { 43 | c, err := er.ReadByte() 44 | if err != nil { 45 | break loop 46 | } 47 | if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { 48 | break 49 | } 50 | buf.Write([]byte(string(c))) 51 | } 52 | } 53 | 54 | return len(data), nil 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - tip 4 | 5 | os: 6 | - linux 7 | - osx 8 | 9 | before_install: 10 | - go get github.com/mattn/goveralls 11 | - go get golang.org/x/tools/cmd/cover 12 | script: 13 | - $HOME/gopath/bin/goveralls -repotoken 3gHdORO5k5ziZcWMBxnd9LrMZaJs8m9x5 14 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/README.md: -------------------------------------------------------------------------------- 1 | # go-isatty 2 | 3 | [![Godoc Reference](https://godoc.org/github.com/mattn/go-isatty?status.svg)](http://godoc.org/github.com/mattn/go-isatty) 4 | [![Build Status](https://travis-ci.org/mattn/go-isatty.svg?branch=master)](https://travis-ci.org/mattn/go-isatty) 5 | [![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master) 6 | [![Go Report Card](https://goreportcard.com/badge/mattn/go-isatty)](https://goreportcard.com/report/mattn/go-isatty) 7 | 8 | isatty for golang 9 | 10 | ## Usage 11 | 12 | ```go 13 | package main 14 | 15 | import ( 16 | "fmt" 17 | "github.com/mattn/go-isatty" 18 | "os" 19 | ) 20 | 21 | func main() { 22 | if isatty.IsTerminal(os.Stdout.Fd()) { 23 | fmt.Println("Is Terminal") 24 | } else if isatty.IsCygwinTerminal(os.Stdout.Fd()) { 25 | fmt.Println("Is Cygwin/MSYS2 Terminal") 26 | } else { 27 | fmt.Println("Is Not Terminal") 28 | } 29 | } 30 | ``` 31 | 32 | ## Installation 33 | 34 | ``` 35 | $ go get github.com/mattn/go-isatty 36 | ``` 37 | 38 | ## License 39 | 40 | MIT 41 | 42 | ## Author 43 | 44 | Yasuhiro Matsumoto (a.k.a mattn) 45 | 46 | ## Thanks 47 | 48 | * k-takata: base idea for IsCygwinTerminal 49 | 50 | https://github.com/k-takata/go-iscygpty 51 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/mattn/go-isatty 2 | 3 | require golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 4 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/go.sum: -------------------------------------------------------------------------------- 1 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8= 2 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 3 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_android.go: -------------------------------------------------------------------------------- 1 | // +build android 2 | 3 | package isatty 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | const ioctlReadTermios = syscall.TCGETS 11 | 12 | // IsTerminal return true if the file descriptor is terminal. 13 | func IsTerminal(fd uintptr) bool { 14 | var termios syscall.Termios 15 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 16 | return err == 0 17 | } 18 | 19 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 20 | // terminal. This is also always false on this environment. 21 | func IsCygwinTerminal(fd uintptr) bool { 22 | return false 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | 20 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 21 | // terminal. This is also always false on this environment. 22 | func IsCygwinTerminal(fd uintptr) bool { 23 | return false 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_others.go: -------------------------------------------------------------------------------- 1 | // +build appengine js nacl 2 | 3 | package isatty 4 | 5 | // IsTerminal returns true if the file descriptor is terminal which 6 | // is always false on js and appengine classic which is a sandboxed PaaS. 7 | func IsTerminal(fd uintptr) bool { 8 | return false 9 | } 10 | 11 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 12 | // terminal. This is also always false on this environment. 13 | func IsCygwinTerminal(fd uintptr) bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "golang.org/x/sys/unix" 8 | ) 9 | 10 | // IsTerminal returns true if the given file descriptor is a terminal. 11 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c 12 | func IsTerminal(fd uintptr) bool { 13 | var termio unix.Termio 14 | err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio) 15 | return err == nil 16 | } 17 | 18 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 19 | // terminal. This is also always false on this environment. 20 | func IsCygwinTerminal(fd uintptr) bool { 21 | return false 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_tcgets.go: -------------------------------------------------------------------------------- 1 | // +build linux aix 2 | // +build !appengine 3 | // +build !android 4 | 5 | package isatty 6 | 7 | import "golang.org/x/sys/unix" 8 | 9 | // IsTerminal return true if the file descriptor is terminal. 10 | func IsTerminal(fd uintptr) bool { 11 | _, err := unix.IoctlGetTermios(int(fd), unix.TCGETS) 12 | return err == nil 13 | } 14 | 15 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 16 | // terminal. This is also always false on this environment. 17 | func IsCygwinTerminal(fd uintptr) bool { 18 | return false 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "strings" 8 | "syscall" 9 | "unicode/utf16" 10 | "unsafe" 11 | ) 12 | 13 | const ( 14 | fileNameInfo uintptr = 2 15 | fileTypePipe = 3 16 | ) 17 | 18 | var ( 19 | kernel32 = syscall.NewLazyDLL("kernel32.dll") 20 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 21 | procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx") 22 | procGetFileType = kernel32.NewProc("GetFileType") 23 | ) 24 | 25 | func init() { 26 | // Check if GetFileInformationByHandleEx is available. 27 | if procGetFileInformationByHandleEx.Find() != nil { 28 | procGetFileInformationByHandleEx = nil 29 | } 30 | } 31 | 32 | // IsTerminal return true if the file descriptor is terminal. 33 | func IsTerminal(fd uintptr) bool { 34 | var st uint32 35 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0) 36 | return r != 0 && e == 0 37 | } 38 | 39 | // Check pipe name is used for cygwin/msys2 pty. 40 | // Cygwin/MSYS2 PTY has a name like: 41 | // \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master 42 | func isCygwinPipeName(name string) bool { 43 | token := strings.Split(name, "-") 44 | if len(token) < 5 { 45 | return false 46 | } 47 | 48 | if token[0] != `\msys` && token[0] != `\cygwin` { 49 | return false 50 | } 51 | 52 | if token[1] == "" { 53 | return false 54 | } 55 | 56 | if !strings.HasPrefix(token[2], "pty") { 57 | return false 58 | } 59 | 60 | if token[3] != `from` && token[3] != `to` { 61 | return false 62 | } 63 | 64 | if token[4] != "master" { 65 | return false 66 | } 67 | 68 | return true 69 | } 70 | 71 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 72 | // terminal. 73 | func IsCygwinTerminal(fd uintptr) bool { 74 | if procGetFileInformationByHandleEx == nil { 75 | return false 76 | } 77 | 78 | // Cygwin/msys's pty is a pipe. 79 | ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0) 80 | if ft != fileTypePipe || e != 0 { 81 | return false 82 | } 83 | 84 | var buf [2 + syscall.MAX_PATH]uint16 85 | r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 86 | 4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)), 87 | uintptr(len(buf)*2), 0, 0) 88 | if r == 0 || e != 0 { 89 | return false 90 | } 91 | 92 | l := *(*uint32)(unsafe.Pointer(&buf)) 93 | return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2]))) 94 | } 95 | -------------------------------------------------------------------------------- /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/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | unix.test 3 | -------------------------------------------------------------------------------- /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/aliases.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 aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build go1.9 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | type Signal = syscall.Signal 13 | type Errno = syscall.Errno 14 | type SysProcAttr = syscall.SysProcAttr 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_aix_ppc64.s: -------------------------------------------------------------------------------- 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for ppc64, AIX are implemented in runtime/syscall_aix.go 11 | // 12 | 13 | TEXT ·syscall6(SB),NOSPLIT,$0-88 14 | JMP syscall·syscall6(SB) 15 | 16 | TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSyscall6(SB) 18 | -------------------------------------------------------------------------------- /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_freebsd_arm64.s: -------------------------------------------------------------------------------- 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_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 ·SyscallNoError(SB),NOSPLIT,$0-48 19 | BL runtime·entersyscall(SB) 20 | MOVD a1+8(FP), R3 21 | MOVD a2+16(FP), R4 22 | MOVD a3+24(FP), R5 23 | MOVD R0, R6 24 | MOVD R0, R7 25 | MOVD R0, R8 26 | MOVD trap+0(FP), R9 // syscall entry 27 | SYSCALL R9 28 | MOVD R3, r1+32(FP) 29 | MOVD R4, r2+40(FP) 30 | BL runtime·exitsyscall(SB) 31 | RET 32 | 33 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 34 | MOVD a1+8(FP), R3 35 | MOVD a2+16(FP), R4 36 | MOVD a3+24(FP), R5 37 | MOVD R0, R6 38 | MOVD R0, R7 39 | MOVD R0, R8 40 | MOVD trap+0(FP), R9 // syscall entry 41 | SYSCALL R9 42 | MOVD R3, r1+32(FP) 43 | MOVD R4, r2+40(FP) 44 | RET 45 | -------------------------------------------------------------------------------- /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_netbsd_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 ARM64, 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 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 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 aix 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_aix_ppc.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 aix 6 | // +build ppc 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used by AIX. 10 | 11 | package unix 12 | 13 | // Major returns the major component of a Linux device number. 14 | func Major(dev uint64) uint32 { 15 | return uint32((dev >> 16) & 0xffff) 16 | } 17 | 18 | // Minor returns the minor component of a Linux device number. 19 | func Minor(dev uint64) uint32 { 20 | return uint32(dev & 0xffff) 21 | } 22 | 23 | // Mkdev returns a Linux device number generated from the given major and minor 24 | // components. 25 | func Mkdev(major, minor uint32) uint64 { 26 | return uint64(((major) << 16) | (minor)) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc64.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 aix 6 | // +build ppc64 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used AIX. 10 | 11 | package unix 12 | 13 | // Major returns the major component of a Linux device number. 14 | func Major(dev uint64) uint32 { 15 | return uint32((dev & 0x3fffffff00000000) >> 32) 16 | } 17 | 18 | // Minor returns the minor component of a Linux device number. 19 | func Minor(dev uint64) uint32 { 20 | return uint32((dev & 0x00000000ffffffff) >> 0) 21 | } 22 | 23 | // Mkdev returns a Linux device number generated from the given major and minor 24 | // components. 25 | func Mkdev(major, minor uint32) uint64 { 26 | var DEVNO64 uint64 27 | DEVNO64 = 0x8000000000000000 28 | return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64) 29 | } 30 | -------------------------------------------------------------------------------- /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 aix 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 aix 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 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, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg)) 18 | var err error 19 | if errno != 0 { 20 | err = errno 21 | } 22 | return int(valptr), err 23 | } 24 | 25 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 26 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 27 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 28 | if errno == 0 { 29 | return nil 30 | } 31 | return errno 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 "unsafe" 8 | 9 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 10 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 11 | return fcntl(int(fd), cmd, arg) 12 | } 13 | 14 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 15 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 16 | _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk)))) 17 | return err 18 | } 19 | -------------------------------------------------------------------------------- /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 | // +build !aix 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | // We can't use the gc-syntax .s files for gccgo. On the plus side 13 | // much of the functionality can be written directly in Go. 14 | 15 | //extern gccgoRealSyscallNoError 16 | func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr) 17 | 18 | //extern gccgoRealSyscall 19 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 20 | 21 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 22 | syscall.Entersyscall() 23 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 24 | syscall.Exitsyscall() 25 | return r, 0 26 | } 27 | 28 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 29 | syscall.Entersyscall() 30 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 31 | syscall.Exitsyscall() 32 | return r, 0, syscall.Errno(errno) 33 | } 34 | 35 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 36 | syscall.Entersyscall() 37 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 38 | syscall.Exitsyscall() 39 | return r, 0, syscall.Errno(errno) 40 | } 41 | 42 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 43 | syscall.Entersyscall() 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 45 | syscall.Exitsyscall() 46 | return r, 0, syscall.Errno(errno) 47 | } 48 | 49 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 50 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 51 | return r, 0 52 | } 53 | 54 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 55 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 56 | return r, 0, syscall.Errno(errno) 57 | } 58 | 59 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 60 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 61 | return r, 0, syscall.Errno(errno) 62 | } 63 | -------------------------------------------------------------------------------- /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 | // +build !aix 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define _STRINGIFY2_(x) #x 13 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 14 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 15 | 16 | // Call syscall from C code because the gccgo support for calling from 17 | // Go to C does not support varargs functions. 18 | 19 | struct ret { 20 | uintptr_t r; 21 | uintptr_t err; 22 | }; 23 | 24 | struct ret 25 | 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) 26 | { 27 | struct ret r; 28 | 29 | errno = 0; 30 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 31 | r.err = errno; 32 | return r; 33 | } 34 | 35 | uintptr_t 36 | 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) 37 | { 38 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 39 | } 40 | -------------------------------------------------------------------------------- /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/ioctl.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 aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "runtime" 10 | 11 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 12 | // 13 | // To change fd's window size, the req argument should be TIOCSWINSZ. 14 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error { 15 | // TODO: if we get the chance, remove the req parameter and 16 | // hardcode TIOCSWINSZ. 17 | err := ioctlSetWinsize(fd, req, value) 18 | runtime.KeepAlive(value) 19 | return err 20 | } 21 | 22 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 23 | // 24 | // The req value will usually be TCSETA or TIOCSETA. 25 | func IoctlSetTermios(fd int, req uint, value *Termios) error { 26 | // TODO: if we get the chance, remove the req parameter. 27 | err := ioctlSetTermios(fd, req, value) 28 | runtime.KeepAlive(value) 29 | return err 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | # Copyright 2011 The Go Authors. All rights reserved. 4 | # Use of this source code is governed by a BSD-style 5 | # license that can be found in the LICENSE file. 6 | 7 | # 8 | # Parse the header files for OpenBSD and generate a Go usable sysctl MIB. 9 | # 10 | # Build a MIB with each entry being an array containing the level, type and 11 | # a hash that will contain additional entries if the current entry is a node. 12 | # We then walk this MIB and create a flattened sysctl name to OID hash. 13 | # 14 | 15 | use strict; 16 | 17 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 18 | print STDERR "GOARCH or GOOS not defined in environment\n"; 19 | exit 1; 20 | } 21 | 22 | my $debug = 0; 23 | my %ctls = (); 24 | 25 | my @headers = qw ( 26 | sys/sysctl.h 27 | sys/socket.h 28 | sys/tty.h 29 | sys/malloc.h 30 | sys/mount.h 31 | sys/namei.h 32 | sys/sem.h 33 | sys/shm.h 34 | sys/vmmeter.h 35 | uvm/uvmexp.h 36 | uvm/uvm_param.h 37 | uvm/uvm_swap_encrypt.h 38 | ddb/db_var.h 39 | net/if.h 40 | net/if_pfsync.h 41 | net/pipex.h 42 | netinet/in.h 43 | netinet/icmp_var.h 44 | netinet/igmp_var.h 45 | netinet/ip_ah.h 46 | netinet/ip_carp.h 47 | netinet/ip_divert.h 48 | netinet/ip_esp.h 49 | netinet/ip_ether.h 50 | netinet/ip_gre.h 51 | netinet/ip_ipcomp.h 52 | netinet/ip_ipip.h 53 | netinet/pim_var.h 54 | netinet/tcp_var.h 55 | netinet/udp_var.h 56 | netinet6/in6.h 57 | netinet6/ip6_divert.h 58 | netinet6/pim6_var.h 59 | netinet/icmp6.h 60 | netmpls/mpls.h 61 | ); 62 | 63 | my @ctls = qw ( 64 | kern 65 | vm 66 | fs 67 | net 68 | #debug # Special handling required 69 | hw 70 | #machdep # Arch specific 71 | user 72 | ddb 73 | #vfs # Special handling required 74 | fs.posix 75 | kern.forkstat 76 | kern.intrcnt 77 | kern.malloc 78 | kern.nchstats 79 | kern.seminfo 80 | kern.shminfo 81 | kern.timecounter 82 | kern.tty 83 | kern.watchdog 84 | net.bpf 85 | net.ifq 86 | net.inet 87 | net.inet.ah 88 | net.inet.carp 89 | net.inet.divert 90 | net.inet.esp 91 | net.inet.etherip 92 | net.inet.gre 93 | net.inet.icmp 94 | net.inet.igmp 95 | net.inet.ip 96 | net.inet.ip.ifq 97 | net.inet.ipcomp 98 | net.inet.ipip 99 | net.inet.mobileip 100 | net.inet.pfsync 101 | net.inet.pim 102 | net.inet.tcp 103 | net.inet.udp 104 | net.inet6 105 | net.inet6.divert 106 | net.inet6.ip6 107 | net.inet6.icmp6 108 | net.inet6.pim6 109 | net.inet6.tcp6 110 | net.inet6.udp6 111 | net.mpls 112 | net.mpls.ifq 113 | net.key 114 | net.pflow 115 | net.pfsync 116 | net.pipex 117 | net.rt 118 | vm.swapencrypt 119 | #vfsgenctl # Special handling required 120 | ); 121 | 122 | # Node name "fixups" 123 | my %ctl_map = ( 124 | "ipproto" => "net.inet", 125 | "net.inet.ipproto" => "net.inet", 126 | "net.inet6.ipv6proto" => "net.inet6", 127 | "net.inet6.ipv6" => "net.inet6.ip6", 128 | "net.inet.icmpv6" => "net.inet6.icmp6", 129 | "net.inet6.divert6" => "net.inet6.divert", 130 | "net.inet6.tcp6" => "net.inet.tcp", 131 | "net.inet6.udp6" => "net.inet.udp", 132 | "mpls" => "net.mpls", 133 | "swpenc" => "vm.swapencrypt" 134 | ); 135 | 136 | # Node mappings 137 | my %node_map = ( 138 | "net.inet.ip.ifq" => "net.ifq", 139 | "net.inet.pfsync" => "net.pfsync", 140 | "net.mpls.ifq" => "net.ifq" 141 | ); 142 | 143 | my $ctlname; 144 | my %mib = (); 145 | my %sysctl = (); 146 | my $node; 147 | 148 | sub debug() { 149 | print STDERR "$_[0]\n" if $debug; 150 | } 151 | 152 | # Walk the MIB and build a sysctl name to OID mapping. 153 | sub build_sysctl() { 154 | my ($node, $name, $oid) = @_; 155 | my %node = %{$node}; 156 | my @oid = @{$oid}; 157 | 158 | foreach my $key (sort keys %node) { 159 | my @node = @{$node{$key}}; 160 | my $nodename = $name.($name ne '' ? '.' : '').$key; 161 | my @nodeoid = (@oid, $node[0]); 162 | if ($node[1] eq 'CTLTYPE_NODE') { 163 | if (exists $node_map{$nodename}) { 164 | $node = \%mib; 165 | $ctlname = $node_map{$nodename}; 166 | foreach my $part (split /\./, $ctlname) { 167 | $node = \%{@{$$node{$part}}[2]}; 168 | } 169 | } else { 170 | $node = $node[2]; 171 | } 172 | &build_sysctl($node, $nodename, \@nodeoid); 173 | } elsif ($node[1] ne '') { 174 | $sysctl{$nodename} = \@nodeoid; 175 | } 176 | } 177 | } 178 | 179 | foreach my $ctl (@ctls) { 180 | $ctls{$ctl} = $ctl; 181 | } 182 | 183 | # Build MIB 184 | foreach my $header (@headers) { 185 | &debug("Processing $header..."); 186 | open HEADER, "/usr/include/$header" || 187 | print STDERR "Failed to open $header\n"; 188 | while (
) { 189 | if ($_ =~ /^#define\s+(CTL_NAMES)\s+{/ || 190 | $_ =~ /^#define\s+(CTL_(.*)_NAMES)\s+{/ || 191 | $_ =~ /^#define\s+((.*)CTL_NAMES)\s+{/) { 192 | if ($1 eq 'CTL_NAMES') { 193 | # Top level. 194 | $node = \%mib; 195 | } else { 196 | # Node. 197 | my $nodename = lc($2); 198 | if ($header =~ /^netinet\//) { 199 | $ctlname = "net.inet.$nodename"; 200 | } elsif ($header =~ /^netinet6\//) { 201 | $ctlname = "net.inet6.$nodename"; 202 | } elsif ($header =~ /^net\//) { 203 | $ctlname = "net.$nodename"; 204 | } else { 205 | $ctlname = "$nodename"; 206 | $ctlname =~ s/^(fs|net|kern)_/$1\./; 207 | } 208 | if (exists $ctl_map{$ctlname}) { 209 | $ctlname = $ctl_map{$ctlname}; 210 | } 211 | if (not exists $ctls{$ctlname}) { 212 | &debug("Ignoring $ctlname..."); 213 | next; 214 | } 215 | 216 | # Walk down from the top of the MIB. 217 | $node = \%mib; 218 | foreach my $part (split /\./, $ctlname) { 219 | if (not exists $$node{$part}) { 220 | &debug("Missing node $part"); 221 | $$node{$part} = [ 0, '', {} ]; 222 | } 223 | $node = \%{@{$$node{$part}}[2]}; 224 | } 225 | } 226 | 227 | # Populate current node with entries. 228 | my $i = -1; 229 | while (defined($_) && $_ !~ /^}/) { 230 | $_ =
; 231 | $i++ if $_ =~ /{.*}/; 232 | next if $_ !~ /{\s+"(\w+)",\s+(CTLTYPE_[A-Z]+)\s+}/; 233 | $$node{$1} = [ $i, $2, {} ]; 234 | } 235 | } 236 | } 237 | close HEADER; 238 | } 239 | 240 | &build_sysctl(\%mib, "", []); 241 | 242 | print < 6.2, pass execpromises to the syscall. 48 | if maj > 6 || (maj == 6 && min > 2) { 49 | exptr, err := syscall.BytePtrFromString(execpromises) 50 | if err != nil { 51 | return err 52 | } 53 | expr = unsafe.Pointer(exptr) 54 | } 55 | 56 | _, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(unsafe.Pointer(pptr)), uintptr(expr), 0) 57 | if e != 0 { 58 | return e 59 | } 60 | 61 | return nil 62 | } 63 | 64 | // PledgePromises implements the pledge syscall. 65 | // 66 | // This changes the promises and leaves the execpromises untouched. 67 | // 68 | // For more information see pledge(2). 69 | func PledgePromises(promises string) error { 70 | maj, min, err := majmin() 71 | if err != nil { 72 | return err 73 | } 74 | 75 | err = pledgeAvailable(maj, min, "") 76 | if err != nil { 77 | return err 78 | } 79 | 80 | // This variable holds the execpromises and is always nil. 81 | var expr unsafe.Pointer 82 | 83 | pptr, err := syscall.BytePtrFromString(promises) 84 | if err != nil { 85 | return err 86 | } 87 | 88 | _, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(unsafe.Pointer(pptr)), uintptr(expr), 0) 89 | if e != 0 { 90 | return e 91 | } 92 | 93 | return nil 94 | } 95 | 96 | // PledgeExecpromises implements the pledge syscall. 97 | // 98 | // This changes the execpromises and leaves the promises untouched. 99 | // 100 | // For more information see pledge(2). 101 | func PledgeExecpromises(execpromises string) error { 102 | maj, min, err := majmin() 103 | if err != nil { 104 | return err 105 | } 106 | 107 | err = pledgeAvailable(maj, min, execpromises) 108 | if err != nil { 109 | return err 110 | } 111 | 112 | // This variable holds the promises and is always nil. 113 | var pptr unsafe.Pointer 114 | 115 | exptr, err := syscall.BytePtrFromString(execpromises) 116 | if err != nil { 117 | return err 118 | } 119 | 120 | _, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(pptr), uintptr(unsafe.Pointer(exptr)), 0) 121 | if e != 0 { 122 | return e 123 | } 124 | 125 | return nil 126 | } 127 | 128 | // majmin returns major and minor version number for an OpenBSD system. 129 | func majmin() (major int, minor int, err error) { 130 | var v Utsname 131 | err = Uname(&v) 132 | if err != nil { 133 | return 134 | } 135 | 136 | major, err = strconv.Atoi(string(v.Release[0])) 137 | if err != nil { 138 | err = errors.New("cannot parse major version number returned by uname") 139 | return 140 | } 141 | 142 | minor, err = strconv.Atoi(string(v.Release[2])) 143 | if err != nil { 144 | err = errors.New("cannot parse minor version number returned by uname") 145 | return 146 | } 147 | 148 | return 149 | } 150 | 151 | // pledgeAvailable checks for availability of the pledge(2) syscall 152 | // based on the running OpenBSD version. 153 | func pledgeAvailable(maj, min int, execpromises string) error { 154 | // If OpenBSD <= 5.9, pledge is not available. 155 | if (maj == 5 && min != 9) || maj < 5 { 156 | return fmt.Errorf("pledge syscall is not available on OpenBSD %d.%d", maj, min) 157 | } 158 | 159 | // If OpenBSD <= 6.2 and execpromises is not empty, 160 | // return an error - execpromises is not available before 6.3 161 | if (maj < 6 || (maj == 6 && min <= 2)) && execpromises != "" { 162 | return fmt.Errorf("cannot use execpromises on OpenBSD %d.%d", maj, min) 163 | } 164 | 165 | return nil 166 | } 167 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/openbsd_unveil.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 openbsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | // Unveil implements the unveil syscall. 15 | // For more information see unveil(2). 16 | // Note that the special case of blocking further 17 | // unveil calls is handled by UnveilBlock. 18 | func Unveil(path string, flags string) error { 19 | pathPtr, err := syscall.BytePtrFromString(path) 20 | if err != nil { 21 | return err 22 | } 23 | flagsPtr, err := syscall.BytePtrFromString(flags) 24 | if err != nil { 25 | return err 26 | } 27 | _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(unsafe.Pointer(pathPtr)), uintptr(unsafe.Pointer(flagsPtr)), 0) 28 | if e != 0 { 29 | return e 30 | } 31 | return nil 32 | } 33 | 34 | // UnveilBlock blocks future unveil calls. 35 | // For more information see unveil(2). 36 | func UnveilBlock() error { 37 | // Both pointers must be nil. 38 | var pathUnsafe, flagsUnsafe unsafe.Pointer 39 | _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(pathUnsafe), uintptr(flagsUnsafe), 0) 40 | if e != 0 { 41 | return e 42 | } 43 | return nil 44 | } 45 | -------------------------------------------------------------------------------- /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 aix 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 aix 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 aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Socket control messages 8 | 9 | package unix 10 | 11 | import ( 12 | "runtime" 13 | "unsafe" 14 | ) 15 | 16 | // Round the length of a raw sockaddr up to align it properly. 17 | func cmsgAlignOf(salen int) int { 18 | salign := SizeofPtr 19 | 20 | switch runtime.GOOS { 21 | case "darwin", "dragonfly", "solaris": 22 | // NOTE: It seems like 64-bit Darwin, DragonFly BSD and 23 | // Solaris kernels still require 32-bit aligned access to 24 | // network subsystem. 25 | if SizeofPtr == 8 { 26 | salign = 4 27 | } 28 | case "openbsd": 29 | // OpenBSD armv7 requires 64-bit alignment. 30 | if runtime.GOARCH == "arm" { 31 | salign = 8 32 | } 33 | } 34 | 35 | return (salen + salign - 1) & ^(salign - 1) 36 | } 37 | 38 | // CmsgLen returns the value to store in the Len field of the Cmsghdr 39 | // structure, taking into account any necessary alignment. 40 | func CmsgLen(datalen int) int { 41 | return cmsgAlignOf(SizeofCmsghdr) + datalen 42 | } 43 | 44 | // CmsgSpace returns the number of bytes an ancillary element with 45 | // payload of the passed data length occupies. 46 | func CmsgSpace(datalen int) int { 47 | return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) 48 | } 49 | 50 | func cmsgData(h *Cmsghdr) unsafe.Pointer { 51 | return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr))) 52 | } 53 | 54 | // SocketControlMessage represents a socket control message. 55 | type SocketControlMessage struct { 56 | Header Cmsghdr 57 | Data []byte 58 | } 59 | 60 | // ParseSocketControlMessage parses b as an array of socket control 61 | // messages. 62 | func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { 63 | var msgs []SocketControlMessage 64 | i := 0 65 | for i+CmsgLen(0) <= len(b) { 66 | h, dbuf, err := socketControlMessageHeaderAndData(b[i:]) 67 | if err != nil { 68 | return nil, err 69 | } 70 | m := SocketControlMessage{Header: *h, Data: dbuf} 71 | msgs = append(msgs, m) 72 | i += cmsgAlignOf(int(h.Len)) 73 | } 74 | return msgs, nil 75 | } 76 | 77 | func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) { 78 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 79 | if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) { 80 | return nil, nil, EINVAL 81 | } 82 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 83 | } 84 | 85 | // UnixRights encodes a set of open file descriptors into a socket 86 | // control message for sending to another process. 87 | func UnixRights(fds ...int) []byte { 88 | datalen := len(fds) * 4 89 | b := make([]byte, CmsgSpace(datalen)) 90 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 91 | h.Level = SOL_SOCKET 92 | h.Type = SCM_RIGHTS 93 | h.SetLen(CmsgLen(datalen)) 94 | data := cmsgData(h) 95 | for _, fd := range fds { 96 | *(*int32)(data) = int32(fd) 97 | data = unsafe.Pointer(uintptr(data) + 4) 98 | } 99 | return b 100 | } 101 | 102 | // ParseUnixRights decodes a socket control message that contains an 103 | // integer array of open file descriptors from another process. 104 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 105 | if m.Header.Level != SOL_SOCKET { 106 | return nil, EINVAL 107 | } 108 | if m.Header.Type != SCM_RIGHTS { 109 | return nil, EINVAL 110 | } 111 | fds := make([]int, len(m.Data)>>2) 112 | for i, j := 0, 0; i < len(m.Data); i += 4 { 113 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 114 | j++ 115 | } 116 | return fds, nil 117 | } 118 | -------------------------------------------------------------------------------- /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 aix 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 aix 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_aix_ppc.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 aix 6 | // +build ppc 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc64.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 aix 6 | // +build ppc64 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: sec, Nsec: nsec} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int64(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (cmsg *Cmsghdr) SetLen(length int) { 33 | cmsg.Len = uint32(length) 34 | } 35 | -------------------------------------------------------------------------------- /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 | ) 12 | 13 | func setTimespec(sec, nsec int64) Timespec { 14 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 15 | } 16 | 17 | func setTimeval(sec, usec int64) Timeval { 18 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 19 | } 20 | 21 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 22 | func Gettimeofday(tv *Timeval) (err error) { 23 | // The tv passed to gettimeofday must be non-nil 24 | // but is otherwise unused. The answers come back 25 | // in the two registers. 26 | sec, usec, err := gettimeofday(tv) 27 | tv.Sec = int32(sec) 28 | tv.Usec = int32(usec) 29 | return err 30 | } 31 | 32 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 33 | k.Ident = uint32(fd) 34 | k.Filter = int16(mode) 35 | k.Flags = uint16(flags) 36 | } 37 | 38 | func (iov *Iovec) SetLen(length int) { 39 | iov.Len = uint32(length) 40 | } 41 | 42 | func (msghdr *Msghdr) SetControllen(length int) { 43 | msghdr.Controllen = uint32(length) 44 | } 45 | 46 | func (cmsg *Cmsghdr) SetLen(length int) { 47 | cmsg.Len = uint32(length) 48 | } 49 | 50 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 51 | 52 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 53 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 54 | const SYS___SYSCTL = SYS_SYSCTL 55 | 56 | //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 57 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 58 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 59 | //sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64 60 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 61 | //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 62 | //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 63 | //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 64 | -------------------------------------------------------------------------------- /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 | ) 12 | 13 | func setTimespec(sec, nsec int64) Timespec { 14 | return Timespec{Sec: sec, Nsec: nsec} 15 | } 16 | 17 | func setTimeval(sec, usec int64) Timeval { 18 | return Timeval{Sec: sec, Usec: int32(usec)} 19 | } 20 | 21 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 22 | func Gettimeofday(tv *Timeval) (err error) { 23 | // The tv passed to gettimeofday must be non-nil 24 | // but is otherwise unused. The answers come back 25 | // in the two registers. 26 | sec, usec, err := gettimeofday(tv) 27 | tv.Sec = sec 28 | tv.Usec = usec 29 | return err 30 | } 31 | 32 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 33 | k.Ident = uint64(fd) 34 | k.Filter = int16(mode) 35 | k.Flags = uint16(flags) 36 | } 37 | 38 | func (iov *Iovec) SetLen(length int) { 39 | iov.Len = uint64(length) 40 | } 41 | 42 | func (msghdr *Msghdr) SetControllen(length int) { 43 | msghdr.Controllen = uint32(length) 44 | } 45 | 46 | func (cmsg *Cmsghdr) SetLen(length int) { 47 | cmsg.Len = uint32(length) 48 | } 49 | 50 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 51 | 52 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 53 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 54 | const SYS___SYSCTL = SYS_SYSCTL 55 | 56 | //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 57 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 58 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 59 | //sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64 60 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 61 | //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 62 | //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 63 | //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 64 | -------------------------------------------------------------------------------- /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 | ) 10 | 11 | func setTimespec(sec, nsec int64) Timespec { 12 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 13 | } 14 | 15 | func setTimeval(sec, usec int64) Timeval { 16 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 17 | } 18 | 19 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 20 | func Gettimeofday(tv *Timeval) (err error) { 21 | // The tv passed to gettimeofday must be non-nil 22 | // but is otherwise unused. The answers come back 23 | // in the two registers. 24 | sec, usec, err := gettimeofday(tv) 25 | tv.Sec = int32(sec) 26 | tv.Usec = int32(usec) 27 | return err 28 | } 29 | 30 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 31 | k.Ident = uint32(fd) 32 | k.Filter = int16(mode) 33 | k.Flags = uint16(flags) 34 | } 35 | 36 | func (iov *Iovec) SetLen(length int) { 37 | iov.Len = uint32(length) 38 | } 39 | 40 | func (msghdr *Msghdr) SetControllen(length int) { 41 | msghdr.Controllen = uint32(length) 42 | } 43 | 44 | func (cmsg *Cmsghdr) SetLen(length int) { 45 | cmsg.Len = uint32(length) 46 | } 47 | 48 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 49 | 50 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 51 | // of darwin/arm the syscall is called sysctl instead of __sysctl. 52 | const SYS___SYSCTL = SYS_SYSCTL 53 | 54 | //sys Fstat(fd int, stat *Stat_t) (err error) 55 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 56 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) 57 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT 58 | //sys Lstat(path string, stat *Stat_t) (err error) 59 | //sys Stat(path string, stat *Stat_t) (err error) 60 | //sys Statfs(path string, stat *Statfs_t) (err error) 61 | 62 | func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { 63 | return 0, ENOSYS 64 | } 65 | -------------------------------------------------------------------------------- /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 | ) 12 | 13 | func setTimespec(sec, nsec int64) Timespec { 14 | return Timespec{Sec: sec, Nsec: nsec} 15 | } 16 | 17 | func setTimeval(sec, usec int64) Timeval { 18 | return Timeval{Sec: sec, Usec: int32(usec)} 19 | } 20 | 21 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 22 | func Gettimeofday(tv *Timeval) (err error) { 23 | // The tv passed to gettimeofday must be non-nil 24 | // but is otherwise unused. The answers come back 25 | // in the two registers. 26 | sec, usec, err := gettimeofday(tv) 27 | tv.Sec = sec 28 | tv.Usec = usec 29 | return err 30 | } 31 | 32 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 33 | k.Ident = uint64(fd) 34 | k.Filter = int16(mode) 35 | k.Flags = uint16(flags) 36 | } 37 | 38 | func (iov *Iovec) SetLen(length int) { 39 | iov.Len = uint64(length) 40 | } 41 | 42 | func (msghdr *Msghdr) SetControllen(length int) { 43 | msghdr.Controllen = uint32(length) 44 | } 45 | 46 | func (cmsg *Cmsghdr) SetLen(length int) { 47 | cmsg.Len = uint32(length) 48 | } 49 | 50 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 51 | 52 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 53 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 54 | const SYS___SYSCTL = SYS_SYSCTL 55 | 56 | //sys Fstat(fd int, stat *Stat_t) (err error) 57 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 58 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) 59 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT 60 | //sys Lstat(path string, stat *Stat_t) (err error) 61 | //sys Stat(path string, stat *Stat_t) (err error) 62 | //sys Statfs(path string, stat *Statfs_t) (err error) 63 | 64 | func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { 65 | return 0, ENOSYS 66 | } 67 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.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 darwin,go1.12 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // Implemented in the runtime package (runtime/sys_darwin.go) 12 | func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 13 | func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 14 | func syscall_syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 15 | func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) // 32-bit only 16 | func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 17 | func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 18 | 19 | //go:linkname syscall_syscall syscall.syscall 20 | //go:linkname syscall_syscall6 syscall.syscall6 21 | //go:linkname syscall_syscall6X syscall.syscall6X 22 | //go:linkname syscall_syscall9 syscall.syscall9 23 | //go:linkname syscall_rawSyscall syscall.rawSyscall 24 | //go:linkname syscall_rawSyscall6 syscall.rawSyscall6 25 | 26 | // Find the entry point for f. See comments in runtime/proc.go for the 27 | // function of the same name. 28 | //go:nosplit 29 | func funcPC(f func()) uintptr { 30 | return **(**uintptr)(unsafe.Pointer(&f)) 31 | } 32 | -------------------------------------------------------------------------------- /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_freebsd_arm64.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 arm64,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_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 | //sysnb EpollCreate(size int) (fd int, err error) 11 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n 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) 22 | //sysnb Getuid() (uid int) 23 | //sysnb inotifyInit() (fd int, err error) 24 | 25 | func InotifyInit() (fd int, err error) { 26 | // First try inotify_init1, because Android's seccomp policy blocks the latter. 27 | fd, err = InotifyInit1(0) 28 | if err == ENOSYS { 29 | fd, err = inotifyInit() 30 | } 31 | return 32 | } 33 | 34 | //sys Ioperm(from int, num int, on int) (err error) 35 | //sys Iopl(level int) (err error) 36 | //sys Lchown(path string, uid int, gid int) (err error) 37 | //sys Listen(s int, n int) (err error) 38 | 39 | func Lstat(path string, stat *Stat_t) (err error) { 40 | return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW) 41 | } 42 | 43 | //sys Pause() (err error) 44 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 45 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 46 | //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) 47 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 48 | 49 | func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { 50 | var ts *Timespec 51 | if timeout != nil { 52 | ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000} 53 | } 54 | return Pselect(nfd, r, w, e, ts, nil) 55 | } 56 | 57 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 58 | //sys Setfsgid(gid int) (err error) 59 | //sys Setfsuid(uid int) (err error) 60 | //sysnb Setregid(rgid int, egid int) (err error) 61 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 62 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 63 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 64 | //sysnb Setreuid(ruid int, euid int) (err error) 65 | //sys Shutdown(fd int, how int) (err error) 66 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 67 | 68 | func Stat(path string, stat *Stat_t) (err error) { 69 | // Use fstatat, because Android's seccomp policy blocks stat. 70 | return Fstatat(AT_FDCWD, path, stat, 0) 71 | } 72 | 73 | //sys Statfs(path string, buf *Statfs_t) (err error) 74 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 75 | //sys Truncate(path string, length int64) (err error) 76 | //sys Ustat(dev int, ubuf *Ustat_t) (err error) 77 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 78 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 79 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 80 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 81 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 82 | //sysnb setgroups(n int, list *_Gid_t) (err error) 83 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 84 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 85 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 86 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 87 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 88 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 89 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 90 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 91 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 92 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 93 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 94 | 95 | //sys futimesat(dirfd int, path string, times *[2]Timeval) (err error) 96 | 97 | func Gettimeofday(tv *Timeval) (err error) { 98 | errno := gettimeofday(tv) 99 | if errno != 0 { 100 | return errno 101 | } 102 | return nil 103 | } 104 | 105 | func Time(t *Time_t) (tt Time_t, err error) { 106 | var tv Timeval 107 | errno := gettimeofday(&tv) 108 | if errno != 0 { 109 | return 0, errno 110 | } 111 | if t != nil { 112 | *t = Time_t(tv.Sec) 113 | } 114 | return Time_t(tv.Sec), nil 115 | } 116 | 117 | //sys Utime(path string, buf *Utimbuf) (err error) 118 | //sys utimes(path string, times *[2]Timeval) (err error) 119 | 120 | func setTimespec(sec, nsec int64) Timespec { 121 | return Timespec{Sec: sec, Nsec: nsec} 122 | } 123 | 124 | func setTimeval(sec, usec int64) Timeval { 125 | return Timeval{Sec: sec, Usec: usec} 126 | } 127 | 128 | //sysnb pipe(p *[2]_C_int) (err error) 129 | 130 | func Pipe(p []int) (err error) { 131 | if len(p) != 2 { 132 | return EINVAL 133 | } 134 | var pp [2]_C_int 135 | err = pipe(&pp) 136 | p[0] = int(pp[0]) 137 | p[1] = int(pp[1]) 138 | return 139 | } 140 | 141 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 142 | 143 | func Pipe2(p []int, flags int) (err error) { 144 | if len(p) != 2 { 145 | return EINVAL 146 | } 147 | var pp [2]_C_int 148 | err = pipe2(&pp, flags) 149 | p[0] = int(pp[0]) 150 | p[1] = int(pp[1]) 151 | return 152 | } 153 | 154 | func (r *PtraceRegs) PC() uint64 { return r.Rip } 155 | 156 | func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc } 157 | 158 | func (iov *Iovec) SetLen(length int) { 159 | iov.Len = uint64(length) 160 | } 161 | 162 | func (msghdr *Msghdr) SetControllen(length int) { 163 | msghdr.Controllen = uint64(length) 164 | } 165 | 166 | func (cmsg *Cmsghdr) SetLen(length int) { 167 | cmsg.Len = uint64(length) 168 | } 169 | 170 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 171 | 172 | func Poll(fds []PollFd, timeout int) (n int, err error) { 173 | if len(fds) == 0 { 174 | return poll(nil, 0, timeout) 175 | } 176 | return poll(&fds[0], len(fds), timeout) 177 | } 178 | 179 | //sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) 180 | 181 | func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { 182 | cmdlineLen := len(cmdline) 183 | if cmdlineLen > 0 { 184 | // Account for the additional NULL byte added by 185 | // BytePtrFromString in kexecFileLoad. The kexec_file_load 186 | // syscall expects a NULL-terminated string. 187 | cmdlineLen++ 188 | } 189 | return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) 190 | } 191 | -------------------------------------------------------------------------------- /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_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_gc_386.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,386 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // Underlying system call writes to newoffset via pointer. 12 | // Implemented in assembly to avoid allocation. 13 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 14 | 15 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 16 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.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,386 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | 22 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 23 | fd, _, err := Syscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 24 | return int(fd), err 25 | } 26 | 27 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 28 | fd, _, err := RawSyscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 29 | return int(fd), err 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.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,arm 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 15 | var newoffset int64 16 | offsetLow := uint32(offset & 0xffffffff) 17 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 18 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 19 | return newoffset, err 20 | } 21 | -------------------------------------------------------------------------------- /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 Dup2(oldfd int, newfd int) (err error) 11 | //sysnb EpollCreate(size int) (fd int, err error) 12 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 13 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 14 | //sys Fchown(fd int, uid int, gid int) (err error) 15 | //sys Fstat(fd int, stat *Stat_t) (err error) 16 | //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT 17 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 18 | //sys Ftruncate(fd int, length int64) (err error) 19 | //sysnb Getegid() (egid int) 20 | //sysnb Geteuid() (euid int) 21 | //sysnb Getgid() (gid int) 22 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT 23 | //sysnb Getuid() (uid int) 24 | //sysnb InotifyInit() (fd int, err error) 25 | //sys Ioperm(from int, num int, on int) (err error) 26 | //sys Iopl(level int) (err error) 27 | //sys Lchown(path string, uid int, gid int) (err error) 28 | //sys Listen(s int, n int) (err error) 29 | //sys Lstat(path string, stat *Stat_t) (err error) 30 | //sys Pause() (err error) 31 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 32 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 33 | //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) 34 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 35 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT 36 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 37 | //sys Setfsgid(gid int) (err error) 38 | //sys Setfsuid(uid int) (err error) 39 | //sysnb Setregid(rgid int, egid int) (err error) 40 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 41 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 42 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 43 | //sysnb Setreuid(ruid int, euid int) (err error) 44 | //sys Shutdown(fd int, how int) (err error) 45 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 46 | //sys Stat(path string, stat *Stat_t) (err error) 47 | //sys Statfs(path string, buf *Statfs_t) (err error) 48 | //sys Truncate(path string, length int64) (err error) 49 | //sys Ustat(dev int, ubuf *Ustat_t) (err error) 50 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 51 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 52 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 53 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 54 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 55 | //sysnb setgroups(n int, list *_Gid_t) (err error) 56 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 57 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 58 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 59 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 60 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 61 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 62 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 63 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 64 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 65 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 66 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 67 | 68 | //sys futimesat(dirfd int, path string, times *[2]Timeval) (err error) 69 | //sysnb Gettimeofday(tv *Timeval) (err error) 70 | //sysnb Time(t *Time_t) (tt Time_t, err error) 71 | //sys Utime(path string, buf *Utimbuf) (err error) 72 | //sys utimes(path string, times *[2]Timeval) (err error) 73 | 74 | func setTimespec(sec, nsec int64) Timespec { 75 | return Timespec{Sec: sec, Nsec: nsec} 76 | } 77 | 78 | func setTimeval(sec, usec int64) Timeval { 79 | return Timeval{Sec: sec, Usec: usec} 80 | } 81 | 82 | func (r *PtraceRegs) PC() uint64 { return r.Nip } 83 | 84 | func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc } 85 | 86 | func (iov *Iovec) SetLen(length int) { 87 | iov.Len = uint64(length) 88 | } 89 | 90 | func (msghdr *Msghdr) SetControllen(length int) { 91 | msghdr.Controllen = uint64(length) 92 | } 93 | 94 | func (cmsg *Cmsghdr) SetLen(length int) { 95 | cmsg.Len = uint64(length) 96 | } 97 | 98 | //sysnb pipe(p *[2]_C_int) (err error) 99 | 100 | func Pipe(p []int) (err error) { 101 | if len(p) != 2 { 102 | return EINVAL 103 | } 104 | var pp [2]_C_int 105 | err = pipe(&pp) 106 | p[0] = int(pp[0]) 107 | p[1] = int(pp[1]) 108 | return 109 | } 110 | 111 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 112 | 113 | func Pipe2(p []int, flags int) (err error) { 114 | if len(p) != 2 { 115 | return EINVAL 116 | } 117 | var pp [2]_C_int 118 | err = pipe2(&pp, flags) 119 | p[0] = int(pp[0]) 120 | p[1] = int(pp[1]) 121 | return 122 | } 123 | 124 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 125 | 126 | func Poll(fds []PollFd, timeout int) (n int, err error) { 127 | if len(fds) == 0 { 128 | return poll(nil, 0, timeout) 129 | } 130 | return poll(&fds[0], len(fds), timeout) 131 | } 132 | 133 | //sys syncFileRange2(fd int, flags int, off int64, n int64) (err error) = SYS_SYNC_FILE_RANGE2 134 | 135 | func SyncFileRange(fd int, off int64, n int64, flags int) error { 136 | // The sync_file_range and sync_file_range2 syscalls differ only in the 137 | // order of their arguments. 138 | return syncFileRange2(fd, flags, off, n) 139 | } 140 | 141 | //sys kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) 142 | 143 | func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error { 144 | cmdlineLen := len(cmdline) 145 | if cmdlineLen > 0 { 146 | // Account for the additional NULL byte added by 147 | // BytePtrFromString in kexecFileLoad. The kexec_file_load 148 | // syscall expects a NULL-terminated string. 149 | cmdlineLen++ 150 | } 151 | return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) 152 | } 153 | -------------------------------------------------------------------------------- /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 Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) 30 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 31 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 32 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 33 | //sys Setfsgid(gid int) (err error) 34 | //sys Setfsuid(uid int) (err error) 35 | //sysnb Setregid(rgid int, egid int) (err error) 36 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 37 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 38 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 39 | //sysnb Setreuid(ruid int, euid int) (err error) 40 | //sys Shutdown(fd int, how int) (err error) 41 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 42 | //sys Stat(path string, stat *Stat_t) (err error) 43 | //sys Statfs(path string, buf *Statfs_t) (err error) 44 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 45 | //sys Truncate(path string, length int64) (err error) 46 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 47 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 48 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 49 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 50 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 51 | //sysnb setgroups(n int, list *_Gid_t) (err error) 52 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 53 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 54 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 55 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 56 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 57 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 58 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 59 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 60 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 61 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 62 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 63 | 64 | func Ioperm(from int, num int, on int) (err error) { 65 | return ENOSYS 66 | } 67 | 68 | func Iopl(level int) (err error) { 69 | return ENOSYS 70 | } 71 | 72 | //sys futimesat(dirfd int, path string, times *[2]Timeval) (err error) 73 | //sysnb Gettimeofday(tv *Timeval) (err error) 74 | 75 | func Time(t *Time_t) (tt Time_t, err error) { 76 | var tv Timeval 77 | err = Gettimeofday(&tv) 78 | if err != nil { 79 | return 0, err 80 | } 81 | if t != nil { 82 | *t = Time_t(tv.Sec) 83 | } 84 | return Time_t(tv.Sec), nil 85 | } 86 | 87 | //sys Utime(path string, buf *Utimbuf) (err error) 88 | //sys utimes(path string, times *[2]Timeval) (err error) 89 | 90 | func setTimespec(sec, nsec int64) Timespec { 91 | return Timespec{Sec: sec, Nsec: nsec} 92 | } 93 | 94 | func setTimeval(sec, usec int64) Timeval { 95 | return Timeval{Sec: sec, Usec: int32(usec)} 96 | } 97 | 98 | func (r *PtraceRegs) PC() uint64 { return r.Tpc } 99 | 100 | func (r *PtraceRegs) SetPC(pc uint64) { r.Tpc = pc } 101 | 102 | func (iov *Iovec) SetLen(length int) { 103 | iov.Len = uint64(length) 104 | } 105 | 106 | func (msghdr *Msghdr) SetControllen(length int) { 107 | msghdr.Controllen = uint64(length) 108 | } 109 | 110 | func (cmsg *Cmsghdr) SetLen(length int) { 111 | cmsg.Len = uint64(length) 112 | } 113 | 114 | //sysnb pipe(p *[2]_C_int) (err error) 115 | 116 | func Pipe(p []int) (err error) { 117 | if len(p) != 2 { 118 | return EINVAL 119 | } 120 | var pp [2]_C_int 121 | err = pipe(&pp) 122 | p[0] = int(pp[0]) 123 | p[1] = int(pp[1]) 124 | return 125 | } 126 | 127 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 128 | 129 | func Pipe2(p []int, flags int) (err error) { 130 | if len(p) != 2 { 131 | return EINVAL 132 | } 133 | var pp [2]_C_int 134 | err = pipe2(&pp, flags) 135 | p[0] = int(pp[0]) 136 | p[1] = int(pp[1]) 137 | return 138 | } 139 | 140 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 141 | 142 | func Poll(fds []PollFd, timeout int) (n int, err error) { 143 | if len(fds) == 0 { 144 | return poll(nil, 0, timeout) 145 | } 146 | return poll(&fds[0], len(fds), timeout) 147 | } 148 | -------------------------------------------------------------------------------- /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_netbsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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,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_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 | 35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 36 | // of openbsd/386 the syscall is called sysctl instead of __sysctl. 37 | const SYS___SYSCTL = SYS_SYSCTL 38 | -------------------------------------------------------------------------------- /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 | 35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 36 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 37 | const SYS___SYSCTL = SYS_SYSCTL 38 | -------------------------------------------------------------------------------- /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 | 35 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 36 | // of openbsd/arm the syscall is called sysctl instead of __sysctl. 37 | const SYS___SYSCTL = SYS_SYSCTL 38 | -------------------------------------------------------------------------------- /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,!ppc64le,!ppc64 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/syscall_unix_gc_ppc64x.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 ppc64le ppc64 7 | // +build !gccgo 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 14 | return syscall.Syscall(trap, a1, a2, a3) 15 | } 16 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 17 | return syscall.Syscall6(trap, a1, a2, a3, a4, a5, a6) 18 | } 19 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 20 | return syscall.RawSyscall(trap, a1, a2, a3) 21 | } 22 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 23 | return syscall.RawSyscall6(trap, a1, a2, a3, a4, a5, a6) 24 | } 25 | -------------------------------------------------------------------------------- /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 aix 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/xattr_bsd.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 freebsd netbsd 6 | 7 | package unix 8 | 9 | import ( 10 | "strings" 11 | "unsafe" 12 | ) 13 | 14 | // Derive extattr namespace and attribute name 15 | 16 | func xattrnamespace(fullattr string) (ns int, attr string, err error) { 17 | s := strings.IndexByte(fullattr, '.') 18 | if s == -1 { 19 | return -1, "", ENOATTR 20 | } 21 | 22 | namespace := fullattr[0:s] 23 | attr = fullattr[s+1:] 24 | 25 | switch namespace { 26 | case "user": 27 | return EXTATTR_NAMESPACE_USER, attr, nil 28 | case "system": 29 | return EXTATTR_NAMESPACE_SYSTEM, attr, nil 30 | default: 31 | return -1, "", ENOATTR 32 | } 33 | } 34 | 35 | func initxattrdest(dest []byte, idx int) (d unsafe.Pointer) { 36 | if len(dest) > idx { 37 | return unsafe.Pointer(&dest[idx]) 38 | } else { 39 | return unsafe.Pointer(_zero) 40 | } 41 | } 42 | 43 | // FreeBSD and NetBSD implement their own syscalls to handle extended attributes 44 | 45 | func Getxattr(file string, attr string, dest []byte) (sz int, err error) { 46 | d := initxattrdest(dest, 0) 47 | destsize := len(dest) 48 | 49 | nsid, a, err := xattrnamespace(attr) 50 | if err != nil { 51 | return -1, err 52 | } 53 | 54 | return ExtattrGetFile(file, nsid, a, uintptr(d), destsize) 55 | } 56 | 57 | func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) { 58 | d := initxattrdest(dest, 0) 59 | destsize := len(dest) 60 | 61 | nsid, a, err := xattrnamespace(attr) 62 | if err != nil { 63 | return -1, err 64 | } 65 | 66 | return ExtattrGetFd(fd, nsid, a, uintptr(d), destsize) 67 | } 68 | 69 | func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) { 70 | d := initxattrdest(dest, 0) 71 | destsize := len(dest) 72 | 73 | nsid, a, err := xattrnamespace(attr) 74 | if err != nil { 75 | return -1, err 76 | } 77 | 78 | return ExtattrGetLink(link, nsid, a, uintptr(d), destsize) 79 | } 80 | 81 | // flags are unused on FreeBSD 82 | 83 | func Fsetxattr(fd int, attr string, data []byte, flags int) (err error) { 84 | var d unsafe.Pointer 85 | if len(data) > 0 { 86 | d = unsafe.Pointer(&data[0]) 87 | } 88 | datasiz := len(data) 89 | 90 | nsid, a, err := xattrnamespace(attr) 91 | if err != nil { 92 | return 93 | } 94 | 95 | _, err = ExtattrSetFd(fd, nsid, a, uintptr(d), datasiz) 96 | return 97 | } 98 | 99 | func Setxattr(file string, attr string, data []byte, flags int) (err error) { 100 | var d unsafe.Pointer 101 | if len(data) > 0 { 102 | d = unsafe.Pointer(&data[0]) 103 | } 104 | datasiz := len(data) 105 | 106 | nsid, a, err := xattrnamespace(attr) 107 | if err != nil { 108 | return 109 | } 110 | 111 | _, err = ExtattrSetFile(file, nsid, a, uintptr(d), datasiz) 112 | return 113 | } 114 | 115 | func Lsetxattr(link string, attr string, data []byte, flags int) (err error) { 116 | var d unsafe.Pointer 117 | if len(data) > 0 { 118 | d = unsafe.Pointer(&data[0]) 119 | } 120 | datasiz := len(data) 121 | 122 | nsid, a, err := xattrnamespace(attr) 123 | if err != nil { 124 | return 125 | } 126 | 127 | _, err = ExtattrSetLink(link, nsid, a, uintptr(d), datasiz) 128 | return 129 | } 130 | 131 | func Removexattr(file string, attr string) (err error) { 132 | nsid, a, err := xattrnamespace(attr) 133 | if err != nil { 134 | return 135 | } 136 | 137 | err = ExtattrDeleteFile(file, nsid, a) 138 | return 139 | } 140 | 141 | func Fremovexattr(fd int, attr string) (err error) { 142 | nsid, a, err := xattrnamespace(attr) 143 | if err != nil { 144 | return 145 | } 146 | 147 | err = ExtattrDeleteFd(fd, nsid, a) 148 | return 149 | } 150 | 151 | func Lremovexattr(link string, attr string) (err error) { 152 | nsid, a, err := xattrnamespace(attr) 153 | if err != nil { 154 | return 155 | } 156 | 157 | err = ExtattrDeleteLink(link, nsid, a) 158 | return 159 | } 160 | 161 | func Listxattr(file string, dest []byte) (sz int, err error) { 162 | d := initxattrdest(dest, 0) 163 | destsiz := len(dest) 164 | 165 | // FreeBSD won't allow you to list xattrs from multiple namespaces 166 | s := 0 167 | for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} { 168 | stmp, e := ExtattrListFile(file, nsid, uintptr(d), destsiz) 169 | 170 | /* Errors accessing system attrs are ignored so that 171 | * we can implement the Linux-like behavior of omitting errors that 172 | * we don't have read permissions on 173 | * 174 | * Linux will still error if we ask for user attributes on a file that 175 | * we don't have read permissions on, so don't ignore those errors 176 | */ 177 | if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER { 178 | continue 179 | } else if e != nil { 180 | return s, e 181 | } 182 | 183 | s += stmp 184 | destsiz -= s 185 | if destsiz < 0 { 186 | destsiz = 0 187 | } 188 | d = initxattrdest(dest, s) 189 | } 190 | 191 | return s, nil 192 | } 193 | 194 | func Flistxattr(fd int, dest []byte) (sz int, err error) { 195 | d := initxattrdest(dest, 0) 196 | destsiz := len(dest) 197 | 198 | s := 0 199 | for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} { 200 | stmp, e := ExtattrListFd(fd, nsid, uintptr(d), destsiz) 201 | if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER { 202 | continue 203 | } else if e != nil { 204 | return s, e 205 | } 206 | 207 | s += stmp 208 | destsiz -= s 209 | if destsiz < 0 { 210 | destsiz = 0 211 | } 212 | d = initxattrdest(dest, s) 213 | } 214 | 215 | return s, nil 216 | } 217 | 218 | func Llistxattr(link string, dest []byte) (sz int, err error) { 219 | d := initxattrdest(dest, 0) 220 | destsiz := len(dest) 221 | 222 | s := 0 223 | for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} { 224 | stmp, e := ExtattrListLink(link, nsid, uintptr(d), destsiz) 225 | if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER { 226 | continue 227 | } else if e != nil { 228 | return s, e 229 | } 230 | 231 | s += stmp 232 | destsiz -= s 233 | if destsiz < 0 { 234 | destsiz = 0 235 | } 236 | d = initxattrdest(dest, s) 237 | } 238 | 239 | return s, nil 240 | } 241 | -------------------------------------------------------------------------------- /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/unix/ztypes_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // cgo -godefs types_aix.go | go run mkpost.go 2 | // Code generated by the command above; see README.md. DO NOT EDIT. 3 | 4 | // +build ppc,aix 5 | 6 | package unix 7 | 8 | const ( 9 | SizeofPtr = 0x4 10 | SizeofShort = 0x2 11 | SizeofInt = 0x4 12 | SizeofLong = 0x4 13 | SizeofLongLong = 0x8 14 | PathMax = 0x3ff 15 | ) 16 | 17 | type ( 18 | _C_short int16 19 | _C_int int32 20 | _C_long int32 21 | _C_long_long int64 22 | ) 23 | 24 | type off64 int64 25 | type off int32 26 | type Mode_t uint32 27 | 28 | type Timespec struct { 29 | Sec int32 30 | Nsec int32 31 | } 32 | 33 | type StTimespec struct { 34 | Sec int32 35 | Nsec int32 36 | } 37 | 38 | type Timeval struct { 39 | Sec int32 40 | Usec int32 41 | } 42 | 43 | type Timeval32 struct { 44 | Sec int32 45 | Usec int32 46 | } 47 | 48 | type Timex struct{} 49 | 50 | type Time_t int32 51 | 52 | type Tms struct{} 53 | 54 | type Utimbuf struct { 55 | Actime int32 56 | Modtime int32 57 | } 58 | 59 | type Timezone struct { 60 | Minuteswest int32 61 | Dsttime int32 62 | } 63 | 64 | type Rusage struct { 65 | Utime Timeval 66 | Stime Timeval 67 | Maxrss int32 68 | Ixrss int32 69 | Idrss int32 70 | Isrss int32 71 | Minflt int32 72 | Majflt int32 73 | Nswap int32 74 | Inblock int32 75 | Oublock int32 76 | Msgsnd int32 77 | Msgrcv int32 78 | Nsignals int32 79 | Nvcsw int32 80 | Nivcsw int32 81 | } 82 | 83 | type Rlimit struct { 84 | Cur uint64 85 | Max uint64 86 | } 87 | 88 | type Pid_t int32 89 | 90 | type _Gid_t uint32 91 | 92 | type dev_t uint32 93 | 94 | type Stat_t struct { 95 | Dev uint32 96 | Ino uint32 97 | Mode uint32 98 | Nlink int16 99 | Flag uint16 100 | Uid uint32 101 | Gid uint32 102 | Rdev uint32 103 | Size int32 104 | Atim StTimespec 105 | Mtim StTimespec 106 | Ctim StTimespec 107 | Blksize int32 108 | Blocks int32 109 | Vfstype int32 110 | Vfs uint32 111 | Type uint32 112 | Gen uint32 113 | Reserved [9]uint32 114 | } 115 | 116 | type StatxTimestamp struct{} 117 | 118 | type Statx_t struct{} 119 | 120 | type Dirent struct { 121 | Offset uint32 122 | Ino uint32 123 | Reclen uint16 124 | Namlen uint16 125 | Name [256]uint8 126 | } 127 | 128 | type RawSockaddrInet4 struct { 129 | Len uint8 130 | Family uint8 131 | Port uint16 132 | Addr [4]byte /* in_addr */ 133 | Zero [8]uint8 134 | } 135 | 136 | type RawSockaddrInet6 struct { 137 | Len uint8 138 | Family uint8 139 | Port uint16 140 | Flowinfo uint32 141 | Addr [16]byte /* in6_addr */ 142 | Scope_id uint32 143 | } 144 | 145 | type RawSockaddrUnix struct { 146 | Len uint8 147 | Family uint8 148 | Path [1023]uint8 149 | } 150 | 151 | type RawSockaddr struct { 152 | Len uint8 153 | Family uint8 154 | Data [14]uint8 155 | } 156 | 157 | type RawSockaddrAny struct { 158 | Addr RawSockaddr 159 | Pad [1012]uint8 160 | } 161 | 162 | type _Socklen uint32 163 | 164 | type Cmsghdr struct { 165 | Len uint32 166 | Level int32 167 | Type int32 168 | } 169 | 170 | type ICMPv6Filter struct { 171 | Filt [8]uint32 172 | } 173 | 174 | type Iovec struct { 175 | Base *byte 176 | Len uint32 177 | } 178 | 179 | type IPMreq struct { 180 | Multiaddr [4]byte /* in_addr */ 181 | Interface [4]byte /* in_addr */ 182 | } 183 | 184 | type IPv6Mreq struct { 185 | Multiaddr [16]byte /* in6_addr */ 186 | Interface uint32 187 | } 188 | 189 | type IPv6MTUInfo struct { 190 | Addr RawSockaddrInet6 191 | Mtu uint32 192 | } 193 | 194 | type Linger struct { 195 | Onoff int32 196 | Linger int32 197 | } 198 | 199 | type Msghdr struct { 200 | Name *byte 201 | Namelen uint32 202 | Iov *Iovec 203 | Iovlen int32 204 | Control *byte 205 | Controllen uint32 206 | Flags int32 207 | } 208 | 209 | const ( 210 | SizeofSockaddrInet4 = 0x10 211 | SizeofSockaddrInet6 = 0x1c 212 | SizeofSockaddrAny = 0x404 213 | SizeofSockaddrUnix = 0x401 214 | SizeofLinger = 0x8 215 | SizeofIPMreq = 0x8 216 | SizeofIPv6Mreq = 0x14 217 | SizeofIPv6MTUInfo = 0x20 218 | SizeofMsghdr = 0x1c 219 | SizeofCmsghdr = 0xc 220 | SizeofICMPv6Filter = 0x20 221 | ) 222 | 223 | const ( 224 | SizeofIfMsghdr = 0x10 225 | ) 226 | 227 | type IfMsgHdr struct { 228 | Msglen uint16 229 | Version uint8 230 | Type uint8 231 | Addrs int32 232 | Flags int32 233 | Index uint16 234 | Addrlen uint8 235 | _ [1]byte 236 | } 237 | 238 | type FdSet struct { 239 | Bits [2048]int32 240 | } 241 | 242 | type Utsname struct { 243 | Sysname [32]byte 244 | Nodename [32]byte 245 | Release [32]byte 246 | Version [32]byte 247 | Machine [32]byte 248 | } 249 | 250 | type Ustat_t struct{} 251 | 252 | type Sigset_t struct { 253 | Losigs uint32 254 | Hisigs uint32 255 | } 256 | 257 | const ( 258 | AT_FDCWD = -0x2 259 | AT_REMOVEDIR = 0x1 260 | AT_SYMLINK_NOFOLLOW = 0x1 261 | ) 262 | 263 | type Termios struct { 264 | Iflag uint32 265 | Oflag uint32 266 | Cflag uint32 267 | Lflag uint32 268 | Cc [16]uint8 269 | } 270 | 271 | type Termio struct { 272 | Iflag uint16 273 | Oflag uint16 274 | Cflag uint16 275 | Lflag uint16 276 | Line uint8 277 | Cc [8]uint8 278 | _ [1]byte 279 | } 280 | 281 | type Winsize struct { 282 | Row uint16 283 | Col uint16 284 | Xpixel uint16 285 | Ypixel uint16 286 | } 287 | 288 | type PollFd struct { 289 | Fd int32 290 | Events uint16 291 | Revents uint16 292 | } 293 | 294 | const ( 295 | POLLERR = 0x4000 296 | POLLHUP = 0x2000 297 | POLLIN = 0x1 298 | POLLNVAL = 0x8000 299 | POLLOUT = 0x2 300 | POLLPRI = 0x4 301 | POLLRDBAND = 0x20 302 | POLLRDNORM = 0x10 303 | POLLWRBAND = 0x40 304 | POLLWRNORM = 0x2 305 | ) 306 | 307 | type Flock_t struct { 308 | Type int16 309 | Whence int16 310 | Sysid uint32 311 | Pid int32 312 | Vfs int32 313 | Start int64 314 | Len int64 315 | } 316 | 317 | type Fsid_t struct { 318 | Val [2]uint32 319 | } 320 | type Fsid64_t struct { 321 | Val [2]uint64 322 | } 323 | 324 | type Statfs_t struct { 325 | Version int32 326 | Type int32 327 | Bsize uint32 328 | Blocks uint32 329 | Bfree uint32 330 | Bavail uint32 331 | Files uint32 332 | Ffree uint32 333 | Fsid Fsid_t 334 | Vfstype int32 335 | Fsize uint32 336 | Vfsnumber int32 337 | Vfsoff int32 338 | Vfslen int32 339 | Vfsvers int32 340 | Fname [32]uint8 341 | Fpack [32]uint8 342 | Name_max int32 343 | } 344 | 345 | const RNDGETENTCNT = 0x80045200 346 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ztypes_aix_ppc64.go: -------------------------------------------------------------------------------- 1 | // cgo -godefs types_aix.go | go run mkpost.go 2 | // Code generated by the command above; see README.md. DO NOT EDIT. 3 | 4 | // +build ppc64,aix 5 | 6 | package unix 7 | 8 | const ( 9 | SizeofPtr = 0x8 10 | SizeofShort = 0x2 11 | SizeofInt = 0x4 12 | SizeofLong = 0x8 13 | SizeofLongLong = 0x8 14 | PathMax = 0x3ff 15 | ) 16 | 17 | type ( 18 | _C_short int16 19 | _C_int int32 20 | _C_long int64 21 | _C_long_long int64 22 | ) 23 | 24 | type off64 int64 25 | type off int64 26 | type Mode_t uint32 27 | 28 | type Timespec struct { 29 | Sec int64 30 | Nsec int64 31 | } 32 | 33 | type StTimespec struct { 34 | Sec int64 35 | Nsec int32 36 | _ [4]byte 37 | } 38 | 39 | type Timeval struct { 40 | Sec int64 41 | Usec int32 42 | _ [4]byte 43 | } 44 | 45 | type Timeval32 struct { 46 | Sec int32 47 | Usec int32 48 | } 49 | 50 | type Timex struct{} 51 | 52 | type Time_t int64 53 | 54 | type Tms struct{} 55 | 56 | type Utimbuf struct { 57 | Actime int64 58 | Modtime int64 59 | } 60 | 61 | type Timezone struct { 62 | Minuteswest int32 63 | Dsttime int32 64 | } 65 | 66 | type Rusage struct { 67 | Utime Timeval 68 | Stime Timeval 69 | Maxrss int64 70 | Ixrss int64 71 | Idrss int64 72 | Isrss int64 73 | Minflt int64 74 | Majflt int64 75 | Nswap int64 76 | Inblock int64 77 | Oublock int64 78 | Msgsnd int64 79 | Msgrcv int64 80 | Nsignals int64 81 | Nvcsw int64 82 | Nivcsw int64 83 | } 84 | 85 | type Rlimit struct { 86 | Cur uint64 87 | Max uint64 88 | } 89 | 90 | type Pid_t int32 91 | 92 | type _Gid_t uint32 93 | 94 | type dev_t uint64 95 | 96 | type Stat_t struct { 97 | Dev uint64 98 | Ino uint64 99 | Mode uint32 100 | Nlink int16 101 | Flag uint16 102 | Uid uint32 103 | Gid uint32 104 | Rdev uint64 105 | Ssize int32 106 | _ [4]byte 107 | Atim StTimespec 108 | Mtim StTimespec 109 | Ctim StTimespec 110 | Blksize int64 111 | Blocks int64 112 | Vfstype int32 113 | Vfs uint32 114 | Type uint32 115 | Gen uint32 116 | Reserved [9]uint32 117 | Padto_ll uint32 118 | Size int64 119 | } 120 | 121 | type StatxTimestamp struct{} 122 | 123 | type Statx_t struct{} 124 | 125 | type Dirent struct { 126 | Offset uint64 127 | Ino uint64 128 | Reclen uint16 129 | Namlen uint16 130 | Name [256]uint8 131 | _ [4]byte 132 | } 133 | 134 | type RawSockaddrInet4 struct { 135 | Len uint8 136 | Family uint8 137 | Port uint16 138 | Addr [4]byte /* in_addr */ 139 | Zero [8]uint8 140 | } 141 | 142 | type RawSockaddrInet6 struct { 143 | Len uint8 144 | Family uint8 145 | Port uint16 146 | Flowinfo uint32 147 | Addr [16]byte /* in6_addr */ 148 | Scope_id uint32 149 | } 150 | 151 | type RawSockaddrUnix struct { 152 | Len uint8 153 | Family uint8 154 | Path [1023]uint8 155 | } 156 | 157 | type RawSockaddr struct { 158 | Len uint8 159 | Family uint8 160 | Data [14]uint8 161 | } 162 | 163 | type RawSockaddrAny struct { 164 | Addr RawSockaddr 165 | Pad [1012]uint8 166 | } 167 | 168 | type _Socklen uint32 169 | 170 | type Cmsghdr struct { 171 | Len uint32 172 | Level int32 173 | Type int32 174 | } 175 | 176 | type ICMPv6Filter struct { 177 | Filt [8]uint32 178 | } 179 | 180 | type Iovec struct { 181 | Base *byte 182 | Len uint64 183 | } 184 | 185 | type IPMreq struct { 186 | Multiaddr [4]byte /* in_addr */ 187 | Interface [4]byte /* in_addr */ 188 | } 189 | 190 | type IPv6Mreq struct { 191 | Multiaddr [16]byte /* in6_addr */ 192 | Interface uint32 193 | } 194 | 195 | type IPv6MTUInfo struct { 196 | Addr RawSockaddrInet6 197 | Mtu uint32 198 | } 199 | 200 | type Linger struct { 201 | Onoff int32 202 | Linger int32 203 | } 204 | 205 | type Msghdr struct { 206 | Name *byte 207 | Namelen uint32 208 | _ [4]byte 209 | Iov *Iovec 210 | Iovlen int32 211 | _ [4]byte 212 | Control *byte 213 | Controllen uint32 214 | Flags int32 215 | } 216 | 217 | const ( 218 | SizeofSockaddrInet4 = 0x10 219 | SizeofSockaddrInet6 = 0x1c 220 | SizeofSockaddrAny = 0x404 221 | SizeofSockaddrUnix = 0x401 222 | SizeofLinger = 0x8 223 | SizeofIPMreq = 0x8 224 | SizeofIPv6Mreq = 0x14 225 | SizeofIPv6MTUInfo = 0x20 226 | SizeofMsghdr = 0x30 227 | SizeofCmsghdr = 0xc 228 | SizeofICMPv6Filter = 0x20 229 | ) 230 | 231 | const ( 232 | SizeofIfMsghdr = 0x10 233 | ) 234 | 235 | type IfMsgHdr struct { 236 | Msglen uint16 237 | Version uint8 238 | Type uint8 239 | Addrs int32 240 | Flags int32 241 | Index uint16 242 | Addrlen uint8 243 | _ [1]byte 244 | } 245 | 246 | type FdSet struct { 247 | Bits [1024]int64 248 | } 249 | 250 | type Utsname struct { 251 | Sysname [32]byte 252 | Nodename [32]byte 253 | Release [32]byte 254 | Version [32]byte 255 | Machine [32]byte 256 | } 257 | 258 | type Ustat_t struct{} 259 | 260 | type Sigset_t struct { 261 | Set [4]uint64 262 | } 263 | 264 | const ( 265 | AT_FDCWD = -0x2 266 | AT_REMOVEDIR = 0x1 267 | AT_SYMLINK_NOFOLLOW = 0x1 268 | ) 269 | 270 | type Termios struct { 271 | Iflag uint32 272 | Oflag uint32 273 | Cflag uint32 274 | Lflag uint32 275 | Cc [16]uint8 276 | } 277 | 278 | type Termio struct { 279 | Iflag uint16 280 | Oflag uint16 281 | Cflag uint16 282 | Lflag uint16 283 | Line uint8 284 | Cc [8]uint8 285 | _ [1]byte 286 | } 287 | 288 | type Winsize struct { 289 | Row uint16 290 | Col uint16 291 | Xpixel uint16 292 | Ypixel uint16 293 | } 294 | 295 | type PollFd struct { 296 | Fd int32 297 | Events uint16 298 | Revents uint16 299 | } 300 | 301 | const ( 302 | POLLERR = 0x4000 303 | POLLHUP = 0x2000 304 | POLLIN = 0x1 305 | POLLNVAL = 0x8000 306 | POLLOUT = 0x2 307 | POLLPRI = 0x4 308 | POLLRDBAND = 0x20 309 | POLLRDNORM = 0x10 310 | POLLWRBAND = 0x40 311 | POLLWRNORM = 0x2 312 | ) 313 | 314 | type Flock_t struct { 315 | Type int16 316 | Whence int16 317 | Sysid uint32 318 | Pid int32 319 | Vfs int32 320 | Start int64 321 | Len int64 322 | } 323 | 324 | type Fsid_t struct { 325 | Val [2]uint32 326 | } 327 | type Fsid64_t struct { 328 | Val [2]uint64 329 | } 330 | 331 | type Statfs_t struct { 332 | Version int32 333 | Type int32 334 | Bsize uint64 335 | Blocks uint64 336 | Bfree uint64 337 | Bavail uint64 338 | Files uint64 339 | Ffree uint64 340 | Fsid Fsid64_t 341 | Vfstype int32 342 | _ [4]byte 343 | Fsize uint64 344 | Vfsnumber int32 345 | Vfsoff int32 346 | Vfslen int32 347 | Vfsvers int32 348 | Fname [32]uint8 349 | Fpack [32]uint8 350 | Name_max int32 351 | _ [4]byte 352 | } 353 | 354 | const RNDGETENTCNT = 0x80045200 355 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/kr/text v0.1.0 2 | github.com/kr/text 3 | # github.com/mattn/go-colorable v0.1.4 4 | github.com/mattn/go-colorable 5 | # github.com/mattn/go-isatty v0.0.8 6 | github.com/mattn/go-isatty 7 | # golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 8 | golang.org/x/sys/unix 9 | --------------------------------------------------------------------------------