├── .travis.yml ├── entrypoint.sh ├── docker-examples ├── docker-compose.yml └── hello │ └── main.go ├── vendor ├── golang.org │ └── x │ │ └── sys │ │ └── unix │ │ ├── asm.s │ │ ├── constants.go │ │ ├── syscall_no_getwd.go │ │ ├── zsysnum_solaris_amd64.go │ │ ├── env_unset.go │ │ ├── flock_linux_32bit.go │ │ ├── asm_solaris_amd64.s │ │ ├── gccgo_linux_amd64.go │ │ ├── race0.go │ │ ├── env_unix.go │ │ ├── asm_linux_arm64.s │ │ ├── str.go │ │ ├── race.go │ │ ├── asm_linux_s390x.s │ │ ├── asm_linux_ppc64x.s │ │ ├── asm_linux_arm.s │ │ ├── asm_linux_mips64x.s │ │ ├── asm_freebsd_arm.s │ │ ├── asm_netbsd_arm.s │ │ ├── asm_darwin_386.s │ │ ├── asm_freebsd_386.s │ │ ├── asm_netbsd_386.s │ │ ├── asm_openbsd_386.s │ │ ├── asm_darwin_amd64.s │ │ ├── asm_freebsd_amd64.s │ │ ├── asm_linux_amd64.s │ │ ├── asm_netbsd_amd64.s │ │ ├── asm_openbsd_amd64.s │ │ ├── asm_dragonfly_amd64.s │ │ ├── asm_darwin_arm.s │ │ ├── bluetooth_linux.go │ │ ├── asm_darwin_arm64.s │ │ ├── flock.go │ │ ├── asm_linux_386.s │ │ ├── syscall_solaris_amd64.go │ │ ├── syscall_openbsd_amd64.go │ │ ├── syscall_netbsd_386.go │ │ ├── syscall_netbsd_arm.go │ │ ├── syscall_netbsd_amd64.go │ │ ├── syscall_openbsd_386.go │ │ ├── gccgo_c.c │ │ ├── sockcmsg_linux.go │ │ ├── LICENSE │ │ ├── syscall_dragonfly_amd64.go │ │ ├── syscall_freebsd_amd64.go │ │ ├── syscall_freebsd_arm.go │ │ ├── syscall_freebsd_386.go │ │ ├── gccgo.go │ │ ├── mkpost.go │ │ ├── syscall_darwin_arm.go │ │ ├── syscall_darwin_arm64.go │ │ ├── syscall_darwin_386.go │ │ ├── syscall_darwin_amd64.go │ │ ├── syscall.go │ │ ├── sockcmsg_unix.go │ │ ├── syscall_linux_ppc64x.go │ │ ├── types_netbsd.go │ │ ├── syscall_linux_amd64.go │ │ ├── types_dragonfly.go │ │ ├── types_openbsd.go │ │ ├── types_darwin.go │ │ ├── types_solaris.go │ │ ├── syscall_linux_arm64.go │ │ ├── syscall_linux_mips64x.go │ │ ├── ztypes_netbsd_386.go │ │ ├── ztypes_netbsd_arm.go │ │ ├── ztypes_netbsd_amd64.go │ │ ├── syscall_unix.go │ │ ├── ztypes_solaris_amd64.go │ │ ├── syscall_linux_arm.go │ │ └── ztypes_dragonfly_amd64.go ├── gopkg.in │ └── fsnotify.v1 │ │ ├── open_mode_bsd.go │ │ ├── open_mode_darwin.go │ │ ├── fen.go │ │ ├── LICENSE │ │ ├── fsnotify.go │ │ └── inotify_poller.go ├── manifest └── github.com │ └── fatih │ └── color │ ├── LICENSE.md │ └── doc.go ├── cmd └── watcher │ └── main.go ├── Dockerfile ├── LICENSE ├── watch_test.go ├── run.go ├── common_test.go ├── common.go ├── watch.go └── README.md /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.6 4 | - 1.5 5 | env: 6 | - GO15VENDOREXPERIMENT=1 7 | 8 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | [[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm" 3 | 4 | gvm use go$GO_VERSION --default 5 | 6 | export GOPATH=/go 7 | 8 | go get ./... 9 | 10 | exec "$@" 11 | -------------------------------------------------------------------------------- /docker-examples/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2.1' 2 | 3 | services: 4 | hello: 5 | image: canthefason/go-watcher:latest 6 | command: watcher -run hello 7 | ports: 8 | - "7000:7000" 9 | environment: 10 | - GO_VERSION=1.7 11 | volumes: 12 | - ./hello:/go/src/hello 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | TEXT ·use(SB),NOSPLIT,$0 10 | RET 11 | -------------------------------------------------------------------------------- /docker-examples/hello/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | func main() { 9 | http.ListenAndServe(":7000", 10 | http.HandlerFunc( 11 | func(w http.ResponseWriter, r *http.Request) { 12 | fmt.Fprintln(w, "watcher is running") 13 | }, 14 | ), 15 | ) 16 | } 17 | -------------------------------------------------------------------------------- /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/gopkg.in/fsnotify.v1/open_mode_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build freebsd openbsd netbsd dragonfly 6 | 7 | package fsnotify 8 | 9 | import "golang.org/x/sys/unix" 10 | 11 | const openMode = unix.O_NONBLOCK | unix.O_RDONLY 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_no_getwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/gopkg.in/fsnotify.v1/open_mode_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin 6 | 7 | package fsnotify 8 | 9 | import "golang.org/x/sys/unix" 10 | 11 | // note: this constant is not defined on BSD 12 | const openMode = unix.O_EVTONLY 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm 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 | -------------------------------------------------------------------------------- /cmd/watcher/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/canthefason/go-watcher" 7 | ) 8 | 9 | func main() { 10 | params := watcher.ParseArgs(os.Args) 11 | 12 | w := watcher.MustRegisterWatcher(params) 13 | 14 | r := watcher.NewRunner() 15 | 16 | // wait for build and run the binary with given params 17 | go r.Run(params) 18 | b := watcher.NewBuilder(w, r) 19 | 20 | // build given package 21 | go b.Build(params) 22 | 23 | // listen for further changes 24 | go w.Watch() 25 | 26 | r.Wait() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-64 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_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/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/manifest: -------------------------------------------------------------------------------- 1 | { 2 | "version": 0, 3 | "dependencies": [ 4 | { 5 | "importpath": "github.com/fatih/color", 6 | "repository": "https://github.com/fatih/color", 7 | "vcs": "git", 8 | "revision": "bf82308e8c8546dc2b945157173eb8a959ae9505", 9 | "branch": "master", 10 | "notests": true 11 | }, 12 | { 13 | "importpath": "golang.org/x/sys/unix", 14 | "repository": "https://go.googlesource.com/sys", 15 | "vcs": "git", 16 | "revision": "c200b10b5d5e122be351b67af224adc6128af5bf", 17 | "branch": "master", 18 | "path": "/unix", 19 | "notests": true 20 | }, 21 | { 22 | "importpath": "gopkg.in/fsnotify.v1", 23 | "repository": "https://gopkg.in/fsnotify.v1", 24 | "vcs": "git", 25 | "revision": "629574ca2a5df945712d3079857300b5e4da0236", 26 | "branch": "master", 27 | "notests": true 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 15 | var fcntl64Syscall uintptr = SYS_FCNTL 16 | 17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 20 | if errno == 0 { 21 | return nil 22 | } 23 | return errno 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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 | // 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 ·RawSyscall(SB),NOSPLIT,$0-28 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·socketcall(SB),NOSPLIT,$0-36 29 | JMP syscall·socketcall(SB) 30 | 31 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 32 | JMP syscall·rawsocketcall(SB) 33 | 34 | TEXT ·seek(SB),NOSPLIT,$0-28 35 | JMP syscall·seek(SB) 36 | -------------------------------------------------------------------------------- /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 TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 10 | 11 | func NsecToTimespec(nsec int64) (ts Timespec) { 12 | ts.Sec = nsec / 1e9 13 | ts.Nsec = nsec % 1e9 14 | return 15 | } 16 | 17 | func NsecToTimeval(nsec int64) (tv Timeval) { 18 | nsec += 999 // round up to microsecond 19 | tv.Usec = nsec % 1e9 / 1e3 20 | tv.Sec = int64(nsec / 1e9) 21 | return 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (cmsg *Cmsghdr) SetLen(length int) { 29 | cmsg.Len = uint32(length) 30 | } 31 | 32 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 33 | // TODO(aram): implement this, see issue 5847. 34 | panic("unimplemented") 35 | } 36 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM buildpack-deps:jessie-scm 2 | MAINTAINER Can Yucel "can.yucel@gmail.com" 3 | 4 | RUN apt-get update && apt-get install -y --no-install-recommends \ 5 | g++ \ 6 | gcc \ 7 | libc6-dev \ 8 | make \ 9 | pkg-config \ 10 | bison \ 11 | && rm -rf /var/lib/apt/lists/* 12 | 13 | SHELL ["/bin/bash", "-c"] 14 | 15 | ENV GO_VERSION 1.7 16 | 17 | RUN curl -s -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer | bash 18 | 19 | RUN . /root/.gvm/scripts/gvm && \ 20 | gvm install go1.4 && \ 21 | gvm use go1.4 && \ 22 | gvm install go1.5 && \ 23 | gvm install go1.6 && \ 24 | gvm install go1.7 25 | 26 | ENV WATCHER_VERSION 0.2.4 27 | 28 | ADD https://github.com/canthefason/go-watcher/releases/download/v${WATCHER_VERSION}/watcher-${WATCHER_VERSION}-linux-amd64 /root/.gvm/bin/watcher 29 | 30 | RUN chmod +x /root/.gvm/bin/watcher 31 | 32 | ENV GOPATH /go 33 | 34 | WORKDIR /go/src 35 | 36 | VOLUME /go/src 37 | ADD entrypoint.sh / 38 | 39 | ENTRYPOINT ["/entrypoint.sh"] 40 | CMD ["watcher"] 41 | -------------------------------------------------------------------------------- /vendor/gopkg.in/fsnotify.v1/fen.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 solaris 6 | 7 | package fsnotify 8 | 9 | import ( 10 | "errors" 11 | ) 12 | 13 | // Watcher watches a set of files, delivering events to a channel. 14 | type Watcher struct { 15 | Events chan Event 16 | Errors chan error 17 | } 18 | 19 | // NewWatcher establishes a new watcher with the underlying OS and begins waiting for events. 20 | func NewWatcher() (*Watcher, error) { 21 | return nil, errors.New("FEN based watcher not yet supported for fsnotify\n") 22 | } 23 | 24 | // Close removes all watches and closes the events channel. 25 | func (w *Watcher) Close() error { 26 | return nil 27 | } 28 | 29 | // Add starts watching the named file or directory (non-recursively). 30 | func (w *Watcher) Add(name string) error { 31 | return nil 32 | } 33 | 34 | // Remove stops watching the the named file or directory (non-recursively). 35 | func (w *Watcher) Remove(name string) error { 36 | return nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = nsec / 1e9 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Can Yucel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Fatih Arslan 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/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *((*Ucred)(cmsgData(h))) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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/gopkg.in/fsnotify.v1/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 The Go Authors. All rights reserved. 2 | Copyright (c) 2012 fsnotify Authors. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 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 FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /vendor/gopkg.in/fsnotify.v1/fsnotify.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 !plan9 6 | 7 | // Package fsnotify provides a platform-independent interface for file system notifications. 8 | package fsnotify 9 | 10 | import ( 11 | "bytes" 12 | "fmt" 13 | ) 14 | 15 | // Event represents a single file system notification. 16 | type Event struct { 17 | Name string // Relative path to the file or directory. 18 | Op Op // File operation that triggered the event. 19 | } 20 | 21 | // Op describes a set of file operations. 22 | type Op uint32 23 | 24 | // These are the generalized file operations that can trigger a notification. 25 | const ( 26 | Create Op = 1 << iota 27 | Write 28 | Remove 29 | Rename 30 | Chmod 31 | ) 32 | 33 | func (op Op) String() string { 34 | // Use a buffer for efficient string concatenation 35 | var buffer bytes.Buffer 36 | 37 | if op&Create == Create { 38 | buffer.WriteString("|CREATE") 39 | } 40 | if op&Remove == Remove { 41 | buffer.WriteString("|REMOVE") 42 | } 43 | if op&Write == Write { 44 | buffer.WriteString("|WRITE") 45 | } 46 | if op&Rename == Rename { 47 | buffer.WriteString("|RENAME") 48 | } 49 | if op&Chmod == Chmod { 50 | buffer.WriteString("|CHMOD") 51 | } 52 | if buffer.Len() == 0 { 53 | return "" 54 | } 55 | return buffer.String()[1:] // Strip leading pipe 56 | } 57 | 58 | // String returns a string representation of the event in the form 59 | // "file: REMOVE|WRITE|..." 60 | func (e Event) String() string { 61 | return fmt.Sprintf("%q: %s", e.Name, e.Op.String()) 62 | } 63 | -------------------------------------------------------------------------------- /watch_test.go: -------------------------------------------------------------------------------- 1 | package watcher 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | ) 7 | 8 | func TestPrepareRootDir(t *testing.T) { 9 | w := &Watcher{} 10 | dir, err := w.prepareRootDir() 11 | if err != nil { 12 | t.Errorf("Expected nil but got %s for prepareRootDir", err) 13 | } 14 | 15 | workingDir, _ := os.Getwd() 16 | if dir != workingDir { 17 | t.Errorf("Expected %s but got %s for prepareRootDir", workingDir, dir) 18 | } 19 | 20 | w.rootdir = "balcony" 21 | os.Setenv("GOPATH", "") 22 | dir, err = w.prepareRootDir() 23 | if err != ErrPathNotSet { 24 | t.Errorf("Expected %s but got %s for prepareRootDir", ErrPathNotSet, err) 25 | } 26 | 27 | os.Setenv("GOPATH", "go") 28 | 29 | dir, err = w.prepareRootDir() 30 | if err != nil { 31 | t.Errorf("Expected nil but got %s for prepareRootDir", err) 32 | } 33 | 34 | if dir != "go/src/balcony" { 35 | t.Errorf("Expected go/src/balcony but got %s for prepareRootDir", dir) 36 | } 37 | } 38 | 39 | func TestIsTestFile(t *testing.T) { 40 | fileName := "/go/src/github.com/canthefason/go-watcher/common.go" 41 | if isTestFile(fileName) { 42 | t.Error("expected false, got true") 43 | } 44 | 45 | fileName = "/go/src/github.com/canthefason/go-watcher/common_test.go" 46 | if !isTestFile(fileName) { 47 | t.Error("expected true, got false") 48 | } 49 | } 50 | 51 | func TestIsWatchedFileType(t *testing.T) { 52 | fileName := "/go/src/github.com/canthefason/go-watcher/common.go" 53 | if !isWatchedFileType(fileName) { 54 | t.Errorf("expected true, got false") 55 | } 56 | 57 | fileName = "/go/src/github.com/canthefason/go-watcher/README.md" 58 | 59 | if isWatchedFileType(fileName) { 60 | t.Errorf("expected false, got true") 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /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 Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_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 Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_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 Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = nsec / 1e9 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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 by mkall.sh. 12 | package main 13 | 14 | import ( 15 | "fmt" 16 | "go/format" 17 | "io/ioutil" 18 | "log" 19 | "os" 20 | "regexp" 21 | ) 22 | 23 | func main() { 24 | b, err := ioutil.ReadAll(os.Stdin) 25 | if err != nil { 26 | log.Fatal(err) 27 | } 28 | s := string(b) 29 | 30 | goarch := os.Getenv("GOARCH") 31 | goos := os.Getenv("GOOS") 32 | if goarch == "s390x" && goos == "linux" { 33 | // Export the types of PtraceRegs fields. 34 | re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)") 35 | s = re.ReplaceAllString(s, "Ptrace$1") 36 | 37 | // Replace padding fields inserted by cgo with blank identifiers. 38 | re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*") 39 | s = re.ReplaceAllString(s, "_") 40 | 41 | // Replace other unwanted fields with blank identifiers. 42 | re = regexp.MustCompile("X_[A-Za-z0-9_]*") 43 | s = re.ReplaceAllString(s, "_") 44 | 45 | // Replace the control_regs union with a blank identifier for now. 46 | re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64") 47 | s = re.ReplaceAllString(s, "_ [0]uint64") 48 | } 49 | 50 | // gofmt 51 | b, err = format.Source([]byte(s)) 52 | if err != nil { 53 | log.Fatal(err) 54 | } 55 | 56 | // Append this command to the header to show where the new file 57 | // came from. 58 | re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)") 59 | b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go")) 60 | 61 | fmt.Printf("%s", b) 62 | } 63 | -------------------------------------------------------------------------------- /run.go: -------------------------------------------------------------------------------- 1 | // Package watcher is a command line tool inspired by fresh (https://github.com/pilu/fresh) and used 2 | // for watching .go file changes, and restarting the app in case of an update/delete/add operation. 3 | // After you installed it, you can run your apps with their default parameters as: 4 | // watcher -c config -p 7000 -h localhost 5 | package watcher 6 | 7 | import ( 8 | "log" 9 | "os/exec" 10 | 11 | "github.com/fatih/color" 12 | ) 13 | 14 | // Runner listens for the change events and depending on that kills 15 | // the obsolete process, and runs a new one 16 | type Runner struct { 17 | start chan string 18 | done chan struct{} 19 | cmd *exec.Cmd 20 | } 21 | 22 | // NewRunner creates a new Runner instance and returns its pointer 23 | func NewRunner() *Runner { 24 | return &Runner{ 25 | start: make(chan string), 26 | done: make(chan struct{}), 27 | } 28 | } 29 | 30 | // Run initializes runner with given parameters. 31 | func (r *Runner) Run(p *Params) { 32 | for fileName := range r.start { 33 | 34 | color.Green("Running %s...\n", p.Get("run")) 35 | 36 | cmd, err := runCommand(fileName, p.Package...) 37 | if err != nil { 38 | log.Printf("Could not run the go binary: %s \n", err) 39 | r.kill(cmd) 40 | 41 | continue 42 | } 43 | 44 | r.cmd = cmd 45 | removeFile(fileName) 46 | 47 | go func(cmd *exec.Cmd) { 48 | if err := cmd.Wait(); err != nil { 49 | log.Printf("process interrupted: %s \n", err) 50 | r.kill(cmd) 51 | } 52 | }(r.cmd) 53 | } 54 | } 55 | 56 | // Restart kills the process, removes the old binary and 57 | // restarts the new process 58 | func (r *Runner) restart(fileName string) { 59 | r.kill(r.cmd) 60 | 61 | r.start <- fileName 62 | } 63 | 64 | func (r *Runner) kill(cmd *exec.Cmd) { 65 | if cmd != nil { 66 | cmd.Process.Kill() 67 | } 68 | } 69 | 70 | func (r *Runner) Close() { 71 | close(r.start) 72 | r.kill(r.cmd) 73 | close(r.done) 74 | } 75 | 76 | func (r *Runner) Wait() { 77 | <-r.done 78 | } 79 | -------------------------------------------------------------------------------- /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 Getpagesize() int { return 4096 } 13 | 14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 15 | 16 | func NsecToTimespec(nsec int64) (ts Timespec) { 17 | ts.Sec = int32(nsec / 1e9) 18 | ts.Nsec = int32(nsec % 1e9) 19 | return 20 | } 21 | 22 | func NsecToTimeval(nsec int64) (tv Timeval) { 23 | nsec += 999 // round up to microsecond 24 | tv.Usec = int32(nsec % 1e9 / 1e3) 25 | tv.Sec = int32(nsec / 1e9) 26 | return 27 | } 28 | 29 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 30 | func Gettimeofday(tv *Timeval) (err error) { 31 | // The tv passed to gettimeofday must be non-nil 32 | // but is otherwise unused. The answers come back 33 | // in the two registers. 34 | sec, usec, err := gettimeofday(tv) 35 | tv.Sec = int32(sec) 36 | tv.Usec = int32(usec) 37 | return err 38 | } 39 | 40 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 41 | k.Ident = uint32(fd) 42 | k.Filter = int16(mode) 43 | k.Flags = uint16(flags) 44 | } 45 | 46 | func (iov *Iovec) SetLen(length int) { 47 | iov.Len = uint32(length) 48 | } 49 | 50 | func (msghdr *Msghdr) SetControllen(length int) { 51 | msghdr.Controllen = uint32(length) 52 | } 53 | 54 | func (cmsg *Cmsghdr) SetLen(length int) { 55 | cmsg.Len = uint32(length) 56 | } 57 | 58 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 59 | var length = uint64(count) 60 | 61 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 62 | 63 | written = int(length) 64 | 65 | if e1 != 0 { 66 | err = e1 67 | } 68 | return 69 | } 70 | 71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 72 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = sec 38 | tv.Usec = usec 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint64(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint64(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = int32(sec) 38 | tv.Usec = int32(usec) 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint32(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint32(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) 15 | 16 | func Getpagesize() int { return 4096 } 17 | 18 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 19 | 20 | func NsecToTimespec(nsec int64) (ts Timespec) { 21 | ts.Sec = nsec / 1e9 22 | ts.Nsec = nsec % 1e9 23 | return 24 | } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /common_test.go: -------------------------------------------------------------------------------- 1 | package watcher 2 | 3 | import "testing" 4 | 5 | func TestParamsGet(t *testing.T) { 6 | params := NewParams() 7 | params.Watcher["run"] = "statler" 8 | 9 | run := params.Get("run") 10 | if run != "statler" { 11 | t.Error("Expected statler but got %s in params.Get()", run) 12 | t.FailNow() 13 | } 14 | } 15 | 16 | func TestParamsClone(t *testing.T) { 17 | params := NewParams() 18 | params.Watcher["run"] = "statler" 19 | 20 | params.cloneRunFlag() 21 | watch := params.Get("watch") 22 | if watch != "statler" { 23 | t.Error("Expected statler but got %s when watch param is not set", watch) 24 | } 25 | 26 | params.Watcher["watch"] = "waldorf" 27 | 28 | params.cloneRunFlag() 29 | 30 | watch = params.Get("watch") 31 | if watch != "waldorf" { 32 | t.Errorf("Expected waldorf but got %s when watch param is set", watch) 33 | } 34 | 35 | } 36 | 37 | func TestPrepareArgs(t *testing.T) { 38 | args := []string{"watcher", "-run", "balcony", "-p", "11880", "--watch", "show", "--host", "localhost"} 39 | 40 | params := ParseArgs(args) 41 | if len(params.Package) != 4 { 42 | t.Fatalf("Expected 2 parameters with their values in Package parameters but got %d", len(params.Package)) 43 | } 44 | 45 | if params.Package[0] != "-p" { 46 | t.Errorf("Expected -p as package parameter but got %s", params.Package[0]) 47 | } 48 | 49 | if params.Package[2] != "--host" { 50 | t.Errorf("Expected --host as package parameter but got %s", params.Package[0]) 51 | } 52 | 53 | if len(params.Watcher) != 2 { 54 | t.Fatalf("Expected 2 parameter with their values in System parameters but got %d", len(params.Watcher)) 55 | } 56 | 57 | if params.Watcher["run"] != "balcony" { 58 | t.Errorf("Expected balcony but got %s", params.Watcher["run"]) 59 | } 60 | 61 | // TODO check this fatal error case 62 | // args = []string{"watcher", "-run", "balcony", "-p", "11880", "--watch"} 63 | // params = PrepareArgs(args) 64 | 65 | } 66 | 67 | func TestStripDash(t *testing.T) { 68 | arg := stripDash("-p") 69 | if arg != "p" { 70 | t.Errorf("Expected p but got %s in stripDash", arg) 71 | } 72 | 73 | arg = stripDash("--host") 74 | if arg != "host" { 75 | t.Errorf("Expected host but got %s in stripDash", arg) 76 | } 77 | 78 | arg = stripDash("--p") 79 | if arg != "p" { 80 | t.Errorf("Expected p but got %s in stripDash", arg) 81 | } 82 | 83 | arg = stripDash("11880") 84 | if arg != "11880" { 85 | t.Errorf("Expected 11880 but got %s in stripDash", arg) 86 | } 87 | 88 | } 89 | 90 | func TestExistIn(t *testing.T) { 91 | input := []string{"a", "b", "c"} 92 | 93 | if !existIn("c", input) { 94 | t.Errorf("expected true, got false") 95 | } 96 | 97 | if existIn("d", input) { 98 | t.Errorf("expected false, got true") 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package unix // import "golang.org/x/sys/unix" 23 | 24 | import "unsafe" 25 | 26 | // ByteSliceFromString returns a NUL-terminated slice of bytes 27 | // containing the text of s. If s contains a NUL byte at any 28 | // location, it returns (nil, EINVAL). 29 | func ByteSliceFromString(s string) ([]byte, error) { 30 | for i := 0; i < len(s); i++ { 31 | if s[i] == 0 { 32 | return nil, EINVAL 33 | } 34 | } 35 | a := make([]byte, len(s)+1) 36 | copy(a, s) 37 | return a, nil 38 | } 39 | 40 | // BytePtrFromString returns a pointer to a NUL-terminated array of 41 | // bytes containing the text of s. If s contains a NUL byte at any 42 | // location, it returns (nil, EINVAL). 43 | func BytePtrFromString(s string) (*byte, error) { 44 | a, err := ByteSliceFromString(s) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return &a[0], nil 49 | } 50 | 51 | // Single-word zero for use when we need a valid pointer to 0 bytes. 52 | // See mkunix.pl. 53 | var _zero uintptr 54 | 55 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 56 | return int64(ts.Sec), int64(ts.Nsec) 57 | } 58 | 59 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 60 | return int64(tv.Sec), int64(tv.Usec) * 1000 61 | } 62 | 63 | func (ts *Timespec) Nano() int64 { 64 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 65 | } 66 | 67 | func (tv *Timeval) Nano() int64 { 68 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 69 | } 70 | 71 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 72 | 73 | // use is a no-op, but the compiler cannot see that it is. 74 | // Calling use(p) ensures that p is kept live until that point. 75 | //go:noescape 76 | func use(p unsafe.Pointer) 77 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Socket control messages 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // Round the length of a raw sockaddr up to align it properly. 14 | func cmsgAlignOf(salen int) int { 15 | salign := sizeofPtr 16 | // NOTE: It seems like 64-bit Darwin and DragonFly BSD kernels 17 | // still require 32-bit aligned access to network subsystem. 18 | if darwin64Bit || dragonfly64Bit { 19 | salign = 4 20 | } 21 | return (salen + salign - 1) & ^(salign - 1) 22 | } 23 | 24 | // CmsgLen returns the value to store in the Len field of the Cmsghdr 25 | // structure, taking into account any necessary alignment. 26 | func CmsgLen(datalen int) int { 27 | return cmsgAlignOf(SizeofCmsghdr) + datalen 28 | } 29 | 30 | // CmsgSpace returns the number of bytes an ancillary element with 31 | // payload of the passed data length occupies. 32 | func CmsgSpace(datalen int) int { 33 | return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) 34 | } 35 | 36 | func cmsgData(h *Cmsghdr) unsafe.Pointer { 37 | return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr))) 38 | } 39 | 40 | // SocketControlMessage represents a socket control message. 41 | type SocketControlMessage struct { 42 | Header Cmsghdr 43 | Data []byte 44 | } 45 | 46 | // ParseSocketControlMessage parses b as an array of socket control 47 | // messages. 48 | func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { 49 | var msgs []SocketControlMessage 50 | i := 0 51 | for i+CmsgLen(0) <= len(b) { 52 | h, dbuf, err := socketControlMessageHeaderAndData(b[i:]) 53 | if err != nil { 54 | return nil, err 55 | } 56 | m := SocketControlMessage{Header: *h, Data: dbuf} 57 | msgs = append(msgs, m) 58 | i += cmsgAlignOf(int(h.Len)) 59 | } 60 | return msgs, nil 61 | } 62 | 63 | func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) { 64 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 65 | if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) { 66 | return nil, nil, EINVAL 67 | } 68 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 69 | } 70 | 71 | // UnixRights encodes a set of open file descriptors into a socket 72 | // control message for sending to another process. 73 | func UnixRights(fds ...int) []byte { 74 | datalen := len(fds) * 4 75 | b := make([]byte, CmsgSpace(datalen)) 76 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 77 | h.Level = SOL_SOCKET 78 | h.Type = SCM_RIGHTS 79 | h.SetLen(CmsgLen(datalen)) 80 | data := cmsgData(h) 81 | for _, fd := range fds { 82 | *(*int32)(data) = int32(fd) 83 | data = unsafe.Pointer(uintptr(data) + 4) 84 | } 85 | return b 86 | } 87 | 88 | // ParseUnixRights decodes a socket control message that contains an 89 | // integer array of open file descriptors from another process. 90 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 91 | if m.Header.Level != SOL_SOCKET { 92 | return nil, EINVAL 93 | } 94 | if m.Header.Type != SCM_RIGHTS { 95 | return nil, EINVAL 96 | } 97 | fds := make([]int, len(m.Data)>>2) 98 | for i, j := 0, 0; i < len(m.Data); i += 4 { 99 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 100 | j++ 101 | } 102 | return fds, nil 103 | } 104 | -------------------------------------------------------------------------------- /common.go: -------------------------------------------------------------------------------- 1 | package watcher 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "log" 7 | "math/rand" 8 | "os" 9 | "os/exec" 10 | "strings" 11 | "time" 12 | ) 13 | 14 | // Binary name used for built package 15 | const binaryName = "watcher" 16 | 17 | var watcherFlags = []string{"run", "watch", "watch-vendor"} 18 | 19 | // Params is used for keeping go-watcher and application flag parameters 20 | type Params struct { 21 | // Package parameters 22 | Package []string 23 | // Go-Watcher parameters 24 | Watcher map[string]string 25 | } 26 | 27 | // NewParams creates a new Params instance 28 | func NewParams() *Params { 29 | return &Params{ 30 | Package: make([]string, 0), 31 | Watcher: make(map[string]string), 32 | } 33 | } 34 | 35 | // Get returns the watcher parameter with the given name 36 | func (p *Params) Get(name string) string { 37 | return p.Watcher[name] 38 | } 39 | 40 | func (p *Params) cloneRunFlag() { 41 | if p.Watcher["watch"] == "" && p.Watcher["run"] != "" { 42 | p.Watcher["watch"] = p.Watcher["run"] 43 | } 44 | } 45 | 46 | func (p *Params) packagePath() string { 47 | run := p.Get("run") 48 | if run != "" { 49 | return run 50 | } 51 | 52 | return "." 53 | } 54 | 55 | // generateBinaryName generates a new binary name for each rebuild, for preventing any sorts of conflicts 56 | func (p *Params) generateBinaryName() string { 57 | rand.Seed(time.Now().UnixNano()) 58 | randName := rand.Int31n(999999) 59 | packageName := strings.Replace(p.packagePath(), "/", "-", -1) 60 | 61 | return fmt.Sprintf("%s-%s-%d", generateBinaryPrefix(), packageName, randName) 62 | } 63 | 64 | func generateBinaryPrefix() string { 65 | path := os.Getenv("GOPATH") 66 | if path != "" { 67 | return fmt.Sprintf("%s/bin/%s", path, binaryName) 68 | } 69 | 70 | return path 71 | } 72 | 73 | // runCommand runs the command with given name and arguments. It copies the 74 | // logs to standard output 75 | func runCommand(name string, args ...string) (*exec.Cmd, error) { 76 | cmd := exec.Command(name, args...) 77 | stderr, err := cmd.StderrPipe() 78 | if err != nil { 79 | return cmd, err 80 | } 81 | 82 | stdout, err := cmd.StdoutPipe() 83 | if err != nil { 84 | return cmd, err 85 | } 86 | 87 | if err := cmd.Start(); err != nil { 88 | return cmd, err 89 | } 90 | 91 | go io.Copy(os.Stdout, stdout) 92 | go io.Copy(os.Stderr, stderr) 93 | 94 | return cmd, nil 95 | } 96 | 97 | // ParseArgs extracts the application parameters from args and returns 98 | // Params instance with separated watcher and application parameters 99 | func ParseArgs(args []string) *Params { 100 | 101 | params := NewParams() 102 | 103 | // remove the command argument 104 | args = args[1:len(args)] 105 | 106 | for i := 0; i < len(args); i++ { 107 | arg := args[i] 108 | arg = stripDash(arg) 109 | 110 | if existIn(arg, watcherFlags) { 111 | // used for fetching the value of the given parameter 112 | if len(args) <= i+1 { 113 | log.Fatalf("missing parameter value: %s", arg) 114 | } 115 | 116 | if strings.HasPrefix(args[i+1], "-") { 117 | log.Fatalf("missing parameter value: %s", arg) 118 | } 119 | 120 | params.Watcher[arg] = args[i+1] 121 | i++ 122 | continue 123 | } 124 | 125 | params.Package = append(params.Package, args[i]) 126 | } 127 | 128 | params.cloneRunFlag() 129 | 130 | return params 131 | } 132 | 133 | // stripDash removes the both single and double dash chars and returns 134 | // the actual parameter name 135 | func stripDash(arg string) string { 136 | if len(arg) > 1 { 137 | if arg[1] == '-' { 138 | return arg[2:] 139 | } else if arg[0] == '-' { 140 | return arg[1:] 141 | } 142 | } 143 | 144 | return arg 145 | } 146 | 147 | func existIn(search string, in []string) bool { 148 | for i := range in { 149 | if search == in[i] { 150 | return true 151 | } 152 | } 153 | 154 | return false 155 | } 156 | 157 | func removeFile(fileName string) { 158 | if fileName != "" { 159 | cmd := exec.Command("rm", fileName) 160 | cmd.Run() 161 | cmd.Wait() 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package color is an ANSI color package to output colorized or SGR defined 3 | output to the standard output. The API can be used in several way, pick one 4 | that suits you. 5 | 6 | Use simple and default helper functions with predefined foreground colors: 7 | 8 | color.Cyan("Prints text in cyan.") 9 | 10 | // a newline will be appended automatically 11 | color.Blue("Prints %s in blue.", "text") 12 | 13 | // More default foreground colors.. 14 | color.Red("We have red") 15 | color.Yellow("Yellow color too!") 16 | color.Magenta("And many others ..") 17 | 18 | However there are times where custom color mixes are required. Below are some 19 | examples to create custom color objects and use the print functions of each 20 | separate color object. 21 | 22 | // Create a new color object 23 | c := color.New(color.FgCyan).Add(color.Underline) 24 | c.Println("Prints cyan text with an underline.") 25 | 26 | // Or just add them to New() 27 | d := color.New(color.FgCyan, color.Bold) 28 | d.Printf("This prints bold cyan %s\n", "too!.") 29 | 30 | 31 | // Mix up foreground and background colors, create new mixes! 32 | red := color.New(color.FgRed) 33 | 34 | boldRed := red.Add(color.Bold) 35 | boldRed.Println("This will print text in bold red.") 36 | 37 | whiteBackground := red.Add(color.BgWhite) 38 | whiteBackground.Println("Red text with White background.") 39 | 40 | 41 | You can create PrintXxx functions to simplify even more: 42 | 43 | // Create a custom print function for convenient 44 | red := color.New(color.FgRed).PrintfFunc() 45 | red("warning") 46 | red("error: %s", err) 47 | 48 | // Mix up multiple attributes 49 | notice := color.New(color.Bold, color.FgGreen).PrintlnFunc() 50 | notice("don't forget this...") 51 | 52 | 53 | Or create SprintXxx functions to mix strings with other non-colorized strings: 54 | 55 | yellow := New(FgYellow).SprintFunc() 56 | red := New(FgRed).SprintFunc() 57 | 58 | fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error")) 59 | 60 | info := New(FgWhite, BgGreen).SprintFunc() 61 | fmt.Printf("this %s rocks!\n", info("package")) 62 | 63 | Windows support is enabled by default. All Print functions works as intended. 64 | However only for color.SprintXXX functions, user should use fmt.FprintXXX and 65 | set the output to color.Output: 66 | 67 | fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS")) 68 | 69 | info := New(FgWhite, BgGreen).SprintFunc() 70 | fmt.Fprintf(color.Output, "this %s rocks!\n", info("package")) 71 | 72 | Using with existing code is possible. Just use the Set() method to set the 73 | standard output to the given parameters. That way a rewrite of an existing 74 | code is not required. 75 | 76 | // Use handy standard colors. 77 | color.Set(color.FgYellow) 78 | 79 | fmt.Println("Existing text will be now in Yellow") 80 | fmt.Printf("This one %s\n", "too") 81 | 82 | color.Unset() // don't forget to unset 83 | 84 | // You can mix up parameters 85 | color.Set(color.FgMagenta, color.Bold) 86 | defer color.Unset() // use it in your function 87 | 88 | fmt.Println("All text will be now bold magenta.") 89 | 90 | There might be a case where you want to disable color output (for example to 91 | pipe the standard output of your app to somewhere else). `Color` has support to 92 | disable colors both globally and for single color definition. For example 93 | suppose you have a CLI app and a `--no-color` bool flag. You can easily disable 94 | the color output with: 95 | 96 | var flagNoColor = flag.Bool("no-color", false, "Disable color output") 97 | 98 | if *flagNoColor { 99 | color.NoColor = true // disables colorized output 100 | } 101 | 102 | It also has support for single color definitions (local). You can 103 | disable/enable color output on the fly: 104 | 105 | c := color.New(color.FgCyan) 106 | c.Println("Prints cyan text") 107 | 108 | c.DisableColor() 109 | c.Println("This is printed without any color") 110 | 111 | c.EnableColor() 112 | c.Println("This prints again cyan...") 113 | */ 114 | package color 115 | -------------------------------------------------------------------------------- /watch.go: -------------------------------------------------------------------------------- 1 | // Package watcher watches all file changes via fsnotify package and sends 2 | // update events to builder 3 | package watcher 4 | 5 | import ( 6 | "errors" 7 | "fmt" 8 | "log" 9 | "os" 10 | "path/filepath" 11 | "strconv" 12 | "strings" 13 | "time" 14 | 15 | fsnotify "gopkg.in/fsnotify.v1" 16 | ) 17 | 18 | // GoPath not set error 19 | var ErrPathNotSet = errors.New("gopath not set") 20 | 21 | var watchedFileExt = []string{".go", ".tmpl", ".tpl", ".html"} 22 | 23 | var watchDelta = 1000 * time.Millisecond 24 | 25 | // Watcher watches the file change events from fsnotify and 26 | // sends update messages. It is also used as a fsnotify.Watcher wrapper 27 | type Watcher struct { 28 | rootdir string 29 | watcher *fsnotify.Watcher 30 | watchVendor bool 31 | // when a file gets changed a message is sent to the update channel 32 | update chan struct{} 33 | } 34 | 35 | // MustRegisterWatcher creates a new Watcher and starts listening to 36 | // given folders 37 | func MustRegisterWatcher(params *Params) *Watcher { 38 | watchVendorStr := params.Get("watch-vendor") 39 | var watchVendor bool 40 | var err error 41 | if watchVendorStr != "" { 42 | watchVendor, err = strconv.ParseBool(watchVendorStr) 43 | if err != nil { 44 | log.Println("Wrong watch-vendor value: %s (default=false)", watchVendorStr) 45 | } 46 | } 47 | 48 | w := &Watcher{ 49 | update: make(chan struct{}), 50 | rootdir: params.Get("watch"), 51 | watchVendor: watchVendor, 52 | } 53 | 54 | w.watcher, err = fsnotify.NewWatcher() 55 | if err != nil { 56 | log.Fatalf("Could not register watcher: %s", err) 57 | } 58 | 59 | // add folders that will be watched 60 | w.watchFolders() 61 | 62 | return w 63 | } 64 | 65 | // Watch listens file updates, and sends signal to 66 | // update channel when .go and .tmpl files are updated 67 | func (w *Watcher) Watch() { 68 | eventSent := false 69 | 70 | for { 71 | select { 72 | case event := <-w.watcher.Events: 73 | // discard chmod events 74 | if event.Op&fsnotify.Chmod != fsnotify.Chmod { 75 | // test files do not need a rebuild 76 | if isTestFile(event.Name) { 77 | continue 78 | } 79 | if !isWatchedFileType(event.Name) { 80 | continue 81 | } 82 | if eventSent { 83 | continue 84 | } 85 | eventSent = true 86 | // prevent consequent builds 87 | go func() { 88 | w.update <- struct{}{} 89 | time.Sleep(watchDelta) 90 | eventSent = false 91 | }() 92 | 93 | } 94 | case err := <-w.watcher.Errors: 95 | if err != nil { 96 | log.Fatalf("Watcher error: %s", err) 97 | } 98 | return 99 | } 100 | } 101 | } 102 | 103 | func isTestFile(fileName string) bool { 104 | return strings.HasSuffix(filepath.Base(fileName), "_test.go") 105 | } 106 | 107 | func isWatchedFileType(fileName string) bool { 108 | ext := filepath.Ext(fileName) 109 | 110 | return existIn(ext, watchedFileExt) 111 | } 112 | 113 | // Wait waits for the latest messages 114 | func (w *Watcher) Wait() <-chan struct{} { 115 | return w.update 116 | } 117 | 118 | // Close closes the fsnotify watcher channel 119 | func (w *Watcher) Close() { 120 | w.watcher.Close() 121 | close(w.update) 122 | } 123 | 124 | // watchFolders recursively adds folders that will be watched against the changes, 125 | // starting from the working directory 126 | func (w *Watcher) watchFolders() { 127 | wd, err := w.prepareRootDir() 128 | 129 | if err != nil { 130 | log.Fatalf("Could not get root working directory: %s", err) 131 | } 132 | 133 | filepath.Walk(wd, func(path string, info os.FileInfo, err error) error { 134 | // skip files 135 | if info == nil { 136 | log.Fatalf("wrong watcher package: %s", path) 137 | } 138 | 139 | if !info.IsDir() { 140 | return nil 141 | } 142 | 143 | if !w.watchVendor { 144 | // skip vendor directory 145 | vendor := fmt.Sprintf("%s/vendor", wd) 146 | if strings.HasPrefix(path, vendor) { 147 | return filepath.SkipDir 148 | } 149 | } 150 | 151 | // skip hidden folders 152 | if len(path) > 1 && strings.HasPrefix(filepath.Base(path), ".") { 153 | return filepath.SkipDir 154 | } 155 | 156 | w.addFolder(path) 157 | 158 | return err 159 | }) 160 | } 161 | 162 | // addFolder adds given folder name to the watched folders, and starts 163 | // watching it for further changes 164 | func (w *Watcher) addFolder(name string) { 165 | if err := w.watcher.Add(name); err != nil { 166 | log.Fatalf("Could not watch folder: %s", err) 167 | } 168 | } 169 | 170 | // prepareRootDir prepares working directory depending on root directory 171 | func (w *Watcher) prepareRootDir() (string, error) { 172 | if w.rootdir == "" { 173 | return os.Getwd() 174 | } 175 | 176 | path := os.Getenv("GOPATH") 177 | if path == "" { 178 | return "", ErrPathNotSet 179 | } 180 | 181 | root := fmt.Sprintf("%s/src/%s", path, w.rootdir) 182 | 183 | return root, nil 184 | } 185 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Watcher [![GoDoc](https://godoc.org/github.com/canthefason/go-watcher?status.svg)](https://godoc.org/github.com/canthefason/go-watcher) [![Build Status](https://travis-ci.org/canthefason/go-watcher.svg?branch=master)](https://travis-ci.org/canthefason/go-watcher) 2 | ======= 3 | 4 | Watcher is a command line tool inspired by [fresh](https://github.com/pilu/fresh) and used for watching .go file changes, and restarting the app in case of an update/delete/add operation. 5 | 6 | Most of the existing file watchers have a configuration burden, and even though Go has a really short build time, this configuration burden makes your binaries really hard to run right away. With Watcher, we aimed simplicity in configuration, and tried to make it as simple as possible. 7 | 8 | ## Installation 9 | 10 | Get the package with: 11 | 12 | `go get github.com/canthefason/go-watcher` 13 | 14 | Install the binary under go/bin folder: 15 | 16 | `go install github.com/canthefason/go-watcher/cmd/watcher` 17 | 18 | After this step, please make sure that your go/bin folder is appended to PATH environment variable. 19 | 20 | ## Usage 21 | 22 | `cd /path/to/myapp` 23 | 24 | Start watcher: 25 | 26 | `watcher` 27 | 28 | Watcher works like your native package binary. You can pass all your existing package arguments to the Watcher, which really lowers the learning curve of the package, and makes it practical. 29 | 30 | ##### Current app usage 31 | `myapp -c config -p 7000 -h localhost` 32 | 33 | ##### With watcher 34 | `watcher -c config -p 7000 -h localhost` 35 | 36 | As you can see nothing changed between these two calls. When you run the command, Watcher starts watching folders recursively, starting from the current working directory. It only watches .go and .tmpl files and ignores hidden folders and _test.go files. 37 | 38 | ##### Package dependency 39 | 40 | By default Watcher recursively watches all files/folders under working directory. If you prefer to use it like `go run`, you can call watcher with -run flag anywhere you want (we assume that your GOPATH is properly set). 41 | 42 | `watcher -c config -run github.com/username/somerootpackagename` 43 | 44 | For the cases where your main function is in another directory other than the dependant package, you can do this by passing a different package name to -watch parameter. 45 | 46 | `watcher -c config -run github.com/username/somerootpackagename -watch github.com/username` 47 | 48 | 49 | ##### Vendor directory 50 | Since Globs and some optional folder arrays will make it harder to configure, we are not planning to have support for a configurable watched folder structure. Only configuration we have here is, by default we have excluded vendor/ folder from watched directories. If your intention is making some changes in place, you can set -watch-vendor flag as "true", and start watching vendor directory. 51 | 52 | ## Watcher in Docker 53 | 54 | If you want to run Watcher in a containerized local environment, you can achieve this by using [canthefason/go-watcher](https://hub.docker.com/r/canthefason/go-watcher/) image in Docker Hub. There is an example project under [/docker-example](https://github.com/canthefason/go-watcher/tree/dockerfile-gvm/docker-examples) directoy. Let's try to dockerize this example code first. 55 | 56 | In our example, we are creating a server that listens to port 7000 and responds to all clients with "watcher is running" string. The most essential thing to run your code in Docker is, mounting your project volume to a container. In the containerized Watcher, our GOPATH is set to /go directory by default, so you need to mount your project to this GOPATH. 57 | 58 | `docker run -v /path/to/hello:/go/src/hello -p 7000:7000 canthefason/go-watcher watcher -run hello` 59 | 60 | Containerized Watcher also supports different versions of Go by leveraging [gvm](https://github.com/moovweb/gvm). Currently it only supports major versions right now. If you don't set anything, by default Watcher will pick version 1.7. If you want to change the Go version, you can use GO_VERSION environment variable. Currently it only supports 1.4, 1.5, 1.6, 1.7 at the moment 61 | 62 | `docker run -v /path/to/hello:/go/src/hello -e GO_VERSION=1.6 -p 7000:7000 canthefason/go-watcher watcher -run hello` 63 | 64 | To provide a more structured repo, we also integrated a docker-compose manifest file. That file already handles volume mounting operation that and exposes the port to the localhost. With docker-compose the only thing that you need to do from the root, invoking `docker-compose up 65 | 66 | #### Known Issues 67 | On Mac OS X, when you make a tls connection, you can get a message like: x509: `certificate signed by unknown authority` 68 | 69 | You can resolve this problem by setting CGO_ENABLED=0 70 | https://github.com/golang/go/issues/14514 71 | https://codereview.appspot.com/22020045 72 | 73 | ## Author 74 | 75 | * [Can Yucel](http://canthefason.com) 76 | 77 | ## License 78 | 79 | The MIT License (MIT) - see LICENSE.md for more details 80 | 81 | 82 | -------------------------------------------------------------------------------- /vendor/gopkg.in/fsnotify.v1/inotify_poller.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 | 7 | package fsnotify 8 | 9 | import ( 10 | "errors" 11 | 12 | "golang.org/x/sys/unix" 13 | ) 14 | 15 | type fdPoller struct { 16 | fd int // File descriptor (as returned by the inotify_init() syscall) 17 | epfd int // Epoll file descriptor 18 | pipe [2]int // Pipe for waking up 19 | } 20 | 21 | func emptyPoller(fd int) *fdPoller { 22 | poller := new(fdPoller) 23 | poller.fd = fd 24 | poller.epfd = -1 25 | poller.pipe[0] = -1 26 | poller.pipe[1] = -1 27 | return poller 28 | } 29 | 30 | // Create a new inotify poller. 31 | // This creates an inotify handler, and an epoll handler. 32 | func newFdPoller(fd int) (*fdPoller, error) { 33 | var errno error 34 | poller := emptyPoller(fd) 35 | defer func() { 36 | if errno != nil { 37 | poller.close() 38 | } 39 | }() 40 | poller.fd = fd 41 | 42 | // Create epoll fd 43 | poller.epfd, errno = unix.EpollCreate1(0) 44 | if poller.epfd == -1 { 45 | return nil, errno 46 | } 47 | // Create pipe; pipe[0] is the read end, pipe[1] the write end. 48 | errno = unix.Pipe2(poller.pipe[:], unix.O_NONBLOCK) 49 | if errno != nil { 50 | return nil, errno 51 | } 52 | 53 | // Register inotify fd with epoll 54 | event := unix.EpollEvent{ 55 | Fd: int32(poller.fd), 56 | Events: unix.EPOLLIN, 57 | } 58 | errno = unix.EpollCtl(poller.epfd, unix.EPOLL_CTL_ADD, poller.fd, &event) 59 | if errno != nil { 60 | return nil, errno 61 | } 62 | 63 | // Register pipe fd with epoll 64 | event = unix.EpollEvent{ 65 | Fd: int32(poller.pipe[0]), 66 | Events: unix.EPOLLIN, 67 | } 68 | errno = unix.EpollCtl(poller.epfd, unix.EPOLL_CTL_ADD, poller.pipe[0], &event) 69 | if errno != nil { 70 | return nil, errno 71 | } 72 | 73 | return poller, nil 74 | } 75 | 76 | // Wait using epoll. 77 | // Returns true if something is ready to be read, 78 | // false if there is not. 79 | func (poller *fdPoller) wait() (bool, error) { 80 | // 3 possible events per fd, and 2 fds, makes a maximum of 6 events. 81 | // I don't know whether epoll_wait returns the number of events returned, 82 | // or the total number of events ready. 83 | // I decided to catch both by making the buffer one larger than the maximum. 84 | events := make([]unix.EpollEvent, 7) 85 | for { 86 | n, errno := unix.EpollWait(poller.epfd, events, -1) 87 | if n == -1 { 88 | if errno == unix.EINTR { 89 | continue 90 | } 91 | return false, errno 92 | } 93 | if n == 0 { 94 | // If there are no events, try again. 95 | continue 96 | } 97 | if n > 6 { 98 | // This should never happen. More events were returned than should be possible. 99 | return false, errors.New("epoll_wait returned more events than I know what to do with") 100 | } 101 | ready := events[:n] 102 | epollhup := false 103 | epollerr := false 104 | epollin := false 105 | for _, event := range ready { 106 | if event.Fd == int32(poller.fd) { 107 | if event.Events&unix.EPOLLHUP != 0 { 108 | // This should not happen, but if it does, treat it as a wakeup. 109 | epollhup = true 110 | } 111 | if event.Events&unix.EPOLLERR != 0 { 112 | // If an error is waiting on the file descriptor, we should pretend 113 | // something is ready to read, and let unix.Read pick up the error. 114 | epollerr = true 115 | } 116 | if event.Events&unix.EPOLLIN != 0 { 117 | // There is data to read. 118 | epollin = true 119 | } 120 | } 121 | if event.Fd == int32(poller.pipe[0]) { 122 | if event.Events&unix.EPOLLHUP != 0 { 123 | // Write pipe descriptor was closed, by us. This means we're closing down the 124 | // watcher, and we should wake up. 125 | } 126 | if event.Events&unix.EPOLLERR != 0 { 127 | // If an error is waiting on the pipe file descriptor. 128 | // This is an absolute mystery, and should never ever happen. 129 | return false, errors.New("Error on the pipe descriptor.") 130 | } 131 | if event.Events&unix.EPOLLIN != 0 { 132 | // This is a regular wakeup, so we have to clear the buffer. 133 | err := poller.clearWake() 134 | if err != nil { 135 | return false, err 136 | } 137 | } 138 | } 139 | } 140 | 141 | if epollhup || epollerr || epollin { 142 | return true, nil 143 | } 144 | return false, nil 145 | } 146 | } 147 | 148 | // Close the write end of the poller. 149 | func (poller *fdPoller) wake() error { 150 | buf := make([]byte, 1) 151 | n, errno := unix.Write(poller.pipe[1], buf) 152 | if n == -1 { 153 | if errno == unix.EAGAIN { 154 | // Buffer is full, poller will wake. 155 | return nil 156 | } 157 | return errno 158 | } 159 | return nil 160 | } 161 | 162 | func (poller *fdPoller) clearWake() error { 163 | // You have to be woken up a LOT in order to get to 100! 164 | buf := make([]byte, 100) 165 | n, errno := unix.Read(poller.pipe[0], buf) 166 | if n == -1 { 167 | if errno == unix.EAGAIN { 168 | // Buffer is empty, someone else cleared our wake. 169 | return nil 170 | } 171 | return errno 172 | } 173 | return nil 174 | } 175 | 176 | // Close all poller file descriptors, but not the one passed to it. 177 | func (poller *fdPoller) close() { 178 | if poller.pipe[1] != -1 { 179 | unix.Close(poller.pipe[1]) 180 | } 181 | if poller.pipe[0] != -1 { 182 | unix.Close(poller.pipe[0]) 183 | } 184 | if poller.epfd != -1 { 185 | unix.Close(poller.epfd) 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | 8 | package unix 9 | 10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 11 | //sys Dup2(oldfd int, newfd int) (err error) 12 | //sys Fchown(fd int, uid int, gid int) (err error) 13 | //sys Fstat(fd int, stat *Stat_t) (err error) 14 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 15 | //sys Ftruncate(fd int, length int64) (err error) 16 | //sysnb Getegid() (egid int) 17 | //sysnb Geteuid() (euid int) 18 | //sysnb Getgid() (gid int) 19 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT 20 | //sysnb Getuid() (uid int) 21 | //sysnb InotifyInit() (fd int, err error) 22 | //sys Ioperm(from int, num int, on int) (err error) 23 | //sys Iopl(level int) (err error) 24 | //sys Lchown(path string, uid int, gid int) (err error) 25 | //sys Listen(s int, n int) (err error) 26 | //sys Lstat(path string, stat *Stat_t) (err error) 27 | //sys Pause() (err error) 28 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 29 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 30 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 31 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 32 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 33 | //sys Setfsgid(gid int) (err error) 34 | //sys Setfsuid(uid int) (err error) 35 | //sysnb Setregid(rgid int, egid int) (err error) 36 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 37 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 38 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 39 | //sysnb Setreuid(ruid int, euid int) (err error) 40 | //sys Shutdown(fd int, how int) (err error) 41 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 42 | //sys Stat(path string, stat *Stat_t) (err error) 43 | //sys Statfs(path string, buf *Statfs_t) (err error) 44 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2 45 | //sys Truncate(path string, length int64) (err error) 46 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 47 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 48 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 49 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 50 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 51 | //sysnb setgroups(n int, list *_Gid_t) (err error) 52 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 53 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 54 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 55 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 56 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 57 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 58 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 59 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 60 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 61 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 62 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 63 | 64 | func Getpagesize() int { return 65536 } 65 | 66 | //sysnb Gettimeofday(tv *Timeval) (err error) 67 | //sysnb Time(t *Time_t) (tt Time_t, err error) 68 | 69 | //sys Utime(path string, buf *Utimbuf) (err error) 70 | 71 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 72 | 73 | func NsecToTimespec(nsec int64) (ts Timespec) { 74 | ts.Sec = nsec / 1e9 75 | ts.Nsec = nsec % 1e9 76 | return 77 | } 78 | 79 | func NsecToTimeval(nsec int64) (tv Timeval) { 80 | nsec += 999 // round up to microsecond 81 | tv.Sec = nsec / 1e9 82 | tv.Usec = nsec % 1e9 / 1e3 83 | return 84 | } 85 | 86 | func (r *PtraceRegs) PC() uint64 { return r.Nip } 87 | 88 | func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc } 89 | 90 | func (iov *Iovec) SetLen(length int) { 91 | iov.Len = uint64(length) 92 | } 93 | 94 | func (msghdr *Msghdr) SetControllen(length int) { 95 | msghdr.Controllen = uint64(length) 96 | } 97 | 98 | func (cmsg *Cmsghdr) SetLen(length int) { 99 | cmsg.Len = uint64(length) 100 | } 101 | 102 | //sysnb pipe(p *[2]_C_int) (err error) 103 | 104 | func Pipe(p []int) (err error) { 105 | if len(p) != 2 { 106 | return EINVAL 107 | } 108 | var pp [2]_C_int 109 | err = pipe(&pp) 110 | p[0] = int(pp[0]) 111 | p[1] = int(pp[1]) 112 | return 113 | } 114 | 115 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 116 | 117 | func Pipe2(p []int, flags int) (err error) { 118 | if len(p) != 2 { 119 | return EINVAL 120 | } 121 | var pp [2]_C_int 122 | err = pipe2(&pp, flags) 123 | p[0] = int(pp[0]) 124 | p[1] = int(pp[1]) 125 | return 126 | } 127 | 128 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 129 | 130 | func Poll(fds []PollFd, timeout int) (n int, err error) { 131 | if len(fds) == 0 { 132 | return poll(nil, 0, timeout) 133 | } 134 | return poll(&fds[0], len(fds), timeout) 135 | } 136 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | enum { 49 | sizeofPtr = sizeof(void*), 50 | }; 51 | 52 | union sockaddr_all { 53 | struct sockaddr s1; // this one gets used for fields 54 | struct sockaddr_in s2; // these pad it out 55 | struct sockaddr_in6 s3; 56 | struct sockaddr_un s4; 57 | struct sockaddr_dl s5; 58 | }; 59 | 60 | struct sockaddr_any { 61 | struct sockaddr addr; 62 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 63 | }; 64 | 65 | */ 66 | import "C" 67 | 68 | // Machine characteristics; for internal use. 69 | 70 | const ( 71 | sizeofPtr = C.sizeofPtr 72 | sizeofShort = C.sizeof_short 73 | sizeofInt = C.sizeof_int 74 | sizeofLong = C.sizeof_long 75 | sizeofLongLong = C.sizeof_longlong 76 | ) 77 | 78 | // Basic types 79 | 80 | type ( 81 | _C_short C.short 82 | _C_int C.int 83 | _C_long C.long 84 | _C_long_long C.longlong 85 | ) 86 | 87 | // Time 88 | 89 | type Timespec C.struct_timespec 90 | 91 | type Timeval C.struct_timeval 92 | 93 | // Processes 94 | 95 | type Rusage C.struct_rusage 96 | 97 | type Rlimit C.struct_rlimit 98 | 99 | type _Gid_t C.gid_t 100 | 101 | // Files 102 | 103 | type Stat_t C.struct_stat 104 | 105 | type Statfs_t C.struct_statfs 106 | 107 | type Flock_t C.struct_flock 108 | 109 | type Dirent C.struct_dirent 110 | 111 | type Fsid C.fsid_t 112 | 113 | // Sockets 114 | 115 | type RawSockaddrInet4 C.struct_sockaddr_in 116 | 117 | type RawSockaddrInet6 C.struct_sockaddr_in6 118 | 119 | type RawSockaddrUnix C.struct_sockaddr_un 120 | 121 | type RawSockaddrDatalink C.struct_sockaddr_dl 122 | 123 | type RawSockaddr C.struct_sockaddr 124 | 125 | type RawSockaddrAny C.struct_sockaddr_any 126 | 127 | type _Socklen C.socklen_t 128 | 129 | type Linger C.struct_linger 130 | 131 | type Iovec C.struct_iovec 132 | 133 | type IPMreq C.struct_ip_mreq 134 | 135 | type IPv6Mreq C.struct_ipv6_mreq 136 | 137 | type Msghdr C.struct_msghdr 138 | 139 | type Cmsghdr C.struct_cmsghdr 140 | 141 | type Inet6Pktinfo C.struct_in6_pktinfo 142 | 143 | type IPv6MTUInfo C.struct_ip6_mtuinfo 144 | 145 | type ICMPv6Filter C.struct_icmp6_filter 146 | 147 | const ( 148 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 149 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 150 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 151 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 152 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 153 | SizeofLinger = C.sizeof_struct_linger 154 | SizeofIPMreq = C.sizeof_struct_ip_mreq 155 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 156 | SizeofMsghdr = C.sizeof_struct_msghdr 157 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 158 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 159 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 160 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 161 | ) 162 | 163 | // Ptrace requests 164 | 165 | const ( 166 | PTRACE_TRACEME = C.PT_TRACE_ME 167 | PTRACE_CONT = C.PT_CONTINUE 168 | PTRACE_KILL = C.PT_KILL 169 | ) 170 | 171 | // Events (kqueue, kevent) 172 | 173 | type Kevent_t C.struct_kevent 174 | 175 | // Select 176 | 177 | type FdSet C.fd_set 178 | 179 | // Routing and interface messages 180 | 181 | const ( 182 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 183 | SizeofIfData = C.sizeof_struct_if_data 184 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 185 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 186 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 187 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 188 | ) 189 | 190 | type IfMsghdr C.struct_if_msghdr 191 | 192 | type IfData C.struct_if_data 193 | 194 | type IfaMsghdr C.struct_ifa_msghdr 195 | 196 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 197 | 198 | type RtMsghdr C.struct_rt_msghdr 199 | 200 | type RtMetrics C.struct_rt_metrics 201 | 202 | type Mclpool C.struct_mclpool 203 | 204 | // Berkeley packet filter 205 | 206 | const ( 207 | SizeofBpfVersion = C.sizeof_struct_bpf_version 208 | SizeofBpfStat = C.sizeof_struct_bpf_stat 209 | SizeofBpfProgram = C.sizeof_struct_bpf_program 210 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 211 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 212 | ) 213 | 214 | type BpfVersion C.struct_bpf_version 215 | 216 | type BpfStat C.struct_bpf_stat 217 | 218 | type BpfProgram C.struct_bpf_program 219 | 220 | type BpfInsn C.struct_bpf_insn 221 | 222 | type BpfHdr C.struct_bpf_hdr 223 | 224 | type BpfTimeval C.struct_bpf_timeval 225 | 226 | // Terminal handling 227 | 228 | type Termios C.struct_termios 229 | 230 | // Sysctl 231 | 232 | type Sysctlnode C.struct_sysctlnode 233 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //sys Dup2(oldfd int, newfd int) (err error) 12 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 13 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 14 | //sys Fchown(fd int, uid int, gid int) (err error) 15 | //sys Fstat(fd int, stat *Stat_t) (err error) 16 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 17 | //sys Ftruncate(fd int, length int64) (err error) 18 | //sysnb Getegid() (egid int) 19 | //sysnb Geteuid() (euid int) 20 | //sysnb Getgid() (gid int) 21 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 22 | //sysnb Getuid() (uid int) 23 | //sysnb InotifyInit() (fd int, err error) 24 | //sys Ioperm(from int, num int, on int) (err error) 25 | //sys Iopl(level int) (err error) 26 | //sys Lchown(path string, uid int, gid int) (err error) 27 | //sys Listen(s int, n int) (err error) 28 | //sys Lstat(path string, stat *Stat_t) (err error) 29 | //sys Pause() (err error) 30 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 31 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 32 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 33 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 34 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 35 | //sys Setfsgid(gid int) (err error) 36 | //sys Setfsuid(uid int) (err error) 37 | //sysnb Setregid(rgid int, egid int) (err error) 38 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 39 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 40 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 41 | //sysnb Setreuid(ruid int, euid int) (err error) 42 | //sys Shutdown(fd int, how int) (err error) 43 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 44 | //sys Stat(path string, stat *Stat_t) (err error) 45 | //sys Statfs(path string, buf *Statfs_t) (err error) 46 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 47 | //sys Truncate(path string, length int64) (err error) 48 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 49 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 50 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 51 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 52 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 53 | //sysnb setgroups(n int, list *_Gid_t) (err error) 54 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 55 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 56 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 57 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 58 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 59 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 60 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 61 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 62 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 63 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 64 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 65 | 66 | //go:noescape 67 | func gettimeofday(tv *Timeval) (err syscall.Errno) 68 | 69 | func Gettimeofday(tv *Timeval) (err error) { 70 | errno := gettimeofday(tv) 71 | if errno != 0 { 72 | return errno 73 | } 74 | return nil 75 | } 76 | 77 | func Getpagesize() int { return 4096 } 78 | 79 | func Time(t *Time_t) (tt Time_t, err error) { 80 | var tv Timeval 81 | errno := gettimeofday(&tv) 82 | if errno != 0 { 83 | return 0, errno 84 | } 85 | if t != nil { 86 | *t = Time_t(tv.Sec) 87 | } 88 | return Time_t(tv.Sec), nil 89 | } 90 | 91 | //sys Utime(path string, buf *Utimbuf) (err error) 92 | 93 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 94 | 95 | func NsecToTimespec(nsec int64) (ts Timespec) { 96 | ts.Sec = nsec / 1e9 97 | ts.Nsec = nsec % 1e9 98 | return 99 | } 100 | 101 | func NsecToTimeval(nsec int64) (tv Timeval) { 102 | nsec += 999 // round up to microsecond 103 | tv.Sec = nsec / 1e9 104 | tv.Usec = nsec % 1e9 / 1e3 105 | return 106 | } 107 | 108 | //sysnb pipe(p *[2]_C_int) (err error) 109 | 110 | func Pipe(p []int) (err error) { 111 | if len(p) != 2 { 112 | return EINVAL 113 | } 114 | var pp [2]_C_int 115 | err = pipe(&pp) 116 | p[0] = int(pp[0]) 117 | p[1] = int(pp[1]) 118 | return 119 | } 120 | 121 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 122 | 123 | func Pipe2(p []int, flags int) (err error) { 124 | if len(p) != 2 { 125 | return EINVAL 126 | } 127 | var pp [2]_C_int 128 | err = pipe2(&pp, flags) 129 | p[0] = int(pp[0]) 130 | p[1] = int(pp[1]) 131 | return 132 | } 133 | 134 | func (r *PtraceRegs) PC() uint64 { return r.Rip } 135 | 136 | func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc } 137 | 138 | func (iov *Iovec) SetLen(length int) { 139 | iov.Len = uint64(length) 140 | } 141 | 142 | func (msghdr *Msghdr) SetControllen(length int) { 143 | msghdr.Controllen = uint64(length) 144 | } 145 | 146 | func (cmsg *Cmsghdr) SetLen(length int) { 147 | cmsg.Len = uint64(length) 148 | } 149 | 150 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 151 | 152 | func Poll(fds []PollFd, timeout int) (n int, err error) { 153 | if len(fds) == 0 { 154 | return poll(nil, 0, timeout) 155 | } 156 | return poll(&fds[0], len(fds), timeout) 157 | } 158 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | enum { 47 | sizeofPtr = sizeof(void*), 48 | }; 49 | 50 | union sockaddr_all { 51 | struct sockaddr s1; // this one gets used for fields 52 | struct sockaddr_in s2; // these pad it out 53 | struct sockaddr_in6 s3; 54 | struct sockaddr_un s4; 55 | struct sockaddr_dl s5; 56 | }; 57 | 58 | struct sockaddr_any { 59 | struct sockaddr addr; 60 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 61 | }; 62 | 63 | */ 64 | import "C" 65 | 66 | // Machine characteristics; for internal use. 67 | 68 | const ( 69 | sizeofPtr = C.sizeofPtr 70 | sizeofShort = C.sizeof_short 71 | sizeofInt = C.sizeof_int 72 | sizeofLong = C.sizeof_long 73 | sizeofLongLong = C.sizeof_longlong 74 | ) 75 | 76 | // Basic types 77 | 78 | type ( 79 | _C_short C.short 80 | _C_int C.int 81 | _C_long C.long 82 | _C_long_long C.longlong 83 | ) 84 | 85 | // Time 86 | 87 | type Timespec C.struct_timespec 88 | 89 | type Timeval C.struct_timeval 90 | 91 | // Processes 92 | 93 | type Rusage C.struct_rusage 94 | 95 | type Rlimit C.struct_rlimit 96 | 97 | type _Gid_t C.gid_t 98 | 99 | // Files 100 | 101 | const ( // Directory mode bits 102 | S_IFMT = C.S_IFMT 103 | S_IFIFO = C.S_IFIFO 104 | S_IFCHR = C.S_IFCHR 105 | S_IFDIR = C.S_IFDIR 106 | S_IFBLK = C.S_IFBLK 107 | S_IFREG = C.S_IFREG 108 | S_IFLNK = C.S_IFLNK 109 | S_IFSOCK = C.S_IFSOCK 110 | S_ISUID = C.S_ISUID 111 | S_ISGID = C.S_ISGID 112 | S_ISVTX = C.S_ISVTX 113 | S_IRUSR = C.S_IRUSR 114 | S_IWUSR = C.S_IWUSR 115 | S_IXUSR = C.S_IXUSR 116 | ) 117 | 118 | type Stat_t C.struct_stat 119 | 120 | type Statfs_t C.struct_statfs 121 | 122 | type Flock_t C.struct_flock 123 | 124 | type Dirent C.struct_dirent 125 | 126 | type Fsid C.struct_fsid 127 | 128 | // Sockets 129 | 130 | type RawSockaddrInet4 C.struct_sockaddr_in 131 | 132 | type RawSockaddrInet6 C.struct_sockaddr_in6 133 | 134 | type RawSockaddrUnix C.struct_sockaddr_un 135 | 136 | type RawSockaddrDatalink C.struct_sockaddr_dl 137 | 138 | type RawSockaddr C.struct_sockaddr 139 | 140 | type RawSockaddrAny C.struct_sockaddr_any 141 | 142 | type _Socklen C.socklen_t 143 | 144 | type Linger C.struct_linger 145 | 146 | type Iovec C.struct_iovec 147 | 148 | type IPMreq C.struct_ip_mreq 149 | 150 | type IPv6Mreq C.struct_ipv6_mreq 151 | 152 | type Msghdr C.struct_msghdr 153 | 154 | type Cmsghdr C.struct_cmsghdr 155 | 156 | type Inet6Pktinfo C.struct_in6_pktinfo 157 | 158 | type IPv6MTUInfo C.struct_ip6_mtuinfo 159 | 160 | type ICMPv6Filter C.struct_icmp6_filter 161 | 162 | const ( 163 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 164 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 165 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 166 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 167 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 168 | SizeofLinger = C.sizeof_struct_linger 169 | SizeofIPMreq = C.sizeof_struct_ip_mreq 170 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 171 | SizeofMsghdr = C.sizeof_struct_msghdr 172 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 173 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 174 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 175 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 176 | ) 177 | 178 | // Ptrace requests 179 | 180 | const ( 181 | PTRACE_TRACEME = C.PT_TRACE_ME 182 | PTRACE_CONT = C.PT_CONTINUE 183 | PTRACE_KILL = C.PT_KILL 184 | ) 185 | 186 | // Events (kqueue, kevent) 187 | 188 | type Kevent_t C.struct_kevent 189 | 190 | // Select 191 | 192 | type FdSet C.fd_set 193 | 194 | // Routing and interface messages 195 | 196 | const ( 197 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 198 | SizeofIfData = C.sizeof_struct_if_data 199 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 200 | SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr 201 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 202 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 203 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 204 | ) 205 | 206 | type IfMsghdr C.struct_if_msghdr 207 | 208 | type IfData C.struct_if_data 209 | 210 | type IfaMsghdr C.struct_ifa_msghdr 211 | 212 | type IfmaMsghdr C.struct_ifma_msghdr 213 | 214 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 215 | 216 | type RtMsghdr C.struct_rt_msghdr 217 | 218 | type RtMetrics C.struct_rt_metrics 219 | 220 | // Berkeley packet filter 221 | 222 | const ( 223 | SizeofBpfVersion = C.sizeof_struct_bpf_version 224 | SizeofBpfStat = C.sizeof_struct_bpf_stat 225 | SizeofBpfProgram = C.sizeof_struct_bpf_program 226 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 227 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 228 | ) 229 | 230 | type BpfVersion C.struct_bpf_version 231 | 232 | type BpfStat C.struct_bpf_stat 233 | 234 | type BpfProgram C.struct_bpf_program 235 | 236 | type BpfInsn C.struct_bpf_insn 237 | 238 | type BpfHdr C.struct_bpf_hdr 239 | 240 | // Terminal handling 241 | 242 | type Termios C.struct_termios 243 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | enum { 48 | sizeofPtr = sizeof(void*), 49 | }; 50 | 51 | union sockaddr_all { 52 | struct sockaddr s1; // this one gets used for fields 53 | struct sockaddr_in s2; // these pad it out 54 | struct sockaddr_in6 s3; 55 | struct sockaddr_un s4; 56 | struct sockaddr_dl s5; 57 | }; 58 | 59 | struct sockaddr_any { 60 | struct sockaddr addr; 61 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 62 | }; 63 | 64 | */ 65 | import "C" 66 | 67 | // Machine characteristics; for internal use. 68 | 69 | const ( 70 | sizeofPtr = C.sizeofPtr 71 | sizeofShort = C.sizeof_short 72 | sizeofInt = C.sizeof_int 73 | sizeofLong = C.sizeof_long 74 | sizeofLongLong = C.sizeof_longlong 75 | ) 76 | 77 | // Basic types 78 | 79 | type ( 80 | _C_short C.short 81 | _C_int C.int 82 | _C_long C.long 83 | _C_long_long C.longlong 84 | ) 85 | 86 | // Time 87 | 88 | type Timespec C.struct_timespec 89 | 90 | type Timeval C.struct_timeval 91 | 92 | // Processes 93 | 94 | type Rusage C.struct_rusage 95 | 96 | type Rlimit C.struct_rlimit 97 | 98 | type _Gid_t C.gid_t 99 | 100 | // Files 101 | 102 | const ( // Directory mode bits 103 | S_IFMT = C.S_IFMT 104 | S_IFIFO = C.S_IFIFO 105 | S_IFCHR = C.S_IFCHR 106 | S_IFDIR = C.S_IFDIR 107 | S_IFBLK = C.S_IFBLK 108 | S_IFREG = C.S_IFREG 109 | S_IFLNK = C.S_IFLNK 110 | S_IFSOCK = C.S_IFSOCK 111 | S_ISUID = C.S_ISUID 112 | S_ISGID = C.S_ISGID 113 | S_ISVTX = C.S_ISVTX 114 | S_IRUSR = C.S_IRUSR 115 | S_IWUSR = C.S_IWUSR 116 | S_IXUSR = C.S_IXUSR 117 | ) 118 | 119 | type Stat_t C.struct_stat 120 | 121 | type Statfs_t C.struct_statfs 122 | 123 | type Flock_t C.struct_flock 124 | 125 | type Dirent C.struct_dirent 126 | 127 | type Fsid C.fsid_t 128 | 129 | // Sockets 130 | 131 | type RawSockaddrInet4 C.struct_sockaddr_in 132 | 133 | type RawSockaddrInet6 C.struct_sockaddr_in6 134 | 135 | type RawSockaddrUnix C.struct_sockaddr_un 136 | 137 | type RawSockaddrDatalink C.struct_sockaddr_dl 138 | 139 | type RawSockaddr C.struct_sockaddr 140 | 141 | type RawSockaddrAny C.struct_sockaddr_any 142 | 143 | type _Socklen C.socklen_t 144 | 145 | type Linger C.struct_linger 146 | 147 | type Iovec C.struct_iovec 148 | 149 | type IPMreq C.struct_ip_mreq 150 | 151 | type IPv6Mreq C.struct_ipv6_mreq 152 | 153 | type Msghdr C.struct_msghdr 154 | 155 | type Cmsghdr C.struct_cmsghdr 156 | 157 | type Inet6Pktinfo C.struct_in6_pktinfo 158 | 159 | type IPv6MTUInfo C.struct_ip6_mtuinfo 160 | 161 | type ICMPv6Filter C.struct_icmp6_filter 162 | 163 | const ( 164 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 165 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 166 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 167 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 168 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 169 | SizeofLinger = C.sizeof_struct_linger 170 | SizeofIPMreq = C.sizeof_struct_ip_mreq 171 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 172 | SizeofMsghdr = C.sizeof_struct_msghdr 173 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 174 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 175 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 176 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 177 | ) 178 | 179 | // Ptrace requests 180 | 181 | const ( 182 | PTRACE_TRACEME = C.PT_TRACE_ME 183 | PTRACE_CONT = C.PT_CONTINUE 184 | PTRACE_KILL = C.PT_KILL 185 | ) 186 | 187 | // Events (kqueue, kevent) 188 | 189 | type Kevent_t C.struct_kevent 190 | 191 | // Select 192 | 193 | type FdSet C.fd_set 194 | 195 | // Routing and interface messages 196 | 197 | const ( 198 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 199 | SizeofIfData = C.sizeof_struct_if_data 200 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 201 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 202 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 203 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 204 | ) 205 | 206 | type IfMsghdr C.struct_if_msghdr 207 | 208 | type IfData C.struct_if_data 209 | 210 | type IfaMsghdr C.struct_ifa_msghdr 211 | 212 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 213 | 214 | type RtMsghdr C.struct_rt_msghdr 215 | 216 | type RtMetrics C.struct_rt_metrics 217 | 218 | type Mclpool C.struct_mclpool 219 | 220 | // Berkeley packet filter 221 | 222 | const ( 223 | SizeofBpfVersion = C.sizeof_struct_bpf_version 224 | SizeofBpfStat = C.sizeof_struct_bpf_stat 225 | SizeofBpfProgram = C.sizeof_struct_bpf_program 226 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 227 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 228 | ) 229 | 230 | type BpfVersion C.struct_bpf_version 231 | 232 | type BpfStat C.struct_bpf_stat 233 | 234 | type BpfProgram C.struct_bpf_program 235 | 236 | type BpfInsn C.struct_bpf_insn 237 | 238 | type BpfHdr C.struct_bpf_hdr 239 | 240 | type BpfTimeval C.struct_bpf_timeval 241 | 242 | // Terminal handling 243 | 244 | type Termios C.struct_termios 245 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define __DARWIN_UNIX03 0 18 | #define KERNEL 19 | #define _DARWIN_USE_64_BIT_INODE 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | enum { 52 | sizeofPtr = sizeof(void*), 53 | }; 54 | 55 | union sockaddr_all { 56 | struct sockaddr s1; // this one gets used for fields 57 | struct sockaddr_in s2; // these pad it out 58 | struct sockaddr_in6 s3; 59 | struct sockaddr_un s4; 60 | struct sockaddr_dl s5; 61 | }; 62 | 63 | struct sockaddr_any { 64 | struct sockaddr addr; 65 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 66 | }; 67 | 68 | */ 69 | import "C" 70 | 71 | // Machine characteristics; for internal use. 72 | 73 | const ( 74 | sizeofPtr = C.sizeofPtr 75 | sizeofShort = C.sizeof_short 76 | sizeofInt = C.sizeof_int 77 | sizeofLong = C.sizeof_long 78 | sizeofLongLong = C.sizeof_longlong 79 | ) 80 | 81 | // Basic types 82 | 83 | type ( 84 | _C_short C.short 85 | _C_int C.int 86 | _C_long C.long 87 | _C_long_long C.longlong 88 | ) 89 | 90 | // Time 91 | 92 | type Timespec C.struct_timespec 93 | 94 | type Timeval C.struct_timeval 95 | 96 | type Timeval32 C.struct_timeval32 97 | 98 | // Processes 99 | 100 | type Rusage C.struct_rusage 101 | 102 | type Rlimit C.struct_rlimit 103 | 104 | type _Gid_t C.gid_t 105 | 106 | // Files 107 | 108 | type Stat_t C.struct_stat64 109 | 110 | type Statfs_t C.struct_statfs64 111 | 112 | type Flock_t C.struct_flock 113 | 114 | type Fstore_t C.struct_fstore 115 | 116 | type Radvisory_t C.struct_radvisory 117 | 118 | type Fbootstraptransfer_t C.struct_fbootstraptransfer 119 | 120 | type Log2phys_t C.struct_log2phys 121 | 122 | type Fsid C.struct_fsid 123 | 124 | type Dirent C.struct_dirent 125 | 126 | // Sockets 127 | 128 | type RawSockaddrInet4 C.struct_sockaddr_in 129 | 130 | type RawSockaddrInet6 C.struct_sockaddr_in6 131 | 132 | type RawSockaddrUnix C.struct_sockaddr_un 133 | 134 | type RawSockaddrDatalink C.struct_sockaddr_dl 135 | 136 | type RawSockaddr C.struct_sockaddr 137 | 138 | type RawSockaddrAny C.struct_sockaddr_any 139 | 140 | type _Socklen C.socklen_t 141 | 142 | type Linger C.struct_linger 143 | 144 | type Iovec C.struct_iovec 145 | 146 | type IPMreq C.struct_ip_mreq 147 | 148 | type IPv6Mreq C.struct_ipv6_mreq 149 | 150 | type Msghdr C.struct_msghdr 151 | 152 | type Cmsghdr C.struct_cmsghdr 153 | 154 | type Inet4Pktinfo C.struct_in_pktinfo 155 | 156 | type Inet6Pktinfo C.struct_in6_pktinfo 157 | 158 | type IPv6MTUInfo C.struct_ip6_mtuinfo 159 | 160 | type ICMPv6Filter C.struct_icmp6_filter 161 | 162 | const ( 163 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 164 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 165 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 166 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 167 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 168 | SizeofLinger = C.sizeof_struct_linger 169 | SizeofIPMreq = C.sizeof_struct_ip_mreq 170 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 171 | SizeofMsghdr = C.sizeof_struct_msghdr 172 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 173 | SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo 174 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 175 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 176 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 177 | ) 178 | 179 | // Ptrace requests 180 | 181 | const ( 182 | PTRACE_TRACEME = C.PT_TRACE_ME 183 | PTRACE_CONT = C.PT_CONTINUE 184 | PTRACE_KILL = C.PT_KILL 185 | ) 186 | 187 | // Events (kqueue, kevent) 188 | 189 | type Kevent_t C.struct_kevent 190 | 191 | // Select 192 | 193 | type FdSet C.fd_set 194 | 195 | // Routing and interface messages 196 | 197 | const ( 198 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 199 | SizeofIfData = C.sizeof_struct_if_data 200 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 201 | SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr 202 | SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2 203 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 204 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 205 | ) 206 | 207 | type IfMsghdr C.struct_if_msghdr 208 | 209 | type IfData C.struct_if_data 210 | 211 | type IfaMsghdr C.struct_ifa_msghdr 212 | 213 | type IfmaMsghdr C.struct_ifma_msghdr 214 | 215 | type IfmaMsghdr2 C.struct_ifma_msghdr2 216 | 217 | type RtMsghdr C.struct_rt_msghdr 218 | 219 | type RtMetrics C.struct_rt_metrics 220 | 221 | // Berkeley packet filter 222 | 223 | const ( 224 | SizeofBpfVersion = C.sizeof_struct_bpf_version 225 | SizeofBpfStat = C.sizeof_struct_bpf_stat 226 | SizeofBpfProgram = C.sizeof_struct_bpf_program 227 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 228 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 229 | ) 230 | 231 | type BpfVersion C.struct_bpf_version 232 | 233 | type BpfStat C.struct_bpf_stat 234 | 235 | type BpfProgram C.struct_bpf_program 236 | 237 | type BpfInsn C.struct_bpf_insn 238 | 239 | type BpfHdr C.struct_bpf_hdr 240 | 241 | // Terminal handling 242 | 243 | type Termios C.struct_termios 244 | 245 | // fchmodat-like syscalls. 246 | 247 | const ( 248 | AT_FDCWD = C.AT_FDCWD 249 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 250 | ) 251 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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 also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | // 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 | 56 | enum { 57 | sizeofPtr = sizeof(void*), 58 | }; 59 | 60 | union sockaddr_all { 61 | struct sockaddr s1; // this one gets used for fields 62 | struct sockaddr_in s2; // these pad it out 63 | struct sockaddr_in6 s3; 64 | struct sockaddr_un s4; 65 | struct sockaddr_dl s5; 66 | }; 67 | 68 | struct sockaddr_any { 69 | struct sockaddr addr; 70 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 71 | }; 72 | 73 | */ 74 | import "C" 75 | 76 | // Machine characteristics; for internal use. 77 | 78 | const ( 79 | sizeofPtr = C.sizeofPtr 80 | sizeofShort = C.sizeof_short 81 | sizeofInt = C.sizeof_int 82 | sizeofLong = C.sizeof_long 83 | sizeofLongLong = C.sizeof_longlong 84 | PathMax = C.PATH_MAX 85 | MaxHostNameLen = C.MAXHOSTNAMELEN 86 | ) 87 | 88 | // Basic types 89 | 90 | type ( 91 | _C_short C.short 92 | _C_int C.int 93 | _C_long C.long 94 | _C_long_long C.longlong 95 | ) 96 | 97 | // Time 98 | 99 | type Timespec C.struct_timespec 100 | 101 | type Timeval C.struct_timeval 102 | 103 | type Timeval32 C.struct_timeval32 104 | 105 | type Tms C.struct_tms 106 | 107 | type Utimbuf C.struct_utimbuf 108 | 109 | // Processes 110 | 111 | type Rusage C.struct_rusage 112 | 113 | type Rlimit C.struct_rlimit 114 | 115 | type _Gid_t C.gid_t 116 | 117 | // Files 118 | 119 | const ( // Directory mode bits 120 | S_IFMT = C.S_IFMT 121 | S_IFIFO = C.S_IFIFO 122 | S_IFCHR = C.S_IFCHR 123 | S_IFDIR = C.S_IFDIR 124 | S_IFBLK = C.S_IFBLK 125 | S_IFREG = C.S_IFREG 126 | S_IFLNK = C.S_IFLNK 127 | S_IFSOCK = C.S_IFSOCK 128 | S_ISUID = C.S_ISUID 129 | S_ISGID = C.S_ISGID 130 | S_ISVTX = C.S_ISVTX 131 | S_IRUSR = C.S_IRUSR 132 | S_IWUSR = C.S_IWUSR 133 | S_IXUSR = C.S_IXUSR 134 | ) 135 | 136 | type Stat_t C.struct_stat 137 | 138 | type Flock_t C.struct_flock 139 | 140 | type Dirent C.struct_dirent 141 | 142 | // Sockets 143 | 144 | type RawSockaddrInet4 C.struct_sockaddr_in 145 | 146 | type RawSockaddrInet6 C.struct_sockaddr_in6 147 | 148 | type RawSockaddrUnix C.struct_sockaddr_un 149 | 150 | type RawSockaddrDatalink C.struct_sockaddr_dl 151 | 152 | type RawSockaddr C.struct_sockaddr 153 | 154 | type RawSockaddrAny C.struct_sockaddr_any 155 | 156 | type _Socklen C.socklen_t 157 | 158 | type Linger C.struct_linger 159 | 160 | type Iovec C.struct_iovec 161 | 162 | type IPMreq C.struct_ip_mreq 163 | 164 | type IPv6Mreq C.struct_ipv6_mreq 165 | 166 | type Msghdr C.struct_msghdr 167 | 168 | type Cmsghdr C.struct_cmsghdr 169 | 170 | type Inet6Pktinfo C.struct_in6_pktinfo 171 | 172 | type IPv6MTUInfo C.struct_ip6_mtuinfo 173 | 174 | type ICMPv6Filter C.struct_icmp6_filter 175 | 176 | const ( 177 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 178 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 179 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 180 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 181 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 182 | SizeofLinger = C.sizeof_struct_linger 183 | SizeofIPMreq = C.sizeof_struct_ip_mreq 184 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 185 | SizeofMsghdr = C.sizeof_struct_msghdr 186 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 187 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 188 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 189 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 190 | ) 191 | 192 | // Select 193 | 194 | type FdSet C.fd_set 195 | 196 | // Misc 197 | 198 | type Utsname C.struct_utsname 199 | 200 | type Ustat_t C.struct_ustat 201 | 202 | const ( 203 | AT_FDCWD = C.AT_FDCWD 204 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 205 | AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW 206 | AT_REMOVEDIR = C.AT_REMOVEDIR 207 | AT_EACCESS = C.AT_EACCESS 208 | ) 209 | 210 | // Routing and interface messages 211 | 212 | const ( 213 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 214 | SizeofIfData = C.sizeof_struct_if_data 215 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 216 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 217 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 218 | ) 219 | 220 | type IfMsghdr C.struct_if_msghdr 221 | 222 | type IfData C.struct_if_data 223 | 224 | type IfaMsghdr C.struct_ifa_msghdr 225 | 226 | type RtMsghdr C.struct_rt_msghdr 227 | 228 | type RtMetrics C.struct_rt_metrics 229 | 230 | // Berkeley packet filter 231 | 232 | const ( 233 | SizeofBpfVersion = C.sizeof_struct_bpf_version 234 | SizeofBpfStat = C.sizeof_struct_bpf_stat 235 | SizeofBpfProgram = C.sizeof_struct_bpf_program 236 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 237 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 238 | ) 239 | 240 | type BpfVersion C.struct_bpf_version 241 | 242 | type BpfStat C.struct_bpf_stat 243 | 244 | type BpfProgram C.struct_bpf_program 245 | 246 | type BpfInsn C.struct_bpf_insn 247 | 248 | type BpfTimeval C.struct_bpf_timeval 249 | 250 | type BpfHdr C.struct_bpf_hdr 251 | 252 | // sysconf information 253 | 254 | const _SC_PAGESIZE = C._SC_PAGESIZE 255 | 256 | // Terminal handling 257 | 258 | type Termios C.struct_termios 259 | 260 | type Termio C.struct_termio 261 | 262 | type Winsize C.struct_winsize 263 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,linux 6 | 7 | package unix 8 | 9 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT 10 | //sys Fchown(fd int, uid int, gid int) (err error) 11 | //sys Fstat(fd int, stat *Stat_t) (err error) 12 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 13 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 14 | //sys Ftruncate(fd int, length int64) (err error) 15 | //sysnb Getegid() (egid int) 16 | //sysnb Geteuid() (euid int) 17 | //sysnb Getgid() (gid int) 18 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 19 | //sysnb Getuid() (uid int) 20 | //sys Listen(s int, n int) (err error) 21 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 22 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 23 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 24 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6 25 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 26 | //sys Setfsgid(gid int) (err error) 27 | //sys Setfsuid(uid int) (err error) 28 | //sysnb Setregid(rgid int, egid int) (err error) 29 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 30 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 31 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 32 | //sysnb Setreuid(ruid int, euid int) (err error) 33 | //sys Shutdown(fd int, how int) (err error) 34 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 35 | 36 | func Stat(path string, stat *Stat_t) (err error) { 37 | return Fstatat(AT_FDCWD, path, stat, 0) 38 | } 39 | 40 | func Lchown(path string, uid int, gid int) (err error) { 41 | return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW) 42 | } 43 | 44 | func Lstat(path string, stat *Stat_t) (err error) { 45 | return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW) 46 | } 47 | 48 | //sys Statfs(path string, buf *Statfs_t) (err error) 49 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 50 | //sys Truncate(path string, length int64) (err error) 51 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 52 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 53 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 54 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 55 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 56 | //sysnb setgroups(n int, list *_Gid_t) (err error) 57 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 58 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 59 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 60 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 61 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 62 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 63 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 64 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 65 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 66 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 67 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 68 | 69 | func Getpagesize() int { return 65536 } 70 | 71 | //sysnb Gettimeofday(tv *Timeval) (err error) 72 | 73 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 74 | 75 | func NsecToTimespec(nsec int64) (ts Timespec) { 76 | ts.Sec = nsec / 1e9 77 | ts.Nsec = nsec % 1e9 78 | return 79 | } 80 | 81 | func NsecToTimeval(nsec int64) (tv Timeval) { 82 | nsec += 999 // round up to microsecond 83 | tv.Sec = nsec / 1e9 84 | tv.Usec = nsec % 1e9 / 1e3 85 | return 86 | } 87 | 88 | func Time(t *Time_t) (Time_t, error) { 89 | var tv Timeval 90 | err := Gettimeofday(&tv) 91 | if err != nil { 92 | return 0, err 93 | } 94 | if t != nil { 95 | *t = Time_t(tv.Sec) 96 | } 97 | return Time_t(tv.Sec), nil 98 | } 99 | 100 | func Utime(path string, buf *Utimbuf) error { 101 | tv := []Timeval{ 102 | {Sec: buf.Actime}, 103 | {Sec: buf.Modtime}, 104 | } 105 | return Utimes(path, tv) 106 | } 107 | 108 | func Pipe(p []int) (err error) { 109 | if len(p) != 2 { 110 | return EINVAL 111 | } 112 | var pp [2]_C_int 113 | err = pipe2(&pp, 0) 114 | p[0] = int(pp[0]) 115 | p[1] = int(pp[1]) 116 | return 117 | } 118 | 119 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 120 | 121 | func Pipe2(p []int, flags int) (err error) { 122 | if len(p) != 2 { 123 | return EINVAL 124 | } 125 | var pp [2]_C_int 126 | err = pipe2(&pp, flags) 127 | p[0] = int(pp[0]) 128 | p[1] = int(pp[1]) 129 | return 130 | } 131 | 132 | func (r *PtraceRegs) PC() uint64 { return r.Pc } 133 | 134 | func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc } 135 | 136 | func (iov *Iovec) SetLen(length int) { 137 | iov.Len = uint64(length) 138 | } 139 | 140 | func (msghdr *Msghdr) SetControllen(length int) { 141 | msghdr.Controllen = uint64(length) 142 | } 143 | 144 | func (cmsg *Cmsghdr) SetLen(length int) { 145 | cmsg.Len = uint64(length) 146 | } 147 | 148 | func InotifyInit() (fd int, err error) { 149 | return InotifyInit1(0) 150 | } 151 | 152 | func Dup2(oldfd int, newfd int) (err error) { 153 | return Dup3(oldfd, newfd, 0) 154 | } 155 | 156 | func Pause() (err error) { 157 | _, _, e1 := Syscall6(SYS_PPOLL, 0, 0, 0, 0, 0, 0) 158 | if e1 != 0 { 159 | err = errnoErr(e1) 160 | } 161 | return 162 | } 163 | 164 | // TODO(dfc): constants that should be in zsysnum_linux_arm64.go, remove 165 | // these when the deprecated syscalls that the syscall package relies on 166 | // are removed. 167 | const ( 168 | SYS_GETPGRP = 1060 169 | SYS_UTIMES = 1037 170 | SYS_FUTIMESAT = 1066 171 | SYS_PAUSE = 1061 172 | SYS_USTAT = 1070 173 | SYS_UTIME = 1063 174 | SYS_LCHOWN = 1032 175 | SYS_TIME = 1062 176 | SYS_EPOLL_CREATE = 1042 177 | SYS_EPOLL_WAIT = 1069 178 | ) 179 | 180 | func Poll(fds []PollFd, timeout int) (n int, err error) { 181 | var ts *Timespec 182 | if timeout >= 0 { 183 | ts = new(Timespec) 184 | *ts = NsecToTimespec(int64(timeout) * 1e6) 185 | } 186 | if len(fds) == 0 { 187 | return ppoll(nil, 0, ts, nil) 188 | } 189 | return ppoll(&fds[0], len(fds), ts, nil) 190 | } 191 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | 8 | package unix 9 | 10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 11 | //sys Fchown(fd int, uid int, gid int) (err error) 12 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 13 | //sys Ftruncate(fd int, length int64) (err error) 14 | //sysnb Getegid() (egid int) 15 | //sysnb Geteuid() (euid int) 16 | //sysnb Getgid() (gid int) 17 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 18 | //sysnb Getuid() (uid int) 19 | //sys Lchown(path string, uid int, gid int) (err error) 20 | //sys Listen(s int, n int) (err error) 21 | //sys Pause() (err error) 22 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 23 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 24 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 25 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6 26 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 27 | //sys Setfsgid(gid int) (err error) 28 | //sys Setfsuid(uid int) (err error) 29 | //sysnb Setregid(rgid int, egid int) (err error) 30 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 31 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 32 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 33 | //sysnb Setreuid(ruid int, euid int) (err error) 34 | //sys Shutdown(fd int, how int) (err error) 35 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 36 | //sys Statfs(path string, buf *Statfs_t) (err error) 37 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 38 | //sys Truncate(path string, length int64) (err error) 39 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 40 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 41 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 42 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 43 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 44 | //sysnb setgroups(n int, list *_Gid_t) (err error) 45 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 46 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 47 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 48 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 49 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 50 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 51 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 52 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 53 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 54 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 55 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 56 | 57 | func Getpagesize() int { return 65536 } 58 | 59 | //sysnb Gettimeofday(tv *Timeval) (err error) 60 | 61 | func Time(t *Time_t) (tt Time_t, err error) { 62 | var tv Timeval 63 | err = Gettimeofday(&tv) 64 | if err != nil { 65 | return 0, err 66 | } 67 | if t != nil { 68 | *t = Time_t(tv.Sec) 69 | } 70 | return Time_t(tv.Sec), nil 71 | } 72 | 73 | //sys Utime(path string, buf *Utimbuf) (err error) 74 | 75 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 76 | 77 | func NsecToTimespec(nsec int64) (ts Timespec) { 78 | ts.Sec = nsec / 1e9 79 | ts.Nsec = nsec % 1e9 80 | return 81 | } 82 | 83 | func NsecToTimeval(nsec int64) (tv Timeval) { 84 | nsec += 999 // round up to microsecond 85 | tv.Sec = nsec / 1e9 86 | tv.Usec = nsec % 1e9 / 1e3 87 | return 88 | } 89 | 90 | func Pipe(p []int) (err error) { 91 | if len(p) != 2 { 92 | return EINVAL 93 | } 94 | var pp [2]_C_int 95 | err = pipe2(&pp, 0) 96 | p[0] = int(pp[0]) 97 | p[1] = int(pp[1]) 98 | return 99 | } 100 | 101 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 102 | 103 | func Pipe2(p []int, flags int) (err error) { 104 | if len(p) != 2 { 105 | return EINVAL 106 | } 107 | var pp [2]_C_int 108 | err = pipe2(&pp, flags) 109 | p[0] = int(pp[0]) 110 | p[1] = int(pp[1]) 111 | return 112 | } 113 | 114 | func Ioperm(from int, num int, on int) (err error) { 115 | return ENOSYS 116 | } 117 | 118 | func Iopl(level int) (err error) { 119 | return ENOSYS 120 | } 121 | 122 | type stat_t struct { 123 | Dev uint32 124 | Pad0 [3]int32 125 | Ino uint64 126 | Mode uint32 127 | Nlink uint32 128 | Uid uint32 129 | Gid uint32 130 | Rdev uint32 131 | Pad1 [3]uint32 132 | Size int64 133 | Atime uint32 134 | Atime_nsec uint32 135 | Mtime uint32 136 | Mtime_nsec uint32 137 | Ctime uint32 138 | Ctime_nsec uint32 139 | Blksize uint32 140 | Pad2 uint32 141 | Blocks int64 142 | } 143 | 144 | //sys fstat(fd int, st *stat_t) (err error) 145 | //sys lstat(path string, st *stat_t) (err error) 146 | //sys stat(path string, st *stat_t) (err error) 147 | 148 | func Fstat(fd int, s *Stat_t) (err error) { 149 | st := &stat_t{} 150 | err = fstat(fd, st) 151 | fillStat_t(s, st) 152 | return 153 | } 154 | 155 | func Lstat(path string, s *Stat_t) (err error) { 156 | st := &stat_t{} 157 | err = lstat(path, st) 158 | fillStat_t(s, st) 159 | return 160 | } 161 | 162 | func Stat(path string, s *Stat_t) (err error) { 163 | st := &stat_t{} 164 | err = stat(path, st) 165 | fillStat_t(s, st) 166 | return 167 | } 168 | 169 | func fillStat_t(s *Stat_t, st *stat_t) { 170 | s.Dev = st.Dev 171 | s.Ino = st.Ino 172 | s.Mode = st.Mode 173 | s.Nlink = st.Nlink 174 | s.Uid = st.Uid 175 | s.Gid = st.Gid 176 | s.Rdev = st.Rdev 177 | s.Size = st.Size 178 | s.Atim = Timespec{int64(st.Atime), int64(st.Atime_nsec)} 179 | s.Mtim = Timespec{int64(st.Mtime), int64(st.Mtime_nsec)} 180 | s.Ctim = Timespec{int64(st.Ctime), int64(st.Ctime_nsec)} 181 | s.Blksize = st.Blksize 182 | s.Blocks = st.Blocks 183 | } 184 | 185 | func (r *PtraceRegs) PC() uint64 { return r.Regs[64] } 186 | 187 | func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = pc } 188 | 189 | func (iov *Iovec) SetLen(length int) { 190 | iov.Len = uint64(length) 191 | } 192 | 193 | func (msghdr *Msghdr) SetControllen(length int) { 194 | msghdr.Controllen = uint64(length) 195 | } 196 | 197 | func (cmsg *Cmsghdr) SetLen(length int) { 198 | cmsg.Len = uint64(length) 199 | } 200 | 201 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 202 | 203 | func Poll(fds []PollFd, timeout int) (n int, err error) { 204 | if len(fds) == 0 { 205 | return poll(nil, 0, timeout) 206 | } 207 | return poll(&fds[0], len(fds), timeout) 208 | } 209 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_netbsd.go 3 | 4 | // +build 386,netbsd 5 | 6 | package unix 7 | 8 | const ( 9 | sizeofPtr = 0x4 10 | sizeofShort = 0x2 11 | sizeofInt = 0x4 12 | sizeofLong = 0x4 13 | sizeofLongLong = 0x8 14 | ) 15 | 16 | type ( 17 | _C_short int16 18 | _C_int int32 19 | _C_long int32 20 | _C_long_long int64 21 | ) 22 | 23 | type Timespec struct { 24 | Sec int64 25 | Nsec int32 26 | } 27 | 28 | type Timeval struct { 29 | Sec int64 30 | Usec int32 31 | } 32 | 33 | type Rusage struct { 34 | Utime Timeval 35 | Stime Timeval 36 | Maxrss int32 37 | Ixrss int32 38 | Idrss int32 39 | Isrss int32 40 | Minflt int32 41 | Majflt int32 42 | Nswap int32 43 | Inblock int32 44 | Oublock int32 45 | Msgsnd int32 46 | Msgrcv int32 47 | Nsignals int32 48 | Nvcsw int32 49 | Nivcsw int32 50 | } 51 | 52 | type Rlimit struct { 53 | Cur uint64 54 | Max uint64 55 | } 56 | 57 | type _Gid_t uint32 58 | 59 | type Stat_t struct { 60 | Dev uint64 61 | Mode uint32 62 | Ino uint64 63 | Nlink uint32 64 | Uid uint32 65 | Gid uint32 66 | Rdev uint64 67 | Atimespec Timespec 68 | Mtimespec Timespec 69 | Ctimespec Timespec 70 | Birthtimespec Timespec 71 | Size int64 72 | Blocks int64 73 | Blksize uint32 74 | Flags uint32 75 | Gen uint32 76 | Spare [2]uint32 77 | } 78 | 79 | type Statfs_t [0]byte 80 | 81 | type Flock_t struct { 82 | Start int64 83 | Len int64 84 | Pid int32 85 | Type int16 86 | Whence int16 87 | } 88 | 89 | type Dirent struct { 90 | Fileno uint64 91 | Reclen uint16 92 | Namlen uint16 93 | Type uint8 94 | Name [512]int8 95 | Pad_cgo_0 [3]byte 96 | } 97 | 98 | type Fsid struct { 99 | X__fsid_val [2]int32 100 | } 101 | 102 | type RawSockaddrInet4 struct { 103 | Len uint8 104 | Family uint8 105 | Port uint16 106 | Addr [4]byte /* in_addr */ 107 | Zero [8]int8 108 | } 109 | 110 | type RawSockaddrInet6 struct { 111 | Len uint8 112 | Family uint8 113 | Port uint16 114 | Flowinfo uint32 115 | Addr [16]byte /* in6_addr */ 116 | Scope_id uint32 117 | } 118 | 119 | type RawSockaddrUnix struct { 120 | Len uint8 121 | Family uint8 122 | Path [104]int8 123 | } 124 | 125 | type RawSockaddrDatalink struct { 126 | Len uint8 127 | Family uint8 128 | Index uint16 129 | Type uint8 130 | Nlen uint8 131 | Alen uint8 132 | Slen uint8 133 | Data [12]int8 134 | } 135 | 136 | type RawSockaddr struct { 137 | Len uint8 138 | Family uint8 139 | Data [14]int8 140 | } 141 | 142 | type RawSockaddrAny struct { 143 | Addr RawSockaddr 144 | Pad [92]int8 145 | } 146 | 147 | type _Socklen uint32 148 | 149 | type Linger struct { 150 | Onoff int32 151 | Linger int32 152 | } 153 | 154 | type Iovec struct { 155 | Base *byte 156 | Len uint32 157 | } 158 | 159 | type IPMreq struct { 160 | Multiaddr [4]byte /* in_addr */ 161 | Interface [4]byte /* in_addr */ 162 | } 163 | 164 | type IPv6Mreq struct { 165 | Multiaddr [16]byte /* in6_addr */ 166 | Interface uint32 167 | } 168 | 169 | type Msghdr struct { 170 | Name *byte 171 | Namelen uint32 172 | Iov *Iovec 173 | Iovlen int32 174 | Control *byte 175 | Controllen uint32 176 | Flags int32 177 | } 178 | 179 | type Cmsghdr struct { 180 | Len uint32 181 | Level int32 182 | Type int32 183 | } 184 | 185 | type Inet6Pktinfo struct { 186 | Addr [16]byte /* in6_addr */ 187 | Ifindex uint32 188 | } 189 | 190 | type IPv6MTUInfo struct { 191 | Addr RawSockaddrInet6 192 | Mtu uint32 193 | } 194 | 195 | type ICMPv6Filter struct { 196 | Filt [8]uint32 197 | } 198 | 199 | const ( 200 | SizeofSockaddrInet4 = 0x10 201 | SizeofSockaddrInet6 = 0x1c 202 | SizeofSockaddrAny = 0x6c 203 | SizeofSockaddrUnix = 0x6a 204 | SizeofSockaddrDatalink = 0x14 205 | SizeofLinger = 0x8 206 | SizeofIPMreq = 0x8 207 | SizeofIPv6Mreq = 0x14 208 | SizeofMsghdr = 0x1c 209 | SizeofCmsghdr = 0xc 210 | SizeofInet6Pktinfo = 0x14 211 | SizeofIPv6MTUInfo = 0x20 212 | SizeofICMPv6Filter = 0x20 213 | ) 214 | 215 | const ( 216 | PTRACE_TRACEME = 0x0 217 | PTRACE_CONT = 0x7 218 | PTRACE_KILL = 0x8 219 | ) 220 | 221 | type Kevent_t struct { 222 | Ident uint32 223 | Filter uint32 224 | Flags uint32 225 | Fflags uint32 226 | Data int64 227 | Udata int32 228 | } 229 | 230 | type FdSet struct { 231 | Bits [8]uint32 232 | } 233 | 234 | const ( 235 | SizeofIfMsghdr = 0x98 236 | SizeofIfData = 0x84 237 | SizeofIfaMsghdr = 0x18 238 | SizeofIfAnnounceMsghdr = 0x18 239 | SizeofRtMsghdr = 0x78 240 | SizeofRtMetrics = 0x50 241 | ) 242 | 243 | type IfMsghdr struct { 244 | Msglen uint16 245 | Version uint8 246 | Type uint8 247 | Addrs int32 248 | Flags int32 249 | Index uint16 250 | Pad_cgo_0 [2]byte 251 | Data IfData 252 | Pad_cgo_1 [4]byte 253 | } 254 | 255 | type IfData struct { 256 | Type uint8 257 | Addrlen uint8 258 | Hdrlen uint8 259 | Pad_cgo_0 [1]byte 260 | Link_state int32 261 | Mtu uint64 262 | Metric uint64 263 | Baudrate uint64 264 | Ipackets uint64 265 | Ierrors uint64 266 | Opackets uint64 267 | Oerrors uint64 268 | Collisions uint64 269 | Ibytes uint64 270 | Obytes uint64 271 | Imcasts uint64 272 | Omcasts uint64 273 | Iqdrops uint64 274 | Noproto uint64 275 | Lastchange Timespec 276 | } 277 | 278 | type IfaMsghdr struct { 279 | Msglen uint16 280 | Version uint8 281 | Type uint8 282 | Addrs int32 283 | Flags int32 284 | Metric int32 285 | Index uint16 286 | Pad_cgo_0 [6]byte 287 | } 288 | 289 | type IfAnnounceMsghdr struct { 290 | Msglen uint16 291 | Version uint8 292 | Type uint8 293 | Index uint16 294 | Name [16]int8 295 | What uint16 296 | } 297 | 298 | type RtMsghdr struct { 299 | Msglen uint16 300 | Version uint8 301 | Type uint8 302 | Index uint16 303 | Pad_cgo_0 [2]byte 304 | Flags int32 305 | Addrs int32 306 | Pid int32 307 | Seq int32 308 | Errno int32 309 | Use int32 310 | Inits int32 311 | Pad_cgo_1 [4]byte 312 | Rmx RtMetrics 313 | } 314 | 315 | type RtMetrics struct { 316 | Locks uint64 317 | Mtu uint64 318 | Hopcount uint64 319 | Recvpipe uint64 320 | Sendpipe uint64 321 | Ssthresh uint64 322 | Rtt uint64 323 | Rttvar uint64 324 | Expire int64 325 | Pksent int64 326 | } 327 | 328 | type Mclpool [0]byte 329 | 330 | const ( 331 | SizeofBpfVersion = 0x4 332 | SizeofBpfStat = 0x80 333 | SizeofBpfProgram = 0x8 334 | SizeofBpfInsn = 0x8 335 | SizeofBpfHdr = 0x14 336 | ) 337 | 338 | type BpfVersion struct { 339 | Major uint16 340 | Minor uint16 341 | } 342 | 343 | type BpfStat struct { 344 | Recv uint64 345 | Drop uint64 346 | Capt uint64 347 | Padding [13]uint64 348 | } 349 | 350 | type BpfProgram struct { 351 | Len uint32 352 | Insns *BpfInsn 353 | } 354 | 355 | type BpfInsn struct { 356 | Code uint16 357 | Jt uint8 358 | Jf uint8 359 | K uint32 360 | } 361 | 362 | type BpfHdr struct { 363 | Tstamp BpfTimeval 364 | Caplen uint32 365 | Datalen uint32 366 | Hdrlen uint16 367 | Pad_cgo_0 [2]byte 368 | } 369 | 370 | type BpfTimeval struct { 371 | Sec int32 372 | Usec int32 373 | } 374 | 375 | type Termios struct { 376 | Iflag uint32 377 | Oflag uint32 378 | Cflag uint32 379 | Lflag uint32 380 | Cc [20]uint8 381 | Ispeed int32 382 | Ospeed int32 383 | } 384 | 385 | type Sysctlnode struct { 386 | Flags uint32 387 | Num int32 388 | Name [32]int8 389 | Ver uint32 390 | X__rsvd uint32 391 | Un [16]byte 392 | X_sysctl_size [8]byte 393 | X_sysctl_func [8]byte 394 | X_sysctl_parent [8]byte 395 | X_sysctl_desc [8]byte 396 | } 397 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_netbsd.go 3 | 4 | // +build arm,netbsd 5 | 6 | package unix 7 | 8 | const ( 9 | sizeofPtr = 0x4 10 | sizeofShort = 0x2 11 | sizeofInt = 0x4 12 | sizeofLong = 0x4 13 | sizeofLongLong = 0x8 14 | ) 15 | 16 | type ( 17 | _C_short int16 18 | _C_int int32 19 | _C_long int32 20 | _C_long_long int64 21 | ) 22 | 23 | type Timespec struct { 24 | Sec int64 25 | Nsec int32 26 | Pad_cgo_0 [4]byte 27 | } 28 | 29 | type Timeval struct { 30 | Sec int64 31 | Usec int32 32 | Pad_cgo_0 [4]byte 33 | } 34 | 35 | type Rusage struct { 36 | Utime Timeval 37 | Stime Timeval 38 | Maxrss int32 39 | Ixrss int32 40 | Idrss int32 41 | Isrss int32 42 | Minflt int32 43 | Majflt int32 44 | Nswap int32 45 | Inblock int32 46 | Oublock int32 47 | Msgsnd int32 48 | Msgrcv int32 49 | Nsignals int32 50 | Nvcsw int32 51 | Nivcsw int32 52 | } 53 | 54 | type Rlimit struct { 55 | Cur uint64 56 | Max uint64 57 | } 58 | 59 | type _Gid_t uint32 60 | 61 | type Stat_t struct { 62 | Dev uint64 63 | Mode uint32 64 | Pad_cgo_0 [4]byte 65 | Ino uint64 66 | Nlink uint32 67 | Uid uint32 68 | Gid uint32 69 | Pad_cgo_1 [4]byte 70 | Rdev uint64 71 | Atimespec Timespec 72 | Mtimespec Timespec 73 | Ctimespec Timespec 74 | Birthtimespec Timespec 75 | Size int64 76 | Blocks int64 77 | Blksize uint32 78 | Flags uint32 79 | Gen uint32 80 | Spare [2]uint32 81 | Pad_cgo_2 [4]byte 82 | } 83 | 84 | type Statfs_t [0]byte 85 | 86 | type Flock_t struct { 87 | Start int64 88 | Len int64 89 | Pid int32 90 | Type int16 91 | Whence int16 92 | } 93 | 94 | type Dirent struct { 95 | Fileno uint64 96 | Reclen uint16 97 | Namlen uint16 98 | Type uint8 99 | Name [512]int8 100 | Pad_cgo_0 [3]byte 101 | } 102 | 103 | type Fsid struct { 104 | X__fsid_val [2]int32 105 | } 106 | 107 | type RawSockaddrInet4 struct { 108 | Len uint8 109 | Family uint8 110 | Port uint16 111 | Addr [4]byte /* in_addr */ 112 | Zero [8]int8 113 | } 114 | 115 | type RawSockaddrInet6 struct { 116 | Len uint8 117 | Family uint8 118 | Port uint16 119 | Flowinfo uint32 120 | Addr [16]byte /* in6_addr */ 121 | Scope_id uint32 122 | } 123 | 124 | type RawSockaddrUnix struct { 125 | Len uint8 126 | Family uint8 127 | Path [104]int8 128 | } 129 | 130 | type RawSockaddrDatalink struct { 131 | Len uint8 132 | Family uint8 133 | Index uint16 134 | Type uint8 135 | Nlen uint8 136 | Alen uint8 137 | Slen uint8 138 | Data [12]int8 139 | } 140 | 141 | type RawSockaddr struct { 142 | Len uint8 143 | Family uint8 144 | Data [14]int8 145 | } 146 | 147 | type RawSockaddrAny struct { 148 | Addr RawSockaddr 149 | Pad [92]int8 150 | } 151 | 152 | type _Socklen uint32 153 | 154 | type Linger struct { 155 | Onoff int32 156 | Linger int32 157 | } 158 | 159 | type Iovec struct { 160 | Base *byte 161 | Len uint32 162 | } 163 | 164 | type IPMreq struct { 165 | Multiaddr [4]byte /* in_addr */ 166 | Interface [4]byte /* in_addr */ 167 | } 168 | 169 | type IPv6Mreq struct { 170 | Multiaddr [16]byte /* in6_addr */ 171 | Interface uint32 172 | } 173 | 174 | type Msghdr struct { 175 | Name *byte 176 | Namelen uint32 177 | Iov *Iovec 178 | Iovlen int32 179 | Control *byte 180 | Controllen uint32 181 | Flags int32 182 | } 183 | 184 | type Cmsghdr struct { 185 | Len uint32 186 | Level int32 187 | Type int32 188 | } 189 | 190 | type Inet6Pktinfo struct { 191 | Addr [16]byte /* in6_addr */ 192 | Ifindex uint32 193 | } 194 | 195 | type IPv6MTUInfo struct { 196 | Addr RawSockaddrInet6 197 | Mtu uint32 198 | } 199 | 200 | type ICMPv6Filter struct { 201 | Filt [8]uint32 202 | } 203 | 204 | const ( 205 | SizeofSockaddrInet4 = 0x10 206 | SizeofSockaddrInet6 = 0x1c 207 | SizeofSockaddrAny = 0x6c 208 | SizeofSockaddrUnix = 0x6a 209 | SizeofSockaddrDatalink = 0x14 210 | SizeofLinger = 0x8 211 | SizeofIPMreq = 0x8 212 | SizeofIPv6Mreq = 0x14 213 | SizeofMsghdr = 0x1c 214 | SizeofCmsghdr = 0xc 215 | SizeofInet6Pktinfo = 0x14 216 | SizeofIPv6MTUInfo = 0x20 217 | SizeofICMPv6Filter = 0x20 218 | ) 219 | 220 | const ( 221 | PTRACE_TRACEME = 0x0 222 | PTRACE_CONT = 0x7 223 | PTRACE_KILL = 0x8 224 | ) 225 | 226 | type Kevent_t struct { 227 | Ident uint32 228 | Filter uint32 229 | Flags uint32 230 | Fflags uint32 231 | Data int64 232 | Udata int32 233 | Pad_cgo_0 [4]byte 234 | } 235 | 236 | type FdSet struct { 237 | Bits [8]uint32 238 | } 239 | 240 | const ( 241 | SizeofIfMsghdr = 0x98 242 | SizeofIfData = 0x88 243 | SizeofIfaMsghdr = 0x18 244 | SizeofIfAnnounceMsghdr = 0x18 245 | SizeofRtMsghdr = 0x78 246 | SizeofRtMetrics = 0x50 247 | ) 248 | 249 | type IfMsghdr struct { 250 | Msglen uint16 251 | Version uint8 252 | Type uint8 253 | Addrs int32 254 | Flags int32 255 | Index uint16 256 | Pad_cgo_0 [2]byte 257 | Data IfData 258 | } 259 | 260 | type IfData struct { 261 | Type uint8 262 | Addrlen uint8 263 | Hdrlen uint8 264 | Pad_cgo_0 [1]byte 265 | Link_state int32 266 | Mtu uint64 267 | Metric uint64 268 | Baudrate uint64 269 | Ipackets uint64 270 | Ierrors uint64 271 | Opackets uint64 272 | Oerrors uint64 273 | Collisions uint64 274 | Ibytes uint64 275 | Obytes uint64 276 | Imcasts uint64 277 | Omcasts uint64 278 | Iqdrops uint64 279 | Noproto uint64 280 | Lastchange Timespec 281 | } 282 | 283 | type IfaMsghdr struct { 284 | Msglen uint16 285 | Version uint8 286 | Type uint8 287 | Addrs int32 288 | Flags int32 289 | Metric int32 290 | Index uint16 291 | Pad_cgo_0 [6]byte 292 | } 293 | 294 | type IfAnnounceMsghdr struct { 295 | Msglen uint16 296 | Version uint8 297 | Type uint8 298 | Index uint16 299 | Name [16]int8 300 | What uint16 301 | } 302 | 303 | type RtMsghdr struct { 304 | Msglen uint16 305 | Version uint8 306 | Type uint8 307 | Index uint16 308 | Pad_cgo_0 [2]byte 309 | Flags int32 310 | Addrs int32 311 | Pid int32 312 | Seq int32 313 | Errno int32 314 | Use int32 315 | Inits int32 316 | Pad_cgo_1 [4]byte 317 | Rmx RtMetrics 318 | } 319 | 320 | type RtMetrics struct { 321 | Locks uint64 322 | Mtu uint64 323 | Hopcount uint64 324 | Recvpipe uint64 325 | Sendpipe uint64 326 | Ssthresh uint64 327 | Rtt uint64 328 | Rttvar uint64 329 | Expire int64 330 | Pksent int64 331 | } 332 | 333 | type Mclpool [0]byte 334 | 335 | const ( 336 | SizeofBpfVersion = 0x4 337 | SizeofBpfStat = 0x80 338 | SizeofBpfProgram = 0x8 339 | SizeofBpfInsn = 0x8 340 | SizeofBpfHdr = 0x14 341 | ) 342 | 343 | type BpfVersion struct { 344 | Major uint16 345 | Minor uint16 346 | } 347 | 348 | type BpfStat struct { 349 | Recv uint64 350 | Drop uint64 351 | Capt uint64 352 | Padding [13]uint64 353 | } 354 | 355 | type BpfProgram struct { 356 | Len uint32 357 | Insns *BpfInsn 358 | } 359 | 360 | type BpfInsn struct { 361 | Code uint16 362 | Jt uint8 363 | Jf uint8 364 | K uint32 365 | } 366 | 367 | type BpfHdr struct { 368 | Tstamp BpfTimeval 369 | Caplen uint32 370 | Datalen uint32 371 | Hdrlen uint16 372 | Pad_cgo_0 [2]byte 373 | } 374 | 375 | type BpfTimeval struct { 376 | Sec int32 377 | Usec int32 378 | } 379 | 380 | type Termios struct { 381 | Iflag uint32 382 | Oflag uint32 383 | Cflag uint32 384 | Lflag uint32 385 | Cc [20]uint8 386 | Ispeed int32 387 | Ospeed int32 388 | } 389 | 390 | type Sysctlnode struct { 391 | Flags uint32 392 | Num int32 393 | Name [32]int8 394 | Ver uint32 395 | X__rsvd uint32 396 | Un [16]byte 397 | X_sysctl_size [8]byte 398 | X_sysctl_func [8]byte 399 | X_sysctl_parent [8]byte 400 | X_sysctl_desc [8]byte 401 | } 402 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_netbsd.go 3 | 4 | // +build amd64,netbsd 5 | 6 | package unix 7 | 8 | const ( 9 | sizeofPtr = 0x8 10 | sizeofShort = 0x2 11 | sizeofInt = 0x4 12 | sizeofLong = 0x8 13 | sizeofLongLong = 0x8 14 | ) 15 | 16 | type ( 17 | _C_short int16 18 | _C_int int32 19 | _C_long int64 20 | _C_long_long int64 21 | ) 22 | 23 | type Timespec struct { 24 | Sec int64 25 | Nsec int64 26 | } 27 | 28 | type Timeval struct { 29 | Sec int64 30 | Usec int32 31 | Pad_cgo_0 [4]byte 32 | } 33 | 34 | type Rusage struct { 35 | Utime Timeval 36 | Stime Timeval 37 | Maxrss int64 38 | Ixrss int64 39 | Idrss int64 40 | Isrss int64 41 | Minflt int64 42 | Majflt int64 43 | Nswap int64 44 | Inblock int64 45 | Oublock int64 46 | Msgsnd int64 47 | Msgrcv int64 48 | Nsignals int64 49 | Nvcsw int64 50 | Nivcsw int64 51 | } 52 | 53 | type Rlimit struct { 54 | Cur uint64 55 | Max uint64 56 | } 57 | 58 | type _Gid_t uint32 59 | 60 | type Stat_t struct { 61 | Dev uint64 62 | Mode uint32 63 | Pad_cgo_0 [4]byte 64 | Ino uint64 65 | Nlink uint32 66 | Uid uint32 67 | Gid uint32 68 | Pad_cgo_1 [4]byte 69 | Rdev uint64 70 | Atimespec Timespec 71 | Mtimespec Timespec 72 | Ctimespec Timespec 73 | Birthtimespec Timespec 74 | Size int64 75 | Blocks int64 76 | Blksize uint32 77 | Flags uint32 78 | Gen uint32 79 | Spare [2]uint32 80 | Pad_cgo_2 [4]byte 81 | } 82 | 83 | type Statfs_t [0]byte 84 | 85 | type Flock_t struct { 86 | Start int64 87 | Len int64 88 | Pid int32 89 | Type int16 90 | Whence int16 91 | } 92 | 93 | type Dirent struct { 94 | Fileno uint64 95 | Reclen uint16 96 | Namlen uint16 97 | Type uint8 98 | Name [512]int8 99 | Pad_cgo_0 [3]byte 100 | } 101 | 102 | type Fsid struct { 103 | X__fsid_val [2]int32 104 | } 105 | 106 | type RawSockaddrInet4 struct { 107 | Len uint8 108 | Family uint8 109 | Port uint16 110 | Addr [4]byte /* in_addr */ 111 | Zero [8]int8 112 | } 113 | 114 | type RawSockaddrInet6 struct { 115 | Len uint8 116 | Family uint8 117 | Port uint16 118 | Flowinfo uint32 119 | Addr [16]byte /* in6_addr */ 120 | Scope_id uint32 121 | } 122 | 123 | type RawSockaddrUnix struct { 124 | Len uint8 125 | Family uint8 126 | Path [104]int8 127 | } 128 | 129 | type RawSockaddrDatalink struct { 130 | Len uint8 131 | Family uint8 132 | Index uint16 133 | Type uint8 134 | Nlen uint8 135 | Alen uint8 136 | Slen uint8 137 | Data [12]int8 138 | } 139 | 140 | type RawSockaddr struct { 141 | Len uint8 142 | Family uint8 143 | Data [14]int8 144 | } 145 | 146 | type RawSockaddrAny struct { 147 | Addr RawSockaddr 148 | Pad [92]int8 149 | } 150 | 151 | type _Socklen uint32 152 | 153 | type Linger struct { 154 | Onoff int32 155 | Linger int32 156 | } 157 | 158 | type Iovec struct { 159 | Base *byte 160 | Len uint64 161 | } 162 | 163 | type IPMreq struct { 164 | Multiaddr [4]byte /* in_addr */ 165 | Interface [4]byte /* in_addr */ 166 | } 167 | 168 | type IPv6Mreq struct { 169 | Multiaddr [16]byte /* in6_addr */ 170 | Interface uint32 171 | } 172 | 173 | type Msghdr struct { 174 | Name *byte 175 | Namelen uint32 176 | Pad_cgo_0 [4]byte 177 | Iov *Iovec 178 | Iovlen int32 179 | Pad_cgo_1 [4]byte 180 | Control *byte 181 | Controllen uint32 182 | Flags int32 183 | } 184 | 185 | type Cmsghdr struct { 186 | Len uint32 187 | Level int32 188 | Type int32 189 | } 190 | 191 | type Inet6Pktinfo struct { 192 | Addr [16]byte /* in6_addr */ 193 | Ifindex uint32 194 | } 195 | 196 | type IPv6MTUInfo struct { 197 | Addr RawSockaddrInet6 198 | Mtu uint32 199 | } 200 | 201 | type ICMPv6Filter struct { 202 | Filt [8]uint32 203 | } 204 | 205 | const ( 206 | SizeofSockaddrInet4 = 0x10 207 | SizeofSockaddrInet6 = 0x1c 208 | SizeofSockaddrAny = 0x6c 209 | SizeofSockaddrUnix = 0x6a 210 | SizeofSockaddrDatalink = 0x14 211 | SizeofLinger = 0x8 212 | SizeofIPMreq = 0x8 213 | SizeofIPv6Mreq = 0x14 214 | SizeofMsghdr = 0x30 215 | SizeofCmsghdr = 0xc 216 | SizeofInet6Pktinfo = 0x14 217 | SizeofIPv6MTUInfo = 0x20 218 | SizeofICMPv6Filter = 0x20 219 | ) 220 | 221 | const ( 222 | PTRACE_TRACEME = 0x0 223 | PTRACE_CONT = 0x7 224 | PTRACE_KILL = 0x8 225 | ) 226 | 227 | type Kevent_t struct { 228 | Ident uint64 229 | Filter uint32 230 | Flags uint32 231 | Fflags uint32 232 | Pad_cgo_0 [4]byte 233 | Data int64 234 | Udata int64 235 | } 236 | 237 | type FdSet struct { 238 | Bits [8]uint32 239 | } 240 | 241 | const ( 242 | SizeofIfMsghdr = 0x98 243 | SizeofIfData = 0x88 244 | SizeofIfaMsghdr = 0x18 245 | SizeofIfAnnounceMsghdr = 0x18 246 | SizeofRtMsghdr = 0x78 247 | SizeofRtMetrics = 0x50 248 | ) 249 | 250 | type IfMsghdr struct { 251 | Msglen uint16 252 | Version uint8 253 | Type uint8 254 | Addrs int32 255 | Flags int32 256 | Index uint16 257 | Pad_cgo_0 [2]byte 258 | Data IfData 259 | } 260 | 261 | type IfData struct { 262 | Type uint8 263 | Addrlen uint8 264 | Hdrlen uint8 265 | Pad_cgo_0 [1]byte 266 | Link_state int32 267 | Mtu uint64 268 | Metric uint64 269 | Baudrate uint64 270 | Ipackets uint64 271 | Ierrors uint64 272 | Opackets uint64 273 | Oerrors uint64 274 | Collisions uint64 275 | Ibytes uint64 276 | Obytes uint64 277 | Imcasts uint64 278 | Omcasts uint64 279 | Iqdrops uint64 280 | Noproto uint64 281 | Lastchange Timespec 282 | } 283 | 284 | type IfaMsghdr struct { 285 | Msglen uint16 286 | Version uint8 287 | Type uint8 288 | Addrs int32 289 | Flags int32 290 | Metric int32 291 | Index uint16 292 | Pad_cgo_0 [6]byte 293 | } 294 | 295 | type IfAnnounceMsghdr struct { 296 | Msglen uint16 297 | Version uint8 298 | Type uint8 299 | Index uint16 300 | Name [16]int8 301 | What uint16 302 | } 303 | 304 | type RtMsghdr struct { 305 | Msglen uint16 306 | Version uint8 307 | Type uint8 308 | Index uint16 309 | Pad_cgo_0 [2]byte 310 | Flags int32 311 | Addrs int32 312 | Pid int32 313 | Seq int32 314 | Errno int32 315 | Use int32 316 | Inits int32 317 | Pad_cgo_1 [4]byte 318 | Rmx RtMetrics 319 | } 320 | 321 | type RtMetrics struct { 322 | Locks uint64 323 | Mtu uint64 324 | Hopcount uint64 325 | Recvpipe uint64 326 | Sendpipe uint64 327 | Ssthresh uint64 328 | Rtt uint64 329 | Rttvar uint64 330 | Expire int64 331 | Pksent int64 332 | } 333 | 334 | type Mclpool [0]byte 335 | 336 | const ( 337 | SizeofBpfVersion = 0x4 338 | SizeofBpfStat = 0x80 339 | SizeofBpfProgram = 0x10 340 | SizeofBpfInsn = 0x8 341 | SizeofBpfHdr = 0x20 342 | ) 343 | 344 | type BpfVersion struct { 345 | Major uint16 346 | Minor uint16 347 | } 348 | 349 | type BpfStat struct { 350 | Recv uint64 351 | Drop uint64 352 | Capt uint64 353 | Padding [13]uint64 354 | } 355 | 356 | type BpfProgram struct { 357 | Len uint32 358 | Pad_cgo_0 [4]byte 359 | Insns *BpfInsn 360 | } 361 | 362 | type BpfInsn struct { 363 | Code uint16 364 | Jt uint8 365 | Jf uint8 366 | K uint32 367 | } 368 | 369 | type BpfHdr struct { 370 | Tstamp BpfTimeval 371 | Caplen uint32 372 | Datalen uint32 373 | Hdrlen uint16 374 | Pad_cgo_0 [6]byte 375 | } 376 | 377 | type BpfTimeval struct { 378 | Sec int64 379 | Usec int64 380 | } 381 | 382 | type Termios struct { 383 | Iflag uint32 384 | Oflag uint32 385 | Cflag uint32 386 | Lflag uint32 387 | Cc [20]uint8 388 | Ispeed int32 389 | Ospeed int32 390 | } 391 | 392 | type Sysctlnode struct { 393 | Flags uint32 394 | Num int32 395 | Name [32]int8 396 | Ver uint32 397 | X__rsvd uint32 398 | Un [16]byte 399 | X_sysctl_size [8]byte 400 | X_sysctl_func [8]byte 401 | X_sysctl_parent [8]byte 402 | X_sysctl_desc [8]byte 403 | } 404 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "sync" 12 | "syscall" 13 | "unsafe" 14 | ) 15 | 16 | var ( 17 | Stdin = 0 18 | Stdout = 1 19 | Stderr = 2 20 | ) 21 | 22 | const ( 23 | darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8 24 | dragonfly64Bit = runtime.GOOS == "dragonfly" && sizeofPtr == 8 25 | netbsd32Bit = runtime.GOOS == "netbsd" && sizeofPtr == 4 26 | ) 27 | 28 | // Do the interface allocations only once for common 29 | // Errno values. 30 | var ( 31 | errEAGAIN error = syscall.EAGAIN 32 | errEINVAL error = syscall.EINVAL 33 | errENOENT error = syscall.ENOENT 34 | ) 35 | 36 | // errnoErr returns common boxed Errno values, to prevent 37 | // allocations at runtime. 38 | func errnoErr(e syscall.Errno) error { 39 | switch e { 40 | case 0: 41 | return nil 42 | case EAGAIN: 43 | return errEAGAIN 44 | case EINVAL: 45 | return errEINVAL 46 | case ENOENT: 47 | return errENOENT 48 | } 49 | return e 50 | } 51 | 52 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 54 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 55 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 56 | 57 | // Mmap manager, for use by operating system-specific implementations. 58 | 59 | type mmapper struct { 60 | sync.Mutex 61 | active map[*byte][]byte // active mappings; key is last byte in mapping 62 | mmap func(addr, length uintptr, prot, flags, fd int, offset int64) (uintptr, error) 63 | munmap func(addr uintptr, length uintptr) error 64 | } 65 | 66 | func (m *mmapper) Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { 67 | if length <= 0 { 68 | return nil, EINVAL 69 | } 70 | 71 | // Map the requested memory. 72 | addr, errno := m.mmap(0, uintptr(length), prot, flags, fd, offset) 73 | if errno != nil { 74 | return nil, errno 75 | } 76 | 77 | // Slice memory layout 78 | var sl = struct { 79 | addr uintptr 80 | len int 81 | cap int 82 | }{addr, length, length} 83 | 84 | // Use unsafe to turn sl into a []byte. 85 | b := *(*[]byte)(unsafe.Pointer(&sl)) 86 | 87 | // Register mapping in m and return it. 88 | p := &b[cap(b)-1] 89 | m.Lock() 90 | defer m.Unlock() 91 | m.active[p] = b 92 | return b, nil 93 | } 94 | 95 | func (m *mmapper) Munmap(data []byte) (err error) { 96 | if len(data) == 0 || len(data) != cap(data) { 97 | return EINVAL 98 | } 99 | 100 | // Find the base of the mapping. 101 | p := &data[cap(data)-1] 102 | m.Lock() 103 | defer m.Unlock() 104 | b := m.active[p] 105 | if b == nil || &b[0] != &data[0] { 106 | return EINVAL 107 | } 108 | 109 | // Unmap the memory and update m. 110 | if errno := m.munmap(uintptr(unsafe.Pointer(&b[0])), uintptr(len(b))); errno != nil { 111 | return errno 112 | } 113 | delete(m.active, p) 114 | return nil 115 | } 116 | 117 | func Read(fd int, p []byte) (n int, err error) { 118 | n, err = read(fd, p) 119 | if raceenabled { 120 | if n > 0 { 121 | raceWriteRange(unsafe.Pointer(&p[0]), n) 122 | } 123 | if err == nil { 124 | raceAcquire(unsafe.Pointer(&ioSync)) 125 | } 126 | } 127 | return 128 | } 129 | 130 | func Write(fd int, p []byte) (n int, err error) { 131 | if raceenabled { 132 | raceReleaseMerge(unsafe.Pointer(&ioSync)) 133 | } 134 | n, err = write(fd, p) 135 | if raceenabled && n > 0 { 136 | raceReadRange(unsafe.Pointer(&p[0]), n) 137 | } 138 | return 139 | } 140 | 141 | // For testing: clients can set this flag to force 142 | // creation of IPv6 sockets to return EAFNOSUPPORT. 143 | var SocketDisableIPv6 bool 144 | 145 | type Sockaddr interface { 146 | sockaddr() (ptr unsafe.Pointer, len _Socklen, err error) // lowercase; only we can define Sockaddrs 147 | } 148 | 149 | type SockaddrInet4 struct { 150 | Port int 151 | Addr [4]byte 152 | raw RawSockaddrInet4 153 | } 154 | 155 | type SockaddrInet6 struct { 156 | Port int 157 | ZoneId uint32 158 | Addr [16]byte 159 | raw RawSockaddrInet6 160 | } 161 | 162 | type SockaddrUnix struct { 163 | Name string 164 | raw RawSockaddrUnix 165 | } 166 | 167 | func Bind(fd int, sa Sockaddr) (err error) { 168 | ptr, n, err := sa.sockaddr() 169 | if err != nil { 170 | return err 171 | } 172 | return bind(fd, ptr, n) 173 | } 174 | 175 | func Connect(fd int, sa Sockaddr) (err error) { 176 | ptr, n, err := sa.sockaddr() 177 | if err != nil { 178 | return err 179 | } 180 | return connect(fd, ptr, n) 181 | } 182 | 183 | func Getpeername(fd int) (sa Sockaddr, err error) { 184 | var rsa RawSockaddrAny 185 | var len _Socklen = SizeofSockaddrAny 186 | if err = getpeername(fd, &rsa, &len); err != nil { 187 | return 188 | } 189 | return anyToSockaddr(&rsa) 190 | } 191 | 192 | func GetsockoptInt(fd, level, opt int) (value int, err error) { 193 | var n int32 194 | vallen := _Socklen(4) 195 | err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen) 196 | return int(n), err 197 | } 198 | 199 | func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) { 200 | var rsa RawSockaddrAny 201 | var len _Socklen = SizeofSockaddrAny 202 | if n, err = recvfrom(fd, p, flags, &rsa, &len); err != nil { 203 | return 204 | } 205 | if rsa.Addr.Family != AF_UNSPEC { 206 | from, err = anyToSockaddr(&rsa) 207 | } 208 | return 209 | } 210 | 211 | func Sendto(fd int, p []byte, flags int, to Sockaddr) (err error) { 212 | ptr, n, err := to.sockaddr() 213 | if err != nil { 214 | return err 215 | } 216 | return sendto(fd, p, flags, ptr, n) 217 | } 218 | 219 | func SetsockoptByte(fd, level, opt int, value byte) (err error) { 220 | return setsockopt(fd, level, opt, unsafe.Pointer(&value), 1) 221 | } 222 | 223 | func SetsockoptInt(fd, level, opt int, value int) (err error) { 224 | var n = int32(value) 225 | return setsockopt(fd, level, opt, unsafe.Pointer(&n), 4) 226 | } 227 | 228 | func SetsockoptInet4Addr(fd, level, opt int, value [4]byte) (err error) { 229 | return setsockopt(fd, level, opt, unsafe.Pointer(&value[0]), 4) 230 | } 231 | 232 | func SetsockoptIPMreq(fd, level, opt int, mreq *IPMreq) (err error) { 233 | return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPMreq) 234 | } 235 | 236 | func SetsockoptIPv6Mreq(fd, level, opt int, mreq *IPv6Mreq) (err error) { 237 | return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPv6Mreq) 238 | } 239 | 240 | func SetsockoptICMPv6Filter(fd, level, opt int, filter *ICMPv6Filter) error { 241 | return setsockopt(fd, level, opt, unsafe.Pointer(filter), SizeofICMPv6Filter) 242 | } 243 | 244 | func SetsockoptLinger(fd, level, opt int, l *Linger) (err error) { 245 | return setsockopt(fd, level, opt, unsafe.Pointer(l), SizeofLinger) 246 | } 247 | 248 | func SetsockoptString(fd, level, opt int, s string) (err error) { 249 | return setsockopt(fd, level, opt, unsafe.Pointer(&[]byte(s)[0]), uintptr(len(s))) 250 | } 251 | 252 | func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (err error) { 253 | return setsockopt(fd, level, opt, unsafe.Pointer(tv), unsafe.Sizeof(*tv)) 254 | } 255 | 256 | func Socket(domain, typ, proto int) (fd int, err error) { 257 | if domain == AF_INET6 && SocketDisableIPv6 { 258 | return -1, EAFNOSUPPORT 259 | } 260 | fd, err = socket(domain, typ, proto) 261 | return 262 | } 263 | 264 | func Socketpair(domain, typ, proto int) (fd [2]int, err error) { 265 | var fdx [2]int32 266 | err = socketpair(domain, typ, proto, &fdx) 267 | if err == nil { 268 | fd[0] = int(fdx[0]) 269 | fd[1] = int(fdx[1]) 270 | } 271 | return 272 | } 273 | 274 | func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 275 | if raceenabled { 276 | raceReleaseMerge(unsafe.Pointer(&ioSync)) 277 | } 278 | return sendfile(outfd, infd, offset, count) 279 | } 280 | 281 | var ioSync int64 282 | 283 | func CloseOnExec(fd int) { fcntl(fd, F_SETFD, FD_CLOEXEC) } 284 | 285 | func SetNonblock(fd int, nonblocking bool) (err error) { 286 | flag, err := fcntl(fd, F_GETFL, 0) 287 | if err != nil { 288 | return err 289 | } 290 | if nonblocking { 291 | flag |= O_NONBLOCK 292 | } else { 293 | flag &= ^O_NONBLOCK 294 | } 295 | _, err = fcntl(fd, F_SETFL, flag) 296 | return err 297 | } 298 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // +build amd64,solaris 2 | // Created by cgo -godefs - DO NOT EDIT 3 | // cgo -godefs types_solaris.go | go run mkpost.go 4 | 5 | package unix 6 | 7 | const ( 8 | sizeofPtr = 0x8 9 | sizeofShort = 0x2 10 | sizeofInt = 0x4 11 | sizeofLong = 0x8 12 | sizeofLongLong = 0x8 13 | PathMax = 0x400 14 | MaxHostNameLen = 0x100 15 | ) 16 | 17 | type ( 18 | _C_short int16 19 | _C_int int32 20 | _C_long int64 21 | _C_long_long int64 22 | ) 23 | 24 | type Timespec struct { 25 | Sec int64 26 | Nsec int64 27 | } 28 | 29 | type Timeval struct { 30 | Sec int64 31 | Usec int64 32 | } 33 | 34 | type Timeval32 struct { 35 | Sec int32 36 | Usec int32 37 | } 38 | 39 | type Tms struct { 40 | Utime int64 41 | Stime int64 42 | Cutime int64 43 | Cstime int64 44 | } 45 | 46 | type Utimbuf struct { 47 | Actime int64 48 | Modtime int64 49 | } 50 | 51 | type Rusage struct { 52 | Utime Timeval 53 | Stime Timeval 54 | Maxrss int64 55 | Ixrss int64 56 | Idrss int64 57 | Isrss int64 58 | Minflt int64 59 | Majflt int64 60 | Nswap int64 61 | Inblock int64 62 | Oublock int64 63 | Msgsnd int64 64 | Msgrcv int64 65 | Nsignals int64 66 | Nvcsw int64 67 | Nivcsw int64 68 | } 69 | 70 | type Rlimit struct { 71 | Cur uint64 72 | Max uint64 73 | } 74 | 75 | type _Gid_t uint32 76 | 77 | const ( 78 | S_IFMT = 0xf000 79 | S_IFIFO = 0x1000 80 | S_IFCHR = 0x2000 81 | S_IFDIR = 0x4000 82 | S_IFBLK = 0x6000 83 | S_IFREG = 0x8000 84 | S_IFLNK = 0xa000 85 | S_IFSOCK = 0xc000 86 | S_ISUID = 0x800 87 | S_ISGID = 0x400 88 | S_ISVTX = 0x200 89 | S_IRUSR = 0x100 90 | S_IWUSR = 0x80 91 | S_IXUSR = 0x40 92 | ) 93 | 94 | type Stat_t struct { 95 | Dev uint64 96 | Ino uint64 97 | Mode uint32 98 | Nlink uint32 99 | Uid uint32 100 | Gid uint32 101 | Rdev uint64 102 | Size int64 103 | Atim Timespec 104 | Mtim Timespec 105 | Ctim Timespec 106 | Blksize int32 107 | Pad_cgo_0 [4]byte 108 | Blocks int64 109 | Fstype [16]int8 110 | } 111 | 112 | type Flock_t struct { 113 | Type int16 114 | Whence int16 115 | Pad_cgo_0 [4]byte 116 | Start int64 117 | Len int64 118 | Sysid int32 119 | Pid int32 120 | Pad [4]int64 121 | } 122 | 123 | type Dirent struct { 124 | Ino uint64 125 | Off int64 126 | Reclen uint16 127 | Name [1]int8 128 | Pad_cgo_0 [5]byte 129 | } 130 | 131 | type RawSockaddrInet4 struct { 132 | Family uint16 133 | Port uint16 134 | Addr [4]byte /* in_addr */ 135 | Zero [8]int8 136 | } 137 | 138 | type RawSockaddrInet6 struct { 139 | Family uint16 140 | Port uint16 141 | Flowinfo uint32 142 | Addr [16]byte /* in6_addr */ 143 | Scope_id uint32 144 | X__sin6_src_id uint32 145 | } 146 | 147 | type RawSockaddrUnix struct { 148 | Family uint16 149 | Path [108]int8 150 | } 151 | 152 | type RawSockaddrDatalink struct { 153 | Family uint16 154 | Index uint16 155 | Type uint8 156 | Nlen uint8 157 | Alen uint8 158 | Slen uint8 159 | Data [244]int8 160 | } 161 | 162 | type RawSockaddr struct { 163 | Family uint16 164 | Data [14]int8 165 | } 166 | 167 | type RawSockaddrAny struct { 168 | Addr RawSockaddr 169 | Pad [236]int8 170 | } 171 | 172 | type _Socklen uint32 173 | 174 | type Linger struct { 175 | Onoff int32 176 | Linger int32 177 | } 178 | 179 | type Iovec struct { 180 | Base *int8 181 | Len uint64 182 | } 183 | 184 | type IPMreq struct { 185 | Multiaddr [4]byte /* in_addr */ 186 | Interface [4]byte /* in_addr */ 187 | } 188 | 189 | type IPv6Mreq struct { 190 | Multiaddr [16]byte /* in6_addr */ 191 | Interface uint32 192 | } 193 | 194 | type Msghdr struct { 195 | Name *byte 196 | Namelen uint32 197 | Pad_cgo_0 [4]byte 198 | Iov *Iovec 199 | Iovlen int32 200 | Pad_cgo_1 [4]byte 201 | Accrights *int8 202 | Accrightslen int32 203 | Pad_cgo_2 [4]byte 204 | } 205 | 206 | type Cmsghdr struct { 207 | Len uint32 208 | Level int32 209 | Type int32 210 | } 211 | 212 | type Inet6Pktinfo struct { 213 | Addr [16]byte /* in6_addr */ 214 | Ifindex uint32 215 | } 216 | 217 | type IPv6MTUInfo struct { 218 | Addr RawSockaddrInet6 219 | Mtu uint32 220 | } 221 | 222 | type ICMPv6Filter struct { 223 | X__icmp6_filt [8]uint32 224 | } 225 | 226 | const ( 227 | SizeofSockaddrInet4 = 0x10 228 | SizeofSockaddrInet6 = 0x20 229 | SizeofSockaddrAny = 0xfc 230 | SizeofSockaddrUnix = 0x6e 231 | SizeofSockaddrDatalink = 0xfc 232 | SizeofLinger = 0x8 233 | SizeofIPMreq = 0x8 234 | SizeofIPv6Mreq = 0x14 235 | SizeofMsghdr = 0x30 236 | SizeofCmsghdr = 0xc 237 | SizeofInet6Pktinfo = 0x14 238 | SizeofIPv6MTUInfo = 0x24 239 | SizeofICMPv6Filter = 0x20 240 | ) 241 | 242 | type FdSet struct { 243 | Bits [1024]int64 244 | } 245 | 246 | type Utsname struct { 247 | Sysname [257]int8 248 | Nodename [257]int8 249 | Release [257]int8 250 | Version [257]int8 251 | Machine [257]int8 252 | } 253 | 254 | type Ustat_t struct { 255 | Tfree int64 256 | Tinode uint64 257 | Fname [6]int8 258 | Fpack [6]int8 259 | Pad_cgo_0 [4]byte 260 | } 261 | 262 | const ( 263 | AT_FDCWD = 0xffd19553 264 | AT_SYMLINK_NOFOLLOW = 0x1000 265 | AT_SYMLINK_FOLLOW = 0x2000 266 | AT_REMOVEDIR = 0x1 267 | AT_EACCESS = 0x4 268 | ) 269 | 270 | const ( 271 | SizeofIfMsghdr = 0x54 272 | SizeofIfData = 0x44 273 | SizeofIfaMsghdr = 0x14 274 | SizeofRtMsghdr = 0x4c 275 | SizeofRtMetrics = 0x28 276 | ) 277 | 278 | type IfMsghdr struct { 279 | Msglen uint16 280 | Version uint8 281 | Type uint8 282 | Addrs int32 283 | Flags int32 284 | Index uint16 285 | Pad_cgo_0 [2]byte 286 | Data IfData 287 | } 288 | 289 | type IfData struct { 290 | Type uint8 291 | Addrlen uint8 292 | Hdrlen uint8 293 | Pad_cgo_0 [1]byte 294 | Mtu uint32 295 | Metric uint32 296 | Baudrate uint32 297 | Ipackets uint32 298 | Ierrors uint32 299 | Opackets uint32 300 | Oerrors uint32 301 | Collisions uint32 302 | Ibytes uint32 303 | Obytes uint32 304 | Imcasts uint32 305 | Omcasts uint32 306 | Iqdrops uint32 307 | Noproto uint32 308 | Lastchange Timeval32 309 | } 310 | 311 | type IfaMsghdr struct { 312 | Msglen uint16 313 | Version uint8 314 | Type uint8 315 | Addrs int32 316 | Flags int32 317 | Index uint16 318 | Pad_cgo_0 [2]byte 319 | Metric int32 320 | } 321 | 322 | type RtMsghdr struct { 323 | Msglen uint16 324 | Version uint8 325 | Type uint8 326 | Index uint16 327 | Pad_cgo_0 [2]byte 328 | Flags int32 329 | Addrs int32 330 | Pid int32 331 | Seq int32 332 | Errno int32 333 | Use int32 334 | Inits uint32 335 | Rmx RtMetrics 336 | } 337 | 338 | type RtMetrics struct { 339 | Locks uint32 340 | Mtu uint32 341 | Hopcount uint32 342 | Expire uint32 343 | Recvpipe uint32 344 | Sendpipe uint32 345 | Ssthresh uint32 346 | Rtt uint32 347 | Rttvar uint32 348 | Pksent uint32 349 | } 350 | 351 | const ( 352 | SizeofBpfVersion = 0x4 353 | SizeofBpfStat = 0x80 354 | SizeofBpfProgram = 0x10 355 | SizeofBpfInsn = 0x8 356 | SizeofBpfHdr = 0x14 357 | ) 358 | 359 | type BpfVersion struct { 360 | Major uint16 361 | Minor uint16 362 | } 363 | 364 | type BpfStat struct { 365 | Recv uint64 366 | Drop uint64 367 | Capt uint64 368 | Padding [13]uint64 369 | } 370 | 371 | type BpfProgram struct { 372 | Len uint32 373 | Pad_cgo_0 [4]byte 374 | Insns *BpfInsn 375 | } 376 | 377 | type BpfInsn struct { 378 | Code uint16 379 | Jt uint8 380 | Jf uint8 381 | K uint32 382 | } 383 | 384 | type BpfTimeval struct { 385 | Sec int32 386 | Usec int32 387 | } 388 | 389 | type BpfHdr struct { 390 | Tstamp BpfTimeval 391 | Caplen uint32 392 | Datalen uint32 393 | Hdrlen uint16 394 | Pad_cgo_0 [2]byte 395 | } 396 | 397 | const _SC_PAGESIZE = 0xb 398 | 399 | type Termios struct { 400 | Iflag uint32 401 | Oflag uint32 402 | Cflag uint32 403 | Lflag uint32 404 | Cc [19]uint8 405 | Pad_cgo_0 [1]byte 406 | } 407 | 408 | type Termio struct { 409 | Iflag uint16 410 | Oflag uint16 411 | Cflag uint16 412 | Lflag uint16 413 | Line int8 414 | Cc [8]uint8 415 | Pad_cgo_0 [1]byte 416 | } 417 | 418 | type Winsize struct { 419 | Row uint16 420 | Col uint16 421 | Xpixel uint16 422 | Ypixel uint16 423 | } 424 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_arm.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 arm,linux 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Sec = int32(nsec / 1e9) 27 | tv.Usec = int32(nsec % 1e9 / 1e3) 28 | return 29 | } 30 | 31 | func Pipe(p []int) (err error) { 32 | if len(p) != 2 { 33 | return EINVAL 34 | } 35 | var pp [2]_C_int 36 | err = pipe2(&pp, 0) 37 | p[0] = int(pp[0]) 38 | p[1] = int(pp[1]) 39 | return 40 | } 41 | 42 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 43 | 44 | func Pipe2(p []int, flags int) (err error) { 45 | if len(p) != 2 { 46 | return EINVAL 47 | } 48 | var pp [2]_C_int 49 | err = pipe2(&pp, flags) 50 | p[0] = int(pp[0]) 51 | p[1] = int(pp[1]) 52 | return 53 | } 54 | 55 | // Underlying system call writes to newoffset via pointer. 56 | // Implemented in assembly to avoid allocation. 57 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 58 | 59 | func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { 60 | newoffset, errno := seek(fd, offset, whence) 61 | if errno != 0 { 62 | return 0, errno 63 | } 64 | return newoffset, nil 65 | } 66 | 67 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 68 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 69 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 70 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 71 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) = SYS_GETGROUPS32 72 | //sysnb setgroups(n int, list *_Gid_t) (err error) = SYS_SETGROUPS32 73 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 74 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 75 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 76 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 77 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 78 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 79 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 80 | //sysnb socketpair(domain int, typ int, flags int, fd *[2]int32) (err error) 81 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 82 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 83 | 84 | // 64-bit file system and 32-bit uid calls 85 | // (16-bit uid calls are not always supported in newer kernels) 86 | //sys Dup2(oldfd int, newfd int) (err error) 87 | //sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32 88 | //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 89 | //sysnb Getegid() (egid int) = SYS_GETEGID32 90 | //sysnb Geteuid() (euid int) = SYS_GETEUID32 91 | //sysnb Getgid() (gid int) = SYS_GETGID32 92 | //sysnb Getuid() (uid int) = SYS_GETUID32 93 | //sysnb InotifyInit() (fd int, err error) 94 | //sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32 95 | //sys Listen(s int, n int) (err error) 96 | //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 97 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64 98 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT 99 | //sys Setfsgid(gid int) (err error) = SYS_SETFSGID32 100 | //sys Setfsuid(uid int) (err error) = SYS_SETFSUID32 101 | //sysnb Setregid(rgid int, egid int) (err error) = SYS_SETREGID32 102 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) = SYS_SETRESGID32 103 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) = SYS_SETRESUID32 104 | //sysnb Setreuid(ruid int, euid int) (err error) = SYS_SETREUID32 105 | //sys Shutdown(fd int, how int) (err error) 106 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) 107 | //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 108 | 109 | // Vsyscalls on amd64. 110 | //sysnb Gettimeofday(tv *Timeval) (err error) 111 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 112 | //sys Pause() (err error) 113 | 114 | func Time(t *Time_t) (Time_t, error) { 115 | var tv Timeval 116 | err := Gettimeofday(&tv) 117 | if err != nil { 118 | return 0, err 119 | } 120 | if t != nil { 121 | *t = Time_t(tv.Sec) 122 | } 123 | return Time_t(tv.Sec), nil 124 | } 125 | 126 | func Utime(path string, buf *Utimbuf) error { 127 | tv := []Timeval{ 128 | {Sec: buf.Actime}, 129 | {Sec: buf.Modtime}, 130 | } 131 | return Utimes(path, tv) 132 | } 133 | 134 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 135 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 136 | //sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64 137 | //sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64 138 | 139 | func Fadvise(fd int, offset int64, length int64, advice int) (err error) { 140 | _, _, e1 := Syscall6(SYS_ARM_FADVISE64_64, uintptr(fd), uintptr(advice), uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32)) 141 | if e1 != 0 { 142 | err = errnoErr(e1) 143 | } 144 | return 145 | } 146 | 147 | //sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) 148 | 149 | func Fstatfs(fd int, buf *Statfs_t) (err error) { 150 | _, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf))) 151 | if e != 0 { 152 | err = e 153 | } 154 | return 155 | } 156 | 157 | func Statfs(path string, buf *Statfs_t) (err error) { 158 | pathp, err := BytePtrFromString(path) 159 | if err != nil { 160 | return err 161 | } 162 | _, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(pathp)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf))) 163 | if e != 0 { 164 | err = e 165 | } 166 | return 167 | } 168 | 169 | func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { 170 | page := uintptr(offset / 4096) 171 | if offset != int64(page)*4096 { 172 | return 0, EINVAL 173 | } 174 | return mmap2(addr, length, prot, flags, fd, page) 175 | } 176 | 177 | type rlimit32 struct { 178 | Cur uint32 179 | Max uint32 180 | } 181 | 182 | //sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_UGETRLIMIT 183 | 184 | const rlimInf32 = ^uint32(0) 185 | const rlimInf64 = ^uint64(0) 186 | 187 | func Getrlimit(resource int, rlim *Rlimit) (err error) { 188 | err = prlimit(0, resource, nil, rlim) 189 | if err != ENOSYS { 190 | return err 191 | } 192 | 193 | rl := rlimit32{} 194 | err = getrlimit(resource, &rl) 195 | if err != nil { 196 | return 197 | } 198 | 199 | if rl.Cur == rlimInf32 { 200 | rlim.Cur = rlimInf64 201 | } else { 202 | rlim.Cur = uint64(rl.Cur) 203 | } 204 | 205 | if rl.Max == rlimInf32 { 206 | rlim.Max = rlimInf64 207 | } else { 208 | rlim.Max = uint64(rl.Max) 209 | } 210 | return 211 | } 212 | 213 | //sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT 214 | 215 | func Setrlimit(resource int, rlim *Rlimit) (err error) { 216 | err = prlimit(0, resource, rlim, nil) 217 | if err != ENOSYS { 218 | return err 219 | } 220 | 221 | rl := rlimit32{} 222 | if rlim.Cur == rlimInf64 { 223 | rl.Cur = rlimInf32 224 | } else if rlim.Cur < uint64(rlimInf32) { 225 | rl.Cur = uint32(rlim.Cur) 226 | } else { 227 | return EINVAL 228 | } 229 | if rlim.Max == rlimInf64 { 230 | rl.Max = rlimInf32 231 | } else if rlim.Max < uint64(rlimInf32) { 232 | rl.Max = uint32(rlim.Max) 233 | } else { 234 | return EINVAL 235 | } 236 | 237 | return setrlimit(resource, &rl) 238 | } 239 | 240 | func (r *PtraceRegs) PC() uint64 { return uint64(r.Uregs[15]) } 241 | 242 | func (r *PtraceRegs) SetPC(pc uint64) { r.Uregs[15] = uint32(pc) } 243 | 244 | func (iov *Iovec) SetLen(length int) { 245 | iov.Len = uint32(length) 246 | } 247 | 248 | func (msghdr *Msghdr) SetControllen(length int) { 249 | msghdr.Controllen = uint32(length) 250 | } 251 | 252 | func (cmsg *Cmsghdr) SetLen(length int) { 253 | cmsg.Len = uint32(length) 254 | } 255 | 256 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 257 | 258 | func Poll(fds []PollFd, timeout int) (n int, err error) { 259 | if len(fds) == 0 { 260 | return poll(nil, 0, timeout) 261 | } 262 | return poll(&fds[0], len(fds), timeout) 263 | } 264 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_dragonfly.go 3 | 4 | // +build amd64,dragonfly 5 | 6 | package unix 7 | 8 | const ( 9 | sizeofPtr = 0x8 10 | sizeofShort = 0x2 11 | sizeofInt = 0x4 12 | sizeofLong = 0x8 13 | sizeofLongLong = 0x8 14 | ) 15 | 16 | type ( 17 | _C_short int16 18 | _C_int int32 19 | _C_long int64 20 | _C_long_long int64 21 | ) 22 | 23 | type Timespec struct { 24 | Sec int64 25 | Nsec int64 26 | } 27 | 28 | type Timeval struct { 29 | Sec int64 30 | Usec int64 31 | } 32 | 33 | type Rusage struct { 34 | Utime Timeval 35 | Stime Timeval 36 | Maxrss int64 37 | Ixrss int64 38 | Idrss int64 39 | Isrss int64 40 | Minflt int64 41 | Majflt int64 42 | Nswap int64 43 | Inblock int64 44 | Oublock int64 45 | Msgsnd int64 46 | Msgrcv int64 47 | Nsignals int64 48 | Nvcsw int64 49 | Nivcsw int64 50 | } 51 | 52 | type Rlimit struct { 53 | Cur int64 54 | Max int64 55 | } 56 | 57 | type _Gid_t uint32 58 | 59 | const ( 60 | S_IFMT = 0xf000 61 | S_IFIFO = 0x1000 62 | S_IFCHR = 0x2000 63 | S_IFDIR = 0x4000 64 | S_IFBLK = 0x6000 65 | S_IFREG = 0x8000 66 | S_IFLNK = 0xa000 67 | S_IFSOCK = 0xc000 68 | S_ISUID = 0x800 69 | S_ISGID = 0x400 70 | S_ISVTX = 0x200 71 | S_IRUSR = 0x100 72 | S_IWUSR = 0x80 73 | S_IXUSR = 0x40 74 | ) 75 | 76 | type Stat_t struct { 77 | Ino uint64 78 | Nlink uint32 79 | Dev uint32 80 | Mode uint16 81 | Padding1 uint16 82 | Uid uint32 83 | Gid uint32 84 | Rdev uint32 85 | Atim Timespec 86 | Mtim Timespec 87 | Ctim Timespec 88 | Size int64 89 | Blocks int64 90 | Blksize uint32 91 | Flags uint32 92 | Gen uint32 93 | Lspare int32 94 | Qspare1 int64 95 | Qspare2 int64 96 | } 97 | 98 | type Statfs_t struct { 99 | Spare2 int64 100 | Bsize int64 101 | Iosize int64 102 | Blocks int64 103 | Bfree int64 104 | Bavail int64 105 | Files int64 106 | Ffree int64 107 | Fsid Fsid 108 | Owner uint32 109 | Type int32 110 | Flags int32 111 | Pad_cgo_0 [4]byte 112 | Syncwrites int64 113 | Asyncwrites int64 114 | Fstypename [16]int8 115 | Mntonname [80]int8 116 | Syncreads int64 117 | Asyncreads int64 118 | Spares1 int16 119 | Mntfromname [80]int8 120 | Spares2 int16 121 | Pad_cgo_1 [4]byte 122 | Spare [2]int64 123 | } 124 | 125 | type Flock_t struct { 126 | Start int64 127 | Len int64 128 | Pid int32 129 | Type int16 130 | Whence int16 131 | } 132 | 133 | type Dirent struct { 134 | Fileno uint64 135 | Namlen uint16 136 | Type uint8 137 | Unused1 uint8 138 | Unused2 uint32 139 | Name [256]int8 140 | } 141 | 142 | type Fsid struct { 143 | Val [2]int32 144 | } 145 | 146 | type RawSockaddrInet4 struct { 147 | Len uint8 148 | Family uint8 149 | Port uint16 150 | Addr [4]byte /* in_addr */ 151 | Zero [8]int8 152 | } 153 | 154 | type RawSockaddrInet6 struct { 155 | Len uint8 156 | Family uint8 157 | Port uint16 158 | Flowinfo uint32 159 | Addr [16]byte /* in6_addr */ 160 | Scope_id uint32 161 | } 162 | 163 | type RawSockaddrUnix struct { 164 | Len uint8 165 | Family uint8 166 | Path [104]int8 167 | } 168 | 169 | type RawSockaddrDatalink struct { 170 | Len uint8 171 | Family uint8 172 | Index uint16 173 | Type uint8 174 | Nlen uint8 175 | Alen uint8 176 | Slen uint8 177 | Data [12]int8 178 | Rcf uint16 179 | Route [16]uint16 180 | } 181 | 182 | type RawSockaddr struct { 183 | Len uint8 184 | Family uint8 185 | Data [14]int8 186 | } 187 | 188 | type RawSockaddrAny struct { 189 | Addr RawSockaddr 190 | Pad [92]int8 191 | } 192 | 193 | type _Socklen uint32 194 | 195 | type Linger struct { 196 | Onoff int32 197 | Linger int32 198 | } 199 | 200 | type Iovec struct { 201 | Base *byte 202 | Len uint64 203 | } 204 | 205 | type IPMreq struct { 206 | Multiaddr [4]byte /* in_addr */ 207 | Interface [4]byte /* in_addr */ 208 | } 209 | 210 | type IPv6Mreq struct { 211 | Multiaddr [16]byte /* in6_addr */ 212 | Interface uint32 213 | } 214 | 215 | type Msghdr struct { 216 | Name *byte 217 | Namelen uint32 218 | Pad_cgo_0 [4]byte 219 | Iov *Iovec 220 | Iovlen int32 221 | Pad_cgo_1 [4]byte 222 | Control *byte 223 | Controllen uint32 224 | Flags int32 225 | } 226 | 227 | type Cmsghdr struct { 228 | Len uint32 229 | Level int32 230 | Type int32 231 | } 232 | 233 | type Inet6Pktinfo struct { 234 | Addr [16]byte /* in6_addr */ 235 | Ifindex uint32 236 | } 237 | 238 | type IPv6MTUInfo struct { 239 | Addr RawSockaddrInet6 240 | Mtu uint32 241 | } 242 | 243 | type ICMPv6Filter struct { 244 | Filt [8]uint32 245 | } 246 | 247 | const ( 248 | SizeofSockaddrInet4 = 0x10 249 | SizeofSockaddrInet6 = 0x1c 250 | SizeofSockaddrAny = 0x6c 251 | SizeofSockaddrUnix = 0x6a 252 | SizeofSockaddrDatalink = 0x36 253 | SizeofLinger = 0x8 254 | SizeofIPMreq = 0x8 255 | SizeofIPv6Mreq = 0x14 256 | SizeofMsghdr = 0x30 257 | SizeofCmsghdr = 0xc 258 | SizeofInet6Pktinfo = 0x14 259 | SizeofIPv6MTUInfo = 0x20 260 | SizeofICMPv6Filter = 0x20 261 | ) 262 | 263 | const ( 264 | PTRACE_TRACEME = 0x0 265 | PTRACE_CONT = 0x7 266 | PTRACE_KILL = 0x8 267 | ) 268 | 269 | type Kevent_t struct { 270 | Ident uint64 271 | Filter int16 272 | Flags uint16 273 | Fflags uint32 274 | Data int64 275 | Udata *byte 276 | } 277 | 278 | type FdSet struct { 279 | Bits [16]uint64 280 | } 281 | 282 | const ( 283 | SizeofIfMsghdr = 0xb0 284 | SizeofIfData = 0xa0 285 | SizeofIfaMsghdr = 0x14 286 | SizeofIfmaMsghdr = 0x10 287 | SizeofIfAnnounceMsghdr = 0x18 288 | SizeofRtMsghdr = 0x98 289 | SizeofRtMetrics = 0x70 290 | ) 291 | 292 | type IfMsghdr struct { 293 | Msglen uint16 294 | Version uint8 295 | Type uint8 296 | Addrs int32 297 | Flags int32 298 | Index uint16 299 | Pad_cgo_0 [2]byte 300 | Data IfData 301 | } 302 | 303 | type IfData struct { 304 | Type uint8 305 | Physical uint8 306 | Addrlen uint8 307 | Hdrlen uint8 308 | Recvquota uint8 309 | Xmitquota uint8 310 | Pad_cgo_0 [2]byte 311 | Mtu uint64 312 | Metric uint64 313 | Link_state uint64 314 | Baudrate uint64 315 | Ipackets uint64 316 | Ierrors uint64 317 | Opackets uint64 318 | Oerrors uint64 319 | Collisions uint64 320 | Ibytes uint64 321 | Obytes uint64 322 | Imcasts uint64 323 | Omcasts uint64 324 | Iqdrops uint64 325 | Noproto uint64 326 | Hwassist uint64 327 | Unused uint64 328 | Lastchange Timeval 329 | } 330 | 331 | type IfaMsghdr struct { 332 | Msglen uint16 333 | Version uint8 334 | Type uint8 335 | Addrs int32 336 | Flags int32 337 | Index uint16 338 | Pad_cgo_0 [2]byte 339 | Metric int32 340 | } 341 | 342 | type IfmaMsghdr struct { 343 | Msglen uint16 344 | Version uint8 345 | Type uint8 346 | Addrs int32 347 | Flags int32 348 | Index uint16 349 | Pad_cgo_0 [2]byte 350 | } 351 | 352 | type IfAnnounceMsghdr struct { 353 | Msglen uint16 354 | Version uint8 355 | Type uint8 356 | Index uint16 357 | Name [16]int8 358 | What uint16 359 | } 360 | 361 | type RtMsghdr struct { 362 | Msglen uint16 363 | Version uint8 364 | Type uint8 365 | Index uint16 366 | Pad_cgo_0 [2]byte 367 | Flags int32 368 | Addrs int32 369 | Pid int32 370 | Seq int32 371 | Errno int32 372 | Use int32 373 | Inits uint64 374 | Rmx RtMetrics 375 | } 376 | 377 | type RtMetrics struct { 378 | Locks uint64 379 | Mtu uint64 380 | Pksent uint64 381 | Expire uint64 382 | Sendpipe uint64 383 | Ssthresh uint64 384 | Rtt uint64 385 | Rttvar uint64 386 | Recvpipe uint64 387 | Hopcount uint64 388 | Mssopt uint16 389 | Pad uint16 390 | Pad_cgo_0 [4]byte 391 | Msl uint64 392 | Iwmaxsegs uint64 393 | Iwcapsegs uint64 394 | } 395 | 396 | const ( 397 | SizeofBpfVersion = 0x4 398 | SizeofBpfStat = 0x8 399 | SizeofBpfProgram = 0x10 400 | SizeofBpfInsn = 0x8 401 | SizeofBpfHdr = 0x20 402 | ) 403 | 404 | type BpfVersion struct { 405 | Major uint16 406 | Minor uint16 407 | } 408 | 409 | type BpfStat struct { 410 | Recv uint32 411 | Drop uint32 412 | } 413 | 414 | type BpfProgram struct { 415 | Len uint32 416 | Pad_cgo_0 [4]byte 417 | Insns *BpfInsn 418 | } 419 | 420 | type BpfInsn struct { 421 | Code uint16 422 | Jt uint8 423 | Jf uint8 424 | K uint32 425 | } 426 | 427 | type BpfHdr struct { 428 | Tstamp Timeval 429 | Caplen uint32 430 | Datalen uint32 431 | Hdrlen uint16 432 | Pad_cgo_0 [6]byte 433 | } 434 | 435 | type Termios struct { 436 | Iflag uint32 437 | Oflag uint32 438 | Cflag uint32 439 | Lflag uint32 440 | Cc [20]uint8 441 | Ispeed uint32 442 | Ospeed uint32 443 | } 444 | --------------------------------------------------------------------------------