├── .gitignore ├── .travis.yml ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── README.md ├── db ├── db.go ├── error.go ├── error_test.go ├── page.go └── tx.go ├── main.go ├── main_test.go ├── server ├── edit.go ├── favicon.go ├── save.go ├── server.go ├── show.go └── templates.go └── vendor ├── github.com ├── boltdb │ └── bolt │ │ ├── LICENSE │ │ ├── bolt_386.go │ │ ├── bolt_amd64.go │ │ ├── bolt_arm.go │ │ ├── bolt_arm64.go │ │ ├── bolt_linux.go │ │ ├── bolt_openbsd.go │ │ ├── bolt_ppc.go │ │ ├── bolt_ppc64.go │ │ ├── bolt_ppc64le.go │ │ ├── bolt_s390x.go │ │ ├── bolt_unix.go │ │ ├── bolt_unix_solaris.go │ │ ├── bolt_windows.go │ │ ├── boltsync_unix.go │ │ ├── bucket.go │ │ ├── cursor.go │ │ ├── db.go │ │ ├── doc.go │ │ ├── errors.go │ │ ├── freelist.go │ │ ├── node.go │ │ ├── page.go │ │ └── tx.go └── russross │ └── blackfriday │ ├── LICENSE.txt │ ├── block.go │ ├── doc.go │ ├── html.go │ ├── inline.go │ ├── latex.go │ ├── markdown.go │ └── smartypants.go └── golang.org └── x └── sys ├── AUTHORS ├── CONTRIBUTORS ├── LICENSE ├── PATENTS └── unix ├── affinity_linux.go ├── asm_darwin_386.s ├── asm_darwin_amd64.s ├── asm_darwin_arm.s ├── asm_darwin_arm64.s ├── asm_dragonfly_amd64.s ├── asm_freebsd_386.s ├── asm_freebsd_amd64.s ├── asm_freebsd_arm.s ├── asm_linux_386.s ├── asm_linux_amd64.s ├── asm_linux_arm.s ├── asm_linux_arm64.s ├── asm_linux_mips64x.s ├── asm_linux_mipsx.s ├── asm_linux_ppc64x.s ├── asm_linux_s390x.s ├── asm_netbsd_386.s ├── asm_netbsd_amd64.s ├── asm_netbsd_arm.s ├── asm_openbsd_386.s ├── asm_openbsd_amd64.s ├── asm_openbsd_arm.s ├── asm_solaris_amd64.s ├── bluetooth_linux.go ├── cap_freebsd.go ├── constants.go ├── dev_darwin.go ├── dev_dragonfly.go ├── dev_freebsd.go ├── dev_linux.go ├── dev_netbsd.go ├── dev_openbsd.go ├── dirent.go ├── endian_big.go ├── endian_little.go ├── env_unix.go ├── errors_freebsd_386.go ├── errors_freebsd_amd64.go ├── errors_freebsd_arm.go ├── flock.go ├── flock_linux_32bit.go ├── gccgo.go ├── gccgo_c.c ├── gccgo_linux_amd64.go ├── mkpost.go ├── openbsd_pledge.go ├── pagesize_unix.go ├── race.go ├── race0.go ├── sockcmsg_linux.go ├── sockcmsg_unix.go ├── str.go ├── syscall.go ├── syscall_bsd.go ├── syscall_darwin.go ├── syscall_darwin_386.go ├── syscall_darwin_amd64.go ├── syscall_darwin_arm.go ├── syscall_darwin_arm64.go ├── syscall_dragonfly.go ├── syscall_dragonfly_amd64.go ├── syscall_freebsd.go ├── syscall_freebsd_386.go ├── syscall_freebsd_amd64.go ├── syscall_freebsd_arm.go ├── syscall_linux.go ├── syscall_linux_386.go ├── syscall_linux_amd64.go ├── syscall_linux_amd64_gc.go ├── syscall_linux_arm.go ├── syscall_linux_arm64.go ├── syscall_linux_mips64x.go ├── syscall_linux_mipsx.go ├── syscall_linux_ppc64x.go ├── syscall_linux_s390x.go ├── syscall_linux_sparc64.go ├── syscall_netbsd.go ├── syscall_netbsd_386.go ├── syscall_netbsd_amd64.go ├── syscall_netbsd_arm.go ├── syscall_openbsd.go ├── syscall_openbsd_386.go ├── syscall_openbsd_amd64.go ├── syscall_openbsd_arm.go ├── syscall_solaris.go ├── syscall_solaris_amd64.go ├── syscall_unix.go ├── syscall_unix_gc.go ├── timestruct.go ├── types_darwin.go ├── types_dragonfly.go ├── types_freebsd.go ├── types_netbsd.go ├── types_openbsd.go ├── types_solaris.go ├── zerrors_darwin_386.go ├── zerrors_darwin_amd64.go ├── zerrors_darwin_arm.go ├── zerrors_darwin_arm64.go ├── zerrors_dragonfly_amd64.go ├── zerrors_freebsd_386.go ├── zerrors_freebsd_amd64.go ├── zerrors_freebsd_arm.go ├── zerrors_linux_386.go ├── zerrors_linux_amd64.go ├── zerrors_linux_arm.go ├── zerrors_linux_arm64.go ├── zerrors_linux_mips.go ├── zerrors_linux_mips64.go ├── zerrors_linux_mips64le.go ├── zerrors_linux_mipsle.go ├── zerrors_linux_ppc64.go ├── zerrors_linux_ppc64le.go ├── zerrors_linux_s390x.go ├── zerrors_linux_sparc64.go ├── zerrors_netbsd_386.go ├── zerrors_netbsd_amd64.go ├── zerrors_netbsd_arm.go ├── zerrors_openbsd_386.go ├── zerrors_openbsd_amd64.go ├── zerrors_openbsd_arm.go ├── zerrors_solaris_amd64.go ├── zptrace386_linux.go ├── zptracearm_linux.go ├── zptracemips_linux.go ├── zptracemipsle_linux.go ├── zsyscall_darwin_386.go ├── zsyscall_darwin_amd64.go ├── zsyscall_darwin_arm.go ├── zsyscall_darwin_arm64.go ├── zsyscall_dragonfly_amd64.go ├── zsyscall_freebsd_386.go ├── zsyscall_freebsd_amd64.go ├── zsyscall_freebsd_arm.go ├── zsyscall_linux_386.go ├── zsyscall_linux_amd64.go ├── zsyscall_linux_arm.go ├── zsyscall_linux_arm64.go ├── zsyscall_linux_mips.go ├── zsyscall_linux_mips64.go ├── zsyscall_linux_mips64le.go ├── zsyscall_linux_mipsle.go ├── zsyscall_linux_ppc64.go ├── zsyscall_linux_ppc64le.go ├── zsyscall_linux_s390x.go ├── zsyscall_linux_sparc64.go ├── zsyscall_netbsd_386.go ├── zsyscall_netbsd_amd64.go ├── zsyscall_netbsd_arm.go ├── zsyscall_openbsd_386.go ├── zsyscall_openbsd_amd64.go ├── zsyscall_openbsd_arm.go ├── zsyscall_solaris_amd64.go ├── zsysctl_openbsd_386.go ├── zsysctl_openbsd_amd64.go ├── zsysctl_openbsd_arm.go ├── zsysnum_darwin_386.go ├── zsysnum_darwin_amd64.go ├── zsysnum_darwin_arm.go ├── zsysnum_darwin_arm64.go ├── zsysnum_dragonfly_amd64.go ├── zsysnum_freebsd_386.go ├── zsysnum_freebsd_amd64.go ├── zsysnum_freebsd_arm.go ├── zsysnum_linux_386.go ├── zsysnum_linux_amd64.go ├── zsysnum_linux_arm.go ├── zsysnum_linux_arm64.go ├── zsysnum_linux_mips.go ├── zsysnum_linux_mips64.go ├── zsysnum_linux_mips64le.go ├── zsysnum_linux_mipsle.go ├── zsysnum_linux_ppc64.go ├── zsysnum_linux_ppc64le.go ├── zsysnum_linux_s390x.go ├── zsysnum_linux_sparc64.go ├── zsysnum_netbsd_386.go ├── zsysnum_netbsd_amd64.go ├── zsysnum_netbsd_arm.go ├── zsysnum_openbsd_386.go ├── zsysnum_openbsd_amd64.go ├── zsysnum_openbsd_arm.go ├── ztypes_darwin_386.go ├── ztypes_darwin_amd64.go ├── ztypes_darwin_arm.go ├── ztypes_darwin_arm64.go ├── ztypes_dragonfly_amd64.go ├── ztypes_freebsd_386.go ├── ztypes_freebsd_amd64.go ├── ztypes_freebsd_arm.go ├── ztypes_linux_386.go ├── ztypes_linux_amd64.go ├── ztypes_linux_arm.go ├── ztypes_linux_arm64.go ├── ztypes_linux_mips.go ├── ztypes_linux_mips64.go ├── ztypes_linux_mips64le.go ├── ztypes_linux_mipsle.go ├── ztypes_linux_ppc64.go ├── ztypes_linux_ppc64le.go ├── ztypes_linux_s390x.go ├── ztypes_linux_sparc64.go ├── ztypes_netbsd_386.go ├── ztypes_netbsd_amd64.go ├── ztypes_netbsd_arm.go ├── ztypes_openbsd_386.go ├── ztypes_openbsd_amd64.go ├── ztypes_openbsd_arm.go └── ztypes_solaris_amd64.go /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/**/.git* 2 | vendor/**/*_test.go 3 | vendor/**/*.yml 4 | vendor/**/*.cfg 5 | tmp 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 1.9.3 4 | 5 | sudo: false 6 | 7 | script: 8 | - go vet ./... 9 | - go test ./... 10 | 11 | branches: 12 | only: 13 | - master 14 | -------------------------------------------------------------------------------- /Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | name = "github.com/boltdb/bolt" 6 | packages = ["."] 7 | revision = "2f1ce7a837dcb8da3ec595b1dac9d0632f0f99e8" 8 | version = "v1.3.1" 9 | 10 | [[projects]] 11 | name = "github.com/russross/blackfriday" 12 | packages = ["."] 13 | revision = "4048872b16cc0fc2c5fd9eacf0ed2c2fedaa0c8c" 14 | version = "v1.5" 15 | 16 | [[projects]] 17 | branch = "master" 18 | name = "golang.org/x/sys" 19 | packages = ["unix"] 20 | revision = "3dbebcf8efb6a5011a60c2b4591c1022a759af8a" 21 | 22 | [solve-meta] 23 | analyzer-name = "dep" 24 | analyzer-version = 1 25 | inputs-digest = "fdf4723998b14c077cb58263e9e1b70664136205a7cc26ee8c3d0d154a43eccc" 26 | solver-name = "gps-cdcl" 27 | solver-version = 1 28 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | [prune] 2 | non-go = true 3 | go-tests = true 4 | unused-packages = true 5 | 6 | [[constraint]] 7 | name = "github.com/boltdb/bolt" 8 | version = "1.3.1" 9 | 10 | [[constraint]] 11 | name = "github.com/russross/blackfriday" 12 | version = "1.0.0" 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2018 Peter Hellberg https://c7.se/ 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the "Software"), 5 | to deal in the Software without restriction, including without limitation 6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the 8 | Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included 11 | in all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 15 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 18 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 19 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Wiki 2 | ==== 3 | 4 | A tiny wiki using [BoltDB](https://github.com/boltdb/bolt) and [Blackfriday](https://github.com/russross/blackfriday). 5 | 6 | [![Build Status](https://travis-ci.org/peterhellberg/wiki.svg?branch=master)](https://travis-ci.org/peterhellberg/wiki) 7 | [![Go Report Card](https://goreportcard.com/badge/github.com/peterhellberg/wiki)](https://goreportcard.com/report/github.com/peterhellberg/wiki) 8 | [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/peterhellberg/wiki) 9 | [![License MIT](https://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](https://github.com/peterhellberg/wiki#license-mit) 10 | 11 | ![wiki](https://assets.c7.se/screenshots/wiki-20170920-015158.png) 12 | 13 | ## Installation 14 | 15 | ```bash 16 | go get -u github.com/peterhellberg/wiki 17 | ``` 18 | 19 | ## Usage 20 | 21 | ```bash 22 | PORT=2017 wiki -db="/tmp/foo.db" 23 | ``` 24 | 25 | ## License (MIT) 26 | 27 | Copyright (c) 2014-2018 [Peter Hellberg](https://c7.se/) 28 | 29 | > Permission is hereby granted, free of charge, to any person obtaining 30 | > a copy of this software and associated documentation files (the 31 | > "Software"), to deal in the Software without restriction, including 32 | > without limitation the rights to use, copy, modify, merge, publish, 33 | > distribute, sublicense, and/or sell copies of the Software, and to 34 | > permit persons to whom the Software is furnished to do so, subject to 35 | > the following conditions: 36 | 37 | > The above copyright notice and this permission notice shall be 38 | > included in all copies or substantial portions of the Software. 39 | 40 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 41 | > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 42 | > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 43 | > NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 44 | > LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 45 | > OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 46 | > WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 47 | -------------------------------------------------------------------------------- /db/db.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/boltdb/bolt" 7 | ) 8 | 9 | // DB represents a Bolt-backed data store. 10 | type DB struct { 11 | *bolt.DB 12 | } 13 | 14 | // Open initializes and opens the database. 15 | func (db *DB) Open(path string, mode os.FileMode) error { 16 | var err error 17 | 18 | db.DB, err = bolt.Open(path, mode, nil) 19 | if err != nil { 20 | return err 21 | } 22 | 23 | // Create buckets. 24 | err = db.Update(func(tx *Tx) error { 25 | if _, err := tx.CreateBucketIfNotExists([]byte("pages")); err != nil { 26 | return &Error{"pages bucket error", err} 27 | } 28 | 29 | return nil 30 | }) 31 | 32 | if err != nil { 33 | db.Close() 34 | 35 | return err 36 | } 37 | 38 | return nil 39 | } 40 | 41 | // View executes a function in the context of a read-only transaction. 42 | func (db *DB) View(fn func(*Tx) error) error { 43 | return db.DB.View(func(tx *bolt.Tx) error { 44 | return fn(&Tx{tx}) 45 | }) 46 | } 47 | 48 | // Update executes a function in the context of a writable transaction. 49 | func (db *DB) Update(fn func(*Tx) error) error { 50 | return db.DB.Update(func(tx *bolt.Tx) error { 51 | return fn(&Tx{tx}) 52 | }) 53 | } 54 | -------------------------------------------------------------------------------- /db/error.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | // Error represents an error condition within the database. 4 | type Error struct { 5 | message string 6 | cause error 7 | } 8 | 9 | // Error returns a string representation of the error. 10 | func (e *Error) Error() string { 11 | if e.cause != nil { 12 | return e.message + ": " + e.cause.Error() 13 | } 14 | return e.message 15 | } 16 | -------------------------------------------------------------------------------- /db/error_test.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "errors" 5 | "testing" 6 | ) 7 | 8 | func TestError(t *testing.T) { 9 | if e := (&Error{"Foo", errors.New("Bar")}); e.Error() != "Foo: Bar" { 10 | t.Errorf(`unexpected error %q`, e) 11 | } 12 | 13 | if e := (&Error{message: "Baz"}); e.Error() != "Baz" { 14 | t.Errorf(`unexpected error %q`, e) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /db/page.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | // Errors 4 | var ( 5 | ErrPageNotFound = &Error{"page not found", nil} 6 | ErrNoPageName = &Error{"no page name", nil} 7 | ) 8 | 9 | // Page represents a Wiki page 10 | type Page struct { 11 | Tx *Tx 12 | Name []byte 13 | Text []byte 14 | } 15 | 16 | func (p *Page) bucket() []byte { 17 | return []byte("pages") 18 | } 19 | 20 | func (p *Page) get() ([]byte, error) { 21 | text := p.Tx.Bucket(p.bucket()).Get(p.Name) 22 | if text == nil { 23 | return nil, ErrPageNotFound 24 | } 25 | 26 | return text, nil 27 | } 28 | 29 | // Load retrieves a page from the database. 30 | func (p *Page) Load() error { 31 | text, err := p.get() 32 | if err != nil { 33 | return err 34 | } 35 | 36 | p.Text = text 37 | 38 | return nil 39 | } 40 | 41 | // Save commits the Page to the database. 42 | func (p *Page) Save() error { 43 | if len(p.Name) == 0 { 44 | return ErrNoPageName 45 | } 46 | 47 | return p.Tx.Bucket(p.bucket()).Put(p.Name, p.Text) 48 | } 49 | -------------------------------------------------------------------------------- /db/tx.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import "github.com/boltdb/bolt" 4 | 5 | // Tx represents a BoltDB transaction 6 | type Tx struct { 7 | *bolt.Tx 8 | } 9 | 10 | // Page retrieves a Page from the database with the given name. 11 | func (tx *Tx) Page(name []byte) (*Page, error) { 12 | p := &Page{ 13 | Tx: tx, 14 | Name: name, 15 | } 16 | 17 | return p, p.Load() 18 | } 19 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2017 Peter Hellberg. 2 | // Released under the terms of the MIT license. 3 | 4 | // wiki is a tiny wiki using BoltDB and Blackfriday. 5 | // 6 | // Installation 7 | // 8 | // You can install wiki with go get: 9 | // 10 | // go get -u github.com/peterhellberg/wiki 11 | // 12 | // Usage 13 | // 14 | // You can specify one (optional) parameter -db 15 | // 16 | // PORT=7272 wiki -db="/tmp/foo.db" 17 | // 18 | package main 19 | 20 | import ( 21 | "context" 22 | "flag" 23 | "log" 24 | "net/http" 25 | "os" 26 | "os/signal" 27 | "syscall" 28 | "time" 29 | 30 | "github.com/peterhellberg/wiki/db" 31 | "github.com/peterhellberg/wiki/server" 32 | ) 33 | 34 | var dbFile string 35 | 36 | func main() { 37 | flag.StringVar(&dbFile, "db", "/tmp/wiki.db", "Path to the BoltDB file") 38 | 39 | flag.Parse() 40 | 41 | // Setup the logger used by the server 42 | logger := log.New(os.Stdout, "", 0) 43 | 44 | // Setup the database used by the server 45 | db, err := newDB(dbFile) 46 | if err != nil { 47 | logger.Fatal(err) 48 | } 49 | defer db.Close() 50 | 51 | hs := setup(logger, db) 52 | 53 | go graceful(hs, 8*time.Second) 54 | 55 | logger.Println("Listening on http://0.0.0.0" + hs.Addr) 56 | if err := hs.ListenAndServe(); err != nil { 57 | logger.Fatal(err) 58 | } 59 | } 60 | 61 | func newDB(fn string) (*db.DB, error) { 62 | db := &db.DB{} 63 | 64 | if err := db.Open(dbFile, 0600); err != nil { 65 | return nil, err 66 | } 67 | 68 | return db, nil 69 | } 70 | 71 | func setup(logger *log.Logger, db *db.DB) *http.Server { 72 | return &http.Server{ 73 | Addr: addr(), 74 | Handler: server.New(logger, db), 75 | ReadTimeout: 5 * time.Second, 76 | WriteTimeout: 5 * time.Second, 77 | IdleTimeout: 2 * time.Minute, 78 | } 79 | } 80 | 81 | func addr() string { 82 | if port := os.Getenv("PORT"); port != "" { 83 | return ":" + port 84 | } 85 | 86 | return ":7272" 87 | } 88 | 89 | func graceful(hs *http.Server, timeout time.Duration) { 90 | signals := make(chan os.Signal, 1) 91 | 92 | signal.Notify(signals, os.Interrupt, syscall.SIGTERM) 93 | 94 | <-signals 95 | 96 | ctx, cancel := context.WithTimeout(context.Background(), timeout) 97 | defer cancel() 98 | 99 | hs.Shutdown(ctx) 100 | } 101 | -------------------------------------------------------------------------------- /main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os/exec" 5 | "strings" 6 | "testing" 7 | ) 8 | 9 | func TestUsageInstructions(t *testing.T) { 10 | out, _ := execGo("run", "main.go", "--help") 11 | 12 | if !strings.Contains(out, "Path to the BoltDB file") { 13 | t.Fatalf(`unexpected output`) 14 | } 15 | } 16 | 17 | func execGo(args ...string) (string, error) { 18 | out, err := exec.Command("go", args...).CombinedOutput() 19 | 20 | return string(out), err 21 | } 22 | -------------------------------------------------------------------------------- /server/edit.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/peterhellberg/wiki/db" 7 | ) 8 | 9 | func (s *Server) edit(w http.ResponseWriter, r *http.Request) { 10 | s.db.View(func(tx *db.Tx) error { 11 | p, _ := tx.Page(s.getPageName(r)) 12 | 13 | return edit.Execute(w, data{ 14 | "Title": string(p.Name), 15 | "Path": "/" + string(p.Name), 16 | "Text": string(p.Text), 17 | }) 18 | }) 19 | } 20 | -------------------------------------------------------------------------------- /server/favicon.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | func (s *Server) favicon(w http.ResponseWriter, r *http.Request) { 8 | w.Write(favicon) 9 | } 10 | 11 | var favicon = []byte{ 12 | 0, 0, 1, 0, 1, 0, 16, 16, 16, 0, 1, 0, 4, 0, 40, 1, 0, 0, 22, 0, 0, 0, 40, 13 | 0, 0, 0, 16, 0, 0, 0, 32, 0, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 14 | 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25 | } 26 | -------------------------------------------------------------------------------- /server/save.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "net/http" 5 | "strings" 6 | 7 | "github.com/peterhellberg/wiki/db" 8 | ) 9 | 10 | func (s *Server) save(w http.ResponseWriter, r *http.Request) { 11 | s.db.Update(func(tx *db.Tx) error { 12 | r.ParseForm() 13 | 14 | p := db.Page{ 15 | Tx: tx, 16 | Name: s.getPageName(r), 17 | } 18 | 19 | p.Text = []byte(strings.TrimSpace(r.FormValue("text"))) 20 | 21 | return p.Save() 22 | }) 23 | 24 | s.redirect(w, r) 25 | } 26 | -------------------------------------------------------------------------------- /server/server.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "html/template" 5 | "log" 6 | "net/http" 7 | "strings" 8 | 9 | "github.com/peterhellberg/wiki/db" 10 | "github.com/russross/blackfriday" 11 | ) 12 | 13 | // Server is the wiki server 14 | type Server struct { 15 | logger *log.Logger 16 | db *db.DB 17 | } 18 | 19 | // New creates a new wiki server 20 | func New(logger *log.Logger, db *db.DB) *Server { 21 | return &Server{logger: logger, db: db} 22 | } 23 | 24 | func (s *Server) redirect(w http.ResponseWriter, r *http.Request) { 25 | if path := r.URL.Path; len(r.URL.Path) > 1 { 26 | target := strings.TrimSuffix(path, "/") 27 | 28 | if target == "/home" { 29 | target = "/" 30 | } 31 | 32 | http.Redirect(w, r, target, 302) 33 | } 34 | } 35 | 36 | func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { 37 | w.Header().Set("Server", "wiki") 38 | 39 | s.logger.Println(r.Method, r.URL.String()) 40 | 41 | switch { 42 | case r.Method == http.MethodPost: 43 | s.save(w, r) 44 | case r.URL.Path == "/favicon.ico": 45 | s.favicon(w, r) 46 | case r.URL.Path == "/home": 47 | s.redirect(w, r) 48 | case strings.HasSuffix(r.URL.Path, "/edit"): 49 | s.edit(w, r) 50 | case strings.HasSuffix(r.URL.Path, "/") && len(r.URL.Path) > 1: 51 | s.redirect(w, r) 52 | default: 53 | s.show(w, r) 54 | } 55 | } 56 | 57 | func (s *Server) getPageName(r *http.Request) []byte { 58 | name := strings.TrimPrefix(strings.TrimSuffix(r.URL.Path, "/edit"), "/") 59 | 60 | if name == "" { 61 | return []byte("home") 62 | } 63 | 64 | return []byte(name) 65 | } 66 | 67 | type data map[string]interface{} 68 | 69 | // bytesAsHTML returns the template bytes as HTML 70 | func bytesAsHTML(b []byte) template.HTML { 71 | return template.HTML(string(b)) 72 | } 73 | 74 | // parsedMarkdown returns provided bytes parsed as Markdown 75 | func parsedMarkdown(b []byte) []byte { 76 | return blackfriday.MarkdownCommon(b) 77 | } 78 | -------------------------------------------------------------------------------- /server/show.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/peterhellberg/wiki/db" 7 | ) 8 | 9 | func (s *Server) show(w http.ResponseWriter, r *http.Request) { 10 | s.db.View(func(tx *db.Tx) error { 11 | p, err := tx.Page(s.getPageName(r)) 12 | 13 | if err != nil || len(p.Text) == 0 { 14 | p.Text = emptyPageText 15 | } 16 | 17 | return show.Execute(w, data{ 18 | "Title": string(p.Name), 19 | "Path": "/" + string(p.Name) + "/edit", 20 | "Text": bytesAsHTML(parsedMarkdown(p.Text)), 21 | }) 22 | }) 23 | } 24 | -------------------------------------------------------------------------------- /server/templates.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import "html/template" 4 | 5 | var emptyPageText = []byte(`# Empty page 6 | So this is an empty page`) 7 | 8 | var show = template.Must(template.New("show").Parse(` 9 | 10 | 11 | {{.Title}} 12 | 13 | 16 | 17 | 18 |
19 | 20 |
21 |
{{.Text}}
22 | 23 | `)) 24 | 25 | var edit = template.Must(template.New("edit").Parse(` 26 | 27 | 28 | {{.Title}} 29 | 30 | 33 | 44 | 45 | 46 |
47 |
48 |
{{.Text}}
49 | 50 |
51 | 52 | `)) 53 | 54 | const stylesheet = ` 55 | a { 56 | color: #0366d6; 57 | text-decoration: none; 58 | } 59 | 60 | a:hover { 61 | text-decoration: underline; 62 | } 63 | 64 | body { 65 | font-family: -apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif; 66 | font-weight: 300; 67 | font-size: 16px; 68 | line-height: 1.5; 69 | margin: 0; 70 | } 71 | 72 | @media only screen and (min-device-width: 960px) { 73 | body { 74 | padding: 3rem 5rem; 75 | } 76 | 77 | button { 78 | position: fixed; 79 | bottom: 0px; 80 | right: 0px; 81 | } 82 | } 83 | 84 | button { 85 | margin: 1rem; 86 | background: #fafafa; 87 | background-image: linear-gradient(to bottom, #fafafa, #dedede); 88 | border-radius: 6px; 89 | font-family: Helvetica; 90 | color: #595959; 91 | font-size: 14px; 92 | padding: 6px 12px 6px 12px; 93 | border: solid #b8b8b8 1px; 94 | cursor: pointer; 95 | } 96 | 97 | button:active { 98 | background: #f7f7f7; 99 | background-image: linear-gradient(to bottom, #f7f7f7, #c4c2c4); 100 | text-decoration: none; 101 | } 102 | 103 | button:focus, textarea:focus { 104 | outline:0; 105 | } 106 | 107 | h1 { font-size: 3.5em; } 108 | h2 { font-size: 3em; } 109 | h3 { font-size: 2.5em; } 110 | h4 { font-size: 2em; } 111 | h5 { font-size: 1.5em; } 112 | h6 { font-size: 1em; } 113 | 114 | h1, h2, h3, h4, h5, h6 { 115 | line-height: 1em; 116 | } 117 | 118 | h1, h2, h3, h4, h5, h6, p { 119 | margin: 0 0 0.5rem 0; 120 | } 121 | 122 | p:last-child, 123 | ul:last-child, 124 | ol:last-child, 125 | dl:last-child, 126 | blockquote:last-child, 127 | pre:last-child, 128 | table:last-child { 129 | margin-bottom: 0; 130 | } 131 | 132 | hr { 133 | border: 0; 134 | height: 0; 135 | border-top: 1px solid rgba(0, 0, 0, 0.1); 136 | border-bottom: 1px solid rgba(255, 255, 255, 0.3); 137 | } 138 | 139 | p { 140 | margin: 0 0 9px; 141 | } 142 | 143 | strong { 144 | font-weight: 700; 145 | } 146 | 147 | blockquote { 148 | border-left: 0.4rem solid #dddfe1; 149 | padding-left: 1rem; 150 | margin-left: 0; 151 | } 152 | 153 | pre { 154 | font-size: 0.9em; 155 | border: 1px solid #dddfe1; 156 | border-radius: 3px; 157 | background: #f6f8fa; 158 | padding: 1rem; 159 | overflow: auto; 160 | } 161 | 162 | code { 163 | font-family: monaco,Consolas,Lucida Console,monospace; 164 | } 165 | 166 | textarea { 167 | display: none; 168 | } 169 | 170 | article { 171 | padding: 0 1rem; 172 | } 173 | 174 | #textdiv { 175 | background: #F6F8FA; 176 | border: 1px solid #dddfe1; 177 | border-radius: 6px; 178 | padding: 0.5rem; 179 | min-height: 1em; 180 | overflow: auto; 181 | white-space: pre; 182 | font-size: 0.8rem; 183 | font-family: monaco,Consolas,Lucida Console,monospace; 184 | } 185 | 186 | #textdiv:focus { 187 | outline: none; 188 | } 189 | ` 190 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Ben Johnson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_386.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | // maxMapSize represents the largest mmap size supported by Bolt. 4 | const maxMapSize = 0x7FFFFFFF // 2GB 5 | 6 | // maxAllocSize is the size used when creating array pointers. 7 | const maxAllocSize = 0xFFFFFFF 8 | 9 | // Are unaligned load/stores broken on this arch? 10 | var brokenUnaligned = false 11 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_amd64.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | // maxMapSize represents the largest mmap size supported by Bolt. 4 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 5 | 6 | // maxAllocSize is the size used when creating array pointers. 7 | const maxAllocSize = 0x7FFFFFFF 8 | 9 | // Are unaligned load/stores broken on this arch? 10 | var brokenUnaligned = false 11 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_arm.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import "unsafe" 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0x7FFFFFFF // 2GB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0xFFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned bool 13 | 14 | func init() { 15 | // Simple check to see whether this arch handles unaligned load/stores 16 | // correctly. 17 | 18 | // ARM9 and older devices require load/stores to be from/to aligned 19 | // addresses. If not, the lower 2 bits are cleared and that address is 20 | // read in a jumbled up order. 21 | 22 | // See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka15414.html 23 | 24 | raw := [6]byte{0xfe, 0xef, 0x11, 0x22, 0x22, 0x11} 25 | val := *(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&raw)) + 2)) 26 | 27 | brokenUnaligned = val != 0x11222211 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_arm64.go: -------------------------------------------------------------------------------- 1 | // +build arm64 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_linux.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | // fdatasync flushes written data to a file descriptor. 8 | func fdatasync(db *DB) error { 9 | return syscall.Fdatasync(int(db.file.Fd())) 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_openbsd.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | const ( 9 | msAsync = 1 << iota // perform asynchronous writes 10 | msSync // perform synchronous writes 11 | msInvalidate // invalidate cached data 12 | ) 13 | 14 | func msync(db *DB) error { 15 | _, _, errno := syscall.Syscall(syscall.SYS_MSYNC, uintptr(unsafe.Pointer(db.data)), uintptr(db.datasz), msInvalidate) 16 | if errno != 0 { 17 | return errno 18 | } 19 | return nil 20 | } 21 | 22 | func fdatasync(db *DB) error { 23 | if db.data != nil { 24 | return msync(db) 25 | } 26 | return db.file.Sync() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_ppc.go: -------------------------------------------------------------------------------- 1 | // +build ppc 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0x7FFFFFFF // 2GB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0xFFFFFFF 10 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_ppc64.go: -------------------------------------------------------------------------------- 1 | // +build ppc64 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_ppc64le.go: -------------------------------------------------------------------------------- 1 | // +build ppc64le 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_s390x.go: -------------------------------------------------------------------------------- 1 | // +build s390x 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!plan9,!solaris 2 | 3 | package bolt 4 | 5 | import ( 6 | "fmt" 7 | "os" 8 | "syscall" 9 | "time" 10 | "unsafe" 11 | ) 12 | 13 | // flock acquires an advisory lock on a file descriptor. 14 | func flock(db *DB, mode os.FileMode, exclusive bool, timeout time.Duration) error { 15 | var t time.Time 16 | for { 17 | // If we're beyond our timeout then return an error. 18 | // This can only occur after we've attempted a flock once. 19 | if t.IsZero() { 20 | t = time.Now() 21 | } else if timeout > 0 && time.Since(t) > timeout { 22 | return ErrTimeout 23 | } 24 | flag := syscall.LOCK_SH 25 | if exclusive { 26 | flag = syscall.LOCK_EX 27 | } 28 | 29 | // Otherwise attempt to obtain an exclusive lock. 30 | err := syscall.Flock(int(db.file.Fd()), flag|syscall.LOCK_NB) 31 | if err == nil { 32 | return nil 33 | } else if err != syscall.EWOULDBLOCK { 34 | return err 35 | } 36 | 37 | // Wait for a bit and try again. 38 | time.Sleep(50 * time.Millisecond) 39 | } 40 | } 41 | 42 | // funlock releases an advisory lock on a file descriptor. 43 | func funlock(db *DB) error { 44 | return syscall.Flock(int(db.file.Fd()), syscall.LOCK_UN) 45 | } 46 | 47 | // mmap memory maps a DB's data file. 48 | func mmap(db *DB, sz int) error { 49 | // Map the data file to memory. 50 | b, err := syscall.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED|db.MmapFlags) 51 | if err != nil { 52 | return err 53 | } 54 | 55 | // Advise the kernel that the mmap is accessed randomly. 56 | if err := madvise(b, syscall.MADV_RANDOM); err != nil { 57 | return fmt.Errorf("madvise: %s", err) 58 | } 59 | 60 | // Save the original byte slice and convert to a byte array pointer. 61 | db.dataref = b 62 | db.data = (*[maxMapSize]byte)(unsafe.Pointer(&b[0])) 63 | db.datasz = sz 64 | return nil 65 | } 66 | 67 | // munmap unmaps a DB's data file from memory. 68 | func munmap(db *DB) error { 69 | // Ignore the unmap if we have no mapped data. 70 | if db.dataref == nil { 71 | return nil 72 | } 73 | 74 | // Unmap using the original byte slice. 75 | err := syscall.Munmap(db.dataref) 76 | db.dataref = nil 77 | db.data = nil 78 | db.datasz = 0 79 | return err 80 | } 81 | 82 | // NOTE: This function is copied from stdlib because it is not available on darwin. 83 | func madvise(b []byte, advice int) (err error) { 84 | _, _, e1 := syscall.Syscall(syscall.SYS_MADVISE, uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), uintptr(advice)) 85 | if e1 != 0 { 86 | err = e1 87 | } 88 | return 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_unix_solaris.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "syscall" 7 | "time" 8 | "unsafe" 9 | 10 | "golang.org/x/sys/unix" 11 | ) 12 | 13 | // flock acquires an advisory lock on a file descriptor. 14 | func flock(db *DB, mode os.FileMode, exclusive bool, timeout time.Duration) error { 15 | var t time.Time 16 | for { 17 | // If we're beyond our timeout then return an error. 18 | // This can only occur after we've attempted a flock once. 19 | if t.IsZero() { 20 | t = time.Now() 21 | } else if timeout > 0 && time.Since(t) > timeout { 22 | return ErrTimeout 23 | } 24 | var lock syscall.Flock_t 25 | lock.Start = 0 26 | lock.Len = 0 27 | lock.Pid = 0 28 | lock.Whence = 0 29 | lock.Pid = 0 30 | if exclusive { 31 | lock.Type = syscall.F_WRLCK 32 | } else { 33 | lock.Type = syscall.F_RDLCK 34 | } 35 | err := syscall.FcntlFlock(db.file.Fd(), syscall.F_SETLK, &lock) 36 | if err == nil { 37 | return nil 38 | } else if err != syscall.EAGAIN { 39 | return err 40 | } 41 | 42 | // Wait for a bit and try again. 43 | time.Sleep(50 * time.Millisecond) 44 | } 45 | } 46 | 47 | // funlock releases an advisory lock on a file descriptor. 48 | func funlock(db *DB) error { 49 | var lock syscall.Flock_t 50 | lock.Start = 0 51 | lock.Len = 0 52 | lock.Type = syscall.F_UNLCK 53 | lock.Whence = 0 54 | return syscall.FcntlFlock(uintptr(db.file.Fd()), syscall.F_SETLK, &lock) 55 | } 56 | 57 | // mmap memory maps a DB's data file. 58 | func mmap(db *DB, sz int) error { 59 | // Map the data file to memory. 60 | b, err := unix.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED|db.MmapFlags) 61 | if err != nil { 62 | return err 63 | } 64 | 65 | // Advise the kernel that the mmap is accessed randomly. 66 | if err := unix.Madvise(b, syscall.MADV_RANDOM); err != nil { 67 | return fmt.Errorf("madvise: %s", err) 68 | } 69 | 70 | // Save the original byte slice and convert to a byte array pointer. 71 | db.dataref = b 72 | db.data = (*[maxMapSize]byte)(unsafe.Pointer(&b[0])) 73 | db.datasz = sz 74 | return nil 75 | } 76 | 77 | // munmap unmaps a DB's data file from memory. 78 | func munmap(db *DB) error { 79 | // Ignore the unmap if we have no mapped data. 80 | if db.dataref == nil { 81 | return nil 82 | } 83 | 84 | // Unmap using the original byte slice. 85 | err := unix.Munmap(db.dataref) 86 | db.dataref = nil 87 | db.data = nil 88 | db.datasz = 0 89 | return err 90 | } 91 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/bolt_windows.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "syscall" 7 | "time" 8 | "unsafe" 9 | ) 10 | 11 | // LockFileEx code derived from golang build filemutex_windows.go @ v1.5.1 12 | var ( 13 | modkernel32 = syscall.NewLazyDLL("kernel32.dll") 14 | procLockFileEx = modkernel32.NewProc("LockFileEx") 15 | procUnlockFileEx = modkernel32.NewProc("UnlockFileEx") 16 | ) 17 | 18 | const ( 19 | lockExt = ".lock" 20 | 21 | // see https://msdn.microsoft.com/en-us/library/windows/desktop/aa365203(v=vs.85).aspx 22 | flagLockExclusive = 2 23 | flagLockFailImmediately = 1 24 | 25 | // see https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx 26 | errLockViolation syscall.Errno = 0x21 27 | ) 28 | 29 | func lockFileEx(h syscall.Handle, flags, reserved, locklow, lockhigh uint32, ol *syscall.Overlapped) (err error) { 30 | r, _, err := procLockFileEx.Call(uintptr(h), uintptr(flags), uintptr(reserved), uintptr(locklow), uintptr(lockhigh), uintptr(unsafe.Pointer(ol))) 31 | if r == 0 { 32 | return err 33 | } 34 | return nil 35 | } 36 | 37 | func unlockFileEx(h syscall.Handle, reserved, locklow, lockhigh uint32, ol *syscall.Overlapped) (err error) { 38 | r, _, err := procUnlockFileEx.Call(uintptr(h), uintptr(reserved), uintptr(locklow), uintptr(lockhigh), uintptr(unsafe.Pointer(ol)), 0) 39 | if r == 0 { 40 | return err 41 | } 42 | return nil 43 | } 44 | 45 | // fdatasync flushes written data to a file descriptor. 46 | func fdatasync(db *DB) error { 47 | return db.file.Sync() 48 | } 49 | 50 | // flock acquires an advisory lock on a file descriptor. 51 | func flock(db *DB, mode os.FileMode, exclusive bool, timeout time.Duration) error { 52 | // Create a separate lock file on windows because a process 53 | // cannot share an exclusive lock on the same file. This is 54 | // needed during Tx.WriteTo(). 55 | f, err := os.OpenFile(db.path+lockExt, os.O_CREATE, mode) 56 | if err != nil { 57 | return err 58 | } 59 | db.lockfile = f 60 | 61 | var t time.Time 62 | for { 63 | // If we're beyond our timeout then return an error. 64 | // This can only occur after we've attempted a flock once. 65 | if t.IsZero() { 66 | t = time.Now() 67 | } else if timeout > 0 && time.Since(t) > timeout { 68 | return ErrTimeout 69 | } 70 | 71 | var flag uint32 = flagLockFailImmediately 72 | if exclusive { 73 | flag |= flagLockExclusive 74 | } 75 | 76 | err := lockFileEx(syscall.Handle(db.lockfile.Fd()), flag, 0, 1, 0, &syscall.Overlapped{}) 77 | if err == nil { 78 | return nil 79 | } else if err != errLockViolation { 80 | return err 81 | } 82 | 83 | // Wait for a bit and try again. 84 | time.Sleep(50 * time.Millisecond) 85 | } 86 | } 87 | 88 | // funlock releases an advisory lock on a file descriptor. 89 | func funlock(db *DB) error { 90 | err := unlockFileEx(syscall.Handle(db.lockfile.Fd()), 0, 1, 0, &syscall.Overlapped{}) 91 | db.lockfile.Close() 92 | os.Remove(db.path + lockExt) 93 | return err 94 | } 95 | 96 | // mmap memory maps a DB's data file. 97 | // Based on: https://github.com/edsrzf/mmap-go 98 | func mmap(db *DB, sz int) error { 99 | if !db.readOnly { 100 | // Truncate the database to the size of the mmap. 101 | if err := db.file.Truncate(int64(sz)); err != nil { 102 | return fmt.Errorf("truncate: %s", err) 103 | } 104 | } 105 | 106 | // Open a file mapping handle. 107 | sizelo := uint32(sz >> 32) 108 | sizehi := uint32(sz) & 0xffffffff 109 | h, errno := syscall.CreateFileMapping(syscall.Handle(db.file.Fd()), nil, syscall.PAGE_READONLY, sizelo, sizehi, nil) 110 | if h == 0 { 111 | return os.NewSyscallError("CreateFileMapping", errno) 112 | } 113 | 114 | // Create the memory map. 115 | addr, errno := syscall.MapViewOfFile(h, syscall.FILE_MAP_READ, 0, 0, uintptr(sz)) 116 | if addr == 0 { 117 | return os.NewSyscallError("MapViewOfFile", errno) 118 | } 119 | 120 | // Close mapping handle. 121 | if err := syscall.CloseHandle(syscall.Handle(h)); err != nil { 122 | return os.NewSyscallError("CloseHandle", err) 123 | } 124 | 125 | // Convert to a byte array. 126 | db.data = ((*[maxMapSize]byte)(unsafe.Pointer(addr))) 127 | db.datasz = sz 128 | 129 | return nil 130 | } 131 | 132 | // munmap unmaps a pointer from a file. 133 | // Based on: https://github.com/edsrzf/mmap-go 134 | func munmap(db *DB) error { 135 | if db.data == nil { 136 | return nil 137 | } 138 | 139 | addr := (uintptr)(unsafe.Pointer(&db.data[0])) 140 | if err := syscall.UnmapViewOfFile(addr); err != nil { 141 | return os.NewSyscallError("UnmapViewOfFile", err) 142 | } 143 | return nil 144 | } 145 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/boltsync_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!plan9,!linux,!openbsd 2 | 3 | package bolt 4 | 5 | // fdatasync flushes written data to a file descriptor. 6 | func fdatasync(db *DB) error { 7 | return db.file.Sync() 8 | } 9 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package bolt implements a low-level key/value store in pure Go. It supports 3 | fully serializable transactions, ACID semantics, and lock-free MVCC with 4 | multiple readers and a single writer. Bolt can be used for projects that 5 | want a simple data store without the need to add large dependencies such as 6 | Postgres or MySQL. 7 | 8 | Bolt is a single-level, zero-copy, B+tree data store. This means that Bolt is 9 | optimized for fast read access and does not require recovery in the event of a 10 | system crash. Transactions which have not finished committing will simply be 11 | rolled back in the event of a crash. 12 | 13 | The design of Bolt is based on Howard Chu's LMDB database project. 14 | 15 | Bolt currently works on Windows, Mac OS X, and Linux. 16 | 17 | 18 | Basics 19 | 20 | There are only a few types in Bolt: DB, Bucket, Tx, and Cursor. The DB is 21 | a collection of buckets and is represented by a single file on disk. A bucket is 22 | a collection of unique keys that are associated with values. 23 | 24 | Transactions provide either read-only or read-write access to the database. 25 | Read-only transactions can retrieve key/value pairs and can use Cursors to 26 | iterate over the dataset sequentially. Read-write transactions can create and 27 | delete buckets and can insert and remove keys. Only one read-write transaction 28 | is allowed at a time. 29 | 30 | 31 | Caveats 32 | 33 | The database uses a read-only, memory-mapped data file to ensure that 34 | applications cannot corrupt the database, however, this means that keys and 35 | values returned from Bolt cannot be changed. Writing to a read-only byte slice 36 | will cause Go to panic. 37 | 38 | Keys and values retrieved from the database are only valid for the life of 39 | the transaction. When used outside the transaction, these byte slices can 40 | point to different data or can point to invalid memory which will cause a panic. 41 | 42 | 43 | */ 44 | package bolt 45 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/errors.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import "errors" 4 | 5 | // These errors can be returned when opening or calling methods on a DB. 6 | var ( 7 | // ErrDatabaseNotOpen is returned when a DB instance is accessed before it 8 | // is opened or after it is closed. 9 | ErrDatabaseNotOpen = errors.New("database not open") 10 | 11 | // ErrDatabaseOpen is returned when opening a database that is 12 | // already open. 13 | ErrDatabaseOpen = errors.New("database already open") 14 | 15 | // ErrInvalid is returned when both meta pages on a database are invalid. 16 | // This typically occurs when a file is not a bolt database. 17 | ErrInvalid = errors.New("invalid database") 18 | 19 | // ErrVersionMismatch is returned when the data file was created with a 20 | // different version of Bolt. 21 | ErrVersionMismatch = errors.New("version mismatch") 22 | 23 | // ErrChecksum is returned when either meta page checksum does not match. 24 | ErrChecksum = errors.New("checksum error") 25 | 26 | // ErrTimeout is returned when a database cannot obtain an exclusive lock 27 | // on the data file after the timeout passed to Open(). 28 | ErrTimeout = errors.New("timeout") 29 | ) 30 | 31 | // These errors can occur when beginning or committing a Tx. 32 | var ( 33 | // ErrTxNotWritable is returned when performing a write operation on a 34 | // read-only transaction. 35 | ErrTxNotWritable = errors.New("tx not writable") 36 | 37 | // ErrTxClosed is returned when committing or rolling back a transaction 38 | // that has already been committed or rolled back. 39 | ErrTxClosed = errors.New("tx closed") 40 | 41 | // ErrDatabaseReadOnly is returned when a mutating transaction is started on a 42 | // read-only database. 43 | ErrDatabaseReadOnly = errors.New("database is in read-only mode") 44 | ) 45 | 46 | // These errors can occur when putting or deleting a value or a bucket. 47 | var ( 48 | // ErrBucketNotFound is returned when trying to access a bucket that has 49 | // not been created yet. 50 | ErrBucketNotFound = errors.New("bucket not found") 51 | 52 | // ErrBucketExists is returned when creating a bucket that already exists. 53 | ErrBucketExists = errors.New("bucket already exists") 54 | 55 | // ErrBucketNameRequired is returned when creating a bucket with a blank name. 56 | ErrBucketNameRequired = errors.New("bucket name required") 57 | 58 | // ErrKeyRequired is returned when inserting a zero-length key. 59 | ErrKeyRequired = errors.New("key required") 60 | 61 | // ErrKeyTooLarge is returned when inserting a key that is larger than MaxKeySize. 62 | ErrKeyTooLarge = errors.New("key too large") 63 | 64 | // ErrValueTooLarge is returned when inserting a value that is larger than MaxValueSize. 65 | ErrValueTooLarge = errors.New("value too large") 66 | 67 | // ErrIncompatibleValue is returned when trying create or delete a bucket 68 | // on an existing non-bucket key or when trying to create or delete a 69 | // non-bucket key on an existing bucket key. 70 | ErrIncompatibleValue = errors.New("incompatible value") 71 | ) 72 | -------------------------------------------------------------------------------- /vendor/github.com/boltdb/bolt/page.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "sort" 7 | "unsafe" 8 | ) 9 | 10 | const pageHeaderSize = int(unsafe.Offsetof(((*page)(nil)).ptr)) 11 | 12 | const minKeysPerPage = 2 13 | 14 | const branchPageElementSize = int(unsafe.Sizeof(branchPageElement{})) 15 | const leafPageElementSize = int(unsafe.Sizeof(leafPageElement{})) 16 | 17 | const ( 18 | branchPageFlag = 0x01 19 | leafPageFlag = 0x02 20 | metaPageFlag = 0x04 21 | freelistPageFlag = 0x10 22 | ) 23 | 24 | const ( 25 | bucketLeafFlag = 0x01 26 | ) 27 | 28 | type pgid uint64 29 | 30 | type page struct { 31 | id pgid 32 | flags uint16 33 | count uint16 34 | overflow uint32 35 | ptr uintptr 36 | } 37 | 38 | // typ returns a human readable page type string used for debugging. 39 | func (p *page) typ() string { 40 | if (p.flags & branchPageFlag) != 0 { 41 | return "branch" 42 | } else if (p.flags & leafPageFlag) != 0 { 43 | return "leaf" 44 | } else if (p.flags & metaPageFlag) != 0 { 45 | return "meta" 46 | } else if (p.flags & freelistPageFlag) != 0 { 47 | return "freelist" 48 | } 49 | return fmt.Sprintf("unknown<%02x>", p.flags) 50 | } 51 | 52 | // meta returns a pointer to the metadata section of the page. 53 | func (p *page) meta() *meta { 54 | return (*meta)(unsafe.Pointer(&p.ptr)) 55 | } 56 | 57 | // leafPageElement retrieves the leaf node by index 58 | func (p *page) leafPageElement(index uint16) *leafPageElement { 59 | n := &((*[0x7FFFFFF]leafPageElement)(unsafe.Pointer(&p.ptr)))[index] 60 | return n 61 | } 62 | 63 | // leafPageElements retrieves a list of leaf nodes. 64 | func (p *page) leafPageElements() []leafPageElement { 65 | if p.count == 0 { 66 | return nil 67 | } 68 | return ((*[0x7FFFFFF]leafPageElement)(unsafe.Pointer(&p.ptr)))[:] 69 | } 70 | 71 | // branchPageElement retrieves the branch node by index 72 | func (p *page) branchPageElement(index uint16) *branchPageElement { 73 | return &((*[0x7FFFFFF]branchPageElement)(unsafe.Pointer(&p.ptr)))[index] 74 | } 75 | 76 | // branchPageElements retrieves a list of branch nodes. 77 | func (p *page) branchPageElements() []branchPageElement { 78 | if p.count == 0 { 79 | return nil 80 | } 81 | return ((*[0x7FFFFFF]branchPageElement)(unsafe.Pointer(&p.ptr)))[:] 82 | } 83 | 84 | // dump writes n bytes of the page to STDERR as hex output. 85 | func (p *page) hexdump(n int) { 86 | buf := (*[maxAllocSize]byte)(unsafe.Pointer(p))[:n] 87 | fmt.Fprintf(os.Stderr, "%x\n", buf) 88 | } 89 | 90 | type pages []*page 91 | 92 | func (s pages) Len() int { return len(s) } 93 | func (s pages) Swap(i, j int) { s[i], s[j] = s[j], s[i] } 94 | func (s pages) Less(i, j int) bool { return s[i].id < s[j].id } 95 | 96 | // branchPageElement represents a node on a branch page. 97 | type branchPageElement struct { 98 | pos uint32 99 | ksize uint32 100 | pgid pgid 101 | } 102 | 103 | // key returns a byte slice of the node key. 104 | func (n *branchPageElement) key() []byte { 105 | buf := (*[maxAllocSize]byte)(unsafe.Pointer(n)) 106 | return (*[maxAllocSize]byte)(unsafe.Pointer(&buf[n.pos]))[:n.ksize] 107 | } 108 | 109 | // leafPageElement represents a node on a leaf page. 110 | type leafPageElement struct { 111 | flags uint32 112 | pos uint32 113 | ksize uint32 114 | vsize uint32 115 | } 116 | 117 | // key returns a byte slice of the node key. 118 | func (n *leafPageElement) key() []byte { 119 | buf := (*[maxAllocSize]byte)(unsafe.Pointer(n)) 120 | return (*[maxAllocSize]byte)(unsafe.Pointer(&buf[n.pos]))[:n.ksize:n.ksize] 121 | } 122 | 123 | // value returns a byte slice of the node value. 124 | func (n *leafPageElement) value() []byte { 125 | buf := (*[maxAllocSize]byte)(unsafe.Pointer(n)) 126 | return (*[maxAllocSize]byte)(unsafe.Pointer(&buf[n.pos+n.ksize]))[:n.vsize:n.vsize] 127 | } 128 | 129 | // PageInfo represents human readable information about a page. 130 | type PageInfo struct { 131 | ID int 132 | Type string 133 | Count int 134 | OverflowCount int 135 | } 136 | 137 | type pgids []pgid 138 | 139 | func (s pgids) Len() int { return len(s) } 140 | func (s pgids) Swap(i, j int) { s[i], s[j] = s[j], s[i] } 141 | func (s pgids) Less(i, j int) bool { return s[i] < s[j] } 142 | 143 | // merge returns the sorted union of a and b. 144 | func (a pgids) merge(b pgids) pgids { 145 | // Return the opposite slice if one is nil. 146 | if len(a) == 0 { 147 | return b 148 | } 149 | if len(b) == 0 { 150 | return a 151 | } 152 | merged := make(pgids, len(a)+len(b)) 153 | mergepgids(merged, a, b) 154 | return merged 155 | } 156 | 157 | // mergepgids copies the sorted union of a and b into dst. 158 | // If dst is too small, it panics. 159 | func mergepgids(dst, a, b pgids) { 160 | if len(dst) < len(a)+len(b) { 161 | panic(fmt.Errorf("mergepgids bad len %d < %d + %d", len(dst), len(a), len(b))) 162 | } 163 | // Copy in the opposite slice if one is nil. 164 | if len(a) == 0 { 165 | copy(dst, b) 166 | return 167 | } 168 | if len(b) == 0 { 169 | copy(dst, a) 170 | return 171 | } 172 | 173 | // Merged will hold all elements from both lists. 174 | merged := dst[:0] 175 | 176 | // Assign lead to the slice with a lower starting value, follow to the higher value. 177 | lead, follow := a, b 178 | if b[0] < a[0] { 179 | lead, follow = b, a 180 | } 181 | 182 | // Continue while there are elements in the lead. 183 | for len(lead) > 0 { 184 | // Merge largest prefix of lead that is ahead of follow[0]. 185 | n := sort.Search(len(lead), func(i int) bool { return lead[i] > follow[0] }) 186 | merged = append(merged, lead[:n]...) 187 | if n >= len(lead) { 188 | break 189 | } 190 | 191 | // Swap lead and follow. 192 | lead, follow = follow, lead[n:] 193 | } 194 | 195 | // Append what's left in follow. 196 | _ = append(merged, follow...) 197 | } 198 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Blackfriday is distributed under the Simplified BSD License: 2 | 3 | > Copyright © 2011 Russ Ross 4 | > All rights reserved. 5 | > 6 | > Redistribution and use in source and binary forms, with or without 7 | > modification, are permitted provided that the following conditions 8 | > are met: 9 | > 10 | > 1. Redistributions of source code must retain the above copyright 11 | > notice, this list of conditions and the following disclaimer. 12 | > 13 | > 2. Redistributions in binary form must reproduce the above 14 | > copyright notice, this list of conditions and the following 15 | > disclaimer in the documentation and/or other materials provided with 16 | > the distribution. 17 | > 18 | > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | > "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | > LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | > FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | > COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | > INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | > BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | > LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | > CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | > LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 28 | > ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | > POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/doc.go: -------------------------------------------------------------------------------- 1 | // Package blackfriday is a Markdown processor. 2 | // 3 | // It translates plain text with simple formatting rules into HTML or LaTeX. 4 | // 5 | // Sanitized Anchor Names 6 | // 7 | // Blackfriday includes an algorithm for creating sanitized anchor names 8 | // corresponding to a given input text. This algorithm is used to create 9 | // anchors for headings when EXTENSION_AUTO_HEADER_IDS is enabled. The 10 | // algorithm is specified below, so that other packages can create 11 | // compatible anchor names and links to those anchors. 12 | // 13 | // The algorithm iterates over the input text, interpreted as UTF-8, 14 | // one Unicode code point (rune) at a time. All runes that are letters (category L) 15 | // or numbers (category N) are considered valid characters. They are mapped to 16 | // lower case, and included in the output. All other runes are considered 17 | // invalid characters. Invalid characters that preceed the first valid character, 18 | // as well as invalid character that follow the last valid character 19 | // are dropped completely. All other sequences of invalid characters 20 | // between two valid characters are replaced with a single dash character '-'. 21 | // 22 | // SanitizedAnchorName exposes this functionality, and can be used to 23 | // create compatible links to the anchor names generated by blackfriday. 24 | // This algorithm is also implemented in a small standalone package at 25 | // github.com/shurcooL/sanitized_anchor_name. It can be useful for clients 26 | // that want a small package and don't need full functionality of blackfriday. 27 | package blackfriday 28 | 29 | // NOTE: Keep Sanitized Anchor Name algorithm in sync with package 30 | // github.com/shurcooL/sanitized_anchor_name. 31 | // Otherwise, users of sanitized_anchor_name will get anchor names 32 | // that are incompatible with those generated by blackfriday. 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/affinity_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // CPU affinity functions 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const cpuSetSize = _CPU_SETSIZE / _NCPUBITS 14 | 15 | // CPUSet represents a CPU affinity mask. 16 | type CPUSet [cpuSetSize]cpuMask 17 | 18 | func schedAffinity(trap uintptr, pid int, set *CPUSet) error { 19 | _, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(set)), uintptr(unsafe.Pointer(set))) 20 | if e != 0 { 21 | return errnoErr(e) 22 | } 23 | return nil 24 | } 25 | 26 | // SchedGetaffinity gets the CPU affinity mask of the thread specified by pid. 27 | // If pid is 0 the calling thread is used. 28 | func SchedGetaffinity(pid int, set *CPUSet) error { 29 | return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set) 30 | } 31 | 32 | // SchedSetaffinity sets the CPU affinity mask of the thread specified by pid. 33 | // If pid is 0 the calling thread is used. 34 | func SchedSetaffinity(pid int, set *CPUSet) error { 35 | return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set) 36 | } 37 | 38 | // Zero clears the set s, so that it contains no CPUs. 39 | func (s *CPUSet) Zero() { 40 | for i := range s { 41 | s[i] = 0 42 | } 43 | } 44 | 45 | func cpuBitsIndex(cpu int) int { 46 | return cpu / _NCPUBITS 47 | } 48 | 49 | func cpuBitsMask(cpu int) cpuMask { 50 | return cpuMask(1 << (uint(cpu) % _NCPUBITS)) 51 | } 52 | 53 | // Set adds cpu to the set s. 54 | func (s *CPUSet) Set(cpu int) { 55 | i := cpuBitsIndex(cpu) 56 | if i < len(s) { 57 | s[i] |= cpuBitsMask(cpu) 58 | } 59 | } 60 | 61 | // Clear removes cpu from the set s. 62 | func (s *CPUSet) Clear(cpu int) { 63 | i := cpuBitsIndex(cpu) 64 | if i < len(s) { 65 | s[i] &^= cpuBitsMask(cpu) 66 | } 67 | } 68 | 69 | // IsSet reports whether cpu is in the set s. 70 | func (s *CPUSet) IsSet(cpu int) bool { 71 | i := cpuBitsIndex(cpu) 72 | if i < len(s) { 73 | return s[i]&cpuBitsMask(cpu) != 0 74 | } 75 | return false 76 | } 77 | 78 | // Count returns the number of CPUs in the set s. 79 | func (s *CPUSet) Count() int { 80 | c := 0 81 | for _, b := range s { 82 | c += onesCount64(uint64(b)) 83 | } 84 | return c 85 | } 86 | 87 | // onesCount64 is a copy of Go 1.9's math/bits.OnesCount64. 88 | // Once this package can require Go 1.9, we can delete this 89 | // and update the caller to use bits.OnesCount64. 90 | func onesCount64(x uint64) int { 91 | const m0 = 0x5555555555555555 // 01010101 ... 92 | const m1 = 0x3333333333333333 // 00110011 ... 93 | const m2 = 0x0f0f0f0f0f0f0f0f // 00001111 ... 94 | const m3 = 0x00ff00ff00ff00ff // etc. 95 | const m4 = 0x0000ffff0000ffff 96 | 97 | // Implementation: Parallel summing of adjacent bits. 98 | // See "Hacker's Delight", Chap. 5: Counting Bits. 99 | // The following pattern shows the general approach: 100 | // 101 | // x = x>>1&(m0&m) + x&(m0&m) 102 | // x = x>>2&(m1&m) + x&(m1&m) 103 | // x = x>>4&(m2&m) + x&(m2&m) 104 | // x = x>>8&(m3&m) + x&(m3&m) 105 | // x = x>>16&(m4&m) + x&(m4&m) 106 | // x = x>>32&(m5&m) + x&(m5&m) 107 | // return int(x) 108 | // 109 | // Masking (& operations) can be left away when there's no 110 | // danger that a field's sum will carry over into the next 111 | // field: Since the result cannot be > 64, 8 bits is enough 112 | // and we can ignore the masks for the shifts by 8 and up. 113 | // Per "Hacker's Delight", the first line can be simplified 114 | // more, but it saves at best one instruction, so we leave 115 | // it alone for clarity. 116 | const m = 1<<64 - 1 117 | x = x>>1&(m0&m) + x&(m0&m) 118 | x = x>>2&(m1&m) + x&(m1&m) 119 | x = (x>>4 + x) & (m2 & m) 120 | x += x >> 8 121 | x += x >> 16 122 | x += x >> 32 123 | return int(x) & (1<<7 - 1) 124 | } 125 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // See ../runtime/sys_linux_386.s for the reason why we always use int 0x80 14 | // instead of the glibc-specific "CALL 0x10(GS)". 15 | #define INVOKE_SYSCALL INT $0x80 16 | 17 | // Just jump to package syscall's implementation for all these functions. 18 | // The runtime may know about them. 19 | 20 | TEXT ·Syscall(SB),NOSPLIT,$0-28 21 | JMP syscall·Syscall(SB) 22 | 23 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 24 | JMP syscall·Syscall6(SB) 25 | 26 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 27 | CALL runtime·entersyscall(SB) 28 | MOVL trap+0(FP), AX // syscall entry 29 | MOVL a1+4(FP), BX 30 | MOVL a2+8(FP), CX 31 | MOVL a3+12(FP), DX 32 | MOVL $0, SI 33 | MOVL $0, DI 34 | INVOKE_SYSCALL 35 | MOVL AX, r1+16(FP) 36 | MOVL DX, r2+20(FP) 37 | CALL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVL trap+0(FP), AX // syscall entry 48 | MOVL a1+4(FP), BX 49 | MOVL a2+8(FP), CX 50 | MOVL a3+12(FP), DX 51 | MOVL $0, SI 52 | MOVL $0, DI 53 | INVOKE_SYSCALL 54 | MOVL AX, r1+16(FP) 55 | MOVL DX, r2+20(FP) 56 | RET 57 | 58 | TEXT ·socketcall(SB),NOSPLIT,$0-36 59 | JMP syscall·socketcall(SB) 60 | 61 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 62 | JMP syscall·rawsocketcall(SB) 63 | 64 | TEXT ·seek(SB),NOSPLIT,$0-28 65 | JMP syscall·seek(SB) 66 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 23 | CALL runtime·entersyscall(SB) 24 | MOVQ a1+8(FP), DI 25 | MOVQ a2+16(FP), SI 26 | MOVQ a3+24(FP), DX 27 | MOVQ $0, R10 28 | MOVQ $0, R8 29 | MOVQ $0, R9 30 | MOVQ trap+0(FP), AX // syscall entry 31 | SYSCALL 32 | MOVQ AX, r1+32(FP) 33 | MOVQ DX, r2+40(FP) 34 | CALL runtime·exitsyscall(SB) 35 | RET 36 | 37 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 38 | JMP syscall·RawSyscall(SB) 39 | 40 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 41 | JMP syscall·RawSyscall6(SB) 42 | 43 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 44 | MOVQ a1+8(FP), DI 45 | MOVQ a2+16(FP), SI 46 | MOVQ a3+24(FP), DX 47 | MOVQ $0, R10 48 | MOVQ $0, R8 49 | MOVQ $0, R9 50 | MOVQ trap+0(FP), AX // syscall entry 51 | SYSCALL 52 | MOVQ AX, r1+32(FP) 53 | MOVQ DX, r2+40(FP) 54 | RET 55 | 56 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 57 | JMP syscall·gettimeofday(SB) 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 23 | BL runtime·entersyscall(SB) 24 | MOVW trap+0(FP), R7 25 | MOVW a1+4(FP), R0 26 | MOVW a2+8(FP), R1 27 | MOVW a3+12(FP), R2 28 | MOVW $0, R3 29 | MOVW $0, R4 30 | MOVW $0, R5 31 | SWI $0 32 | MOVW R0, r1+16(FP) 33 | MOVW $0, R0 34 | MOVW R0, r2+20(FP) 35 | BL runtime·exitsyscall(SB) 36 | RET 37 | 38 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 39 | B syscall·RawSyscall(SB) 40 | 41 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 42 | B syscall·RawSyscall6(SB) 43 | 44 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 45 | MOVW trap+0(FP), R7 // syscall entry 46 | MOVW a1+4(FP), R0 47 | MOVW a2+8(FP), R1 48 | MOVW a3+12(FP), R2 49 | SWI $0 50 | MOVW R0, r1+16(FP) 51 | MOVW $0, R0 52 | MOVW R0, r2+20(FP) 53 | RET 54 | 55 | TEXT ·seek(SB),NOSPLIT,$0-28 56 | B syscall·seek(SB) 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 21 | BL runtime·entersyscall(SB) 22 | MOVD a1+8(FP), R0 23 | MOVD a2+16(FP), R1 24 | MOVD a3+24(FP), R2 25 | MOVD $0, R3 26 | MOVD $0, R4 27 | MOVD $0, R5 28 | MOVD trap+0(FP), R8 // syscall entry 29 | SVC 30 | MOVD R0, r1+32(FP) // r1 31 | MOVD R1, r2+40(FP) // r2 32 | BL runtime·exitsyscall(SB) 33 | RET 34 | 35 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 36 | B syscall·RawSyscall(SB) 37 | 38 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 39 | B syscall·RawSyscall6(SB) 40 | 41 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 42 | MOVD a1+8(FP), R0 43 | MOVD a2+16(FP), R1 44 | MOVD a3+24(FP), R2 45 | MOVD $0, R3 46 | MOVD $0, R4 47 | MOVD $0, R5 48 | MOVD trap+0(FP), R8 // syscall entry 49 | SVC 50 | MOVD R0, r1+32(FP) 51 | MOVD R1, r2+40(FP) 52 | RET 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | JAL runtime·entersyscall(SB) 26 | MOVV a1+8(FP), R4 27 | MOVV a2+16(FP), R5 28 | MOVV a3+24(FP), R6 29 | MOVV R0, R7 30 | MOVV R0, R8 31 | MOVV R0, R9 32 | MOVV trap+0(FP), R2 // syscall entry 33 | SYSCALL 34 | MOVV R2, r1+32(FP) 35 | MOVV R3, r2+40(FP) 36 | JAL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | JMP syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | JMP syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVV a1+8(FP), R4 47 | MOVV a2+16(FP), R5 48 | MOVV a3+24(FP), R6 49 | MOVV R0, R7 50 | MOVV R0, R8 51 | MOVV R0, R9 52 | MOVV trap+0(FP), R2 // syscall entry 53 | SYSCALL 54 | MOVV R2, r1+32(FP) 55 | MOVV R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 28 | JAL runtime·entersyscall(SB) 29 | MOVW a1+4(FP), R4 30 | MOVW a2+8(FP), R5 31 | MOVW a3+12(FP), R6 32 | MOVW R0, R7 33 | MOVW trap+0(FP), R2 // syscall entry 34 | SYSCALL 35 | MOVW R2, r1+16(FP) // r1 36 | MOVW R3, r2+20(FP) // r2 37 | JAL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVW a1+4(FP), R4 48 | MOVW a2+8(FP), R5 49 | MOVW a3+12(FP), R6 50 | MOVW trap+0(FP), R2 // syscall entry 51 | SYSCALL 52 | MOVW R2, r1+16(FP) 53 | MOVW R3, r2+20(FP) 54 | RET 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | BL runtime·entersyscall(SB) 26 | MOVD a1+8(FP), R3 27 | MOVD a2+16(FP), R4 28 | MOVD a3+24(FP), R5 29 | MOVD R0, R6 30 | MOVD R0, R7 31 | MOVD R0, R8 32 | MOVD trap+0(FP), R9 // syscall entry 33 | SYSCALL R9 34 | MOVD R3, r1+32(FP) 35 | MOVD R4, r2+40(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | BR syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | BR syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVD a1+8(FP), R3 47 | MOVD a2+16(FP), R4 48 | MOVD a3+24(FP), R5 49 | MOVD R0, R6 50 | MOVD R0, R7 51 | MOVD R0, R8 52 | MOVD trap+0(FP), R9 // syscall entry 53 | SYSCALL R9 54 | MOVD R3, r1+32(FP) 55 | MOVD R4, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | BL runtime·entersyscall(SB) 26 | MOVD a1+8(FP), R2 27 | MOVD a2+16(FP), R3 28 | MOVD a3+24(FP), R4 29 | MOVD $0, R5 30 | MOVD $0, R6 31 | MOVD $0, R7 32 | MOVD trap+0(FP), R1 // syscall entry 33 | SYSCALL 34 | MOVD R2, r1+32(FP) 35 | MOVD R3, r2+40(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | BR syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | BR syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVD a1+8(FP), R2 47 | MOVD a2+16(FP), R3 48 | MOVD a3+24(FP), R4 49 | MOVD $0, R5 50 | MOVD $0, R6 51 | MOVD $0, R7 52 | MOVD trap+0(FP), R1 // syscall entry 53 | SYSCALL 54 | MOVD R2, r1+32(FP) 55 | MOVD R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/cap_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | errorspkg "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 errorspkg.New("bad rights size") 64 | } 65 | 66 | for _, right := range setrights { 67 | if caprver(right) != CAP_RIGHTS_VERSION_00 { 68 | return errorspkg.New("bad right version") 69 | } 70 | i, err := rightToIndex(right) 71 | if err != nil { 72 | return err 73 | } 74 | if i >= n { 75 | return errorspkg.New("index overflow") 76 | } 77 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 78 | return errorspkg.New("index mismatch") 79 | } 80 | rights.Rights[i] |= right 81 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 82 | return errorspkg.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 errorspkg.New("bad rights size") 99 | } 100 | 101 | for _, right := range clearrights { 102 | if caprver(right) != CAP_RIGHTS_VERSION_00 { 103 | return errorspkg.New("bad right version") 104 | } 105 | i, err := rightToIndex(right) 106 | if err != nil { 107 | return err 108 | } 109 | if i >= n { 110 | return errorspkg.New("index overflow") 111 | } 112 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 113 | return errorspkg.New("index mismatch") 114 | } 115 | rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF) 116 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 117 | return errorspkg.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, errorspkg.New("bad rights size") 134 | } 135 | 136 | for _, right := range setrights { 137 | if caprver(right) != CAP_RIGHTS_VERSION_00 { 138 | return false, errorspkg.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, errorspkg.New("index overflow") 146 | } 147 | if capidxbit(rights.Rights[i]) != capidxbit(right) { 148 | return false, errorspkg.New("index mismatch") 149 | } 150 | if (rights.Rights[i] & right) != right { 151 | return false, nil 152 | } 153 | } 154 | 155 | return true, nil 156 | } 157 | 158 | func capright(idx uint64, bit uint64) uint64 { 159 | return ((1 << (57 + idx)) | bit) 160 | } 161 | 162 | // CapRightsInit returns a pointer to an initialised CapRights structure filled with rights. 163 | // See man cap_rights_init(3) and rights(4). 164 | func CapRightsInit(rights []uint64) (*CapRights, error) { 165 | var r CapRights 166 | r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0) 167 | r.Rights[1] = capright(1, 0) 168 | 169 | err := CapRightsSet(&r, rights) 170 | if err != nil { 171 | return nil, err 172 | } 173 | return &r, nil 174 | } 175 | 176 | // CapRightsLimit reduces the operations permitted on fd to at most those contained in rights. 177 | // The capability rights on fd can never be increased by CapRightsLimit. 178 | // See man cap_rights_limit(2) and rights(4). 179 | func CapRightsLimit(fd uintptr, rights *CapRights) error { 180 | return capRightsLimit(int(fd), rights) 181 | } 182 | 183 | // CapRightsGet returns a CapRights structure containing the operations permitted on fd. 184 | // See man cap_rights_get(3) and rights(4). 185 | func CapRightsGet(fd uintptr) (*CapRights, error) { 186 | r, err := CapRightsInit(nil) 187 | if err != nil { 188 | return nil, err 189 | } 190 | err = capRightsGet(capRightsGoVersion, int(fd), r) 191 | if err != nil { 192 | return nil, err 193 | } 194 | return r, nil 195 | } 196 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Darwin's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a Darwin device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev >> 24) & 0xff) 13 | } 14 | 15 | // Minor returns the minor component of a Darwin device number. 16 | func Minor(dev uint64) uint32 { 17 | return uint32(dev & 0xffffff) 18 | } 19 | 20 | // Mkdev returns a Darwin device number generated from the given major and minor 21 | // components. 22 | func Mkdev(major, minor uint32) uint64 { 23 | return (uint64(major) << 24) | uint64(minor) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Dragonfly's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a DragonFlyBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a DragonFlyBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a DragonFlyBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in FreeBSD's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a FreeBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a FreeBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a FreeBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used by the Linux kernel and glibc. 7 | // 8 | // The information below is extracted and adapted from bits/sysmacros.h in the 9 | // glibc sources: 10 | // 11 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's 12 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major 13 | // number and m is a hex digit of the minor number. This is backward compatible 14 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also 15 | // backward compatible with the Linux kernel, which for some architectures uses 16 | // 32-bit dev_t, encoded as mmmM MMmm. 17 | 18 | package unix 19 | 20 | // Major returns the major component of a Linux device number. 21 | func Major(dev uint64) uint32 { 22 | major := uint32((dev & 0x00000000000fff00) >> 8) 23 | major |= uint32((dev & 0xfffff00000000000) >> 32) 24 | return major 25 | } 26 | 27 | // Minor returns the minor component of a Linux device number. 28 | func Minor(dev uint64) uint32 { 29 | minor := uint32((dev & 0x00000000000000ff) >> 0) 30 | minor |= uint32((dev & 0x00000ffffff00000) >> 12) 31 | return minor 32 | } 33 | 34 | // Mkdev returns a Linux device number generated from the given major and minor 35 | // components. 36 | func Mkdev(major, minor uint32) uint64 { 37 | dev := (uint64(major) & 0x00000fff) << 8 38 | dev |= (uint64(major) & 0xfffff000) << 32 39 | dev |= (uint64(minor) & 0x000000ff) << 0 40 | dev |= (uint64(minor) & 0xffffff00) << 12 41 | return dev 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in NetBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a NetBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x000fff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of a NetBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xfff00000) >> 12) 19 | return minor 20 | } 21 | 22 | // Mkdev returns a NetBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x000fff00 26 | dev |= (uint64(minor) << 12) & 0xfff00000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in OpenBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of an OpenBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x0000ff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of an OpenBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xffff0000) >> 8) 19 | return minor 20 | } 21 | 22 | // Mkdev returns an OpenBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x0000ff00 26 | dev |= (uint64(minor) << 8) & 0xffff0000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dirent.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // ParseDirent parses up to max directory entries in buf, 12 | // appending the names to names. It returns the number of 13 | // bytes consumed from buf, the number of entries added 14 | // to names, and the new names slice. 15 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { 16 | return syscall.ParseDirent(buf, max, names) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | 29 | func Unsetenv(key string) error { 30 | return syscall.Unsetenv(key) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 16 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 17 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 18 | if errno == 0 { 19 | return nil 20 | } 21 | return errno 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscallNoError 15 | func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr) 16 | 17 | //extern gccgoRealSyscall 18 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 19 | 20 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 21 | syscall.Entersyscall() 22 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 23 | syscall.Exitsyscall() 24 | return r, 0 25 | } 26 | 27 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 28 | syscall.Entersyscall() 29 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 30 | syscall.Exitsyscall() 31 | return r, 0, syscall.Errno(errno) 32 | } 33 | 34 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 35 | syscall.Entersyscall() 36 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 37 | syscall.Exitsyscall() 38 | return r, 0, syscall.Errno(errno) 39 | } 40 | 41 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 42 | syscall.Entersyscall() 43 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 44 | syscall.Exitsyscall() 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | 48 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 49 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 50 | return r, 0 51 | } 52 | 53 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 54 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 55 | return r, 0, syscall.Errno(errno) 56 | } 57 | 58 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 59 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 60 | return r, 0, syscall.Errno(errno) 61 | } 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | uintptr_t 35 | gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 36 | { 37 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 38 | } 39 | 40 | // Define the use function in C so that it is not inlined. 41 | 42 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 43 | 44 | void 45 | use(void *p __attribute__ ((unused))) 46 | { 47 | } 48 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mkpost.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | // mkpost processes the output of cgo -godefs to 8 | // modify the generated types. It is used to clean up 9 | // the sys API in an architecture specific manner. 10 | // 11 | // mkpost is run after cgo -godefs; see README.md. 12 | package main 13 | 14 | import ( 15 | "bytes" 16 | "fmt" 17 | "go/format" 18 | "io/ioutil" 19 | "log" 20 | "os" 21 | "regexp" 22 | ) 23 | 24 | func main() { 25 | // Get the OS and architecture (using GOARCH_TARGET if it exists) 26 | goos := os.Getenv("GOOS") 27 | goarch := os.Getenv("GOARCH_TARGET") 28 | if goarch == "" { 29 | goarch = os.Getenv("GOARCH") 30 | } 31 | // Check that we are using the new build system if we should be. 32 | if goos == "linux" && goarch != "sparc64" { 33 | if os.Getenv("GOLANG_SYS_BUILD") != "docker" { 34 | os.Stderr.WriteString("In the new build system, mkpost should not be called directly.\n") 35 | os.Stderr.WriteString("See README.md\n") 36 | os.Exit(1) 37 | } 38 | } 39 | 40 | b, err := ioutil.ReadAll(os.Stdin) 41 | if err != nil { 42 | log.Fatal(err) 43 | } 44 | 45 | // If we have empty Ptrace structs, we should delete them. Only s390x emits 46 | // nonempty Ptrace structs. 47 | ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`) 48 | b = ptraceRexexp.ReplaceAll(b, nil) 49 | 50 | // Replace the control_regs union with a blank identifier for now. 51 | controlRegsRegex := regexp.MustCompile(`(Control_regs)\s+\[0\]uint64`) 52 | b = controlRegsRegex.ReplaceAll(b, []byte("_ [0]uint64")) 53 | 54 | // Remove fields that are added by glibc 55 | // Note that this is unstable as the identifers are private. 56 | removeFieldsRegex := regexp.MustCompile(`X__glibc\S*`) 57 | b = removeFieldsRegex.ReplaceAll(b, []byte("_")) 58 | 59 | // Convert [65]int8 to [65]byte in Utsname members to simplify 60 | // conversion to string; see golang.org/issue/20753 61 | convertUtsnameRegex := regexp.MustCompile(`((Sys|Node|Domain)name|Release|Version|Machine)(\s+)\[(\d+)\]u?int8`) 62 | b = convertUtsnameRegex.ReplaceAll(b, []byte("$1$3[$4]byte")) 63 | 64 | // Remove spare fields (e.g. in Statx_t) 65 | spareFieldsRegex := regexp.MustCompile(`X__spare\S*`) 66 | b = spareFieldsRegex.ReplaceAll(b, []byte("_")) 67 | 68 | // Remove cgo padding fields 69 | removePaddingFieldsRegex := regexp.MustCompile(`Pad_cgo_\d+`) 70 | b = removePaddingFieldsRegex.ReplaceAll(b, []byte("_")) 71 | 72 | // We refuse to export private fields on s390x 73 | if goarch == "s390x" && goos == "linux" { 74 | // Remove padding, hidden, or unused fields 75 | removeFieldsRegex = regexp.MustCompile(`\bX_\S+`) 76 | b = removeFieldsRegex.ReplaceAll(b, []byte("_")) 77 | } 78 | 79 | // Remove the first line of warning from cgo 80 | b = b[bytes.IndexByte(b, '\n')+1:] 81 | // Modify the command in the header to include: 82 | // mkpost, our own warning, and a build tag. 83 | replacement := fmt.Sprintf(`$1 | go run mkpost.go 84 | // Code generated by the command above; see README.md. DO NOT EDIT. 85 | 86 | // +build %s,%s`, goarch, goos) 87 | cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`) 88 | b = cgoCommandRegex.ReplaceAll(b, []byte(replacement)) 89 | 90 | // gofmt 91 | b, err = format.Source(b) 92 | if err != nil { 93 | log.Fatal(err) 94 | } 95 | 96 | os.Stdout.Write(b) 97 | } 98 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/openbsd_pledge.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build openbsd 6 | // +build 386 amd64 arm 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | const ( 16 | SYS_PLEDGE = 108 17 | ) 18 | 19 | // Pledge implements the pledge syscall. For more information see pledge(2). 20 | func Pledge(promises string, paths []string) error { 21 | promisesPtr, err := syscall.BytePtrFromString(promises) 22 | if err != nil { 23 | return err 24 | } 25 | promisesUnsafe, pathsUnsafe := unsafe.Pointer(promisesPtr), unsafe.Pointer(nil) 26 | if paths != nil { 27 | var pathsPtr []*byte 28 | if pathsPtr, err = syscall.SlicePtrFromStrings(paths); err != nil { 29 | return err 30 | } 31 | pathsUnsafe = unsafe.Pointer(&pathsPtr[0]) 32 | } 33 | _, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(promisesUnsafe), uintptr(pathsUnsafe), 0) 34 | if e != 0 { 35 | return e 36 | } 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/pagesize_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // For Unix, get the pagesize from the runtime. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getpagesize() int { 14 | return syscall.Getpagesize() 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *((*Ucred)(cmsgData(h))) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Socket control messages 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // Round the length of a raw sockaddr up to align it properly. 14 | func cmsgAlignOf(salen int) int { 15 | salign := sizeofPtr 16 | // NOTE: It seems like 64-bit Darwin, DragonFly BSD and 17 | // Solaris kernels still require 32-bit aligned access to 18 | // network subsystem. 19 | if darwin64Bit || dragonfly64Bit || solaris64Bit { 20 | salign = 4 21 | } 22 | return (salen + salign - 1) & ^(salign - 1) 23 | } 24 | 25 | // CmsgLen returns the value to store in the Len field of the Cmsghdr 26 | // structure, taking into account any necessary alignment. 27 | func CmsgLen(datalen int) int { 28 | return cmsgAlignOf(SizeofCmsghdr) + datalen 29 | } 30 | 31 | // CmsgSpace returns the number of bytes an ancillary element with 32 | // payload of the passed data length occupies. 33 | func CmsgSpace(datalen int) int { 34 | return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) 35 | } 36 | 37 | func cmsgData(h *Cmsghdr) unsafe.Pointer { 38 | return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr))) 39 | } 40 | 41 | // SocketControlMessage represents a socket control message. 42 | type SocketControlMessage struct { 43 | Header Cmsghdr 44 | Data []byte 45 | } 46 | 47 | // ParseSocketControlMessage parses b as an array of socket control 48 | // messages. 49 | func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { 50 | var msgs []SocketControlMessage 51 | i := 0 52 | for i+CmsgLen(0) <= len(b) { 53 | h, dbuf, err := socketControlMessageHeaderAndData(b[i:]) 54 | if err != nil { 55 | return nil, err 56 | } 57 | m := SocketControlMessage{Header: *h, Data: dbuf} 58 | msgs = append(msgs, m) 59 | i += cmsgAlignOf(int(h.Len)) 60 | } 61 | return msgs, nil 62 | } 63 | 64 | func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) { 65 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 66 | if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) { 67 | return nil, nil, EINVAL 68 | } 69 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 70 | } 71 | 72 | // UnixRights encodes a set of open file descriptors into a socket 73 | // control message for sending to another process. 74 | func UnixRights(fds ...int) []byte { 75 | datalen := len(fds) * 4 76 | b := make([]byte, CmsgSpace(datalen)) 77 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 78 | h.Level = SOL_SOCKET 79 | h.Type = SCM_RIGHTS 80 | h.SetLen(CmsgLen(datalen)) 81 | data := cmsgData(h) 82 | for _, fd := range fds { 83 | *(*int32)(data) = int32(fd) 84 | data = unsafe.Pointer(uintptr(data) + 4) 85 | } 86 | return b 87 | } 88 | 89 | // ParseUnixRights decodes a socket control message that contains an 90 | // integer array of open file descriptors from another process. 91 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 92 | if m.Header.Level != SOL_SOCKET { 93 | return nil, EINVAL 94 | } 95 | if m.Header.Type != SCM_RIGHTS { 96 | return nil, EINVAL 97 | } 98 | fds := make([]int, len(m.Data)>>2) 99 | for i, j := 0, 0; i < len(m.Data); i += 4 { 100 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 101 | j++ 102 | } 103 | return fds, nil 104 | } 105 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package unix // import "golang.org/x/sys/unix" 23 | 24 | // ByteSliceFromString returns a NUL-terminated slice of bytes 25 | // containing the text of s. If s contains a NUL byte at any 26 | // location, it returns (nil, EINVAL). 27 | func ByteSliceFromString(s string) ([]byte, error) { 28 | for i := 0; i < len(s); i++ { 29 | if s[i] == 0 { 30 | return nil, EINVAL 31 | } 32 | } 33 | a := make([]byte, len(s)+1) 34 | copy(a, s) 35 | return a, nil 36 | } 37 | 38 | // BytePtrFromString returns a pointer to a NUL-terminated array of 39 | // bytes containing the text of s. If s contains a NUL byte at any 40 | // location, it returns (nil, EINVAL). 41 | func BytePtrFromString(s string) (*byte, error) { 42 | a, err := ByteSliceFromString(s) 43 | if err != nil { 44 | return nil, err 45 | } 46 | return &a[0], nil 47 | } 48 | 49 | // Single-word zero for use when we need a valid pointer to 0 bytes. 50 | // See mkunix.pl. 51 | var _zero uintptr 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = int32(sec) 29 | tv.Usec = int32(usec) 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint32(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint32(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = sec 29 | tv.Usec = usec 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func setTimespec(sec, nsec int64) Timespec { 13 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 14 | } 15 | 16 | func setTimeval(sec, usec int64) Timeval { 17 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 18 | } 19 | 20 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 21 | func Gettimeofday(tv *Timeval) (err error) { 22 | // The tv passed to gettimeofday must be non-nil 23 | // but is otherwise unused. The answers come back 24 | // in the two registers. 25 | sec, usec, err := gettimeofday(tv) 26 | tv.Sec = int32(sec) 27 | tv.Usec = int32(usec) 28 | return err 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var length = uint64(count) 51 | 52 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 53 | 54 | written = int(length) 55 | 56 | if e1 != 0 { 57 | err = e1 58 | } 59 | return 60 | } 61 | 62 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 63 | 64 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 65 | // of darwin/arm the syscall is called sysctl instead of __sysctl. 66 | const SYS___SYSCTL = SYS_SYSCTL 67 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = sec 29 | tv.Usec = usec 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | 7 | package unix 8 | 9 | //sys Dup2(oldfd int, newfd int) (err error) 10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 11 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 12 | //sys Fchown(fd int, uid int, gid int) (err error) 13 | //sys Fstat(fd int, stat *Stat_t) (err error) 14 | //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT 15 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 16 | //sys Ftruncate(fd int, length int64) (err error) 17 | //sysnb Getegid() (egid int) 18 | //sysnb Geteuid() (euid int) 19 | //sysnb Getgid() (gid int) 20 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 21 | //sysnb Getuid() (uid int) 22 | //sysnb InotifyInit() (fd int, err error) 23 | //sys Ioperm(from int, num int, on int) (err error) 24 | //sys Iopl(level int) (err error) 25 | //sys Lchown(path string, uid int, gid int) (err error) 26 | //sys Listen(s int, n int) (err error) 27 | //sys Lstat(path string, stat *Stat_t) (err error) 28 | //sys Pause() (err error) 29 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 30 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 31 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 32 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 33 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 34 | //sys Setfsgid(gid int) (err error) 35 | //sys Setfsuid(uid int) (err error) 36 | //sysnb Setregid(rgid int, egid int) (err error) 37 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 38 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 39 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 40 | //sysnb Setreuid(ruid int, euid int) (err error) 41 | //sys Shutdown(fd int, how int) (err error) 42 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 43 | //sys Stat(path string, stat *Stat_t) (err error) 44 | //sys Statfs(path string, buf *Statfs_t) (err error) 45 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 46 | //sys Truncate(path string, length int64) (err error) 47 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 48 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 49 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 50 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 51 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 52 | //sysnb setgroups(n int, list *_Gid_t) (err error) 53 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 54 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 55 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 56 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 57 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 58 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 59 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 60 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 61 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 62 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 63 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 64 | 65 | func Gettimeofday(tv *Timeval) (err error) { 66 | errno := gettimeofday(tv) 67 | if errno != 0 { 68 | return errno 69 | } 70 | return nil 71 | } 72 | 73 | func Time(t *Time_t) (tt Time_t, err error) { 74 | var tv Timeval 75 | errno := gettimeofday(&tv) 76 | if errno != 0 { 77 | return 0, errno 78 | } 79 | if t != nil { 80 | *t = Time_t(tv.Sec) 81 | } 82 | return Time_t(tv.Sec), nil 83 | } 84 | 85 | //sys Utime(path string, buf *Utimbuf) (err error) 86 | 87 | func setTimespec(sec, nsec int64) Timespec { 88 | return Timespec{Sec: sec, Nsec: nsec} 89 | } 90 | 91 | func setTimeval(sec, usec int64) Timeval { 92 | return Timeval{Sec: sec, Usec: usec} 93 | } 94 | 95 | //sysnb pipe(p *[2]_C_int) (err error) 96 | 97 | func Pipe(p []int) (err error) { 98 | if len(p) != 2 { 99 | return EINVAL 100 | } 101 | var pp [2]_C_int 102 | err = pipe(&pp) 103 | p[0] = int(pp[0]) 104 | p[1] = int(pp[1]) 105 | return 106 | } 107 | 108 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 109 | 110 | func Pipe2(p []int, flags int) (err error) { 111 | if len(p) != 2 { 112 | return EINVAL 113 | } 114 | var pp [2]_C_int 115 | err = pipe2(&pp, flags) 116 | p[0] = int(pp[0]) 117 | p[1] = int(pp[1]) 118 | return 119 | } 120 | 121 | func (r *PtraceRegs) PC() uint64 { return r.Rip } 122 | 123 | func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc } 124 | 125 | func (iov *Iovec) SetLen(length int) { 126 | iov.Len = uint64(length) 127 | } 128 | 129 | func (msghdr *Msghdr) SetControllen(length int) { 130 | msghdr.Controllen = uint64(length) 131 | } 132 | 133 | func (cmsg *Cmsghdr) SetLen(length int) { 134 | cmsg.Len = uint64(length) 135 | } 136 | 137 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 138 | 139 | func Poll(fds []PollFd, timeout int) (n int, err error) { 140 | if len(fds) == 0 { 141 | return poll(nil, 0, timeout) 142 | } 143 | return poll(&fds[0], len(fds), timeout) 144 | } 145 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,linux 6 | 7 | package unix 8 | 9 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT 10 | //sys Fchown(fd int, uid int, gid int) (err error) 11 | //sys Fstat(fd int, stat *Stat_t) (err error) 12 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 13 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 14 | //sys Ftruncate(fd int, length int64) (err error) 15 | //sysnb Getegid() (egid int) 16 | //sysnb Geteuid() (euid int) 17 | //sysnb Getgid() (gid int) 18 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 19 | //sysnb Getuid() (uid int) 20 | //sys Listen(s int, n int) (err error) 21 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 22 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 23 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 24 | 25 | func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { 26 | ts := Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000} 27 | return Pselect(nfd, r, w, e, &ts, nil) 28 | } 29 | 30 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 31 | //sys Setfsgid(gid int) (err error) 32 | //sys Setfsuid(uid int) (err error) 33 | //sysnb Setregid(rgid int, egid int) (err error) 34 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 35 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 36 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 37 | //sysnb Setreuid(ruid int, euid int) (err error) 38 | //sys Shutdown(fd int, how int) (err error) 39 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 40 | 41 | func Stat(path string, stat *Stat_t) (err error) { 42 | return Fstatat(AT_FDCWD, path, stat, 0) 43 | } 44 | 45 | func Lchown(path string, uid int, gid int) (err error) { 46 | return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW) 47 | } 48 | 49 | func Lstat(path string, stat *Stat_t) (err error) { 50 | return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW) 51 | } 52 | 53 | //sys Statfs(path string, buf *Statfs_t) (err error) 54 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 55 | //sys Truncate(path string, length int64) (err error) 56 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 57 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 58 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 59 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 60 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 61 | //sysnb setgroups(n int, list *_Gid_t) (err error) 62 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 63 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 64 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 65 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 66 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 67 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 68 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 69 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 70 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 71 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 72 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 73 | 74 | //sysnb Gettimeofday(tv *Timeval) (err error) 75 | 76 | func setTimespec(sec, nsec int64) Timespec { 77 | return Timespec{Sec: sec, Nsec: nsec} 78 | } 79 | 80 | func setTimeval(sec, usec int64) Timeval { 81 | return Timeval{Sec: sec, Usec: usec} 82 | } 83 | 84 | func Time(t *Time_t) (Time_t, error) { 85 | var tv Timeval 86 | err := Gettimeofday(&tv) 87 | if err != nil { 88 | return 0, err 89 | } 90 | if t != nil { 91 | *t = Time_t(tv.Sec) 92 | } 93 | return Time_t(tv.Sec), nil 94 | } 95 | 96 | func Utime(path string, buf *Utimbuf) error { 97 | tv := []Timeval{ 98 | {Sec: buf.Actime}, 99 | {Sec: buf.Modtime}, 100 | } 101 | return Utimes(path, tv) 102 | } 103 | 104 | func Pipe(p []int) (err error) { 105 | if len(p) != 2 { 106 | return EINVAL 107 | } 108 | var pp [2]_C_int 109 | err = pipe2(&pp, 0) 110 | p[0] = int(pp[0]) 111 | p[1] = int(pp[1]) 112 | return 113 | } 114 | 115 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 116 | 117 | func Pipe2(p []int, flags int) (err error) { 118 | if len(p) != 2 { 119 | return EINVAL 120 | } 121 | var pp [2]_C_int 122 | err = pipe2(&pp, flags) 123 | p[0] = int(pp[0]) 124 | p[1] = int(pp[1]) 125 | return 126 | } 127 | 128 | func (r *PtraceRegs) PC() uint64 { return r.Pc } 129 | 130 | func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc } 131 | 132 | func (iov *Iovec) SetLen(length int) { 133 | iov.Len = uint64(length) 134 | } 135 | 136 | func (msghdr *Msghdr) SetControllen(length int) { 137 | msghdr.Controllen = uint64(length) 138 | } 139 | 140 | func (cmsg *Cmsghdr) SetLen(length int) { 141 | cmsg.Len = uint64(length) 142 | } 143 | 144 | func InotifyInit() (fd int, err error) { 145 | return InotifyInit1(0) 146 | } 147 | 148 | func Dup2(oldfd int, newfd int) (err error) { 149 | return Dup3(oldfd, newfd, 0) 150 | } 151 | 152 | func Pause() (err error) { 153 | _, _, e1 := Syscall6(SYS_PPOLL, 0, 0, 0, 0, 0, 0) 154 | if e1 != 0 { 155 | err = errnoErr(e1) 156 | } 157 | return 158 | } 159 | 160 | // TODO(dfc): constants that should be in zsysnum_linux_arm64.go, remove 161 | // these when the deprecated syscalls that the syscall package relies on 162 | // are removed. 163 | const ( 164 | SYS_GETPGRP = 1060 165 | SYS_UTIMES = 1037 166 | SYS_FUTIMESAT = 1066 167 | SYS_PAUSE = 1061 168 | SYS_USTAT = 1070 169 | SYS_UTIME = 1063 170 | SYS_LCHOWN = 1032 171 | SYS_TIME = 1062 172 | SYS_EPOLL_CREATE = 1042 173 | SYS_EPOLL_WAIT = 1069 174 | ) 175 | 176 | func Poll(fds []PollFd, timeout int) (n int, err error) { 177 | var ts *Timespec 178 | if timeout >= 0 { 179 | ts = new(Timespec) 180 | *ts = NsecToTimespec(int64(timeout) * 1e6) 181 | } 182 | if len(fds) == 0 { 183 | return ppoll(nil, 0, ts, nil) 184 | } 185 | return ppoll(&fds[0], len(fds), ts, nil) 186 | } 187 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | 8 | package unix 9 | 10 | //sys Dup2(oldfd int, newfd int) (err error) 11 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 12 | //sys Fchown(fd int, uid int, gid int) (err error) 13 | //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT 14 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 15 | //sys Ftruncate(fd int, length int64) (err error) 16 | //sysnb Getegid() (egid int) 17 | //sysnb Geteuid() (euid int) 18 | //sysnb Getgid() (gid int) 19 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 20 | //sysnb Getuid() (uid int) 21 | //sys Lchown(path string, uid int, gid int) (err error) 22 | //sys Listen(s int, n int) (err error) 23 | //sys Pause() (err error) 24 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 25 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 26 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 27 | 28 | func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { 29 | ts := Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000} 30 | return Pselect(nfd, r, w, e, &ts, nil) 31 | } 32 | 33 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 34 | //sys Setfsgid(gid int) (err error) 35 | //sys Setfsuid(uid int) (err error) 36 | //sysnb Setregid(rgid int, egid int) (err error) 37 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 38 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 39 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 40 | //sysnb Setreuid(ruid int, euid int) (err error) 41 | //sys Shutdown(fd int, how int) (err error) 42 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, 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 | //sysnb Gettimeofday(tv *Timeval) (err error) 65 | 66 | func Time(t *Time_t) (tt Time_t, err error) { 67 | var tv Timeval 68 | err = Gettimeofday(&tv) 69 | if err != nil { 70 | return 0, err 71 | } 72 | if t != nil { 73 | *t = Time_t(tv.Sec) 74 | } 75 | return Time_t(tv.Sec), nil 76 | } 77 | 78 | //sys Utime(path string, buf *Utimbuf) (err error) 79 | 80 | func setTimespec(sec, nsec int64) Timespec { 81 | return Timespec{Sec: sec, Nsec: nsec} 82 | } 83 | 84 | func setTimeval(sec, usec int64) Timeval { 85 | return Timeval{Sec: sec, Usec: usec} 86 | } 87 | 88 | func Pipe(p []int) (err error) { 89 | if len(p) != 2 { 90 | return EINVAL 91 | } 92 | var pp [2]_C_int 93 | err = pipe2(&pp, 0) 94 | p[0] = int(pp[0]) 95 | p[1] = int(pp[1]) 96 | return 97 | } 98 | 99 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 100 | 101 | func Pipe2(p []int, flags int) (err error) { 102 | if len(p) != 2 { 103 | return EINVAL 104 | } 105 | var pp [2]_C_int 106 | err = pipe2(&pp, flags) 107 | p[0] = int(pp[0]) 108 | p[1] = int(pp[1]) 109 | return 110 | } 111 | 112 | func Ioperm(from int, num int, on int) (err error) { 113 | return ENOSYS 114 | } 115 | 116 | func Iopl(level int) (err error) { 117 | return ENOSYS 118 | } 119 | 120 | type stat_t struct { 121 | Dev uint32 122 | Pad0 [3]int32 123 | Ino uint64 124 | Mode uint32 125 | Nlink uint32 126 | Uid uint32 127 | Gid uint32 128 | Rdev uint32 129 | Pad1 [3]uint32 130 | Size int64 131 | Atime uint32 132 | Atime_nsec uint32 133 | Mtime uint32 134 | Mtime_nsec uint32 135 | Ctime uint32 136 | Ctime_nsec uint32 137 | Blksize uint32 138 | Pad2 uint32 139 | Blocks int64 140 | } 141 | 142 | //sys fstat(fd int, st *stat_t) (err error) 143 | //sys lstat(path string, st *stat_t) (err error) 144 | //sys stat(path string, st *stat_t) (err error) 145 | 146 | func Fstat(fd int, s *Stat_t) (err error) { 147 | st := &stat_t{} 148 | err = fstat(fd, st) 149 | fillStat_t(s, st) 150 | return 151 | } 152 | 153 | func Lstat(path string, s *Stat_t) (err error) { 154 | st := &stat_t{} 155 | err = lstat(path, st) 156 | fillStat_t(s, st) 157 | return 158 | } 159 | 160 | func Stat(path string, s *Stat_t) (err error) { 161 | st := &stat_t{} 162 | err = stat(path, st) 163 | fillStat_t(s, st) 164 | return 165 | } 166 | 167 | func fillStat_t(s *Stat_t, st *stat_t) { 168 | s.Dev = st.Dev 169 | s.Ino = st.Ino 170 | s.Mode = st.Mode 171 | s.Nlink = st.Nlink 172 | s.Uid = st.Uid 173 | s.Gid = st.Gid 174 | s.Rdev = st.Rdev 175 | s.Size = st.Size 176 | s.Atim = Timespec{int64(st.Atime), int64(st.Atime_nsec)} 177 | s.Mtim = Timespec{int64(st.Mtime), int64(st.Mtime_nsec)} 178 | s.Ctim = Timespec{int64(st.Ctime), int64(st.Ctime_nsec)} 179 | s.Blksize = st.Blksize 180 | s.Blocks = st.Blocks 181 | } 182 | 183 | func (r *PtraceRegs) PC() uint64 { return r.Epc } 184 | 185 | func (r *PtraceRegs) SetPC(pc uint64) { r.Epc = pc } 186 | 187 | func (iov *Iovec) SetLen(length int) { 188 | iov.Len = uint64(length) 189 | } 190 | 191 | func (msghdr *Msghdr) SetControllen(length int) { 192 | msghdr.Controllen = uint64(length) 193 | } 194 | 195 | func (cmsg *Cmsghdr) SetLen(length int) { 196 | cmsg.Len = uint64(length) 197 | } 198 | 199 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 200 | 201 | func Poll(fds []PollFd, timeout int) (n int, err error) { 202 | if len(fds) == 0 { 203 | return poll(nil, 0, timeout) 204 | } 205 | return poll(&fds[0], len(fds), timeout) 206 | } 207 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | 8 | package unix 9 | 10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 11 | //sys Dup2(oldfd int, newfd int) (err error) 12 | //sys Fchown(fd int, uid int, gid int) (err error) 13 | //sys Fstat(fd int, stat *Stat_t) (err error) 14 | //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT 15 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 16 | //sys Ftruncate(fd int, length int64) (err error) 17 | //sysnb Getegid() (egid int) 18 | //sysnb Geteuid() (euid int) 19 | //sysnb Getgid() (gid int) 20 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT 21 | //sysnb Getuid() (uid int) 22 | //sysnb InotifyInit() (fd int, err error) 23 | //sys Ioperm(from int, num int, on int) (err error) 24 | //sys Iopl(level int) (err error) 25 | //sys Lchown(path string, uid int, gid int) (err error) 26 | //sys Listen(s int, n int) (err error) 27 | //sys Lstat(path string, stat *Stat_t) (err error) 28 | //sys Pause() (err error) 29 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 30 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 31 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 32 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT 33 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 34 | //sys Setfsgid(gid int) (err error) 35 | //sys Setfsuid(uid int) (err error) 36 | //sysnb Setregid(rgid int, egid int) (err error) 37 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 38 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 39 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 40 | //sysnb Setreuid(ruid int, euid int) (err error) 41 | //sys Shutdown(fd int, how int) (err error) 42 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 43 | //sys Stat(path string, stat *Stat_t) (err error) 44 | //sys Statfs(path string, buf *Statfs_t) (err error) 45 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2 46 | //sys Truncate(path string, length int64) (err error) 47 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 48 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 49 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 50 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 51 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 52 | //sysnb setgroups(n int, list *_Gid_t) (err error) 53 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 54 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 55 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 56 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 57 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 58 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 59 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 60 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 61 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 62 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 63 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 64 | 65 | //sysnb Gettimeofday(tv *Timeval) (err error) 66 | //sysnb Time(t *Time_t) (tt Time_t, err error) 67 | 68 | //sys Utime(path string, buf *Utimbuf) (err error) 69 | 70 | func setTimespec(sec, nsec int64) Timespec { 71 | return Timespec{Sec: sec, Nsec: nsec} 72 | } 73 | 74 | func setTimeval(sec, usec int64) Timeval { 75 | return Timeval{Sec: sec, Usec: usec} 76 | } 77 | 78 | func (r *PtraceRegs) PC() uint64 { return r.Nip } 79 | 80 | func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc } 81 | 82 | func (iov *Iovec) SetLen(length int) { 83 | iov.Len = uint64(length) 84 | } 85 | 86 | func (msghdr *Msghdr) SetControllen(length int) { 87 | msghdr.Controllen = uint64(length) 88 | } 89 | 90 | func (cmsg *Cmsghdr) SetLen(length int) { 91 | cmsg.Len = uint64(length) 92 | } 93 | 94 | //sysnb pipe(p *[2]_C_int) (err error) 95 | 96 | func Pipe(p []int) (err error) { 97 | if len(p) != 2 { 98 | return EINVAL 99 | } 100 | var pp [2]_C_int 101 | err = pipe(&pp) 102 | p[0] = int(pp[0]) 103 | p[1] = int(pp[1]) 104 | return 105 | } 106 | 107 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 108 | 109 | func Pipe2(p []int, flags int) (err error) { 110 | if len(p) != 2 { 111 | return EINVAL 112 | } 113 | var pp [2]_C_int 114 | err = pipe2(&pp, flags) 115 | p[0] = int(pp[0]) 116 | p[1] = int(pp[1]) 117 | return 118 | } 119 | 120 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 121 | 122 | func Poll(fds []PollFd, timeout int) (n int, err error) { 123 | if len(fds) == 0 { 124 | return poll(nil, 0, timeout) 125 | } 126 | return poll(&fds[0], len(fds), timeout) 127 | } 128 | -------------------------------------------------------------------------------- /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 Dup2(oldfd int, newfd int) (err error) 11 | //sys Fchown(fd int, uid int, gid int) (err error) 12 | //sys Fstat(fd int, stat *Stat_t) (err error) 13 | //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 14 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 15 | //sys Ftruncate(fd int, length int64) (err error) 16 | //sysnb Getegid() (egid int) 17 | //sysnb Geteuid() (euid int) 18 | //sysnb Getgid() (gid int) 19 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 20 | //sysnb Getuid() (uid int) 21 | //sysnb InotifyInit() (fd int, err error) 22 | //sys Lchown(path string, uid int, gid int) (err error) 23 | //sys Listen(s int, n int) (err error) 24 | //sys Lstat(path string, stat *Stat_t) (err error) 25 | //sys Pause() (err error) 26 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 27 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 28 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 29 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 30 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 31 | //sys Setfsgid(gid int) (err error) 32 | //sys Setfsuid(uid int) (err error) 33 | //sysnb Setregid(rgid int, egid int) (err error) 34 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 35 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 36 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 37 | //sysnb Setreuid(ruid int, euid int) (err error) 38 | //sys Shutdown(fd int, how int) (err error) 39 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 40 | //sys Stat(path string, stat *Stat_t) (err error) 41 | //sys Statfs(path string, buf *Statfs_t) (err error) 42 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 43 | //sys Truncate(path string, length int64) (err error) 44 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 45 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 46 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 47 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 48 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 49 | //sysnb setgroups(n int, list *_Gid_t) (err error) 50 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 51 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 52 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 53 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 54 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 55 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 56 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 57 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 58 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 59 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 60 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 61 | 62 | func Ioperm(from int, num int, on int) (err error) { 63 | return ENOSYS 64 | } 65 | 66 | func Iopl(level int) (err error) { 67 | return ENOSYS 68 | } 69 | 70 | //sysnb Gettimeofday(tv *Timeval) (err error) 71 | 72 | func Time(t *Time_t) (tt Time_t, err error) { 73 | var tv Timeval 74 | err = Gettimeofday(&tv) 75 | if err != nil { 76 | return 0, err 77 | } 78 | if t != nil { 79 | *t = Time_t(tv.Sec) 80 | } 81 | return Time_t(tv.Sec), nil 82 | } 83 | 84 | //sys Utime(path string, buf *Utimbuf) (err error) 85 | 86 | func setTimespec(sec, nsec int64) Timespec { 87 | return Timespec{Sec: sec, Nsec: nsec} 88 | } 89 | 90 | func setTimeval(sec, usec int64) Timeval { 91 | return Timeval{Sec: sec, Usec: int32(usec)} 92 | } 93 | 94 | func (r *PtraceRegs) PC() uint64 { return r.Tpc } 95 | 96 | func (r *PtraceRegs) SetPC(pc uint64) { r.Tpc = pc } 97 | 98 | func (iov *Iovec) SetLen(length int) { 99 | iov.Len = uint64(length) 100 | } 101 | 102 | func (msghdr *Msghdr) SetControllen(length int) { 103 | msghdr.Controllen = uint64(length) 104 | } 105 | 106 | func (cmsg *Cmsghdr) SetLen(length int) { 107 | cmsg.Len = uint64(length) 108 | } 109 | 110 | //sysnb pipe(p *[2]_C_int) (err error) 111 | 112 | func Pipe(p []int) (err error) { 113 | if len(p) != 2 { 114 | return EINVAL 115 | } 116 | var pp [2]_C_int 117 | err = pipe(&pp) 118 | p[0] = int(pp[0]) 119 | p[1] = int(pp[1]) 120 | return 121 | } 122 | 123 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 124 | 125 | func Pipe2(p []int, flags int) (err error) { 126 | if len(p) != 2 { 127 | return EINVAL 128 | } 129 | var pp [2]_C_int 130 | err = pipe2(&pp, flags) 131 | p[0] = int(pp[0]) 132 | p[1] = int(pp[1]) 133 | return 134 | } 135 | 136 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 137 | 138 | func Poll(fds []PollFd, timeout int) (n int, err error) { 139 | if len(fds) == 0 { 140 | return poll(nil, 0, timeout) 141 | } 142 | return poll(&fds[0], len(fds), timeout) 143 | } 144 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func (iov *Iovec) SetLen(length int) { 18 | iov.Len = uint64(length) 19 | } 20 | 21 | func (cmsg *Cmsghdr) SetLen(length int) { 22 | cmsg.Len = uint32(length) 23 | } 24 | 25 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 26 | // TODO(aram): implement this, see issue 5847. 27 | panic("unimplemented") 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/timestruct.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "time" 10 | 11 | // TimespecToNsec converts a Timespec value into a number of 12 | // nanoseconds since the Unix epoch. 13 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 14 | 15 | // NsecToTimespec takes a number of nanoseconds since the Unix epoch 16 | // and returns the corresponding Timespec value. 17 | func NsecToTimespec(nsec int64) Timespec { 18 | sec := nsec / 1e9 19 | nsec = nsec % 1e9 20 | if nsec < 0 { 21 | nsec += 1e9 22 | sec-- 23 | } 24 | return setTimespec(sec, nsec) 25 | } 26 | 27 | // TimeToTimespec converts t into a Timespec. 28 | // On some 32-bit systems the range of valid Timespec values are smaller 29 | // than that of time.Time values. So if t is out of the valid range of 30 | // Timespec, it returns a zero Timespec and ERANGE. 31 | func TimeToTimespec(t time.Time) (Timespec, error) { 32 | sec := t.Unix() 33 | nsec := int64(t.Nanosecond()) 34 | ts := setTimespec(sec, nsec) 35 | 36 | // Currently all targets have either int32 or int64 for Timespec.Sec. 37 | // If there were a new target with floating point type for it, we have 38 | // to consider the rounding error. 39 | if int64(ts.Sec) != sec { 40 | return Timespec{}, ERANGE 41 | } 42 | return ts, nil 43 | } 44 | 45 | // TimevalToNsec converts a Timeval value into a number of nanoseconds 46 | // since the Unix epoch. 47 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 48 | 49 | // NsecToTimeval takes a number of nanoseconds since the Unix epoch 50 | // and returns the corresponding Timeval value. 51 | func NsecToTimeval(nsec int64) Timeval { 52 | nsec += 999 // round up to microsecond 53 | usec := nsec % 1e9 / 1e3 54 | sec := nsec / 1e9 55 | if usec < 0 { 56 | usec += 1e6 57 | sec-- 58 | } 59 | return setTimeval(sec, usec) 60 | } 61 | 62 | // Unix returns ts as the number of seconds and nanoseconds elapsed since the 63 | // Unix epoch. 64 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 65 | return int64(ts.Sec), int64(ts.Nsec) 66 | } 67 | 68 | // Unix returns tv as the number of seconds and nanoseconds elapsed since the 69 | // Unix epoch. 70 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 71 | return int64(tv.Sec), int64(tv.Usec) * 1000 72 | } 73 | 74 | // Nano returns ts as the number of nanoseconds elapsed since the Unix epoch. 75 | func (ts *Timespec) Nano() int64 { 76 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 77 | } 78 | 79 | // Nano returns tv as the number of nanoseconds elapsed since the Unix epoch. 80 | func (tv *Timeval) Nano() int64 { 81 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 82 | } 83 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | /* 8 | Input to cgo -godefs. See README.md 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define __DARWIN_UNIX03 0 18 | #define KERNEL 19 | #define _DARWIN_USE_64_BIT_INODE 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | 53 | enum { 54 | sizeofPtr = sizeof(void*), 55 | }; 56 | 57 | union sockaddr_all { 58 | struct sockaddr s1; // this one gets used for fields 59 | struct sockaddr_in s2; // these pad it out 60 | struct sockaddr_in6 s3; 61 | struct sockaddr_un s4; 62 | struct sockaddr_dl s5; 63 | }; 64 | 65 | struct sockaddr_any { 66 | struct sockaddr addr; 67 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 68 | }; 69 | 70 | */ 71 | import "C" 72 | 73 | // Machine characteristics; for internal use. 74 | 75 | const ( 76 | sizeofPtr = C.sizeofPtr 77 | sizeofShort = C.sizeof_short 78 | sizeofInt = C.sizeof_int 79 | sizeofLong = C.sizeof_long 80 | sizeofLongLong = C.sizeof_longlong 81 | ) 82 | 83 | // Basic types 84 | 85 | type ( 86 | _C_short C.short 87 | _C_int C.int 88 | _C_long C.long 89 | _C_long_long C.longlong 90 | ) 91 | 92 | // Time 93 | 94 | type Timespec C.struct_timespec 95 | 96 | type Timeval C.struct_timeval 97 | 98 | type Timeval32 C.struct_timeval32 99 | 100 | // Processes 101 | 102 | type Rusage C.struct_rusage 103 | 104 | type Rlimit C.struct_rlimit 105 | 106 | type _Gid_t C.gid_t 107 | 108 | // Files 109 | 110 | type Stat_t C.struct_stat64 111 | 112 | type Statfs_t C.struct_statfs64 113 | 114 | type Flock_t C.struct_flock 115 | 116 | type Fstore_t C.struct_fstore 117 | 118 | type Radvisory_t C.struct_radvisory 119 | 120 | type Fbootstraptransfer_t C.struct_fbootstraptransfer 121 | 122 | type Log2phys_t C.struct_log2phys 123 | 124 | type Fsid C.struct_fsid 125 | 126 | type Dirent C.struct_dirent 127 | 128 | // Sockets 129 | 130 | type RawSockaddrInet4 C.struct_sockaddr_in 131 | 132 | type RawSockaddrInet6 C.struct_sockaddr_in6 133 | 134 | type RawSockaddrUnix C.struct_sockaddr_un 135 | 136 | type RawSockaddrDatalink C.struct_sockaddr_dl 137 | 138 | type RawSockaddr C.struct_sockaddr 139 | 140 | type RawSockaddrAny C.struct_sockaddr_any 141 | 142 | type _Socklen C.socklen_t 143 | 144 | type Linger C.struct_linger 145 | 146 | type Iovec C.struct_iovec 147 | 148 | type IPMreq C.struct_ip_mreq 149 | 150 | type IPv6Mreq C.struct_ipv6_mreq 151 | 152 | type Msghdr C.struct_msghdr 153 | 154 | type Cmsghdr C.struct_cmsghdr 155 | 156 | type Inet4Pktinfo C.struct_in_pktinfo 157 | 158 | type Inet6Pktinfo C.struct_in6_pktinfo 159 | 160 | type IPv6MTUInfo C.struct_ip6_mtuinfo 161 | 162 | type ICMPv6Filter C.struct_icmp6_filter 163 | 164 | const ( 165 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 166 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 167 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 168 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 169 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 170 | SizeofLinger = C.sizeof_struct_linger 171 | SizeofIPMreq = C.sizeof_struct_ip_mreq 172 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 173 | SizeofMsghdr = C.sizeof_struct_msghdr 174 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 175 | SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo 176 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 177 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 178 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 179 | ) 180 | 181 | // Ptrace requests 182 | 183 | const ( 184 | PTRACE_TRACEME = C.PT_TRACE_ME 185 | PTRACE_CONT = C.PT_CONTINUE 186 | PTRACE_KILL = C.PT_KILL 187 | ) 188 | 189 | // Events (kqueue, kevent) 190 | 191 | type Kevent_t C.struct_kevent 192 | 193 | // Select 194 | 195 | type FdSet C.fd_set 196 | 197 | // Routing and interface messages 198 | 199 | const ( 200 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 201 | SizeofIfData = C.sizeof_struct_if_data 202 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 203 | SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr 204 | SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2 205 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 206 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 207 | ) 208 | 209 | type IfMsghdr C.struct_if_msghdr 210 | 211 | type IfData C.struct_if_data 212 | 213 | type IfaMsghdr C.struct_ifa_msghdr 214 | 215 | type IfmaMsghdr C.struct_ifma_msghdr 216 | 217 | type IfmaMsghdr2 C.struct_ifma_msghdr2 218 | 219 | type RtMsghdr C.struct_rt_msghdr 220 | 221 | type RtMetrics C.struct_rt_metrics 222 | 223 | // Berkeley packet filter 224 | 225 | const ( 226 | SizeofBpfVersion = C.sizeof_struct_bpf_version 227 | SizeofBpfStat = C.sizeof_struct_bpf_stat 228 | SizeofBpfProgram = C.sizeof_struct_bpf_program 229 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 230 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 231 | ) 232 | 233 | type BpfVersion C.struct_bpf_version 234 | 235 | type BpfStat C.struct_bpf_stat 236 | 237 | type BpfProgram C.struct_bpf_program 238 | 239 | type BpfInsn C.struct_bpf_insn 240 | 241 | type BpfHdr C.struct_bpf_hdr 242 | 243 | // Terminal handling 244 | 245 | type Termios C.struct_termios 246 | 247 | type Winsize C.struct_winsize 248 | 249 | // fchmodat-like syscalls. 250 | 251 | const ( 252 | AT_FDCWD = C.AT_FDCWD 253 | AT_REMOVEDIR = C.AT_REMOVEDIR 254 | AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW 255 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 256 | ) 257 | 258 | // poll 259 | 260 | type PollFd C.struct_pollfd 261 | 262 | const ( 263 | POLLERR = C.POLLERR 264 | POLLHUP = C.POLLHUP 265 | POLLIN = C.POLLIN 266 | POLLNVAL = C.POLLNVAL 267 | POLLOUT = C.POLLOUT 268 | POLLPRI = C.POLLPRI 269 | POLLRDBAND = C.POLLRDBAND 270 | POLLRDNORM = C.POLLRDNORM 271 | POLLWRBAND = C.POLLWRBAND 272 | POLLWRNORM = C.POLLWRNORM 273 | ) 274 | 275 | // uname 276 | 277 | type Utsname C.struct_utsname 278 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | /* 8 | Input to cgo -godefs. See README.md 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | enum { 49 | sizeofPtr = sizeof(void*), 50 | }; 51 | 52 | union sockaddr_all { 53 | struct sockaddr s1; // this one gets used for fields 54 | struct sockaddr_in s2; // these pad it out 55 | struct sockaddr_in6 s3; 56 | struct sockaddr_un s4; 57 | struct sockaddr_dl s5; 58 | }; 59 | 60 | struct sockaddr_any { 61 | struct sockaddr addr; 62 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 63 | }; 64 | 65 | */ 66 | import "C" 67 | 68 | // Machine characteristics; for internal use. 69 | 70 | const ( 71 | sizeofPtr = C.sizeofPtr 72 | sizeofShort = C.sizeof_short 73 | sizeofInt = C.sizeof_int 74 | sizeofLong = C.sizeof_long 75 | sizeofLongLong = C.sizeof_longlong 76 | ) 77 | 78 | // Basic types 79 | 80 | type ( 81 | _C_short C.short 82 | _C_int C.int 83 | _C_long C.long 84 | _C_long_long C.longlong 85 | ) 86 | 87 | // Time 88 | 89 | type Timespec C.struct_timespec 90 | 91 | type Timeval C.struct_timeval 92 | 93 | // Processes 94 | 95 | type Rusage C.struct_rusage 96 | 97 | type Rlimit C.struct_rlimit 98 | 99 | type _Gid_t C.gid_t 100 | 101 | // Files 102 | 103 | const ( // Directory mode bits 104 | S_IFMT = C.S_IFMT 105 | S_IFIFO = C.S_IFIFO 106 | S_IFCHR = C.S_IFCHR 107 | S_IFDIR = C.S_IFDIR 108 | S_IFBLK = C.S_IFBLK 109 | S_IFREG = C.S_IFREG 110 | S_IFLNK = C.S_IFLNK 111 | S_IFSOCK = C.S_IFSOCK 112 | S_ISUID = C.S_ISUID 113 | S_ISGID = C.S_ISGID 114 | S_ISVTX = C.S_ISVTX 115 | S_IRUSR = C.S_IRUSR 116 | S_IWUSR = C.S_IWUSR 117 | S_IXUSR = C.S_IXUSR 118 | ) 119 | 120 | type Stat_t C.struct_stat 121 | 122 | type Statfs_t C.struct_statfs 123 | 124 | type Flock_t C.struct_flock 125 | 126 | type Dirent C.struct_dirent 127 | 128 | type Fsid C.struct_fsid 129 | 130 | // File system limits 131 | 132 | const ( 133 | PathMax = C.PATH_MAX 134 | ) 135 | 136 | // Sockets 137 | 138 | type RawSockaddrInet4 C.struct_sockaddr_in 139 | 140 | type RawSockaddrInet6 C.struct_sockaddr_in6 141 | 142 | type RawSockaddrUnix C.struct_sockaddr_un 143 | 144 | type RawSockaddrDatalink C.struct_sockaddr_dl 145 | 146 | type RawSockaddr C.struct_sockaddr 147 | 148 | type RawSockaddrAny C.struct_sockaddr_any 149 | 150 | type _Socklen C.socklen_t 151 | 152 | type Linger C.struct_linger 153 | 154 | type Iovec C.struct_iovec 155 | 156 | type IPMreq C.struct_ip_mreq 157 | 158 | type IPv6Mreq C.struct_ipv6_mreq 159 | 160 | type Msghdr C.struct_msghdr 161 | 162 | type Cmsghdr C.struct_cmsghdr 163 | 164 | type Inet6Pktinfo C.struct_in6_pktinfo 165 | 166 | type IPv6MTUInfo C.struct_ip6_mtuinfo 167 | 168 | type ICMPv6Filter C.struct_icmp6_filter 169 | 170 | const ( 171 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 172 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 173 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 174 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 175 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 176 | SizeofLinger = C.sizeof_struct_linger 177 | SizeofIPMreq = C.sizeof_struct_ip_mreq 178 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 179 | SizeofMsghdr = C.sizeof_struct_msghdr 180 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 181 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 182 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 183 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 184 | ) 185 | 186 | // Ptrace requests 187 | 188 | const ( 189 | PTRACE_TRACEME = C.PT_TRACE_ME 190 | PTRACE_CONT = C.PT_CONTINUE 191 | PTRACE_KILL = C.PT_KILL 192 | ) 193 | 194 | // Events (kqueue, kevent) 195 | 196 | type Kevent_t C.struct_kevent 197 | 198 | // Select 199 | 200 | type FdSet C.fd_set 201 | 202 | // Routing and interface messages 203 | 204 | const ( 205 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 206 | SizeofIfData = C.sizeof_struct_if_data 207 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 208 | SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr 209 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 210 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 211 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 212 | ) 213 | 214 | type IfMsghdr C.struct_if_msghdr 215 | 216 | type IfData C.struct_if_data 217 | 218 | type IfaMsghdr C.struct_ifa_msghdr 219 | 220 | type IfmaMsghdr C.struct_ifma_msghdr 221 | 222 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 223 | 224 | type RtMsghdr C.struct_rt_msghdr 225 | 226 | type RtMetrics C.struct_rt_metrics 227 | 228 | // Berkeley packet filter 229 | 230 | const ( 231 | SizeofBpfVersion = C.sizeof_struct_bpf_version 232 | SizeofBpfStat = C.sizeof_struct_bpf_stat 233 | SizeofBpfProgram = C.sizeof_struct_bpf_program 234 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 235 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 236 | ) 237 | 238 | type BpfVersion C.struct_bpf_version 239 | 240 | type BpfStat C.struct_bpf_stat 241 | 242 | type BpfProgram C.struct_bpf_program 243 | 244 | type BpfInsn C.struct_bpf_insn 245 | 246 | type BpfHdr C.struct_bpf_hdr 247 | 248 | // Terminal handling 249 | 250 | type Termios C.struct_termios 251 | 252 | type Winsize C.struct_winsize 253 | 254 | // fchmodat-like syscalls. 255 | 256 | const ( 257 | AT_FDCWD = C.AT_FDCWD 258 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 259 | ) 260 | 261 | // poll 262 | 263 | type PollFd C.struct_pollfd 264 | 265 | const ( 266 | POLLERR = C.POLLERR 267 | POLLHUP = C.POLLHUP 268 | POLLIN = C.POLLIN 269 | POLLNVAL = C.POLLNVAL 270 | POLLOUT = C.POLLOUT 271 | POLLPRI = C.POLLPRI 272 | POLLRDBAND = C.POLLRDBAND 273 | POLLRDNORM = C.POLLRDNORM 274 | POLLWRBAND = C.POLLWRBAND 275 | POLLWRNORM = C.POLLWRNORM 276 | ) 277 | 278 | // Uname 279 | 280 | type Utsname C.struct_utsname 281 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | /* 8 | Input to cgo -godefs. See README.md 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | enum { 51 | sizeofPtr = sizeof(void*), 52 | }; 53 | 54 | union sockaddr_all { 55 | struct sockaddr s1; // this one gets used for fields 56 | struct sockaddr_in s2; // these pad it out 57 | struct sockaddr_in6 s3; 58 | struct sockaddr_un s4; 59 | struct sockaddr_dl s5; 60 | }; 61 | 62 | struct sockaddr_any { 63 | struct sockaddr addr; 64 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 65 | }; 66 | 67 | */ 68 | import "C" 69 | 70 | // Machine characteristics; for internal use. 71 | 72 | const ( 73 | sizeofPtr = C.sizeofPtr 74 | sizeofShort = C.sizeof_short 75 | sizeofInt = C.sizeof_int 76 | sizeofLong = C.sizeof_long 77 | sizeofLongLong = C.sizeof_longlong 78 | ) 79 | 80 | // Basic types 81 | 82 | type ( 83 | _C_short C.short 84 | _C_int C.int 85 | _C_long C.long 86 | _C_long_long C.longlong 87 | ) 88 | 89 | // Time 90 | 91 | type Timespec C.struct_timespec 92 | 93 | type Timeval C.struct_timeval 94 | 95 | // Processes 96 | 97 | type Rusage C.struct_rusage 98 | 99 | type Rlimit C.struct_rlimit 100 | 101 | type _Gid_t C.gid_t 102 | 103 | // Files 104 | 105 | type Stat_t C.struct_stat 106 | 107 | type Statfs_t C.struct_statfs 108 | 109 | type Flock_t C.struct_flock 110 | 111 | type Dirent C.struct_dirent 112 | 113 | type Fsid C.fsid_t 114 | 115 | // File system limits 116 | 117 | const ( 118 | PathMax = C.PATH_MAX 119 | ) 120 | 121 | // Sockets 122 | 123 | type RawSockaddrInet4 C.struct_sockaddr_in 124 | 125 | type RawSockaddrInet6 C.struct_sockaddr_in6 126 | 127 | type RawSockaddrUnix C.struct_sockaddr_un 128 | 129 | type RawSockaddrDatalink C.struct_sockaddr_dl 130 | 131 | type RawSockaddr C.struct_sockaddr 132 | 133 | type RawSockaddrAny C.struct_sockaddr_any 134 | 135 | type _Socklen C.socklen_t 136 | 137 | type Linger C.struct_linger 138 | 139 | type Iovec C.struct_iovec 140 | 141 | type IPMreq C.struct_ip_mreq 142 | 143 | type IPv6Mreq C.struct_ipv6_mreq 144 | 145 | type Msghdr C.struct_msghdr 146 | 147 | type Cmsghdr C.struct_cmsghdr 148 | 149 | type Inet6Pktinfo C.struct_in6_pktinfo 150 | 151 | type IPv6MTUInfo C.struct_ip6_mtuinfo 152 | 153 | type ICMPv6Filter C.struct_icmp6_filter 154 | 155 | const ( 156 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 157 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 158 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 159 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 160 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 161 | SizeofLinger = C.sizeof_struct_linger 162 | SizeofIPMreq = C.sizeof_struct_ip_mreq 163 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 164 | SizeofMsghdr = C.sizeof_struct_msghdr 165 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 166 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 167 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 168 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 169 | ) 170 | 171 | // Ptrace requests 172 | 173 | const ( 174 | PTRACE_TRACEME = C.PT_TRACE_ME 175 | PTRACE_CONT = C.PT_CONTINUE 176 | PTRACE_KILL = C.PT_KILL 177 | ) 178 | 179 | // Events (kqueue, kevent) 180 | 181 | type Kevent_t C.struct_kevent 182 | 183 | // Select 184 | 185 | type FdSet C.fd_set 186 | 187 | // Routing and interface messages 188 | 189 | const ( 190 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 191 | SizeofIfData = C.sizeof_struct_if_data 192 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 193 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 194 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 195 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 196 | ) 197 | 198 | type IfMsghdr C.struct_if_msghdr 199 | 200 | type IfData C.struct_if_data 201 | 202 | type IfaMsghdr C.struct_ifa_msghdr 203 | 204 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 205 | 206 | type RtMsghdr C.struct_rt_msghdr 207 | 208 | type RtMetrics C.struct_rt_metrics 209 | 210 | type Mclpool C.struct_mclpool 211 | 212 | // Berkeley packet filter 213 | 214 | const ( 215 | SizeofBpfVersion = C.sizeof_struct_bpf_version 216 | SizeofBpfStat = C.sizeof_struct_bpf_stat 217 | SizeofBpfProgram = C.sizeof_struct_bpf_program 218 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 219 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 220 | ) 221 | 222 | type BpfVersion C.struct_bpf_version 223 | 224 | type BpfStat C.struct_bpf_stat 225 | 226 | type BpfProgram C.struct_bpf_program 227 | 228 | type BpfInsn C.struct_bpf_insn 229 | 230 | type BpfHdr C.struct_bpf_hdr 231 | 232 | type BpfTimeval C.struct_bpf_timeval 233 | 234 | // Terminal handling 235 | 236 | type Termios C.struct_termios 237 | 238 | type Winsize C.struct_winsize 239 | 240 | // fchmodat-like syscalls. 241 | 242 | const ( 243 | AT_FDCWD = C.AT_FDCWD 244 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 245 | ) 246 | 247 | // poll 248 | 249 | type PollFd C.struct_pollfd 250 | 251 | const ( 252 | POLLERR = C.POLLERR 253 | POLLHUP = C.POLLHUP 254 | POLLIN = C.POLLIN 255 | POLLNVAL = C.POLLNVAL 256 | POLLOUT = C.POLLOUT 257 | POLLPRI = C.POLLPRI 258 | POLLRDBAND = C.POLLRDBAND 259 | POLLRDNORM = C.POLLRDNORM 260 | POLLWRBAND = C.POLLWRBAND 261 | POLLWRNORM = C.POLLWRNORM 262 | ) 263 | 264 | // Sysctl 265 | 266 | type Sysctlnode C.struct_sysctlnode 267 | 268 | // Uname 269 | 270 | type Utsname C.struct_utsname 271 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | /* 8 | Input to cgo -godefs. See README.md 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | enum { 50 | sizeofPtr = sizeof(void*), 51 | }; 52 | 53 | union sockaddr_all { 54 | struct sockaddr s1; // this one gets used for fields 55 | struct sockaddr_in s2; // these pad it out 56 | struct sockaddr_in6 s3; 57 | struct sockaddr_un s4; 58 | struct sockaddr_dl s5; 59 | }; 60 | 61 | struct sockaddr_any { 62 | struct sockaddr addr; 63 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 64 | }; 65 | 66 | */ 67 | import "C" 68 | 69 | // Machine characteristics; for internal use. 70 | 71 | const ( 72 | sizeofPtr = C.sizeofPtr 73 | sizeofShort = C.sizeof_short 74 | sizeofInt = C.sizeof_int 75 | sizeofLong = C.sizeof_long 76 | sizeofLongLong = C.sizeof_longlong 77 | ) 78 | 79 | // Basic types 80 | 81 | type ( 82 | _C_short C.short 83 | _C_int C.int 84 | _C_long C.long 85 | _C_long_long C.longlong 86 | ) 87 | 88 | // Time 89 | 90 | type Timespec C.struct_timespec 91 | 92 | type Timeval C.struct_timeval 93 | 94 | // Processes 95 | 96 | type Rusage C.struct_rusage 97 | 98 | type Rlimit C.struct_rlimit 99 | 100 | type _Gid_t C.gid_t 101 | 102 | // Files 103 | 104 | const ( // Directory mode bits 105 | S_IFMT = C.S_IFMT 106 | S_IFIFO = C.S_IFIFO 107 | S_IFCHR = C.S_IFCHR 108 | S_IFDIR = C.S_IFDIR 109 | S_IFBLK = C.S_IFBLK 110 | S_IFREG = C.S_IFREG 111 | S_IFLNK = C.S_IFLNK 112 | S_IFSOCK = C.S_IFSOCK 113 | S_ISUID = C.S_ISUID 114 | S_ISGID = C.S_ISGID 115 | S_ISVTX = C.S_ISVTX 116 | S_IRUSR = C.S_IRUSR 117 | S_IWUSR = C.S_IWUSR 118 | S_IXUSR = C.S_IXUSR 119 | ) 120 | 121 | type Stat_t C.struct_stat 122 | 123 | type Statfs_t C.struct_statfs 124 | 125 | type Flock_t C.struct_flock 126 | 127 | type Dirent C.struct_dirent 128 | 129 | type Fsid C.fsid_t 130 | 131 | // File system limits 132 | 133 | const ( 134 | PathMax = C.PATH_MAX 135 | ) 136 | 137 | // Sockets 138 | 139 | type RawSockaddrInet4 C.struct_sockaddr_in 140 | 141 | type RawSockaddrInet6 C.struct_sockaddr_in6 142 | 143 | type RawSockaddrUnix C.struct_sockaddr_un 144 | 145 | type RawSockaddrDatalink C.struct_sockaddr_dl 146 | 147 | type RawSockaddr C.struct_sockaddr 148 | 149 | type RawSockaddrAny C.struct_sockaddr_any 150 | 151 | type _Socklen C.socklen_t 152 | 153 | type Linger C.struct_linger 154 | 155 | type Iovec C.struct_iovec 156 | 157 | type IPMreq C.struct_ip_mreq 158 | 159 | type IPv6Mreq C.struct_ipv6_mreq 160 | 161 | type Msghdr C.struct_msghdr 162 | 163 | type Cmsghdr C.struct_cmsghdr 164 | 165 | type Inet6Pktinfo C.struct_in6_pktinfo 166 | 167 | type IPv6MTUInfo C.struct_ip6_mtuinfo 168 | 169 | type ICMPv6Filter C.struct_icmp6_filter 170 | 171 | const ( 172 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 173 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 174 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 175 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 176 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 177 | SizeofLinger = C.sizeof_struct_linger 178 | SizeofIPMreq = C.sizeof_struct_ip_mreq 179 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 180 | SizeofMsghdr = C.sizeof_struct_msghdr 181 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 182 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 183 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 184 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 185 | ) 186 | 187 | // Ptrace requests 188 | 189 | const ( 190 | PTRACE_TRACEME = C.PT_TRACE_ME 191 | PTRACE_CONT = C.PT_CONTINUE 192 | PTRACE_KILL = C.PT_KILL 193 | ) 194 | 195 | // Events (kqueue, kevent) 196 | 197 | type Kevent_t C.struct_kevent 198 | 199 | // Select 200 | 201 | type FdSet C.fd_set 202 | 203 | // Routing and interface messages 204 | 205 | const ( 206 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 207 | SizeofIfData = C.sizeof_struct_if_data 208 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 209 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 210 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 211 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 212 | ) 213 | 214 | type IfMsghdr C.struct_if_msghdr 215 | 216 | type IfData C.struct_if_data 217 | 218 | type IfaMsghdr C.struct_ifa_msghdr 219 | 220 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 221 | 222 | type RtMsghdr C.struct_rt_msghdr 223 | 224 | type RtMetrics C.struct_rt_metrics 225 | 226 | type Mclpool C.struct_mclpool 227 | 228 | // Berkeley packet filter 229 | 230 | const ( 231 | SizeofBpfVersion = C.sizeof_struct_bpf_version 232 | SizeofBpfStat = C.sizeof_struct_bpf_stat 233 | SizeofBpfProgram = C.sizeof_struct_bpf_program 234 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 235 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 236 | ) 237 | 238 | type BpfVersion C.struct_bpf_version 239 | 240 | type BpfStat C.struct_bpf_stat 241 | 242 | type BpfProgram C.struct_bpf_program 243 | 244 | type BpfInsn C.struct_bpf_insn 245 | 246 | type BpfHdr C.struct_bpf_hdr 247 | 248 | type BpfTimeval C.struct_bpf_timeval 249 | 250 | // Terminal handling 251 | 252 | type Termios C.struct_termios 253 | 254 | type Winsize C.struct_winsize 255 | 256 | // fchmodat-like syscalls. 257 | 258 | const ( 259 | AT_FDCWD = C.AT_FDCWD 260 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 261 | ) 262 | 263 | // poll 264 | 265 | type PollFd C.struct_pollfd 266 | 267 | const ( 268 | POLLERR = C.POLLERR 269 | POLLHUP = C.POLLHUP 270 | POLLIN = C.POLLIN 271 | POLLNVAL = C.POLLNVAL 272 | POLLOUT = C.POLLOUT 273 | POLLPRI = C.POLLPRI 274 | POLLRDBAND = C.POLLRDBAND 275 | POLLRDNORM = C.POLLRDNORM 276 | POLLWRBAND = C.POLLWRBAND 277 | POLLWRNORM = C.POLLWRNORM 278 | ) 279 | 280 | // Uname 281 | 282 | type Utsname C.struct_utsname 283 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | /* 8 | Input to cgo -godefs. See README.md 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | // These defines ensure that builds done on newer versions of Solaris are 19 | // backwards-compatible with older versions of Solaris and 20 | // OpenSolaris-based derivatives. 21 | #define __USE_SUNOS_SOCKETS__ // msghdr 22 | #define __USE_LEGACY_PROTOTYPES__ // iovec 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | 58 | enum { 59 | sizeofPtr = sizeof(void*), 60 | }; 61 | 62 | union sockaddr_all { 63 | struct sockaddr s1; // this one gets used for fields 64 | struct sockaddr_in s2; // these pad it out 65 | struct sockaddr_in6 s3; 66 | struct sockaddr_un s4; 67 | struct sockaddr_dl s5; 68 | }; 69 | 70 | struct sockaddr_any { 71 | struct sockaddr addr; 72 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 73 | }; 74 | 75 | */ 76 | import "C" 77 | 78 | // Machine characteristics; for internal use. 79 | 80 | const ( 81 | sizeofPtr = C.sizeofPtr 82 | sizeofShort = C.sizeof_short 83 | sizeofInt = C.sizeof_int 84 | sizeofLong = C.sizeof_long 85 | sizeofLongLong = C.sizeof_longlong 86 | PathMax = C.PATH_MAX 87 | MaxHostNameLen = C.MAXHOSTNAMELEN 88 | ) 89 | 90 | // Basic types 91 | 92 | type ( 93 | _C_short C.short 94 | _C_int C.int 95 | _C_long C.long 96 | _C_long_long C.longlong 97 | ) 98 | 99 | // Time 100 | 101 | type Timespec C.struct_timespec 102 | 103 | type Timeval C.struct_timeval 104 | 105 | type Timeval32 C.struct_timeval32 106 | 107 | type Tms C.struct_tms 108 | 109 | type Utimbuf C.struct_utimbuf 110 | 111 | // Processes 112 | 113 | type Rusage C.struct_rusage 114 | 115 | type Rlimit C.struct_rlimit 116 | 117 | type _Gid_t C.gid_t 118 | 119 | // Files 120 | 121 | const ( // Directory mode bits 122 | S_IFMT = C.S_IFMT 123 | S_IFIFO = C.S_IFIFO 124 | S_IFCHR = C.S_IFCHR 125 | S_IFDIR = C.S_IFDIR 126 | S_IFBLK = C.S_IFBLK 127 | S_IFREG = C.S_IFREG 128 | S_IFLNK = C.S_IFLNK 129 | S_IFSOCK = C.S_IFSOCK 130 | S_ISUID = C.S_ISUID 131 | S_ISGID = C.S_ISGID 132 | S_ISVTX = C.S_ISVTX 133 | S_IRUSR = C.S_IRUSR 134 | S_IWUSR = C.S_IWUSR 135 | S_IXUSR = C.S_IXUSR 136 | ) 137 | 138 | type Stat_t C.struct_stat 139 | 140 | type Flock_t C.struct_flock 141 | 142 | type Dirent C.struct_dirent 143 | 144 | // Filesystems 145 | 146 | type _Fsblkcnt_t C.fsblkcnt_t 147 | 148 | type Statvfs_t C.struct_statvfs 149 | 150 | // Sockets 151 | 152 | type RawSockaddrInet4 C.struct_sockaddr_in 153 | 154 | type RawSockaddrInet6 C.struct_sockaddr_in6 155 | 156 | type RawSockaddrUnix C.struct_sockaddr_un 157 | 158 | type RawSockaddrDatalink C.struct_sockaddr_dl 159 | 160 | type RawSockaddr C.struct_sockaddr 161 | 162 | type RawSockaddrAny C.struct_sockaddr_any 163 | 164 | type _Socklen C.socklen_t 165 | 166 | type Linger C.struct_linger 167 | 168 | type Iovec C.struct_iovec 169 | 170 | type IPMreq C.struct_ip_mreq 171 | 172 | type IPv6Mreq C.struct_ipv6_mreq 173 | 174 | type Msghdr C.struct_msghdr 175 | 176 | type Cmsghdr C.struct_cmsghdr 177 | 178 | type Inet6Pktinfo C.struct_in6_pktinfo 179 | 180 | type IPv6MTUInfo C.struct_ip6_mtuinfo 181 | 182 | type ICMPv6Filter C.struct_icmp6_filter 183 | 184 | const ( 185 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 186 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 187 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 188 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 189 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 190 | SizeofLinger = C.sizeof_struct_linger 191 | SizeofIPMreq = C.sizeof_struct_ip_mreq 192 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 193 | SizeofMsghdr = C.sizeof_struct_msghdr 194 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 195 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 196 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 197 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 198 | ) 199 | 200 | // Select 201 | 202 | type FdSet C.fd_set 203 | 204 | // Misc 205 | 206 | type Utsname C.struct_utsname 207 | 208 | type Ustat_t C.struct_ustat 209 | 210 | const ( 211 | AT_FDCWD = C.AT_FDCWD 212 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 213 | AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW 214 | AT_REMOVEDIR = C.AT_REMOVEDIR 215 | AT_EACCESS = C.AT_EACCESS 216 | ) 217 | 218 | // Routing and interface messages 219 | 220 | const ( 221 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 222 | SizeofIfData = C.sizeof_struct_if_data 223 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 224 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 225 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 226 | ) 227 | 228 | type IfMsghdr C.struct_if_msghdr 229 | 230 | type IfData C.struct_if_data 231 | 232 | type IfaMsghdr C.struct_ifa_msghdr 233 | 234 | type RtMsghdr C.struct_rt_msghdr 235 | 236 | type RtMetrics C.struct_rt_metrics 237 | 238 | // Berkeley packet filter 239 | 240 | const ( 241 | SizeofBpfVersion = C.sizeof_struct_bpf_version 242 | SizeofBpfStat = C.sizeof_struct_bpf_stat 243 | SizeofBpfProgram = C.sizeof_struct_bpf_program 244 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 245 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 246 | ) 247 | 248 | type BpfVersion C.struct_bpf_version 249 | 250 | type BpfStat C.struct_bpf_stat 251 | 252 | type BpfProgram C.struct_bpf_program 253 | 254 | type BpfInsn C.struct_bpf_insn 255 | 256 | type BpfTimeval C.struct_bpf_timeval 257 | 258 | type BpfHdr C.struct_bpf_hdr 259 | 260 | // Terminal handling 261 | 262 | type Termios C.struct_termios 263 | 264 | type Termio C.struct_termio 265 | 266 | type Winsize C.struct_winsize 267 | 268 | // poll 269 | 270 | type PollFd C.struct_pollfd 271 | 272 | const ( 273 | POLLERR = C.POLLERR 274 | POLLHUP = C.POLLHUP 275 | POLLIN = C.POLLIN 276 | POLLNVAL = C.POLLNVAL 277 | POLLOUT = C.POLLOUT 278 | POLLPRI = C.POLLPRI 279 | POLLRDBAND = C.POLLRDBAND 280 | POLLRDNORM = C.POLLRDNORM 281 | POLLWRBAND = C.POLLWRBAND 282 | POLLWRNORM = C.POLLWRNORM 283 | ) 284 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------