├── .gitignore ├── .travis.yml ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── Makefile ├── README.md ├── README.template.md ├── cmd └── jp │ ├── bar.go │ ├── canvas_other.go │ ├── canvas_windows.go │ ├── csv.go │ ├── flag.go │ ├── hist.go │ ├── hist2d.go │ ├── line.go │ ├── main.go │ ├── scatter.go │ └── split.go ├── docs ├── bar_chart.png ├── bar_chart_full_escape.png ├── hist2d_full_escape.png ├── line_chart.png ├── scatter_plot.png └── sin.png ├── examples ├── eth.csv ├── mvrnorm.json ├── sin.csv ├── sin.json └── tcp-time.json ├── pkg ├── data │ ├── heatmap.go │ ├── histogram.go │ └── table.go ├── draw │ ├── box.go │ ├── braille.go │ ├── buffer.go │ ├── canvas.go │ ├── full.go │ ├── full_escape.go │ ├── heatmap.go │ ├── line.go │ ├── quarter.go │ ├── runes.go │ └── runes_windows.go ├── jsonpath │ ├── LICENSE │ ├── funcs.go │ ├── jsonpath.go │ ├── node.go │ └── parser.go ├── plot │ ├── barchart.go │ ├── format.go │ ├── heatmap.go │ ├── linechart.go │ └── scatterchart.go └── terminal │ ├── terminal.go │ ├── terminal_nosysioctl.go │ └── terminal_sysioctl.go └── vendor └── golang.org └── x └── sys ├── .gitattributes ├── .gitignore ├── AUTHORS ├── CONTRIBUTING.md ├── CONTRIBUTORS ├── LICENSE ├── PATENTS ├── README.md ├── codereview.cfg ├── plan9 ├── asm.s ├── asm_plan9_386.s ├── asm_plan9_amd64.s ├── asm_plan9_arm.s ├── const_plan9.go ├── dir_plan9.go ├── env_plan9.go ├── errors_plan9.go ├── mkall.sh ├── mkerrors.sh ├── mksyscall.pl ├── mksysnum_plan9.sh ├── pwd_go15_plan9.go ├── pwd_plan9.go ├── race.go ├── race0.go ├── str.go ├── syscall.go ├── syscall_plan9.go ├── syscall_test.go ├── zsyscall_plan9_386.go ├── zsyscall_plan9_amd64.go ├── zsyscall_plan9_arm.go └── zsysnum_plan9.go ├── unix ├── .gitignore ├── README.md ├── affinity_linux.go ├── asm_darwin_386.s ├── asm_darwin_amd64.s ├── asm_darwin_arm.s ├── asm_darwin_arm64.s ├── asm_dragonfly_amd64.s ├── asm_freebsd_386.s ├── asm_freebsd_amd64.s ├── asm_freebsd_arm.s ├── asm_linux_386.s ├── asm_linux_amd64.s ├── asm_linux_arm.s ├── asm_linux_arm64.s ├── asm_linux_mips64x.s ├── asm_linux_mipsx.s ├── asm_linux_ppc64x.s ├── asm_linux_s390x.s ├── asm_netbsd_386.s ├── asm_netbsd_amd64.s ├── asm_netbsd_arm.s ├── asm_openbsd_386.s ├── asm_openbsd_amd64.s ├── asm_openbsd_arm.s ├── asm_solaris_amd64.s ├── bluetooth_linux.go ├── cap_freebsd.go ├── constants.go ├── creds_test.go ├── dev_darwin.go ├── dev_darwin_test.go ├── dev_dragonfly.go ├── dev_dragonfly_test.go ├── dev_freebsd.go ├── dev_linux.go ├── dev_linux_test.go ├── dev_netbsd.go ├── dev_netbsd_test.go ├── dev_openbsd.go ├── dev_openbsd_test.go ├── dev_solaris_test.go ├── dirent.go ├── endian_big.go ├── endian_little.go ├── env_unix.go ├── errors_freebsd_386.go ├── errors_freebsd_amd64.go ├── errors_freebsd_arm.go ├── example_test.go ├── export_test.go ├── flock.go ├── flock_linux_32bit.go ├── gccgo.go ├── gccgo_c.c ├── gccgo_linux_amd64.go ├── linux │ ├── Dockerfile │ ├── mkall.go │ ├── mksysnum.pl │ └── types.go ├── mkall.sh ├── mkerrors.sh ├── mkpost.go ├── mksyscall.pl ├── mksyscall_solaris.pl ├── mksysctl_openbsd.pl ├── mksysnum_darwin.pl ├── mksysnum_dragonfly.pl ├── mksysnum_freebsd.pl ├── mksysnum_netbsd.pl ├── mksysnum_openbsd.pl ├── mmap_unix_test.go ├── openbsd_pledge.go ├── openbsd_test.go ├── pagesize_unix.go ├── race.go ├── race0.go ├── sockcmsg_linux.go ├── sockcmsg_unix.go ├── str.go ├── syscall.go ├── syscall_bsd.go ├── syscall_bsd_test.go ├── syscall_darwin.go ├── syscall_darwin_386.go ├── syscall_darwin_amd64.go ├── syscall_darwin_arm.go ├── syscall_darwin_arm64.go ├── syscall_dragonfly.go ├── syscall_dragonfly_amd64.go ├── syscall_freebsd.go ├── syscall_freebsd_386.go ├── syscall_freebsd_amd64.go ├── syscall_freebsd_arm.go ├── syscall_freebsd_test.go ├── syscall_linux.go ├── syscall_linux_386.go ├── syscall_linux_amd64.go ├── syscall_linux_amd64_gc.go ├── syscall_linux_arm.go ├── syscall_linux_arm64.go ├── syscall_linux_gc.go ├── syscall_linux_gccgo.go ├── syscall_linux_mips64x.go ├── syscall_linux_mipsx.go ├── syscall_linux_ppc64x.go ├── syscall_linux_s390x.go ├── syscall_linux_sparc64.go ├── syscall_linux_test.go ├── syscall_netbsd.go ├── syscall_netbsd_386.go ├── syscall_netbsd_amd64.go ├── syscall_netbsd_arm.go ├── syscall_openbsd.go ├── syscall_openbsd_386.go ├── syscall_openbsd_amd64.go ├── syscall_openbsd_arm.go ├── syscall_solaris.go ├── syscall_solaris_amd64.go ├── syscall_solaris_test.go ├── syscall_test.go ├── syscall_unix.go ├── syscall_unix_gc.go ├── syscall_unix_test.go ├── timestruct.go ├── timestruct_test.go ├── types_darwin.go ├── types_dragonfly.go ├── types_freebsd.go ├── types_netbsd.go ├── types_openbsd.go ├── types_solaris.go ├── zerrors_darwin_386.go ├── zerrors_darwin_amd64.go ├── zerrors_darwin_arm.go ├── zerrors_darwin_arm64.go ├── zerrors_dragonfly_amd64.go ├── zerrors_freebsd_386.go ├── zerrors_freebsd_amd64.go ├── zerrors_freebsd_arm.go ├── zerrors_linux_386.go ├── zerrors_linux_amd64.go ├── zerrors_linux_arm.go ├── zerrors_linux_arm64.go ├── zerrors_linux_mips.go ├── zerrors_linux_mips64.go ├── zerrors_linux_mips64le.go ├── zerrors_linux_mipsle.go ├── zerrors_linux_ppc64.go ├── zerrors_linux_ppc64le.go ├── zerrors_linux_s390x.go ├── zerrors_linux_sparc64.go ├── zerrors_netbsd_386.go ├── zerrors_netbsd_amd64.go ├── zerrors_netbsd_arm.go ├── zerrors_openbsd_386.go ├── zerrors_openbsd_amd64.go ├── zerrors_openbsd_arm.go ├── zerrors_solaris_amd64.go ├── zptrace386_linux.go ├── zptracearm_linux.go ├── zptracemips_linux.go ├── zptracemipsle_linux.go ├── zsyscall_darwin_386.go ├── zsyscall_darwin_amd64.go ├── zsyscall_darwin_arm.go ├── zsyscall_darwin_arm64.go ├── zsyscall_dragonfly_amd64.go ├── zsyscall_freebsd_386.go ├── zsyscall_freebsd_amd64.go ├── zsyscall_freebsd_arm.go ├── zsyscall_linux_386.go ├── zsyscall_linux_amd64.go ├── zsyscall_linux_arm.go ├── zsyscall_linux_arm64.go ├── zsyscall_linux_mips.go ├── zsyscall_linux_mips64.go ├── zsyscall_linux_mips64le.go ├── zsyscall_linux_mipsle.go ├── zsyscall_linux_ppc64.go ├── zsyscall_linux_ppc64le.go ├── zsyscall_linux_s390x.go ├── zsyscall_linux_sparc64.go ├── zsyscall_netbsd_386.go ├── zsyscall_netbsd_amd64.go ├── zsyscall_netbsd_arm.go ├── zsyscall_openbsd_386.go ├── zsyscall_openbsd_amd64.go ├── zsyscall_openbsd_arm.go ├── zsyscall_solaris_amd64.go ├── zsysctl_openbsd_386.go ├── zsysctl_openbsd_amd64.go ├── zsysctl_openbsd_arm.go ├── zsysnum_darwin_386.go ├── zsysnum_darwin_amd64.go ├── zsysnum_darwin_arm.go ├── zsysnum_darwin_arm64.go ├── zsysnum_dragonfly_amd64.go ├── zsysnum_freebsd_386.go ├── zsysnum_freebsd_amd64.go ├── zsysnum_freebsd_arm.go ├── zsysnum_linux_386.go ├── zsysnum_linux_amd64.go ├── zsysnum_linux_arm.go ├── zsysnum_linux_arm64.go ├── zsysnum_linux_mips.go ├── zsysnum_linux_mips64.go ├── zsysnum_linux_mips64le.go ├── zsysnum_linux_mipsle.go ├── zsysnum_linux_ppc64.go ├── zsysnum_linux_ppc64le.go ├── zsysnum_linux_s390x.go ├── zsysnum_linux_sparc64.go ├── zsysnum_netbsd_386.go ├── zsysnum_netbsd_amd64.go ├── zsysnum_netbsd_arm.go ├── zsysnum_openbsd_386.go ├── zsysnum_openbsd_amd64.go ├── zsysnum_openbsd_arm.go ├── ztypes_darwin_386.go ├── ztypes_darwin_amd64.go ├── ztypes_darwin_arm.go ├── ztypes_darwin_arm64.go ├── ztypes_dragonfly_amd64.go ├── ztypes_freebsd_386.go ├── ztypes_freebsd_amd64.go ├── ztypes_freebsd_arm.go ├── ztypes_linux_386.go ├── ztypes_linux_amd64.go ├── ztypes_linux_arm.go ├── ztypes_linux_arm64.go ├── ztypes_linux_mips.go ├── ztypes_linux_mips64.go ├── ztypes_linux_mips64le.go ├── ztypes_linux_mipsle.go ├── ztypes_linux_ppc64.go ├── ztypes_linux_ppc64le.go ├── ztypes_linux_s390x.go ├── ztypes_linux_sparc64.go ├── ztypes_netbsd_386.go ├── ztypes_netbsd_amd64.go ├── ztypes_netbsd_arm.go ├── ztypes_openbsd_386.go ├── ztypes_openbsd_amd64.go ├── ztypes_openbsd_arm.go └── ztypes_solaris_amd64.go └── windows ├── asm_windows_386.s ├── asm_windows_amd64.s ├── dll_windows.go ├── env_windows.go ├── eventlog.go ├── exec_windows.go ├── memory_windows.go ├── mksyscall.go ├── race.go ├── race0.go ├── registry ├── export_test.go ├── key.go ├── mksyscall.go ├── registry_test.go ├── syscall.go ├── value.go └── zsyscall_windows.go ├── security_windows.go ├── service.go ├── str.go ├── svc ├── debug │ ├── log.go │ └── service.go ├── event.go ├── eventlog │ ├── install.go │ ├── log.go │ └── log_test.go ├── example │ ├── beep.go │ ├── install.go │ ├── main.go │ ├── manage.go │ └── service.go ├── go12.c ├── go12.go ├── go13.go ├── mgr │ ├── config.go │ ├── mgr.go │ ├── mgr_test.go │ └── service.go ├── security.go ├── service.go ├── svc_test.go ├── sys_386.s └── sys_amd64.s ├── syscall.go ├── syscall_test.go ├── syscall_windows.go ├── syscall_windows_test.go ├── types_windows.go ├── types_windows_386.go ├── types_windows_amd64.go └── zsyscall_windows.go /.gitignore: -------------------------------------------------------------------------------- 1 | /*.json 2 | /*.csv 3 | /binaries/ 4 | /release/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - "1.10" 4 | script: make zip README.md 5 | deploy: 6 | provider: releases 7 | api_key: 8 | secure: "ZFj9EipPgHU5RLyzgOXx+dI4P3UOgwHb//dplU5YIQaSoaYutdakhmzqxVjwHl5UxyNGnUiUaaPS1TG+rfW3fV2ENA7+WTxGZCxPidLC2XQgMKfQyabGxA460A7VPdY8X1nVz2mZnbGa8VRNaI2Z8838Imivo1biKo07bySU850JsU0OFezZqDpC3I0TLsvBnLWszFjJxCUIPvrlQTZsAmtBtNPqmTuJB5HxPKKFaB1ScKmZT91MxBrdkn+s2jmv+ucSe4gz+ktnS2htfzDkbXBbFGVTA1FVXgIHyq/ErVLjC5RFOPXn4bv6HOSqfQ5X78ICQ3BdIPoq7XJt4goH1fBDe2xBLG/HKGZRe8nS7AuJb+DAlcl3qJp1miUldVNF9o0sjvYaw0rrhcRwXm6bR4HVQ34/9zGU4OxQMMRIMOGEIi5dnE9bcC0gyeqBkyI+zCwAGhZt5GfXpSzxSUfhSW3GkiuVVoZctpwRo+snbf+RzThDxuXe1ipHj7djkGs6YdLgEHXOnVF0lVrDH6sciiN+i4CDlHZqypERLVfcSAwOgz6Ulie54dW0CHj6y9IAz75LsphlSa2SUN8YLPeKPptvFhEiMGEC/KRWIws+h3o2lv1ff8DpK3sgf1IIKwPduZnCu5YNDc60qGiGtCc0v/MT+ykYV5aAJtbuWYG0+Ng=" 9 | file_glob: true 10 | file: release/* 11 | skip_cleanup: true 12 | on: 13 | tags: true -------------------------------------------------------------------------------- /Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | branch = "master" 6 | name = "golang.org/x/sys" 7 | packages = ["unix"] 8 | revision = "c488ab1dd8481ef762f96a79a9577c27825be697" 9 | 10 | [solve-meta] 11 | analyzer-name = "dep" 12 | analyzer-version = 1 13 | inputs-digest = "908c5eaf175d5ae62e87c6b9deb05d4c06725db8681b0071110c30c067c1a2f2" 14 | solver-name = "gps-cdcl" 15 | solver-version = 1 16 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgreben/jp/5e551d10fba930729382096bdf0034901b0b7fe3/Gopkg.toml -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Sergey Grebenshchikov 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 | -------------------------------------------------------------------------------- /cmd/jp/bar.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "reflect" 7 | 8 | "github.com/sgreben/jp/pkg/data" 9 | "github.com/sgreben/jp/pkg/draw" 10 | "github.com/sgreben/jp/pkg/plot" 11 | ) 12 | 13 | func barPlotData(xv, yv []reflect.Value) (x []string, y []float64) { 14 | for i := range xv { 15 | if xv[i].IsValid() && xv[i].CanInterface() { 16 | x = append(x, fmt.Sprint(xv[i].Interface())) 17 | } 18 | } 19 | for i := range yv { 20 | if yv[i].IsValid() && yv[i].CanInterface() { 21 | yvi, ok := yv[i].Interface().(float64) 22 | if ok { 23 | y = append(y, yvi) 24 | } 25 | } 26 | } 27 | return 28 | } 29 | 30 | func barPlot(xv, yv []reflect.Value, c draw.Canvas) string { 31 | groups, y := barPlotData(xv, yv) 32 | chart := plot.NewBarChart(c) 33 | data := new(data.Table) 34 | if len(y) == 0 { 35 | log.Fatal("no valid y values given") 36 | } 37 | if len(groups) != len(y) { 38 | for i := range y { 39 | data.AddColumn(fmt.Sprint(i)) 40 | } 41 | } else { 42 | for _, g := range groups { 43 | data.AddColumn(g) 44 | } 45 | } 46 | data.AddRow(y...) 47 | return chart.Draw(data) 48 | } 49 | -------------------------------------------------------------------------------- /cmd/jp/canvas_other.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package main 4 | 5 | var autoCanvas = map[string]string{ 6 | plotTypeBar: canvasTypeQuarter, 7 | plotTypeLine: canvasTypeQuarter, 8 | plotTypeScatter: canvasTypeBraille, 9 | plotTypeHist: canvasTypeQuarter, 10 | plotTypeHist2D: canvasTypeFull, 11 | } 12 | -------------------------------------------------------------------------------- /cmd/jp/canvas_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package main 4 | 5 | var autoCanvas = map[string]string{ 6 | plotTypeBar: canvasTypeFull, 7 | plotTypeLine: canvasTypeFull, 8 | plotTypeScatter: canvasTypeFull, 9 | plotTypeHist: canvasTypeFull, 10 | plotTypeHist2D: canvasTypeFull, 11 | } 12 | -------------------------------------------------------------------------------- /cmd/jp/csv.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "strconv" 4 | 5 | func parseCell(cell string) interface{} { 6 | f, err := strconv.ParseFloat(cell, 64) 7 | if err == nil { 8 | return f 9 | } 10 | b, err := strconv.ParseBool(cell) 11 | if err == nil { 12 | if b { 13 | return 1 14 | } 15 | return 0 16 | } 17 | return cell 18 | } 19 | 20 | func parseRows(rows [][]string) (out [][]interface{}) { 21 | out = make([][]interface{}, len(rows)) 22 | for i, row := range rows { 23 | out[i] = make([]interface{}, len(row)) 24 | for j, cell := range row { 25 | out[i][j] = parseCell(cell) 26 | } 27 | } 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /cmd/jp/flag.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | type enumVar struct { 9 | Choices []string 10 | Value string 11 | } 12 | 13 | // Set implements the flag.Value interface. 14 | func (so *enumVar) Set(v string) error { 15 | for _, c := range so.Choices { 16 | if c == v { 17 | so.Value = v 18 | return nil 19 | } 20 | } 21 | return fmt.Errorf("must be one of [%s]", strings.Join(so.Choices, " ")) 22 | } 23 | 24 | func (so *enumVar) String() string { 25 | return so.Value 26 | } 27 | -------------------------------------------------------------------------------- /cmd/jp/hist.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "reflect" 6 | 7 | "github.com/sgreben/jp/pkg/data" 8 | "github.com/sgreben/jp/pkg/draw" 9 | "github.com/sgreben/jp/pkg/plot" 10 | ) 11 | 12 | func histogramData(xv []reflect.Value, nbins uint) (groups []string, counts []float64) { 13 | var x []float64 14 | for i := range xv { 15 | if xv[i].IsValid() && xv[i].CanInterface() { 16 | xvi, ok := xv[i].Interface().(float64) 17 | if ok { 18 | x = append(x, xvi) 19 | } 20 | } 21 | } 22 | if len(x) == 0 { 23 | log.Fatal("no valid x values given") 24 | } 25 | bins := data.NewBins(x) 26 | bins.Number = int(nbins) 27 | if nbins == 0 { 28 | bins.Number = data.BinsSturges(len(x)) 29 | } 30 | hist := data.Histogram(x, bins) 31 | groups = make([]string, len(hist)) 32 | counts = make([]float64, len(hist)) 33 | for i, b := range hist { 34 | groups[i] = b.String() 35 | counts[i] = float64(b.Count) 36 | } 37 | return 38 | } 39 | 40 | func histogram(xv []reflect.Value, c draw.Canvas, nbins uint) string { 41 | groups, counts := histogramData(xv, nbins) 42 | chart := plot.NewBarChart(c) 43 | chart.BarPaddingX = 0 44 | data := new(data.Table) 45 | for _, g := range groups { 46 | data.AddColumn(g) 47 | } 48 | data.AddRow(counts...) 49 | return chart.Draw(data) 50 | } 51 | -------------------------------------------------------------------------------- /cmd/jp/hist2d.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "reflect" 6 | 7 | "github.com/sgreben/jp/pkg/data" 8 | "github.com/sgreben/jp/pkg/draw" 9 | "github.com/sgreben/jp/pkg/plot" 10 | ) 11 | 12 | func hist2DData(xv, yv []reflect.Value, nbins uint) (heatmap *data.Heatmap) { 13 | var x, y []float64 14 | for i := range xv { 15 | if xv[i].IsValid() && xv[i].CanInterface() { 16 | xvi, ok := xv[i].Interface().(float64) 17 | if ok { 18 | x = append(x, xvi) 19 | } 20 | } 21 | } 22 | for i := range yv { 23 | if yv[i].IsValid() && yv[i].CanInterface() { 24 | yvi, ok := yv[i].Interface().(float64) 25 | if ok { 26 | y = append(y, yvi) 27 | } 28 | } 29 | } 30 | if len(x) != len(y) { 31 | log.Fatal(len(x), " = len(x) != len(y) = ", len(y)) 32 | } 33 | points := make([][2]float64, len(x)) 34 | for i := 0; i < len(x); i++ { 35 | points[i] = [2]float64{x[i], y[i]} 36 | } 37 | if len(x) == 0 { 38 | log.Fatal("no valid x values given") 39 | } 40 | bins := data.NewBins2D(points) 41 | bins.X.Number = int(nbins) 42 | bins.Y.Number = int(nbins) 43 | if nbins == 0 { 44 | bins.X.Number = data.BinsSturges(len(points)) 45 | bins.Y.Number = data.BinsSturges(len(points)) 46 | } 47 | heatmap = data.NewHeatmap(data.Histogram2D(points, bins)) 48 | return 49 | } 50 | 51 | func hist2D(xv, yv []reflect.Value, c draw.Canvas, nbins uint) string { 52 | heatmap := hist2DData(xv, yv, nbins) 53 | chart := plot.NewHeatMap(c.GetBuffer()) 54 | return chart.Draw(heatmap) 55 | } 56 | -------------------------------------------------------------------------------- /cmd/jp/line.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "reflect" 6 | 7 | "github.com/sgreben/jp/pkg/data" 8 | "github.com/sgreben/jp/pkg/draw" 9 | 10 | "github.com/sgreben/jp/pkg/plot" 11 | ) 12 | 13 | func linePlotData(xv, yv []reflect.Value) (x, y []float64) { 14 | for i := range xv { 15 | if xv[i].IsValid() && xv[i].CanInterface() { 16 | xvi, ok := xv[i].Interface().(float64) 17 | if ok { 18 | x = append(x, xvi) 19 | } 20 | } 21 | } 22 | for i := range yv { 23 | if yv[i].IsValid() && yv[i].CanInterface() { 24 | yvi, ok := yv[i].Interface().(float64) 25 | if ok { 26 | y = append(y, yvi) 27 | } 28 | } 29 | } 30 | return 31 | } 32 | 33 | func linePlot(xv, yv []reflect.Value, c draw.Canvas) string { 34 | x, y := linePlotData(xv, yv) 35 | chart := plot.NewLineChart(c) 36 | data := new(data.Table) 37 | data.AddColumn("x") 38 | data.AddColumn("y") 39 | n := len(x) 40 | if len(y) > n { 41 | n = len(y) 42 | } 43 | if len(y) == 0 { 44 | log.Fatal("no valid y values given") 45 | } 46 | // If no valid xs are given, use the indices as x values. 47 | if len(x) == 0 { 48 | x = make([]float64, len(y)) 49 | for i := 0; i < len(y); i++ { 50 | x[i] = float64(i) 51 | } 52 | } 53 | for i := 0; i < n; i++ { 54 | data.AddRow(x[i%len(x)], y[i%len(y)]) 55 | } 56 | return chart.Draw(data) 57 | } 58 | -------------------------------------------------------------------------------- /cmd/jp/scatter.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "reflect" 6 | 7 | "github.com/sgreben/jp/pkg/data" 8 | "github.com/sgreben/jp/pkg/draw" 9 | "github.com/sgreben/jp/pkg/plot" 10 | ) 11 | 12 | func scatterPlotData(xv, yv []reflect.Value) (x, y []float64) { 13 | for i := range xv { 14 | if xv[i].IsValid() && xv[i].CanInterface() { 15 | xvi, ok := xv[i].Interface().(float64) 16 | if ok { 17 | x = append(x, xvi) 18 | } 19 | } 20 | } 21 | for i := range yv { 22 | if yv[i].IsValid() && yv[i].CanInterface() { 23 | yvi, ok := yv[i].Interface().(float64) 24 | if ok { 25 | y = append(y, yvi) 26 | } 27 | } 28 | } 29 | return 30 | } 31 | 32 | func scatterPlot(xv, yv []reflect.Value, c draw.Canvas) string { 33 | x, y := scatterPlotData(xv, yv) 34 | chart := plot.NewScatterChart(c) 35 | data := new(data.Table) 36 | data.AddColumn("x") 37 | data.AddColumn("y") 38 | n := len(x) 39 | if len(y) > n { 40 | n = len(y) 41 | } 42 | if len(y) == 0 { 43 | log.Fatal("no valid y values given") 44 | } 45 | // If no valid xs are given, use the indices as x values. 46 | if len(x) == 0 { 47 | x = make([]float64, len(y)) 48 | for i := 0; i < len(y); i++ { 49 | x[i] = float64(i) 50 | } 51 | } 52 | for i := 0; i < n; i++ { 53 | data.AddRow(x[i%len(x)], y[i%len(y)]) 54 | } 55 | return chart.Draw(data) 56 | } 57 | -------------------------------------------------------------------------------- /cmd/jp/split.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "reflect" 4 | 5 | var indexableKind = map[reflect.Kind]bool{ 6 | reflect.Slice: true, 7 | reflect.Array: true, 8 | } 9 | 10 | func flatten(in [][]reflect.Value) (out []reflect.Value) { 11 | for _, a := range in { 12 | for _, v := range a { 13 | if !v.IsValid() { 14 | continue 15 | } 16 | if indexableKind[v.Kind()] { 17 | sub := make([]reflect.Value, v.Len()) 18 | for j := 0; j < v.Len(); j++ { 19 | sub = append(sub, v.Index(j)) 20 | } 21 | out = append(out, flatten([][]reflect.Value{sub})...) 22 | continue 23 | } 24 | if v.CanInterface() { 25 | if sub, ok := v.Interface().([]interface{}); ok { 26 | for i := range sub { 27 | out = append(out, reflect.ValueOf(sub[i])) 28 | } 29 | continue 30 | } 31 | } 32 | out = append(out, v) 33 | } 34 | } 35 | return 36 | } 37 | 38 | func split(in [][]reflect.Value) (x, y []reflect.Value) { 39 | flat := flatten(in) 40 | n := len(flat) 41 | x = make([]reflect.Value, 0, n/2) 42 | y = make([]reflect.Value, 0, n/2) 43 | for i := range flat { 44 | if i&1 == 0 { 45 | x = append(x, flat[i]) 46 | } else { 47 | y = append(y, flat[i]) 48 | } 49 | } 50 | return 51 | } 52 | -------------------------------------------------------------------------------- /docs/bar_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgreben/jp/5e551d10fba930729382096bdf0034901b0b7fe3/docs/bar_chart.png -------------------------------------------------------------------------------- /docs/bar_chart_full_escape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgreben/jp/5e551d10fba930729382096bdf0034901b0b7fe3/docs/bar_chart_full_escape.png -------------------------------------------------------------------------------- /docs/hist2d_full_escape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgreben/jp/5e551d10fba930729382096bdf0034901b0b7fe3/docs/hist2d_full_escape.png -------------------------------------------------------------------------------- /docs/line_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgreben/jp/5e551d10fba930729382096bdf0034901b0b7fe3/docs/line_chart.png -------------------------------------------------------------------------------- /docs/scatter_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgreben/jp/5e551d10fba930729382096bdf0034901b0b7fe3/docs/scatter_plot.png -------------------------------------------------------------------------------- /docs/sin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgreben/jp/5e551d10fba930729382096bdf0034901b0b7fe3/docs/sin.png -------------------------------------------------------------------------------- /pkg/data/heatmap.go: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | import "math" 4 | 5 | type Heatmap struct { 6 | X, Y []Bin 7 | Z [][]float64 8 | MinX, MaxX uint64 9 | MinY, MaxY uint64 10 | MinZ, MaxZ uint64 11 | } 12 | 13 | func NewHeatmap(x, y []Bin, z [][]uint64) *Heatmap { 14 | h := new(Heatmap) 15 | h.X, h.Y = x, y 16 | h.Z = make([][]float64, len(z)) 17 | h.MinX, h.MinY, h.MinZ = math.MaxUint64, math.MaxUint64, math.MaxUint64 18 | h.MaxX, h.MaxY, h.MaxZ = 0, 0, 0 19 | for _, b := range x { 20 | if b.Count > h.MaxX { 21 | h.MaxX = b.Count 22 | } 23 | if b.Count < h.MinX { 24 | h.MinX = b.Count 25 | } 26 | } 27 | for _, b := range x { 28 | b.CountNorm = float64(b.Count-h.MinX) / float64(h.MaxX-h.MinX) 29 | } 30 | for _, b := range y { 31 | if b.Count > h.MaxY { 32 | h.MaxY = b.Count 33 | } 34 | if b.Count < h.MinY { 35 | h.MinY = b.Count 36 | } 37 | } 38 | for _, b := range y { 39 | b.CountNorm = float64(b.Count-h.MinY) / float64(h.MaxY-h.MinY) 40 | } 41 | for i := range z { 42 | h.Z[i] = make([]float64, len(z[i])) 43 | for _, b := range z[i] { 44 | if b > h.MaxZ { 45 | h.MaxZ = b 46 | } 47 | if b < h.MinZ { 48 | h.MinZ = b 49 | } 50 | } 51 | } 52 | for i := range z { 53 | for j := range z[i] { 54 | h.Z[i][j] = float64(z[i][j]-h.MinZ) / float64(h.MaxZ-h.MinZ) 55 | } 56 | } 57 | if h.MaxX == 0 { 58 | h.MaxX = 1 59 | } 60 | if h.MaxY == 0 { 61 | h.MaxY = 1 62 | } 63 | if h.MaxZ == 0 { 64 | h.MaxZ = 1 65 | } 66 | 67 | return h 68 | } 69 | -------------------------------------------------------------------------------- /pkg/data/table.go: -------------------------------------------------------------------------------- 1 | package data 2 | 3 | type Table struct { 4 | Columns []string 5 | Rows [][]float64 6 | } 7 | 8 | func (d *Table) AddColumn(name string) { 9 | d.Columns = append(d.Columns, name) 10 | } 11 | 12 | func (d *Table) AddRow(elms ...float64) { 13 | d.Rows = append(d.Rows, elms) 14 | } 15 | -------------------------------------------------------------------------------- /pkg/draw/box.go: -------------------------------------------------------------------------------- 1 | package draw 2 | 3 | type Box struct { 4 | Width int 5 | Height int 6 | } 7 | -------------------------------------------------------------------------------- /pkg/draw/braille.go: -------------------------------------------------------------------------------- 1 | package draw 2 | 3 | var _ Pixels = &Braille{} 4 | 5 | const ( 6 | brailleScaleX = 2 7 | brailleScaleY = 4 8 | brailleEmpty = rune(0x2800) 9 | ) 10 | 11 | type Braille struct{ *Buffer } 12 | 13 | func (b *Braille) Size() Box { 14 | return Box{ 15 | Width: b.Width * brailleScaleX, 16 | Height: b.Height * brailleScaleY, 17 | } 18 | } 19 | 20 | func (b *Braille) Clear() { b.Fill(brailleEmpty) } 21 | 22 | func (b *Braille) Set(y, x int) { 23 | ry := y / brailleScaleY 24 | rx := x / brailleScaleX 25 | b.SetOr(ry, rx, braillePoint(y, x)) 26 | } 27 | 28 | func braillePoint(y, x int) rune { 29 | var cy, cx int 30 | if y >= 0 { 31 | cy = y % 4 32 | } else { 33 | cy = 3 + ((y + 1) % 4) 34 | } 35 | if x >= 0 { 36 | cx = x % 2 37 | } else { 38 | cx = 1 + ((x + 1) % 2) 39 | } 40 | pixelMap := [4][2]rune{{1, 8}, {2, 16}, {4, 32}, {64, 128}} 41 | return pixelMap[3-cy][cx] 42 | } 43 | -------------------------------------------------------------------------------- /pkg/draw/buffer.go: -------------------------------------------------------------------------------- 1 | package draw 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | type Buffer struct { 8 | Runes [][]rune 9 | Box 10 | } 11 | 12 | func (b *Buffer) GetBuffer() *Buffer { return b } 13 | 14 | func NewBuffer(size Box) *Buffer { 15 | r := make([][]rune, size.Height) 16 | for i := range r { 17 | r[i] = make([]rune, size.Width) 18 | } 19 | return &Buffer{ 20 | Runes: r, 21 | Box: size, 22 | } 23 | } 24 | 25 | func (b *Buffer) Fill(r rune) { 26 | for i := range b.Runes { 27 | for j := range b.Runes[i] { 28 | b.Runes[i][j] = r 29 | } 30 | } 31 | } 32 | 33 | func (b *Buffer) Get(y, x int) rune { 34 | if y < 0 || y >= b.Height { 35 | return 0 36 | } 37 | if x < 0 || x >= b.Width { 38 | return 0 39 | } 40 | return b.Runes[y][x] 41 | } 42 | 43 | func (b *Buffer) Set(y, x int, r rune) { 44 | if y < 0 || y >= b.Height { 45 | return 46 | } 47 | if x < 0 || x >= b.Width { 48 | return 49 | } 50 | b.Runes[y][x] = r 51 | } 52 | 53 | func (b *Buffer) SetRow(y, x1, x2 int, r rune) { 54 | for i := x1; i < x2; i++ { 55 | b.Set(y, i, r) 56 | } 57 | } 58 | 59 | func (b *Buffer) SetColumn(y1, y2, x int, r rune) { 60 | for i := y1; i < y2; i++ { 61 | b.Set(i, x, r) 62 | } 63 | } 64 | 65 | func (b *Buffer) SetOr(y, x int, r rune) { 66 | if y < 0 || y >= b.Height { 67 | return 68 | } 69 | if x < 0 || x >= b.Width { 70 | return 71 | } 72 | b.Runes[y][x] |= r 73 | } 74 | 75 | func (b *Buffer) Write(y, x int, r []rune) { 76 | if y < 0 || y >= b.Height { 77 | return 78 | } 79 | for i := 0; i < len(r); i++ { 80 | xi := x + i 81 | if xi < 0 || xi >= b.Width { 82 | continue 83 | } 84 | b.Runes[y][xi] = r[i] 85 | } 86 | } 87 | 88 | func (b *Buffer) WriteLeft(y, x int, r []rune) { 89 | b.Write(y, x-len(r), r) 90 | } 91 | 92 | func (b *Buffer) WriteRight(y, x int, r []rune) { 93 | b.Write(y, x, r) 94 | } 95 | 96 | func (b *Buffer) WriteCenter(y, x int, r []rune) { 97 | b.Write(y, x-len(r)/2, r) 98 | } 99 | 100 | func (b *Buffer) Render(w io.Writer) { 101 | for i := range b.Runes { 102 | row := b.Runes[b.Height-i-1] 103 | w.Write([]byte(string(row))) 104 | if i < b.Height-1 { 105 | w.Write([]byte{'\n'}) 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /pkg/draw/canvas.go: -------------------------------------------------------------------------------- 1 | package draw 2 | 3 | type Pixels interface { 4 | GetBuffer() *Buffer 5 | Clear() 6 | Set(y, x int) 7 | Size() Box 8 | } 9 | 10 | type Canvas struct{ Pixels } 11 | 12 | func (c *Canvas) RuneSize() Box { 13 | pixelBox := c.Size() 14 | runeBox := c.GetBuffer().Box 15 | return Box{ 16 | Width: pixelBox.Width / runeBox.Width, 17 | Height: pixelBox.Height / runeBox.Height, 18 | } 19 | } 20 | 21 | func (c *Canvas) DrawLine(y0, x0, y1, x1 int) { 22 | line(y0, x0, y1, x1, c.Set) 23 | } 24 | -------------------------------------------------------------------------------- /pkg/draw/full.go: -------------------------------------------------------------------------------- 1 | package draw 2 | 3 | var _ Pixels = &Full{} 4 | 5 | const fullBlock = '█' 6 | 7 | type Full struct{ *Buffer } 8 | 9 | func (b *Full) Size() Box { return b.Box } 10 | 11 | func (b *Full) Set(y, x int) { b.Buffer.Set(y, x, fullBlock) } 12 | 13 | func (b *Full) Clear() { b.Fill(' ') } 14 | -------------------------------------------------------------------------------- /pkg/draw/full_escape.go: -------------------------------------------------------------------------------- 1 | package draw 2 | 3 | import "strings" 4 | 5 | var invertEscape = replacer(map[rune]string{ 6 | '█': "\033[7m \033[27m", 7 | }) 8 | 9 | var colorEscapeBW = replacer(map[rune]string{ 10 | '█': "\033[48;5;231m \033[49m", 11 | '▓': "\033[48;5;252m \033[49m", 12 | '▒': "\033[48;5;248m \033[49m", 13 | '░': "\033[48;5;240m \033[49m", 14 | '·': "\033[48;5;236m \033[49m", 15 | ' ': "\033[48;5;232m ", 16 | }) 17 | 18 | var colorEscapeWB = replacer(map[rune]string{ 19 | '█': "\033[48;5;232m \033[49m", 20 | '▓': "\033[48;5;236m \033[49m", 21 | '▒': "\033[48;5;240m \033[49m", 22 | '░': "\033[48;5;248m \033[49m", 23 | '·': "\033[48;5;252m \033[49m", 24 | ' ': "\033[48;5;231m ", 25 | }) 26 | 27 | func replacer(m map[rune]string) *strings.Replacer { 28 | r := make([]string, 0, len(m)*2) 29 | for old, new := range m { 30 | r = append(r, string(old)) 31 | r = append(r, new) 32 | } 33 | return strings.NewReplacer(r...) 34 | } 35 | 36 | func FullEscape(full string) string { 37 | return invertEscape.Replace(full) 38 | } 39 | 40 | func FullEscapeBW(full string) string { 41 | return colorEscapeBW.Replace(full) 42 | } 43 | 44 | func FullEscapeWB(full string) string { 45 | return colorEscapeWB.Replace(full) 46 | } 47 | -------------------------------------------------------------------------------- /pkg/draw/heatmap.go: -------------------------------------------------------------------------------- 1 | package draw 2 | 3 | type Heatmap struct{ *Buffer } 4 | 5 | func (b *Heatmap) Size() Box { return b.Box } 6 | 7 | var shades = []rune(" ·░▒▒▒▒▓▓▓▓█") 8 | var nonZeroShade = 1.0 / float64(len(shades)-1) 9 | 10 | func (b *Heatmap) Set(y, x int, fill float64) { 11 | if fill < 0.0 { 12 | fill = 0.0 13 | } 14 | if fill > 0.0 && fill < nonZeroShade { 15 | fill = nonZeroShade 16 | } 17 | if fill > 1.0 { 18 | fill = 1.0 19 | } 20 | b.Buffer.Set(y, x, shades[int(fill*float64(len(shades)-1))]) 21 | } 22 | 23 | func (b *Heatmap) Clear() { b.Fill(shades[0]) } 24 | -------------------------------------------------------------------------------- /pkg/draw/line.go: -------------------------------------------------------------------------------- 1 | package draw 2 | 3 | // Adapted from https://github.com/buger/goterm under the MIT License. 4 | 5 | /* 6 | MIT License 7 | 8 | Copyright (c) 2016 Leonid Bugaev 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | */ 29 | 30 | func line(y0, x0, y1, x1 int, plot func(y, x int)) { 31 | dx := x1 - x0 32 | if dx < 0 { 33 | dx = -dx 34 | } 35 | dy := y1 - y0 36 | if dy < 0 { 37 | dy = -dy 38 | } 39 | var sx, sy int 40 | if x0 < x1 { 41 | sx = 1 42 | } else { 43 | sx = -1 44 | } 45 | if y0 < y1 { 46 | sy = 1 47 | } else { 48 | sy = -1 49 | } 50 | err := dx - dy 51 | 52 | for { 53 | plot(y0, x0) 54 | if x0 == x1 && y0 == y1 { 55 | break 56 | } 57 | e2 := 2 * err 58 | if e2 > -dy { 59 | err -= dy 60 | x0 += sx 61 | } 62 | if e2 < dx { 63 | err += dx 64 | y0 += sy 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /pkg/draw/quarter.go: -------------------------------------------------------------------------------- 1 | package draw 2 | 3 | var _ Pixels = &Quarter{} 4 | 5 | const ( 6 | quarterScaleX = 2 7 | quarterScaleY = 2 8 | ) 9 | 10 | type Quarter struct{ *Buffer } 11 | 12 | func (b *Quarter) Size() Box { 13 | return Box{ 14 | Width: b.Width * quarterScaleX, 15 | Height: b.Height * quarterScaleY, 16 | } 17 | } 18 | 19 | func (b *Quarter) Set(y, x int) { 20 | ry, cy := y/2, 1-y%2 21 | rx, cx := x/2, x%2 22 | i := index(b.Get(ry, rx)) 23 | b.Buffer.Set(ry, rx, runes[i|(1<= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/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 plan9 6 | 7 | // Package plan9 contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display the OS-specific documentation for the current 10 | // system. If you want godoc to display documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // 15 | // The primary use of this package is inside other packages that provide a more 16 | // portable interface to the system, such as "os", "time" and "net". Use 17 | // those packages rather than this one if you can. 18 | // 19 | // For details of the functions and data types in this package consult 20 | // the manuals for the appropriate operating system. 21 | // 22 | // These calls return err == nil to indicate success; otherwise 23 | // err represents an operating system error describing the failure and 24 | // holds a value of type syscall.ErrorString. 25 | package plan9 // import "golang.org/x/sys/plan9" 26 | 27 | import "unsafe" 28 | 29 | // ByteSliceFromString returns a NUL-terminated slice of bytes 30 | // containing the text of s. If s contains a NUL byte at any 31 | // location, it returns (nil, EINVAL). 32 | func ByteSliceFromString(s string) ([]byte, error) { 33 | for i := 0; i < len(s); i++ { 34 | if s[i] == 0 { 35 | return nil, EINVAL 36 | } 37 | } 38 | a := make([]byte, len(s)+1) 39 | copy(a, s) 40 | return a, nil 41 | } 42 | 43 | // BytePtrFromString returns a pointer to a NUL-terminated array of 44 | // bytes containing the text of s. If s contains a NUL byte at any 45 | // location, it returns (nil, EINVAL). 46 | func BytePtrFromString(s string) (*byte, error) { 47 | a, err := ByteSliceFromString(s) 48 | if err != nil { 49 | return nil, err 50 | } 51 | return &a[0], nil 52 | } 53 | 54 | // Single-word zero for use when we need a valid pointer to 0 bytes. 55 | // See mksyscall.pl. 56 | var _zero uintptr 57 | 58 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 59 | return int64(ts.Sec), int64(ts.Nsec) 60 | } 61 | 62 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 63 | return int64(tv.Sec), int64(tv.Usec) * 1000 64 | } 65 | 66 | func (ts *Timespec) Nano() int64 { 67 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 68 | } 69 | 70 | func (tv *Timeval) Nano() int64 { 71 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 72 | } 73 | 74 | // use is a no-op, but the compiler cannot see that it is. 75 | // Calling use(p) ensures that p is kept live until that point. 76 | //go:noescape 77 | func use(p unsafe.Pointer) 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/syscall_test.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 plan9 6 | 7 | package plan9_test 8 | 9 | import ( 10 | "testing" 11 | 12 | "golang.org/x/sys/plan9" 13 | ) 14 | 15 | func testSetGetenv(t *testing.T, key, value string) { 16 | err := plan9.Setenv(key, value) 17 | if err != nil { 18 | t.Fatalf("Setenv failed to set %q: %v", value, err) 19 | } 20 | newvalue, found := plan9.Getenv(key) 21 | if !found { 22 | t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value) 23 | } 24 | if newvalue != value { 25 | t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value) 26 | } 27 | } 28 | 29 | func TestEnv(t *testing.T) { 30 | testSetGetenv(t, "TESTENV", "AVALUE") 31 | // make sure TESTENV gets set to "", not deleted 32 | testSetGetenv(t, "TESTENV", "") 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/zsysnum_plan9.go: -------------------------------------------------------------------------------- 1 | // mksysnum_plan9.sh /opt/plan9/sys/src/libc/9syscall/sys.h 2 | // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT 3 | 4 | package plan9 5 | 6 | const ( 7 | SYS_SYSR1 = 0 8 | SYS_BIND = 2 9 | SYS_CHDIR = 3 10 | SYS_CLOSE = 4 11 | SYS_DUP = 5 12 | SYS_ALARM = 6 13 | SYS_EXEC = 7 14 | SYS_EXITS = 8 15 | SYS_FAUTH = 10 16 | SYS_SEGBRK = 12 17 | SYS_OPEN = 14 18 | SYS_OSEEK = 16 19 | SYS_SLEEP = 17 20 | SYS_RFORK = 19 21 | SYS_PIPE = 21 22 | SYS_CREATE = 22 23 | SYS_FD2PATH = 23 24 | SYS_BRK_ = 24 25 | SYS_REMOVE = 25 26 | SYS_NOTIFY = 28 27 | SYS_NOTED = 29 28 | SYS_SEGATTACH = 30 29 | SYS_SEGDETACH = 31 30 | SYS_SEGFREE = 32 31 | SYS_SEGFLUSH = 33 32 | SYS_RENDEZVOUS = 34 33 | SYS_UNMOUNT = 35 34 | SYS_SEMACQUIRE = 37 35 | SYS_SEMRELEASE = 38 36 | SYS_SEEK = 39 37 | SYS_FVERSION = 40 38 | SYS_ERRSTR = 41 39 | SYS_STAT = 42 40 | SYS_FSTAT = 43 41 | SYS_WSTAT = 44 42 | SYS_FWSTAT = 45 43 | SYS_MOUNT = 46 44 | SYS_AWAIT = 47 45 | SYS_PREAD = 50 46 | SYS_PWRITE = 51 47 | SYS_TSEMACQUIRE = 52 48 | SYS_NSEC = 53 49 | ) 50 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | unix.test 3 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // See ../runtime/sys_linux_386.s for the reason why we always use int 0x80 14 | // instead of the glibc-specific "CALL 0x10(GS)". 15 | #define INVOKE_SYSCALL INT $0x80 16 | 17 | // Just jump to package syscall's implementation for all these functions. 18 | // The runtime may know about them. 19 | 20 | TEXT ·Syscall(SB),NOSPLIT,$0-28 21 | JMP syscall·Syscall(SB) 22 | 23 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 24 | JMP syscall·Syscall6(SB) 25 | 26 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 27 | CALL runtime·entersyscall(SB) 28 | MOVL trap+0(FP), AX // syscall entry 29 | MOVL a1+4(FP), BX 30 | MOVL a2+8(FP), CX 31 | MOVL a3+12(FP), DX 32 | MOVL $0, SI 33 | MOVL $0, DI 34 | INVOKE_SYSCALL 35 | MOVL AX, r1+16(FP) 36 | MOVL DX, r2+20(FP) 37 | CALL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVL trap+0(FP), AX // syscall entry 48 | MOVL a1+4(FP), BX 49 | MOVL a2+8(FP), CX 50 | MOVL a3+12(FP), DX 51 | MOVL $0, SI 52 | MOVL $0, DI 53 | INVOKE_SYSCALL 54 | MOVL AX, r1+16(FP) 55 | MOVL DX, r2+20(FP) 56 | RET 57 | 58 | TEXT ·socketcall(SB),NOSPLIT,$0-36 59 | JMP syscall·socketcall(SB) 60 | 61 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 62 | JMP syscall·rawsocketcall(SB) 63 | 64 | TEXT ·seek(SB),NOSPLIT,$0-28 65 | JMP syscall·seek(SB) 66 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 23 | CALL runtime·entersyscall(SB) 24 | MOVQ a1+8(FP), DI 25 | MOVQ a2+16(FP), SI 26 | MOVQ a3+24(FP), DX 27 | MOVQ $0, R10 28 | MOVQ $0, R8 29 | MOVQ $0, R9 30 | MOVQ trap+0(FP), AX // syscall entry 31 | SYSCALL 32 | MOVQ AX, r1+32(FP) 33 | MOVQ DX, r2+40(FP) 34 | CALL runtime·exitsyscall(SB) 35 | RET 36 | 37 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 38 | JMP syscall·RawSyscall(SB) 39 | 40 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 41 | JMP syscall·RawSyscall6(SB) 42 | 43 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 44 | MOVQ a1+8(FP), DI 45 | MOVQ a2+16(FP), SI 46 | MOVQ a3+24(FP), DX 47 | MOVQ $0, R10 48 | MOVQ $0, R8 49 | MOVQ $0, R9 50 | MOVQ trap+0(FP), AX // syscall entry 51 | SYSCALL 52 | MOVQ AX, r1+32(FP) 53 | MOVQ DX, r2+40(FP) 54 | RET 55 | 56 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 57 | JMP syscall·gettimeofday(SB) 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 23 | BL runtime·entersyscall(SB) 24 | MOVW trap+0(FP), R7 25 | MOVW a1+4(FP), R0 26 | MOVW a2+8(FP), R1 27 | MOVW a3+12(FP), R2 28 | MOVW $0, R3 29 | MOVW $0, R4 30 | MOVW $0, R5 31 | SWI $0 32 | MOVW R0, r1+16(FP) 33 | MOVW $0, R0 34 | MOVW R0, r2+20(FP) 35 | BL runtime·exitsyscall(SB) 36 | RET 37 | 38 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 39 | B syscall·RawSyscall(SB) 40 | 41 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 42 | B syscall·RawSyscall6(SB) 43 | 44 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 45 | MOVW trap+0(FP), R7 // syscall entry 46 | MOVW a1+4(FP), R0 47 | MOVW a2+8(FP), R1 48 | MOVW a3+12(FP), R2 49 | SWI $0 50 | MOVW R0, r1+16(FP) 51 | MOVW $0, R0 52 | MOVW R0, r2+20(FP) 53 | RET 54 | 55 | TEXT ·seek(SB),NOSPLIT,$0-28 56 | B syscall·seek(SB) 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 21 | BL runtime·entersyscall(SB) 22 | MOVD a1+8(FP), R0 23 | MOVD a2+16(FP), R1 24 | MOVD a3+24(FP), R2 25 | MOVD $0, R3 26 | MOVD $0, R4 27 | MOVD $0, R5 28 | MOVD trap+0(FP), R8 // syscall entry 29 | SVC 30 | MOVD R0, r1+32(FP) // r1 31 | MOVD R1, r2+40(FP) // r2 32 | BL runtime·exitsyscall(SB) 33 | RET 34 | 35 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 36 | B syscall·RawSyscall(SB) 37 | 38 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 39 | B syscall·RawSyscall6(SB) 40 | 41 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 42 | MOVD a1+8(FP), R0 43 | MOVD a2+16(FP), R1 44 | MOVD a3+24(FP), R2 45 | MOVD $0, R3 46 | MOVD $0, R4 47 | MOVD $0, R5 48 | MOVD trap+0(FP), R8 // syscall entry 49 | SVC 50 | MOVD R0, r1+32(FP) 51 | MOVD R1, r2+40(FP) 52 | RET 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | JAL runtime·entersyscall(SB) 26 | MOVV a1+8(FP), R4 27 | MOVV a2+16(FP), R5 28 | MOVV a3+24(FP), R6 29 | MOVV R0, R7 30 | MOVV R0, R8 31 | MOVV R0, R9 32 | MOVV trap+0(FP), R2 // syscall entry 33 | SYSCALL 34 | MOVV R2, r1+32(FP) 35 | MOVV R3, r2+40(FP) 36 | JAL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | JMP syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | JMP syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVV a1+8(FP), R4 47 | MOVV a2+16(FP), R5 48 | MOVV a3+24(FP), R6 49 | MOVV R0, R7 50 | MOVV R0, R8 51 | MOVV R0, R9 52 | MOVV trap+0(FP), R2 // syscall entry 53 | SYSCALL 54 | MOVV R2, r1+32(FP) 55 | MOVV R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 28 | JAL runtime·entersyscall(SB) 29 | MOVW a1+4(FP), R4 30 | MOVW a2+8(FP), R5 31 | MOVW a3+12(FP), R6 32 | MOVW R0, R7 33 | MOVW trap+0(FP), R2 // syscall entry 34 | SYSCALL 35 | MOVW R2, r1+16(FP) // r1 36 | MOVW R3, r2+20(FP) // r2 37 | JAL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 47 | MOVW a1+4(FP), R4 48 | MOVW a2+8(FP), R5 49 | MOVW a3+12(FP), R6 50 | MOVW trap+0(FP), R2 // syscall entry 51 | SYSCALL 52 | MOVW R2, r1+16(FP) 53 | MOVW R3, r2+20(FP) 54 | RET 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | BL runtime·entersyscall(SB) 26 | MOVD a1+8(FP), R3 27 | MOVD a2+16(FP), R4 28 | MOVD a3+24(FP), R5 29 | MOVD R0, R6 30 | MOVD R0, R7 31 | MOVD R0, R8 32 | MOVD trap+0(FP), R9 // syscall entry 33 | SYSCALL R9 34 | MOVD R3, r1+32(FP) 35 | MOVD R4, r2+40(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | BR syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | BR syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVD a1+8(FP), R3 47 | MOVD a2+16(FP), R4 48 | MOVD a3+24(FP), R5 49 | MOVD R0, R6 50 | MOVD R0, R7 51 | MOVD R0, R8 52 | MOVD trap+0(FP), R9 // syscall entry 53 | SYSCALL R9 54 | MOVD R3, r1+32(FP) 55 | MOVD R4, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 25 | BL runtime·entersyscall(SB) 26 | MOVD a1+8(FP), R2 27 | MOVD a2+16(FP), R3 28 | MOVD a3+24(FP), R4 29 | MOVD $0, R5 30 | MOVD $0, R6 31 | MOVD $0, R7 32 | MOVD trap+0(FP), R1 // syscall entry 33 | SYSCALL 34 | MOVD R2, r1+32(FP) 35 | MOVD R3, r2+40(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 40 | BR syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 43 | BR syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 46 | MOVD a1+8(FP), R2 47 | MOVD a2+16(FP), R3 48 | MOVD a3+24(FP), R4 49 | MOVD $0, R5 50 | MOVD $0, R6 51 | MOVD $0, R7 52 | MOVD trap+0(FP), R1 // syscall entry 53 | SYSCALL 54 | MOVD R2, r1+32(FP) 55 | MOVD R3, r2+40(FP) 56 | RET 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Darwin's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a Darwin device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev >> 24) & 0xff) 13 | } 14 | 15 | // Minor returns the minor component of a Darwin device number. 16 | func Minor(dev uint64) uint32 { 17 | return uint32(dev & 0xffffff) 18 | } 19 | 20 | // Mkdev returns a Darwin device number generated from the given major and minor 21 | // components. 22 | func Mkdev(major, minor uint32) uint64 { 23 | return (uint64(major) << 24) | uint64(minor) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_darwin_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package unix_test 8 | 9 | import ( 10 | "fmt" 11 | "testing" 12 | 13 | "golang.org/x/sys/unix" 14 | ) 15 | 16 | func TestDevices(t *testing.T) { 17 | testCases := []struct { 18 | path string 19 | major uint32 20 | minor uint32 21 | }{ 22 | // Most of the device major/minor numbers on Darwin are 23 | // dynamically generated by devfs. These are some well-known 24 | // static numbers. 25 | {"/dev/ttyp0", 4, 0}, 26 | {"/dev/ttys0", 4, 48}, 27 | {"/dev/ptyp0", 5, 0}, 28 | {"/dev/ptyr0", 5, 32}, 29 | } 30 | for _, tc := range testCases { 31 | t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) { 32 | var stat unix.Stat_t 33 | err := unix.Stat(tc.path, &stat) 34 | if err != nil { 35 | t.Errorf("failed to stat device: %v", err) 36 | return 37 | } 38 | 39 | dev := uint64(stat.Rdev) 40 | if unix.Major(dev) != tc.major { 41 | t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major) 42 | } 43 | if unix.Minor(dev) != tc.minor { 44 | t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor) 45 | } 46 | if unix.Mkdev(tc.major, tc.minor) != dev { 47 | t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev) 48 | } 49 | }) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Dragonfly's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a DragonFlyBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a DragonFlyBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a DragonFlyBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_dragonfly_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package unix_test 8 | 9 | import ( 10 | "fmt" 11 | "testing" 12 | 13 | "golang.org/x/sys/unix" 14 | ) 15 | 16 | func TestDevices(t *testing.T) { 17 | testCases := []struct { 18 | path string 19 | major uint32 20 | minor uint32 21 | }{ 22 | // Minor is a cookie instead of an index on DragonFlyBSD 23 | {"/dev/null", 10, 0x00000002}, 24 | {"/dev/random", 10, 0x00000003}, 25 | {"/dev/urandom", 10, 0x00000004}, 26 | {"/dev/zero", 10, 0x0000000c}, 27 | {"/dev/bpf", 15, 0xffff00ff}, 28 | } 29 | for _, tc := range testCases { 30 | t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) { 31 | var stat unix.Stat_t 32 | err := unix.Stat(tc.path, &stat) 33 | if err != nil { 34 | t.Errorf("failed to stat device: %v", err) 35 | return 36 | } 37 | 38 | dev := uint64(stat.Rdev) 39 | if unix.Major(dev) != tc.major { 40 | t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major) 41 | } 42 | if unix.Minor(dev) != tc.minor { 43 | t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor) 44 | } 45 | if unix.Mkdev(tc.major, tc.minor) != dev { 46 | t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev) 47 | } 48 | }) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in FreeBSD's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a FreeBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a FreeBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a FreeBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used by the Linux kernel and glibc. 7 | // 8 | // The information below is extracted and adapted from bits/sysmacros.h in the 9 | // glibc sources: 10 | // 11 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's 12 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major 13 | // number and m is a hex digit of the minor number. This is backward compatible 14 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also 15 | // backward compatible with the Linux kernel, which for some architectures uses 16 | // 32-bit dev_t, encoded as mmmM MMmm. 17 | 18 | package unix 19 | 20 | // Major returns the major component of a Linux device number. 21 | func Major(dev uint64) uint32 { 22 | major := uint32((dev & 0x00000000000fff00) >> 8) 23 | major |= uint32((dev & 0xfffff00000000000) >> 32) 24 | return major 25 | } 26 | 27 | // Minor returns the minor component of a Linux device number. 28 | func Minor(dev uint64) uint32 { 29 | minor := uint32((dev & 0x00000000000000ff) >> 0) 30 | minor |= uint32((dev & 0x00000ffffff00000) >> 12) 31 | return minor 32 | } 33 | 34 | // Mkdev returns a Linux device number generated from the given major and minor 35 | // components. 36 | func Mkdev(major, minor uint32) uint64 { 37 | dev := (uint64(major) & 0x00000fff) << 8 38 | dev |= (uint64(major) & 0xfffff000) << 32 39 | dev |= (uint64(minor) & 0x000000ff) << 0 40 | dev |= (uint64(minor) & 0xffffff00) << 12 41 | return dev 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_linux_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package unix_test 8 | 9 | import ( 10 | "fmt" 11 | "testing" 12 | 13 | "golang.org/x/sys/unix" 14 | ) 15 | 16 | func TestDevices(t *testing.T) { 17 | testCases := []struct { 18 | path string 19 | major uint32 20 | minor uint32 21 | }{ 22 | // well known major/minor numbers according to 23 | // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/devices.txt 24 | {"/dev/null", 1, 3}, 25 | {"/dev/zero", 1, 5}, 26 | {"/dev/random", 1, 8}, 27 | {"/dev/full", 1, 7}, 28 | {"/dev/urandom", 1, 9}, 29 | {"/dev/tty", 5, 0}, 30 | } 31 | for _, tc := range testCases { 32 | t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) { 33 | var stat unix.Stat_t 34 | err := unix.Stat(tc.path, &stat) 35 | if err != nil { 36 | t.Errorf("failed to stat device: %v", err) 37 | return 38 | } 39 | 40 | dev := uint64(stat.Rdev) 41 | if unix.Major(dev) != tc.major { 42 | t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major) 43 | } 44 | if unix.Minor(dev) != tc.minor { 45 | t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor) 46 | } 47 | if unix.Mkdev(tc.major, tc.minor) != dev { 48 | t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev) 49 | } 50 | }) 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in NetBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a NetBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x000fff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of a NetBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xfff00000) >> 12) 19 | return minor 20 | } 21 | 22 | // Mkdev returns a NetBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x000fff00 26 | dev |= (uint64(minor) << 12) & 0xfff00000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_netbsd_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package unix_test 8 | 9 | import ( 10 | "fmt" 11 | "testing" 12 | 13 | "golang.org/x/sys/unix" 14 | ) 15 | 16 | func TestDevices(t *testing.T) { 17 | testCases := []struct { 18 | path string 19 | major uint32 20 | minor uint32 21 | }{ 22 | // well known major/minor numbers according to /dev/MAKEDEV on 23 | // NetBSD 8.0 24 | {"/dev/null", 2, 2}, 25 | {"/dev/zero", 2, 12}, 26 | {"/dev/random", 46, 0}, 27 | {"/dev/urandom", 46, 1}, 28 | } 29 | for _, tc := range testCases { 30 | t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) { 31 | var stat unix.Stat_t 32 | err := unix.Stat(tc.path, &stat) 33 | if err != nil { 34 | t.Errorf("failed to stat device: %v", err) 35 | return 36 | } 37 | 38 | dev := uint64(stat.Rdev) 39 | if unix.Major(dev) != tc.major { 40 | t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major) 41 | } 42 | if unix.Minor(dev) != tc.minor { 43 | t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor) 44 | } 45 | if unix.Mkdev(tc.major, tc.minor) != dev { 46 | t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev) 47 | } 48 | }) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in OpenBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of an OpenBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x0000ff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of an OpenBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xffff0000) >> 8) 19 | return minor 20 | } 21 | 22 | // Mkdev returns an OpenBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x0000ff00 26 | dev |= (uint64(minor) << 8) & 0xffff0000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_openbsd_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package unix_test 8 | 9 | import ( 10 | "fmt" 11 | "testing" 12 | 13 | "golang.org/x/sys/unix" 14 | ) 15 | 16 | func TestDevices(t *testing.T) { 17 | testCases := []struct { 18 | path string 19 | major uint32 20 | minor uint32 21 | }{ 22 | // well known major/minor numbers according to /dev/MAKEDEV on 23 | // OpenBSD 6.0 24 | {"/dev/null", 2, 2}, 25 | {"/dev/zero", 2, 12}, 26 | {"/dev/ttyp0", 5, 0}, 27 | {"/dev/ttyp1", 5, 1}, 28 | {"/dev/random", 45, 0}, 29 | {"/dev/srandom", 45, 1}, 30 | {"/dev/urandom", 45, 2}, 31 | {"/dev/arandom", 45, 3}, 32 | } 33 | for _, tc := range testCases { 34 | t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) { 35 | var stat unix.Stat_t 36 | err := unix.Stat(tc.path, &stat) 37 | if err != nil { 38 | t.Errorf("failed to stat device: %v", err) 39 | return 40 | } 41 | 42 | dev := uint64(stat.Rdev) 43 | if unix.Major(dev) != tc.major { 44 | t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major) 45 | } 46 | if unix.Minor(dev) != tc.minor { 47 | t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor) 48 | } 49 | if unix.Mkdev(tc.major, tc.minor) != dev { 50 | t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev) 51 | } 52 | }) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_solaris_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package unix_test 8 | 9 | import ( 10 | "fmt" 11 | "testing" 12 | 13 | "golang.org/x/sys/unix" 14 | ) 15 | 16 | func TestDevices(t *testing.T) { 17 | testCases := []struct { 18 | path string 19 | major uint32 20 | minor uint32 21 | }{ 22 | // Well-known major/minor numbers on OpenSolaris according to 23 | // /etc/name_to_major 24 | {"/dev/zero", 134, 12}, 25 | {"/dev/null", 134, 2}, 26 | {"/dev/ptyp0", 172, 0}, 27 | {"/dev/ttyp0", 175, 0}, 28 | {"/dev/ttyp1", 175, 1}, 29 | } 30 | for _, tc := range testCases { 31 | t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) { 32 | var stat unix.Stat_t 33 | err := unix.Stat(tc.path, &stat) 34 | if err != nil { 35 | t.Errorf("failed to stat device: %v", err) 36 | return 37 | } 38 | 39 | dev := uint64(stat.Rdev) 40 | if unix.Major(dev) != tc.major { 41 | t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major) 42 | } 43 | if unix.Minor(dev) != tc.minor { 44 | t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor) 45 | } 46 | if unix.Mkdev(tc.major, tc.minor) != dev { 47 | t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev) 48 | } 49 | }) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dirent.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // ParseDirent parses up to max directory entries in buf, 12 | // appending the names to names. It returns the number of 13 | // bytes consumed from buf, the number of entries added 14 | // to names, and the new names slice. 15 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { 16 | return syscall.ParseDirent(buf, max, names) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | 29 | func Unsetenv(key string) error { 30 | return syscall.Unsetenv(key) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix_test 8 | 9 | import ( 10 | "log" 11 | "os" 12 | 13 | "golang.org/x/sys/unix" 14 | ) 15 | 16 | func ExampleExec() { 17 | err := unix.Exec("/bin/ls", []string{"ls", "-al"}, os.Environ()) 18 | log.Fatal(err) 19 | } 20 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/export_test.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 | var Itoa = itoa 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 16 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 17 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 18 | if errno == 0 { 19 | return nil 20 | } 21 | return errno 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscallNoError 15 | func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr) 16 | 17 | //extern gccgoRealSyscall 18 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 19 | 20 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 21 | syscall.Entersyscall() 22 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 23 | syscall.Exitsyscall() 24 | return r, 0 25 | } 26 | 27 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 28 | syscall.Entersyscall() 29 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 30 | syscall.Exitsyscall() 31 | return r, 0, syscall.Errno(errno) 32 | } 33 | 34 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 35 | syscall.Entersyscall() 36 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 37 | syscall.Exitsyscall() 38 | return r, 0, syscall.Errno(errno) 39 | } 40 | 41 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 42 | syscall.Entersyscall() 43 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 44 | syscall.Exitsyscall() 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | 48 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 49 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 50 | return r, 0 51 | } 52 | 53 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 54 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 55 | return r, 0, syscall.Errno(errno) 56 | } 57 | 58 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 59 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 60 | return r, 0, syscall.Errno(errno) 61 | } 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | uintptr_t 35 | gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 36 | { 37 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 38 | } 39 | 40 | // Define the use function in C so that it is not inlined. 41 | 42 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 43 | 44 | void 45 | use(void *p __attribute__ ((unused))) 46 | { 47 | } 48 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/linux/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:17.10 2 | 3 | # Dependencies to get the git sources and go binaries 4 | RUN apt-get update && apt-get install -y \ 5 | curl \ 6 | git \ 7 | && rm -rf /var/lib/apt/lists/* 8 | 9 | # Get the git sources. If not cached, this takes O(5 minutes). 10 | WORKDIR /git 11 | RUN git config --global advice.detachedHead false 12 | # Linux Kernel: Released 28 Jan 2018 13 | RUN git clone --branch v4.15 --depth 1 https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux 14 | # GNU C library: Released 01 Feb 2018 (we should try to get a secure way to clone this) 15 | RUN git clone --branch glibc-2.27 --depth 1 git://sourceware.org/git/glibc.git 16 | 17 | # Get Go 1.10 18 | ENV GOLANG_VERSION 1.10 19 | ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz 20 | ENV GOLANG_DOWNLOAD_SHA256 b5a64335f1490277b585832d1f6c7f8c6c11206cba5cd3f771dcb87b98ad1a33 21 | 22 | RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ 23 | && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ 24 | && tar -C /usr/local -xzf golang.tar.gz \ 25 | && rm golang.tar.gz 26 | 27 | ENV PATH /usr/local/go/bin:$PATH 28 | 29 | # Linux and Glibc build dependencies 30 | RUN apt-get update && apt-get install -y \ 31 | bison gawk make python \ 32 | gcc gcc-multilib \ 33 | gettext texinfo \ 34 | && rm -rf /var/lib/apt/lists/* 35 | # Emulator and cross compilers 36 | RUN apt-get update && apt-get install -y \ 37 | qemu \ 38 | gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi \ 39 | gcc-mips-linux-gnu gcc-mips64-linux-gnuabi64 \ 40 | gcc-mips64el-linux-gnuabi64 gcc-mipsel-linux-gnu \ 41 | gcc-powerpc64-linux-gnu gcc-powerpc64le-linux-gnu \ 42 | gcc-s390x-linux-gnu gcc-sparc64-linux-gnu \ 43 | && rm -rf /var/lib/apt/lists/* 44 | 45 | # Let the scripts know they are in the docker environment 46 | ENV GOLANG_SYS_BUILD docker 47 | WORKDIR /build 48 | ENTRYPOINT ["go", "run", "linux/mkall.go", "/git/linux", "/git/glibc"] 49 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/linux/mksysnum.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | 6 | use strict; 7 | 8 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 9 | print STDERR "GOARCH or GOOS not defined in environment\n"; 10 | exit 1; 11 | } 12 | 13 | # Check that we are using the new build system if we should 14 | if($ENV{'GOLANG_SYS_BUILD'} ne "docker") { 15 | print STDERR "In the new build system, mksysnum should not be called directly.\n"; 16 | print STDERR "See README.md\n"; 17 | exit 1; 18 | } 19 | 20 | my $command = "$0 ". join(' ', @ARGV); 21 | 22 | print < 999){ 38 | # ignore deprecated syscalls that are no longer implemented 39 | # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 40 | return; 41 | } 42 | $name =~ y/a-z/A-Z/; 43 | $num = $num + $offset; 44 | print " SYS_$name = $num;\n"; 45 | } 46 | 47 | my $prev; 48 | open(CC, "$ENV{'CC'} -E -dD @ARGV |") || die "can't run $ENV{'CC'}"; 49 | while(){ 50 | if(/^#define __NR_Linux\s+([0-9]+)/){ 51 | # mips/mips64: extract offset 52 | $offset = $1; 53 | } 54 | elsif(/^#define __NR(\w*)_SYSCALL_BASE\s+([0-9]+)/){ 55 | # arm: extract offset 56 | $offset = $1; 57 | } 58 | elsif(/^#define __NR_syscalls\s+/) { 59 | # ignore redefinitions of __NR_syscalls 60 | } 61 | elsif(/^#define __NR_(\w*)Linux_syscalls\s+/) { 62 | # mips/mips64: ignore definitions about the number of syscalls 63 | } 64 | elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ 65 | $prev = $2; 66 | fmt($1, $2); 67 | } 68 | elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ 69 | $prev = $2; 70 | fmt($1, $2); 71 | } 72 | elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ 73 | fmt($1, $prev+$2) 74 | } 75 | elsif(/^#define __NR_(\w+)\s+\(__NR_Linux \+ ([0-9]+)/){ 76 | fmt($1, $2); 77 | } 78 | elsif(/^#define __NR_(\w+)\s+\(__NR_SYSCALL_BASE \+ ([0-9]+)/){ 79 | fmt($1, $2); 80 | } 81 | } 82 | 83 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '13' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // 15 | // The primary use of this package is inside other packages that provide a more 16 | // portable interface to the system, such as "os", "time" and "net". Use 17 | // those packages rather than this one if you can. 18 | // 19 | // For details of the functions and data types in this package consult 20 | // the manuals for the appropriate operating system. 21 | // 22 | // These calls return err == nil to indicate success; otherwise 23 | // err represents an operating system error describing the failure and 24 | // holds a value of type syscall.Errno. 25 | package unix // import "golang.org/x/sys/unix" 26 | 27 | // ByteSliceFromString returns a NUL-terminated slice of bytes 28 | // containing the text of s. If s contains a NUL byte at any 29 | // location, it returns (nil, EINVAL). 30 | func ByteSliceFromString(s string) ([]byte, error) { 31 | for i := 0; i < len(s); i++ { 32 | if s[i] == 0 { 33 | return nil, EINVAL 34 | } 35 | } 36 | a := make([]byte, len(s)+1) 37 | copy(a, s) 38 | return a, nil 39 | } 40 | 41 | // BytePtrFromString returns a pointer to a NUL-terminated array of 42 | // bytes containing the text of s. If s contains a NUL byte at any 43 | // location, it returns (nil, EINVAL). 44 | func BytePtrFromString(s string) (*byte, error) { 45 | a, err := ByteSliceFromString(s) 46 | if err != nil { 47 | return nil, err 48 | } 49 | return &a[0], nil 50 | } 51 | 52 | // Single-word zero for use when we need a valid pointer to 0 bytes. 53 | // See mkunix.pl. 54 | var _zero uintptr 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_bsd_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd openbsd 6 | 7 | package unix_test 8 | 9 | import ( 10 | "os/exec" 11 | "runtime" 12 | "testing" 13 | "time" 14 | 15 | "golang.org/x/sys/unix" 16 | ) 17 | 18 | const MNT_WAIT = 1 19 | const MNT_NOWAIT = 2 20 | 21 | func TestGetfsstat(t *testing.T) { 22 | const flags = MNT_NOWAIT // see golang.org/issue/16937 23 | n, err := unix.Getfsstat(nil, flags) 24 | if err != nil { 25 | t.Fatal(err) 26 | } 27 | 28 | data := make([]unix.Statfs_t, n) 29 | n2, err := unix.Getfsstat(data, flags) 30 | if err != nil { 31 | t.Fatal(err) 32 | } 33 | if n != n2 { 34 | t.Errorf("Getfsstat(nil) = %d, but subsequent Getfsstat(slice) = %d", n, n2) 35 | } 36 | for i, stat := range data { 37 | if stat == (unix.Statfs_t{}) { 38 | t.Errorf("index %v is an empty Statfs_t struct", i) 39 | } 40 | } 41 | if t.Failed() { 42 | for i, stat := range data[:n2] { 43 | t.Logf("data[%v] = %+v", i, stat) 44 | } 45 | mount, err := exec.Command("mount").CombinedOutput() 46 | if err != nil { 47 | t.Logf("mount: %v\n%s", err, mount) 48 | } else { 49 | t.Logf("mount: %s", mount) 50 | } 51 | } 52 | } 53 | 54 | func TestSelect(t *testing.T) { 55 | err := unix.Select(0, nil, nil, nil, &unix.Timeval{Sec: 0, Usec: 0}) 56 | if err != nil { 57 | t.Fatalf("Select: %v", err) 58 | } 59 | 60 | dur := 250 * time.Millisecond 61 | tv := unix.NsecToTimeval(int64(dur)) 62 | start := time.Now() 63 | err = unix.Select(0, nil, nil, nil, &tv) 64 | took := time.Since(start) 65 | if err != nil { 66 | t.Fatalf("Select: %v", err) 67 | } 68 | 69 | // On some BSDs the actual timeout might also be slightly less than the requested. 70 | // Add an acceptable margin to avoid flaky tests. 71 | if took < dur*2/3 { 72 | t.Errorf("Select: timeout should have been at least %v, got %v", dur, took) 73 | } 74 | } 75 | 76 | func TestSysctlRaw(t *testing.T) { 77 | if runtime.GOOS == "openbsd" { 78 | t.Skip("kern.proc.pid does not exist on OpenBSD") 79 | } 80 | 81 | _, err := unix.SysctlRaw("kern.proc.pid", unix.Getpid()) 82 | if err != nil { 83 | t.Fatal(err) 84 | } 85 | } 86 | 87 | func TestSysctlUint32(t *testing.T) { 88 | maxproc, err := unix.SysctlUint32("kern.maxproc") 89 | if err != nil { 90 | t.Fatal(err) 91 | } 92 | t.Logf("kern.maxproc: %v", maxproc) 93 | } 94 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = int32(sec) 29 | tv.Usec = int32(usec) 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint32(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint32(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = sec 29 | tv.Usec = usec 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func setTimespec(sec, nsec int64) Timespec { 13 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 14 | } 15 | 16 | func setTimeval(sec, usec int64) Timeval { 17 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 18 | } 19 | 20 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 21 | func Gettimeofday(tv *Timeval) (err error) { 22 | // The tv passed to gettimeofday must be non-nil 23 | // but is otherwise unused. The answers come back 24 | // in the two registers. 25 | sec, usec, err := gettimeofday(tv) 26 | tv.Sec = int32(sec) 27 | tv.Usec = int32(usec) 28 | return err 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var length = uint64(count) 51 | 52 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 53 | 54 | written = int(length) 55 | 56 | if e1 != 0 { 57 | err = e1 58 | } 59 | return 60 | } 61 | 62 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 63 | 64 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 65 | // of darwin/arm the syscall is called sysctl instead of __sysctl. 66 | const SYS___SYSCTL = SYS_SYSCTL 67 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = sec 29 | tv.Usec = usec 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: usec} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint64(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint64(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,!gccgo 6 | 7 | package unix 8 | 9 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail. 10 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 11 | 12 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't 13 | // fail. 14 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build gccgo 7 | // +build 386 arm 8 | 9 | package unix 10 | 11 | import ( 12 | "syscall" 13 | "unsafe" 14 | ) 15 | 16 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) { 17 | offsetLow := uint32(offset & 0xffffffff) 18 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 19 | _, _, err = Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 20 | return newoffset, err 21 | } 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func (iov *Iovec) SetLen(length int) { 18 | iov.Len = uint64(length) 19 | } 20 | 21 | func (cmsg *Cmsghdr) SetLen(length int) { 22 | cmsg.Len = uint32(length) 23 | } 24 | 25 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 26 | // TODO(aram): implement this, see issue 5847. 27 | panic("unimplemented") 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build solaris 6 | 7 | package unix_test 8 | 9 | import ( 10 | "os/exec" 11 | "testing" 12 | "time" 13 | 14 | "golang.org/x/sys/unix" 15 | ) 16 | 17 | func TestSelect(t *testing.T) { 18 | err := unix.Select(0, nil, nil, nil, &unix.Timeval{Sec: 0, Usec: 0}) 19 | if err != nil { 20 | t.Fatalf("Select: %v", err) 21 | } 22 | 23 | dur := 150 * time.Millisecond 24 | tv := unix.NsecToTimeval(int64(dur)) 25 | start := time.Now() 26 | err = unix.Select(0, nil, nil, nil, &tv) 27 | took := time.Since(start) 28 | if err != nil { 29 | t.Fatalf("Select: %v", err) 30 | } 31 | 32 | if took < dur { 33 | t.Errorf("Select: timeout should have been at least %v, got %v", dur, took) 34 | } 35 | } 36 | 37 | func TestStatvfs(t *testing.T) { 38 | if err := unix.Statvfs("", nil); err == nil { 39 | t.Fatal(`Statvfs("") expected failure`) 40 | } 41 | 42 | statvfs := unix.Statvfs_t{} 43 | if err := unix.Statvfs("/", &statvfs); err != nil { 44 | t.Errorf(`Statvfs("/") failed: %v`, err) 45 | } 46 | 47 | if t.Failed() { 48 | mount, err := exec.Command("mount").CombinedOutput() 49 | if err != nil { 50 | t.Logf("mount: %v\n%s", err, mount) 51 | } else { 52 | t.Logf("mount: %s", mount) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix_test 8 | 9 | import ( 10 | "fmt" 11 | "testing" 12 | 13 | "golang.org/x/sys/unix" 14 | ) 15 | 16 | func testSetGetenv(t *testing.T, key, value string) { 17 | err := unix.Setenv(key, value) 18 | if err != nil { 19 | t.Fatalf("Setenv failed to set %q: %v", value, err) 20 | } 21 | newvalue, found := unix.Getenv(key) 22 | if !found { 23 | t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value) 24 | } 25 | if newvalue != value { 26 | t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value) 27 | } 28 | } 29 | 30 | func TestEnv(t *testing.T) { 31 | testSetGetenv(t, "TESTENV", "AVALUE") 32 | // make sure TESTENV gets set to "", not deleted 33 | testSetGetenv(t, "TESTENV", "") 34 | } 35 | 36 | func TestItoa(t *testing.T) { 37 | // Make most negative integer: 0x8000... 38 | i := 1 39 | for i<<1 != 0 { 40 | i <<= 1 41 | } 42 | if i >= 0 { 43 | t.Fatal("bad math") 44 | } 45 | s := unix.Itoa(i) 46 | f := fmt.Sprint(i) 47 | if s != f { 48 | t.Fatalf("itoa(%d) = %s, want %s", i, s, f) 49 | } 50 | } 51 | 52 | func TestUname(t *testing.T) { 53 | var utsname unix.Utsname 54 | err := unix.Uname(&utsname) 55 | if err != nil { 56 | t.Fatalf("Uname: %v", err) 57 | } 58 | 59 | t.Logf("OS: %s/%s %s", utsname.Sysname[:], utsname.Machine[:], utsname.Release[:]) 60 | } 61 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/timestruct.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "time" 10 | 11 | // TimespecToNsec converts a Timespec value into a number of 12 | // nanoseconds since the Unix epoch. 13 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 14 | 15 | // NsecToTimespec takes a number of nanoseconds since the Unix epoch 16 | // and returns the corresponding Timespec value. 17 | func NsecToTimespec(nsec int64) Timespec { 18 | sec := nsec / 1e9 19 | nsec = nsec % 1e9 20 | if nsec < 0 { 21 | nsec += 1e9 22 | sec-- 23 | } 24 | return setTimespec(sec, nsec) 25 | } 26 | 27 | // TimeToTimespec converts t into a Timespec. 28 | // On some 32-bit systems the range of valid Timespec values are smaller 29 | // than that of time.Time values. So if t is out of the valid range of 30 | // Timespec, it returns a zero Timespec and ERANGE. 31 | func TimeToTimespec(t time.Time) (Timespec, error) { 32 | sec := t.Unix() 33 | nsec := int64(t.Nanosecond()) 34 | ts := setTimespec(sec, nsec) 35 | 36 | // Currently all targets have either int32 or int64 for Timespec.Sec. 37 | // If there were a new target with floating point type for it, we have 38 | // to consider the rounding error. 39 | if int64(ts.Sec) != sec { 40 | return Timespec{}, ERANGE 41 | } 42 | return ts, nil 43 | } 44 | 45 | // TimevalToNsec converts a Timeval value into a number of nanoseconds 46 | // since the Unix epoch. 47 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 48 | 49 | // NsecToTimeval takes a number of nanoseconds since the Unix epoch 50 | // and returns the corresponding Timeval value. 51 | func NsecToTimeval(nsec int64) Timeval { 52 | nsec += 999 // round up to microsecond 53 | usec := nsec % 1e9 / 1e3 54 | sec := nsec / 1e9 55 | if usec < 0 { 56 | usec += 1e6 57 | sec-- 58 | } 59 | return setTimeval(sec, usec) 60 | } 61 | 62 | // Unix returns ts as the number of seconds and nanoseconds elapsed since the 63 | // Unix epoch. 64 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 65 | return int64(ts.Sec), int64(ts.Nsec) 66 | } 67 | 68 | // Unix returns tv as the number of seconds and nanoseconds elapsed since the 69 | // Unix epoch. 70 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 71 | return int64(tv.Sec), int64(tv.Usec) * 1000 72 | } 73 | 74 | // Nano returns ts as the number of nanoseconds elapsed since the Unix epoch. 75 | func (ts *Timespec) Nano() int64 { 76 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 77 | } 78 | 79 | // Nano returns tv as the number of nanoseconds elapsed since the Unix epoch. 80 | func (tv *Timeval) Nano() int64 { 81 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 82 | } 83 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/timestruct_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All right reserved. 2 | // 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_test 8 | 9 | import ( 10 | "testing" 11 | "time" 12 | "unsafe" 13 | 14 | "golang.org/x/sys/unix" 15 | ) 16 | 17 | func TestTimeToTimespec(t *testing.T) { 18 | timeTests := []struct { 19 | time time.Time 20 | valid bool 21 | }{ 22 | {time.Unix(0, 0), true}, 23 | {time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC), true}, 24 | {time.Date(2262, time.December, 31, 23, 0, 0, 0, time.UTC), false}, 25 | {time.Unix(0x7FFFFFFF, 0), true}, 26 | {time.Unix(0x80000000, 0), false}, 27 | {time.Unix(0x7FFFFFFF, 1000000000), false}, 28 | {time.Unix(0x7FFFFFFF, 999999999), true}, 29 | {time.Unix(-0x80000000, 0), true}, 30 | {time.Unix(-0x80000001, 0), false}, 31 | {time.Date(2038, time.January, 19, 3, 14, 7, 0, time.UTC), true}, 32 | {time.Date(2038, time.January, 19, 3, 14, 8, 0, time.UTC), false}, 33 | {time.Date(1901, time.December, 13, 20, 45, 52, 0, time.UTC), true}, 34 | {time.Date(1901, time.December, 13, 20, 45, 51, 0, time.UTC), false}, 35 | } 36 | 37 | // Currently all targets have either int32 or int64 for Timespec.Sec. 38 | // If there were a new target with unsigned or floating point type for 39 | // it, this test must be adjusted. 40 | have64BitTime := (unsafe.Sizeof(unix.Timespec{}.Sec) == 8) 41 | for _, tt := range timeTests { 42 | ts, err := unix.TimeToTimespec(tt.time) 43 | tt.valid = tt.valid || have64BitTime 44 | if tt.valid && err != nil { 45 | t.Errorf("TimeToTimespec(%v): %v", tt.time, err) 46 | } 47 | if err == nil { 48 | tstime := time.Unix(int64(ts.Sec), int64(ts.Nsec)) 49 | if !tstime.Equal(tt.time) { 50 | t.Errorf("TimeToTimespec(%v) is the time %v", tt.time, tstime) 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace386_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(386, amd64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build 386 amd64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegs386 is the registers used by 386 binaries. 11 | type PtraceRegs386 struct { 12 | Ebx int32 13 | Ecx int32 14 | Edx int32 15 | Esi int32 16 | Edi int32 17 | Ebp int32 18 | Eax int32 19 | Xds int32 20 | Xes int32 21 | Xfs int32 22 | Xgs int32 23 | Orig_eax int32 24 | Eip int32 25 | Xcs int32 26 | Eflags int32 27 | Esp int32 28 | Xss int32 29 | } 30 | 31 | // PtraceGetRegs386 fetches the registers used by 386 binaries. 32 | func PtraceGetRegs386(pid int, regsout *PtraceRegs386) error { 33 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 34 | } 35 | 36 | // PtraceSetRegs386 sets the registers used by 386 binaries. 37 | func PtraceSetRegs386(pid int, regs *PtraceRegs386) error { 38 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 39 | } 40 | 41 | // PtraceRegsAmd64 is the registers used by amd64 binaries. 42 | type PtraceRegsAmd64 struct { 43 | R15 uint64 44 | R14 uint64 45 | R13 uint64 46 | R12 uint64 47 | Rbp uint64 48 | Rbx uint64 49 | R11 uint64 50 | R10 uint64 51 | R9 uint64 52 | R8 uint64 53 | Rax uint64 54 | Rcx uint64 55 | Rdx uint64 56 | Rsi uint64 57 | Rdi uint64 58 | Orig_rax uint64 59 | Rip uint64 60 | Cs uint64 61 | Eflags uint64 62 | Rsp uint64 63 | Ss uint64 64 | Fs_base uint64 65 | Gs_base uint64 66 | Ds uint64 67 | Es uint64 68 | Fs uint64 69 | Gs uint64 70 | } 71 | 72 | // PtraceGetRegsAmd64 fetches the registers used by amd64 binaries. 73 | func PtraceGetRegsAmd64(pid int, regsout *PtraceRegsAmd64) error { 74 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 75 | } 76 | 77 | // PtraceSetRegsAmd64 sets the registers used by amd64 binaries. 78 | func PtraceSetRegsAmd64(pid int, regs *PtraceRegsAmd64) error { 79 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 80 | } 81 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracearm_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(arm, arm64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build arm arm64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsArm is the registers used by arm binaries. 11 | type PtraceRegsArm struct { 12 | Uregs [18]uint32 13 | } 14 | 15 | // PtraceGetRegsArm fetches the registers used by arm binaries. 16 | func PtraceGetRegsArm(pid int, regsout *PtraceRegsArm) error { 17 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 18 | } 19 | 20 | // PtraceSetRegsArm sets the registers used by arm binaries. 21 | func PtraceSetRegsArm(pid int, regs *PtraceRegsArm) error { 22 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 23 | } 24 | 25 | // PtraceRegsArm64 is the registers used by arm64 binaries. 26 | type PtraceRegsArm64 struct { 27 | Regs [31]uint64 28 | Sp uint64 29 | Pc uint64 30 | Pstate uint64 31 | } 32 | 33 | // PtraceGetRegsArm64 fetches the registers used by arm64 binaries. 34 | func PtraceGetRegsArm64(pid int, regsout *PtraceRegsArm64) error { 35 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 36 | } 37 | 38 | // PtraceSetRegsArm64 sets the registers used by arm64 binaries. 39 | func PtraceSetRegsArm64(pid int, regs *PtraceRegsArm64) error { 40 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracemips_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(mips, mips64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build mips mips64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsMips is the registers used by mips binaries. 11 | type PtraceRegsMips struct { 12 | Regs [32]uint64 13 | Lo uint64 14 | Hi uint64 15 | Epc uint64 16 | Badvaddr uint64 17 | Status uint64 18 | Cause uint64 19 | } 20 | 21 | // PtraceGetRegsMips fetches the registers used by mips binaries. 22 | func PtraceGetRegsMips(pid int, regsout *PtraceRegsMips) error { 23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 24 | } 25 | 26 | // PtraceSetRegsMips sets the registers used by mips binaries. 27 | func PtraceSetRegsMips(pid int, regs *PtraceRegsMips) error { 28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 29 | } 30 | 31 | // PtraceRegsMips64 is the registers used by mips64 binaries. 32 | type PtraceRegsMips64 struct { 33 | Regs [32]uint64 34 | Lo uint64 35 | Hi uint64 36 | Epc uint64 37 | Badvaddr uint64 38 | Status uint64 39 | Cause uint64 40 | } 41 | 42 | // PtraceGetRegsMips64 fetches the registers used by mips64 binaries. 43 | func PtraceGetRegsMips64(pid int, regsout *PtraceRegsMips64) error { 44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 45 | } 46 | 47 | // PtraceSetRegsMips64 sets the registers used by mips64 binaries. 48 | func PtraceSetRegsMips64(pid int, regs *PtraceRegsMips64) error { 49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptracemipsle_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(mipsle, mips64le). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build mipsle mips64le 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegsMipsle is the registers used by mipsle binaries. 11 | type PtraceRegsMipsle struct { 12 | Regs [32]uint64 13 | Lo uint64 14 | Hi uint64 15 | Epc uint64 16 | Badvaddr uint64 17 | Status uint64 18 | Cause uint64 19 | } 20 | 21 | // PtraceGetRegsMipsle fetches the registers used by mipsle binaries. 22 | func PtraceGetRegsMipsle(pid int, regsout *PtraceRegsMipsle) error { 23 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 24 | } 25 | 26 | // PtraceSetRegsMipsle sets the registers used by mipsle binaries. 27 | func PtraceSetRegsMipsle(pid int, regs *PtraceRegsMipsle) error { 28 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 29 | } 30 | 31 | // PtraceRegsMips64le is the registers used by mips64le binaries. 32 | type PtraceRegsMips64le struct { 33 | Regs [32]uint64 34 | Lo uint64 35 | Hi uint64 36 | Epc uint64 37 | Badvaddr uint64 38 | Status uint64 39 | Cause uint64 40 | } 41 | 42 | // PtraceGetRegsMips64le fetches the registers used by mips64le binaries. 43 | func PtraceGetRegsMips64le(pid int, regsout *PtraceRegsMips64le) error { 44 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 45 | } 46 | 47 | // PtraceSetRegsMips64le sets the registers used by mips64le binaries. 48 | func PtraceSetRegsMips64le(pid int, regs *PtraceRegsMips64le) error { 49 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/asm_windows_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // 6 | // System calls for 386, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-8 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-4 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/asm_windows_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // 6 | // System calls for amd64, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-32 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-8 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/env_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Windows environment variables. 6 | 7 | package windows 8 | 9 | import "syscall" 10 | 11 | func Getenv(key string) (value string, found bool) { 12 | return syscall.Getenv(key) 13 | } 14 | 15 | func Setenv(key, value string) error { 16 | return syscall.Setenv(key, value) 17 | } 18 | 19 | func Clearenv() { 20 | syscall.Clearenv() 21 | } 22 | 23 | func Environ() []string { 24 | return syscall.Environ() 25 | } 26 | 27 | func Unsetenv(key string) error { 28 | return syscall.Unsetenv(key) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/eventlog.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package windows 8 | 9 | const ( 10 | EVENTLOG_SUCCESS = 0 11 | EVENTLOG_ERROR_TYPE = 1 12 | EVENTLOG_WARNING_TYPE = 2 13 | EVENTLOG_INFORMATION_TYPE = 4 14 | EVENTLOG_AUDIT_SUCCESS = 8 15 | EVENTLOG_AUDIT_FAILURE = 16 16 | ) 17 | 18 | //sys RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) [failretval==0] = advapi32.RegisterEventSourceW 19 | //sys DeregisterEventSource(handle Handle) (err error) = advapi32.DeregisterEventSource 20 | //sys ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) = advapi32.ReportEventW 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/exec_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Fork, exec, wait, etc. 6 | 7 | package windows 8 | 9 | // EscapeArg rewrites command line argument s as prescribed 10 | // in http://msdn.microsoft.com/en-us/library/ms880421. 11 | // This function returns "" (2 double quotes) if s is empty. 12 | // Alternatively, these transformations are done: 13 | // - every back slash (\) is doubled, but only if immediately 14 | // followed by double quote ("); 15 | // - every double quote (") is escaped by back slash (\); 16 | // - finally, s is wrapped with double quotes (arg -> "arg"), 17 | // but only if there is space or tab inside s. 18 | func EscapeArg(s string) string { 19 | if len(s) == 0 { 20 | return "\"\"" 21 | } 22 | n := len(s) 23 | hasSpace := false 24 | for i := 0; i < len(s); i++ { 25 | switch s[i] { 26 | case '"', '\\': 27 | n++ 28 | case ' ', '\t': 29 | hasSpace = true 30 | } 31 | } 32 | if hasSpace { 33 | n += 2 34 | } 35 | if n == len(s) { 36 | return s 37 | } 38 | 39 | qs := make([]byte, n) 40 | j := 0 41 | if hasSpace { 42 | qs[j] = '"' 43 | j++ 44 | } 45 | slashes := 0 46 | for i := 0; i < len(s); i++ { 47 | switch s[i] { 48 | default: 49 | slashes = 0 50 | qs[j] = s[i] 51 | case '\\': 52 | slashes++ 53 | qs[j] = s[i] 54 | case '"': 55 | for ; slashes > 0; slashes-- { 56 | qs[j] = '\\' 57 | j++ 58 | } 59 | qs[j] = '\\' 60 | j++ 61 | qs[j] = s[i] 62 | } 63 | j++ 64 | } 65 | if hasSpace { 66 | for ; slashes > 0; slashes-- { 67 | qs[j] = '\\' 68 | j++ 69 | } 70 | qs[j] = '"' 71 | j++ 72 | } 73 | return string(qs[:j]) 74 | } 75 | 76 | func CloseOnExec(fd Handle) { 77 | SetHandleInformation(Handle(fd), HANDLE_FLAG_INHERIT, 0) 78 | } 79 | 80 | // FullPath retrieves the full path of the specified file. 81 | func FullPath(name string) (path string, err error) { 82 | p, err := UTF16PtrFromString(name) 83 | if err != nil { 84 | return "", err 85 | } 86 | n := uint32(100) 87 | for { 88 | buf := make([]uint16, n) 89 | n, err = GetFullPathName(p, uint32(len(buf)), &buf[0], nil) 90 | if err != nil { 91 | return "", err 92 | } 93 | if n <= uint32(len(buf)) { 94 | return UTF16ToString(buf[:n]), nil 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/memory_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | const ( 8 | MEM_COMMIT = 0x00001000 9 | MEM_RESERVE = 0x00002000 10 | MEM_DECOMMIT = 0x00004000 11 | MEM_RELEASE = 0x00008000 12 | MEM_RESET = 0x00080000 13 | MEM_TOP_DOWN = 0x00100000 14 | MEM_WRITE_WATCH = 0x00200000 15 | MEM_PHYSICAL = 0x00400000 16 | MEM_RESET_UNDO = 0x01000000 17 | MEM_LARGE_PAGES = 0x20000000 18 | 19 | PAGE_NOACCESS = 0x01 20 | PAGE_READONLY = 0x02 21 | PAGE_READWRITE = 0x04 22 | PAGE_WRITECOPY = 0x08 23 | PAGE_EXECUTE_READ = 0x20 24 | PAGE_EXECUTE_READWRITE = 0x40 25 | PAGE_EXECUTE_WRITECOPY = 0x80 26 | ) 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/mksyscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go 8 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,race 6 | 7 | package windows 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,!race 6 | 7 | package windows 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/registry/export_test.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 windows 6 | 7 | package registry 8 | 9 | func (k Key) SetValue(name string, valtype uint32, data []byte) error { 10 | return k.setValue(name, valtype, data) 11 | } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/registry/mksyscall.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 registry 6 | 7 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go 8 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/registry/syscall.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 windows 6 | 7 | package registry 8 | 9 | import "syscall" 10 | 11 | const ( 12 | _REG_OPTION_NON_VOLATILE = 0 13 | 14 | _REG_CREATED_NEW_KEY = 1 15 | _REG_OPENED_EXISTING_KEY = 2 16 | 17 | _ERROR_NO_MORE_ITEMS syscall.Errno = 259 18 | ) 19 | 20 | func LoadRegLoadMUIString() error { 21 | return procRegLoadMUIStringW.Find() 22 | } 23 | 24 | //sys regCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *uint16, options uint32, desired uint32, sa *syscall.SecurityAttributes, result *syscall.Handle, disposition *uint32) (regerrno error) = advapi32.RegCreateKeyExW 25 | //sys regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) = advapi32.RegDeleteKeyW 26 | //sys regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) = advapi32.RegSetValueExW 27 | //sys regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegEnumValueW 28 | //sys regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) = advapi32.RegDeleteValueW 29 | //sys regLoadMUIString(key syscall.Handle, name *uint16, buf *uint16, buflen uint32, buflenCopied *uint32, flags uint32, dir *uint16) (regerrno error) = advapi32.RegLoadMUIStringW 30 | //sys regConnectRegistry(machinename *uint16, key syscall.Handle, result *syscall.Handle) (regerrno error) = advapi32.RegConnectRegistryW 31 | 32 | //sys expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) = kernel32.ExpandEnvironmentStringsW 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package windows 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + itoa(-val) 12 | } 13 | var buf [32]byte // big enough for int64 14 | i := len(buf) - 1 15 | for val >= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/debug/log.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package debug 8 | 9 | import ( 10 | "os" 11 | "strconv" 12 | ) 13 | 14 | // Log interface allows different log implementations to be used. 15 | type Log interface { 16 | Close() error 17 | Info(eid uint32, msg string) error 18 | Warning(eid uint32, msg string) error 19 | Error(eid uint32, msg string) error 20 | } 21 | 22 | // ConsoleLog provides access to the console. 23 | type ConsoleLog struct { 24 | Name string 25 | } 26 | 27 | // New creates new ConsoleLog. 28 | func New(source string) *ConsoleLog { 29 | return &ConsoleLog{Name: source} 30 | } 31 | 32 | // Close closes console log l. 33 | func (l *ConsoleLog) Close() error { 34 | return nil 35 | } 36 | 37 | func (l *ConsoleLog) report(kind string, eid uint32, msg string) error { 38 | s := l.Name + "." + kind + "(" + strconv.Itoa(int(eid)) + "): " + msg + "\n" 39 | _, err := os.Stdout.Write([]byte(s)) 40 | return err 41 | } 42 | 43 | // Info writes an information event msg with event id eid to the console l. 44 | func (l *ConsoleLog) Info(eid uint32, msg string) error { 45 | return l.report("info", eid, msg) 46 | } 47 | 48 | // Warning writes an warning event msg with event id eid to the console l. 49 | func (l *ConsoleLog) Warning(eid uint32, msg string) error { 50 | return l.report("warn", eid, msg) 51 | } 52 | 53 | // Error writes an error event msg with event id eid to the console l. 54 | func (l *ConsoleLog) Error(eid uint32, msg string) error { 55 | return l.report("error", eid, msg) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/debug/service.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | // Package debug provides facilities to execute svc.Handler on console. 8 | // 9 | package debug 10 | 11 | import ( 12 | "os" 13 | "os/signal" 14 | "syscall" 15 | 16 | "golang.org/x/sys/windows/svc" 17 | ) 18 | 19 | // Run executes service name by calling appropriate handler function. 20 | // The process is running on console, unlike real service. Use Ctrl+C to 21 | // send "Stop" command to your service. 22 | func Run(name string, handler svc.Handler) error { 23 | cmds := make(chan svc.ChangeRequest) 24 | changes := make(chan svc.Status) 25 | 26 | sig := make(chan os.Signal) 27 | signal.Notify(sig) 28 | 29 | go func() { 30 | status := svc.Status{State: svc.Stopped} 31 | for { 32 | select { 33 | case <-sig: 34 | cmds <- svc.ChangeRequest{svc.Stop, 0, 0, status} 35 | case status = <-changes: 36 | } 37 | } 38 | }() 39 | 40 | _, errno := handler.Execute([]string{name}, cmds, changes) 41 | if errno != 0 { 42 | return syscall.Errno(errno) 43 | } 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/event.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package svc 8 | 9 | import ( 10 | "errors" 11 | 12 | "golang.org/x/sys/windows" 13 | ) 14 | 15 | // event represents auto-reset, initially non-signaled Windows event. 16 | // It is used to communicate between go and asm parts of this package. 17 | type event struct { 18 | h windows.Handle 19 | } 20 | 21 | func newEvent() (*event, error) { 22 | h, err := windows.CreateEvent(nil, 0, 0, nil) 23 | if err != nil { 24 | return nil, err 25 | } 26 | return &event{h: h}, nil 27 | } 28 | 29 | func (e *event) Close() error { 30 | return windows.CloseHandle(e.h) 31 | } 32 | 33 | func (e *event) Set() error { 34 | return windows.SetEvent(e.h) 35 | } 36 | 37 | func (e *event) Wait() error { 38 | s, err := windows.WaitForSingleObject(e.h, windows.INFINITE) 39 | switch s { 40 | case windows.WAIT_OBJECT_0: 41 | break 42 | case windows.WAIT_FAILED: 43 | return err 44 | default: 45 | return errors.New("unexpected result from WaitForSingleObject") 46 | } 47 | return nil 48 | } 49 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/eventlog/install.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package eventlog 8 | 9 | import ( 10 | "errors" 11 | 12 | "golang.org/x/sys/windows" 13 | "golang.org/x/sys/windows/registry" 14 | ) 15 | 16 | const ( 17 | // Log levels. 18 | Info = windows.EVENTLOG_INFORMATION_TYPE 19 | Warning = windows.EVENTLOG_WARNING_TYPE 20 | Error = windows.EVENTLOG_ERROR_TYPE 21 | ) 22 | 23 | const addKeyName = `SYSTEM\CurrentControlSet\Services\EventLog\Application` 24 | 25 | // Install modifies PC registry to allow logging with an event source src. 26 | // It adds all required keys and values to the event log registry key. 27 | // Install uses msgFile as the event message file. If useExpandKey is true, 28 | // the event message file is installed as REG_EXPAND_SZ value, 29 | // otherwise as REG_SZ. Use bitwise of log.Error, log.Warning and 30 | // log.Info to specify events supported by the new event source. 31 | func Install(src, msgFile string, useExpandKey bool, eventsSupported uint32) error { 32 | appkey, err := registry.OpenKey(registry.LOCAL_MACHINE, addKeyName, registry.CREATE_SUB_KEY) 33 | if err != nil { 34 | return err 35 | } 36 | defer appkey.Close() 37 | 38 | sk, alreadyExist, err := registry.CreateKey(appkey, src, registry.SET_VALUE) 39 | if err != nil { 40 | return err 41 | } 42 | defer sk.Close() 43 | if alreadyExist { 44 | return errors.New(addKeyName + `\` + src + " registry key already exists") 45 | } 46 | 47 | err = sk.SetDWordValue("CustomSource", 1) 48 | if err != nil { 49 | return err 50 | } 51 | if useExpandKey { 52 | err = sk.SetExpandStringValue("EventMessageFile", msgFile) 53 | } else { 54 | err = sk.SetStringValue("EventMessageFile", msgFile) 55 | } 56 | if err != nil { 57 | return err 58 | } 59 | err = sk.SetDWordValue("TypesSupported", eventsSupported) 60 | if err != nil { 61 | return err 62 | } 63 | return nil 64 | } 65 | 66 | // InstallAsEventCreate is the same as Install, but uses 67 | // %SystemRoot%\System32\EventCreate.exe as the event message file. 68 | func InstallAsEventCreate(src string, eventsSupported uint32) error { 69 | return Install(src, "%SystemRoot%\\System32\\EventCreate.exe", true, eventsSupported) 70 | } 71 | 72 | // Remove deletes all registry elements installed by the correspondent Install. 73 | func Remove(src string) error { 74 | appkey, err := registry.OpenKey(registry.LOCAL_MACHINE, addKeyName, registry.SET_VALUE) 75 | if err != nil { 76 | return err 77 | } 78 | defer appkey.Close() 79 | return registry.DeleteKey(appkey, src) 80 | } 81 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/eventlog/log.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | // Package eventlog implements access to Windows event log. 8 | // 9 | package eventlog 10 | 11 | import ( 12 | "errors" 13 | "syscall" 14 | 15 | "golang.org/x/sys/windows" 16 | ) 17 | 18 | // Log provides access to the system log. 19 | type Log struct { 20 | Handle windows.Handle 21 | } 22 | 23 | // Open retrieves a handle to the specified event log. 24 | func Open(source string) (*Log, error) { 25 | return OpenRemote("", source) 26 | } 27 | 28 | // OpenRemote does the same as Open, but on different computer host. 29 | func OpenRemote(host, source string) (*Log, error) { 30 | if source == "" { 31 | return nil, errors.New("Specify event log source") 32 | } 33 | var s *uint16 34 | if host != "" { 35 | s = syscall.StringToUTF16Ptr(host) 36 | } 37 | h, err := windows.RegisterEventSource(s, syscall.StringToUTF16Ptr(source)) 38 | if err != nil { 39 | return nil, err 40 | } 41 | return &Log{Handle: h}, nil 42 | } 43 | 44 | // Close closes event log l. 45 | func (l *Log) Close() error { 46 | return windows.DeregisterEventSource(l.Handle) 47 | } 48 | 49 | func (l *Log) report(etype uint16, eid uint32, msg string) error { 50 | ss := []*uint16{syscall.StringToUTF16Ptr(msg)} 51 | return windows.ReportEvent(l.Handle, etype, 0, eid, 0, 1, 0, &ss[0], nil) 52 | } 53 | 54 | // Info writes an information event msg with event id eid to the end of event log l. 55 | // When EventCreate.exe is used, eid must be between 1 and 1000. 56 | func (l *Log) Info(eid uint32, msg string) error { 57 | return l.report(windows.EVENTLOG_INFORMATION_TYPE, eid, msg) 58 | } 59 | 60 | // Warning writes an warning event msg with event id eid to the end of event log l. 61 | // When EventCreate.exe is used, eid must be between 1 and 1000. 62 | func (l *Log) Warning(eid uint32, msg string) error { 63 | return l.report(windows.EVENTLOG_WARNING_TYPE, eid, msg) 64 | } 65 | 66 | // Error writes an error event msg with event id eid to the end of event log l. 67 | // When EventCreate.exe is used, eid must be between 1 and 1000. 68 | func (l *Log) Error(eid uint32, msg string) error { 69 | return l.report(windows.EVENTLOG_ERROR_TYPE, eid, msg) 70 | } 71 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/eventlog/log_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package eventlog_test 8 | 9 | import ( 10 | "testing" 11 | 12 | "golang.org/x/sys/windows/svc/eventlog" 13 | ) 14 | 15 | func TestLog(t *testing.T) { 16 | if testing.Short() { 17 | t.Skip("skipping test in short mode - it modifies system logs") 18 | } 19 | 20 | const name = "mylog" 21 | const supports = eventlog.Error | eventlog.Warning | eventlog.Info 22 | err := eventlog.InstallAsEventCreate(name, supports) 23 | if err != nil { 24 | t.Fatalf("Install failed: %s", err) 25 | } 26 | defer func() { 27 | err = eventlog.Remove(name) 28 | if err != nil { 29 | t.Fatalf("Remove failed: %s", err) 30 | } 31 | }() 32 | 33 | l, err := eventlog.Open(name) 34 | if err != nil { 35 | t.Fatalf("Open failed: %s", err) 36 | } 37 | defer l.Close() 38 | 39 | err = l.Info(1, "info") 40 | if err != nil { 41 | t.Fatalf("Info failed: %s", err) 42 | } 43 | err = l.Warning(2, "warning") 44 | if err != nil { 45 | t.Fatalf("Warning failed: %s", err) 46 | } 47 | err = l.Error(3, "error") 48 | if err != nil { 49 | t.Fatalf("Error failed: %s", err) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/example/beep.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package main 8 | 9 | import ( 10 | "syscall" 11 | ) 12 | 13 | // BUG(brainman): MessageBeep Windows api is broken on Windows 7, 14 | // so this example does not beep when runs as service on Windows 7. 15 | 16 | var ( 17 | beepFunc = syscall.MustLoadDLL("user32.dll").MustFindProc("MessageBeep") 18 | ) 19 | 20 | func beep() { 21 | beepFunc.Call(0xffffffff) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/example/install.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "os" 12 | "path/filepath" 13 | 14 | "golang.org/x/sys/windows/svc/eventlog" 15 | "golang.org/x/sys/windows/svc/mgr" 16 | ) 17 | 18 | func exePath() (string, error) { 19 | prog := os.Args[0] 20 | p, err := filepath.Abs(prog) 21 | if err != nil { 22 | return "", err 23 | } 24 | fi, err := os.Stat(p) 25 | if err == nil { 26 | if !fi.Mode().IsDir() { 27 | return p, nil 28 | } 29 | err = fmt.Errorf("%s is directory", p) 30 | } 31 | if filepath.Ext(p) == "" { 32 | p += ".exe" 33 | fi, err := os.Stat(p) 34 | if err == nil { 35 | if !fi.Mode().IsDir() { 36 | return p, nil 37 | } 38 | err = fmt.Errorf("%s is directory", p) 39 | } 40 | } 41 | return "", err 42 | } 43 | 44 | func installService(name, desc string) error { 45 | exepath, err := exePath() 46 | if err != nil { 47 | return err 48 | } 49 | m, err := mgr.Connect() 50 | if err != nil { 51 | return err 52 | } 53 | defer m.Disconnect() 54 | s, err := m.OpenService(name) 55 | if err == nil { 56 | s.Close() 57 | return fmt.Errorf("service %s already exists", name) 58 | } 59 | s, err = m.CreateService(name, exepath, mgr.Config{DisplayName: desc}, "is", "auto-started") 60 | if err != nil { 61 | return err 62 | } 63 | defer s.Close() 64 | err = eventlog.InstallAsEventCreate(name, eventlog.Error|eventlog.Warning|eventlog.Info) 65 | if err != nil { 66 | s.Delete() 67 | return fmt.Errorf("SetupEventLogSource() failed: %s", err) 68 | } 69 | return nil 70 | } 71 | 72 | func removeService(name string) error { 73 | m, err := mgr.Connect() 74 | if err != nil { 75 | return err 76 | } 77 | defer m.Disconnect() 78 | s, err := m.OpenService(name) 79 | if err != nil { 80 | return fmt.Errorf("service %s is not installed", name) 81 | } 82 | defer s.Close() 83 | err = s.Delete() 84 | if err != nil { 85 | return err 86 | } 87 | err = eventlog.Remove(name) 88 | if err != nil { 89 | return fmt.Errorf("RemoveEventLogSource() failed: %s", err) 90 | } 91 | return nil 92 | } 93 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/example/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | // Example service program that beeps. 8 | // 9 | // The program demonstrates how to create Windows service and 10 | // install / remove it on a computer. It also shows how to 11 | // stop / start / pause / continue any service, and how to 12 | // write to event log. It also shows how to use debug 13 | // facilities available in debug package. 14 | // 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "log" 20 | "os" 21 | "strings" 22 | 23 | "golang.org/x/sys/windows/svc" 24 | ) 25 | 26 | func usage(errmsg string) { 27 | fmt.Fprintf(os.Stderr, 28 | "%s\n\n"+ 29 | "usage: %s \n"+ 30 | " where is one of\n"+ 31 | " install, remove, debug, start, stop, pause or continue.\n", 32 | errmsg, os.Args[0]) 33 | os.Exit(2) 34 | } 35 | 36 | func main() { 37 | const svcName = "myservice" 38 | 39 | isIntSess, err := svc.IsAnInteractiveSession() 40 | if err != nil { 41 | log.Fatalf("failed to determine if we are running in an interactive session: %v", err) 42 | } 43 | if !isIntSess { 44 | runService(svcName, false) 45 | return 46 | } 47 | 48 | if len(os.Args) < 2 { 49 | usage("no command specified") 50 | } 51 | 52 | cmd := strings.ToLower(os.Args[1]) 53 | switch cmd { 54 | case "debug": 55 | runService(svcName, true) 56 | return 57 | case "install": 58 | err = installService(svcName, "my service") 59 | case "remove": 60 | err = removeService(svcName) 61 | case "start": 62 | err = startService(svcName) 63 | case "stop": 64 | err = controlService(svcName, svc.Stop, svc.Stopped) 65 | case "pause": 66 | err = controlService(svcName, svc.Pause, svc.Paused) 67 | case "continue": 68 | err = controlService(svcName, svc.Continue, svc.Running) 69 | default: 70 | usage(fmt.Sprintf("invalid command %s", cmd)) 71 | } 72 | if err != nil { 73 | log.Fatalf("failed to %s %s: %v", cmd, svcName, err) 74 | } 75 | return 76 | } 77 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/example/manage.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "time" 12 | 13 | "golang.org/x/sys/windows/svc" 14 | "golang.org/x/sys/windows/svc/mgr" 15 | ) 16 | 17 | func startService(name string) error { 18 | m, err := mgr.Connect() 19 | if err != nil { 20 | return err 21 | } 22 | defer m.Disconnect() 23 | s, err := m.OpenService(name) 24 | if err != nil { 25 | return fmt.Errorf("could not access service: %v", err) 26 | } 27 | defer s.Close() 28 | err = s.Start("is", "manual-started") 29 | if err != nil { 30 | return fmt.Errorf("could not start service: %v", err) 31 | } 32 | return nil 33 | } 34 | 35 | func controlService(name string, c svc.Cmd, to svc.State) error { 36 | m, err := mgr.Connect() 37 | if err != nil { 38 | return err 39 | } 40 | defer m.Disconnect() 41 | s, err := m.OpenService(name) 42 | if err != nil { 43 | return fmt.Errorf("could not access service: %v", err) 44 | } 45 | defer s.Close() 46 | status, err := s.Control(c) 47 | if err != nil { 48 | return fmt.Errorf("could not send control=%d: %v", c, err) 49 | } 50 | timeout := time.Now().Add(10 * time.Second) 51 | for status.State != to { 52 | if timeout.Before(time.Now()) { 53 | return fmt.Errorf("timeout waiting for service to go to state=%d", to) 54 | } 55 | time.Sleep(300 * time.Millisecond) 56 | status, err = s.Query() 57 | if err != nil { 58 | return fmt.Errorf("could not retrieve service status: %v", err) 59 | } 60 | } 61 | return nil 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/example/service.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "time" 12 | 13 | "golang.org/x/sys/windows/svc" 14 | "golang.org/x/sys/windows/svc/debug" 15 | "golang.org/x/sys/windows/svc/eventlog" 16 | ) 17 | 18 | var elog debug.Log 19 | 20 | type myservice struct{} 21 | 22 | func (m *myservice) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) { 23 | const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown | svc.AcceptPauseAndContinue 24 | changes <- svc.Status{State: svc.StartPending} 25 | fasttick := time.Tick(500 * time.Millisecond) 26 | slowtick := time.Tick(2 * time.Second) 27 | tick := fasttick 28 | changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted} 29 | loop: 30 | for { 31 | select { 32 | case <-tick: 33 | beep() 34 | elog.Info(1, "beep") 35 | case c := <-r: 36 | switch c.Cmd { 37 | case svc.Interrogate: 38 | changes <- c.CurrentStatus 39 | // Testing deadlock from https://code.google.com/p/winsvc/issues/detail?id=4 40 | time.Sleep(100 * time.Millisecond) 41 | changes <- c.CurrentStatus 42 | case svc.Stop, svc.Shutdown: 43 | break loop 44 | case svc.Pause: 45 | changes <- svc.Status{State: svc.Paused, Accepts: cmdsAccepted} 46 | tick = slowtick 47 | case svc.Continue: 48 | changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted} 49 | tick = fasttick 50 | default: 51 | elog.Error(1, fmt.Sprintf("unexpected control request #%d", c)) 52 | } 53 | } 54 | } 55 | changes <- svc.Status{State: svc.StopPending} 56 | return 57 | } 58 | 59 | func runService(name string, isDebug bool) { 60 | var err error 61 | if isDebug { 62 | elog = debug.New(name) 63 | } else { 64 | elog, err = eventlog.Open(name) 65 | if err != nil { 66 | return 67 | } 68 | } 69 | defer elog.Close() 70 | 71 | elog.Info(1, fmt.Sprintf("starting %s service", name)) 72 | run := svc.Run 73 | if isDebug { 74 | run = debug.Run 75 | } 76 | err = run(name, &myservice{}) 77 | if err != nil { 78 | elog.Error(1, fmt.Sprintf("%s service failed: %v", name, err)) 79 | return 80 | } 81 | elog.Info(1, fmt.Sprintf("%s service stopped", name)) 82 | } 83 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/go12.c: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | // +build !go1.3 7 | 8 | // copied from pkg/runtime 9 | typedef unsigned int uint32; 10 | typedef unsigned long long int uint64; 11 | #ifdef _64BIT 12 | typedef uint64 uintptr; 13 | #else 14 | typedef uint32 uintptr; 15 | #endif 16 | 17 | // from sys_386.s or sys_amd64.s 18 | void ·servicemain(void); 19 | 20 | void 21 | ·getServiceMain(uintptr *r) 22 | { 23 | *r = (uintptr)·servicemain; 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/go12.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 windows 6 | // +build !go1.3 7 | 8 | package svc 9 | 10 | // from go12.c 11 | func getServiceMain(r *uintptr) 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/go13.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 windows 6 | // +build go1.3 7 | 8 | package svc 9 | 10 | import "unsafe" 11 | 12 | const ptrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const 13 | 14 | // Should be a built-in for unsafe.Pointer? 15 | func add(p unsafe.Pointer, x uintptr) unsafe.Pointer { 16 | return unsafe.Pointer(uintptr(p) + x) 17 | } 18 | 19 | // funcPC returns the entry PC of the function f. 20 | // It assumes that f is a func value. Otherwise the behavior is undefined. 21 | func funcPC(f interface{}) uintptr { 22 | return **(**uintptr)(add(unsafe.Pointer(&f), ptrSize)) 23 | } 24 | 25 | // from sys_386.s and sys_amd64.s 26 | func servicectlhandler(ctl uint32) uintptr 27 | func servicemain(argc uint32, argv **uint16) 28 | 29 | func getServiceMain(r *uintptr) { 30 | *r = funcPC(servicemain) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/mgr/service.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package mgr 8 | 9 | import ( 10 | "syscall" 11 | 12 | "golang.org/x/sys/windows" 13 | "golang.org/x/sys/windows/svc" 14 | ) 15 | 16 | // TODO(brainman): Use EnumDependentServices to enumerate dependent services. 17 | 18 | // Service is used to access Windows service. 19 | type Service struct { 20 | Name string 21 | Handle windows.Handle 22 | } 23 | 24 | // Delete marks service s for deletion from the service control manager database. 25 | func (s *Service) Delete() error { 26 | return windows.DeleteService(s.Handle) 27 | } 28 | 29 | // Close relinquish access to the service s. 30 | func (s *Service) Close() error { 31 | return windows.CloseServiceHandle(s.Handle) 32 | } 33 | 34 | // Start starts service s. 35 | // args will be passed to svc.Handler.Execute. 36 | func (s *Service) Start(args ...string) error { 37 | var p **uint16 38 | if len(args) > 0 { 39 | vs := make([]*uint16, len(args)) 40 | for i := range vs { 41 | vs[i] = syscall.StringToUTF16Ptr(args[i]) 42 | } 43 | p = &vs[0] 44 | } 45 | return windows.StartService(s.Handle, uint32(len(args)), p) 46 | } 47 | 48 | // Control sends state change request c to the servce s. 49 | func (s *Service) Control(c svc.Cmd) (svc.Status, error) { 50 | var t windows.SERVICE_STATUS 51 | err := windows.ControlService(s.Handle, uint32(c), &t) 52 | if err != nil { 53 | return svc.Status{}, err 54 | } 55 | return svc.Status{ 56 | State: svc.State(t.CurrentState), 57 | Accepts: svc.Accepted(t.ControlsAccepted), 58 | }, nil 59 | } 60 | 61 | // Query returns current status of service s. 62 | func (s *Service) Query() (svc.Status, error) { 63 | var t windows.SERVICE_STATUS 64 | err := windows.QueryServiceStatus(s.Handle, &t) 65 | if err != nil { 66 | return svc.Status{}, err 67 | } 68 | return svc.Status{ 69 | State: svc.State(t.CurrentState), 70 | Accepts: svc.Accepted(t.ControlsAccepted), 71 | }, nil 72 | } 73 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/security.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package svc 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "golang.org/x/sys/windows" 13 | ) 14 | 15 | func allocSid(subAuth0 uint32) (*windows.SID, error) { 16 | var sid *windows.SID 17 | err := windows.AllocateAndInitializeSid(&windows.SECURITY_NT_AUTHORITY, 18 | 1, subAuth0, 0, 0, 0, 0, 0, 0, 0, &sid) 19 | if err != nil { 20 | return nil, err 21 | } 22 | return sid, nil 23 | } 24 | 25 | // IsAnInteractiveSession determines if calling process is running interactively. 26 | // It queries the process token for membership in the Interactive group. 27 | // http://stackoverflow.com/questions/2668851/how-do-i-detect-that-my-application-is-running-as-service-or-in-an-interactive-s 28 | func IsAnInteractiveSession() (bool, error) { 29 | interSid, err := allocSid(windows.SECURITY_INTERACTIVE_RID) 30 | if err != nil { 31 | return false, err 32 | } 33 | defer windows.FreeSid(interSid) 34 | 35 | serviceSid, err := allocSid(windows.SECURITY_SERVICE_RID) 36 | if err != nil { 37 | return false, err 38 | } 39 | defer windows.FreeSid(serviceSid) 40 | 41 | t, err := windows.OpenCurrentProcessToken() 42 | if err != nil { 43 | return false, err 44 | } 45 | defer t.Close() 46 | 47 | gs, err := t.GetTokenGroups() 48 | if err != nil { 49 | return false, err 50 | } 51 | p := unsafe.Pointer(&gs.Groups[0]) 52 | groups := (*[2 << 20]windows.SIDAndAttributes)(p)[:gs.GroupCount] 53 | for _, g := range groups { 54 | if windows.EqualSid(g.Sid, interSid) { 55 | return true, nil 56 | } 57 | if windows.EqualSid(g.Sid, serviceSid) { 58 | return false, nil 59 | } 60 | } 61 | return false, nil 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/sys_386.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 windows 6 | 7 | // func servicemain(argc uint32, argv **uint16) 8 | TEXT ·servicemain(SB),7,$0 9 | MOVL argc+0(FP), AX 10 | MOVL AX, ·sArgc(SB) 11 | MOVL argv+4(FP), AX 12 | MOVL AX, ·sArgv(SB) 13 | 14 | PUSHL BP 15 | PUSHL BX 16 | PUSHL SI 17 | PUSHL DI 18 | 19 | SUBL $12, SP 20 | 21 | MOVL ·sName(SB), AX 22 | MOVL AX, (SP) 23 | MOVL $·servicectlhandler(SB), AX 24 | MOVL AX, 4(SP) 25 | MOVL $0, 8(SP) 26 | MOVL ·cRegisterServiceCtrlHandlerExW(SB), AX 27 | MOVL SP, BP 28 | CALL AX 29 | MOVL BP, SP 30 | CMPL AX, $0 31 | JE exit 32 | MOVL AX, ·ssHandle(SB) 33 | 34 | MOVL ·goWaitsH(SB), AX 35 | MOVL AX, (SP) 36 | MOVL ·cSetEvent(SB), AX 37 | MOVL SP, BP 38 | CALL AX 39 | MOVL BP, SP 40 | 41 | MOVL ·cWaitsH(SB), AX 42 | MOVL AX, (SP) 43 | MOVL $-1, AX 44 | MOVL AX, 4(SP) 45 | MOVL ·cWaitForSingleObject(SB), AX 46 | MOVL SP, BP 47 | CALL AX 48 | MOVL BP, SP 49 | 50 | exit: 51 | ADDL $12, SP 52 | 53 | POPL DI 54 | POPL SI 55 | POPL BX 56 | POPL BP 57 | 58 | MOVL 0(SP), CX 59 | ADDL $12, SP 60 | JMP CX 61 | 62 | // I do not know why, but this seems to be the only way to call 63 | // ctlHandlerProc on Windows 7. 64 | 65 | // func servicectlhandler(ctl uint32, evtype uint32, evdata uintptr, context uintptr) uintptr { 66 | TEXT ·servicectlhandler(SB),7,$0 67 | MOVL ·ctlHandlerExProc(SB), CX 68 | JMP CX 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/sys_amd64.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 windows 6 | 7 | // func servicemain(argc uint32, argv **uint16) 8 | TEXT ·servicemain(SB),7,$0 9 | MOVL CX, ·sArgc(SB) 10 | MOVL DX, ·sArgv(SB) 11 | 12 | SUBQ $32, SP // stack for the first 4 syscall params 13 | 14 | MOVQ ·sName(SB), CX 15 | MOVQ $·servicectlhandler(SB), DX 16 | // BUG(pastarmovj): Figure out a way to pass in context in R8. 17 | MOVQ ·cRegisterServiceCtrlHandlerExW(SB), AX 18 | CALL AX 19 | CMPQ AX, $0 20 | JE exit 21 | MOVQ AX, ·ssHandle(SB) 22 | 23 | MOVQ ·goWaitsH(SB), CX 24 | MOVQ ·cSetEvent(SB), AX 25 | CALL AX 26 | 27 | MOVQ ·cWaitsH(SB), CX 28 | MOVQ $4294967295, DX 29 | MOVQ ·cWaitForSingleObject(SB), AX 30 | CALL AX 31 | 32 | exit: 33 | ADDQ $32, SP 34 | RET 35 | 36 | // I do not know why, but this seems to be the only way to call 37 | // ctlHandlerProc on Windows 7. 38 | 39 | // func ·servicectlhandler(ctl uint32, evtype uint32, evdata uintptr, context uintptr) uintptr { 40 | TEXT ·servicectlhandler(SB),7,$0 41 | MOVQ ·ctlHandlerExProc(SB), AX 42 | JMP AX 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | // Package windows contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display the OS-specific documentation for the current 10 | // system. If you want godoc to display syscall documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // 15 | // The primary use of this package is inside other packages that provide a more 16 | // portable interface to the system, such as "os", "time" and "net". Use 17 | // those packages rather than this one if you can. 18 | // 19 | // For details of the functions and data types in this package consult 20 | // the manuals for the appropriate operating system. 21 | // 22 | // These calls return err == nil to indicate success; otherwise 23 | // err represents an operating system error describing the failure and 24 | // holds a value of type syscall.Errno. 25 | package windows // import "golang.org/x/sys/windows" 26 | 27 | import ( 28 | "syscall" 29 | ) 30 | 31 | // ByteSliceFromString returns a NUL-terminated slice of bytes 32 | // containing the text of s. If s contains a NUL byte at any 33 | // location, it returns (nil, syscall.EINVAL). 34 | func ByteSliceFromString(s string) ([]byte, error) { 35 | for i := 0; i < len(s); i++ { 36 | if s[i] == 0 { 37 | return nil, syscall.EINVAL 38 | } 39 | } 40 | a := make([]byte, len(s)+1) 41 | copy(a, s) 42 | return a, nil 43 | } 44 | 45 | // BytePtrFromString returns a pointer to a NUL-terminated array of 46 | // bytes containing the text of s. If s contains a NUL byte at any 47 | // location, it returns (nil, syscall.EINVAL). 48 | func BytePtrFromString(s string) (*byte, error) { 49 | a, err := ByteSliceFromString(s) 50 | if err != nil { 51 | return nil, err 52 | } 53 | return &a[0], nil 54 | } 55 | 56 | // Single-word zero for use when we need a valid pointer to 0 bytes. 57 | // See mksyscall.pl. 58 | var _zero uintptr 59 | 60 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 61 | return int64(ts.Sec), int64(ts.Nsec) 62 | } 63 | 64 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 65 | return int64(tv.Sec), int64(tv.Usec) * 1000 66 | } 67 | 68 | func (ts *Timespec) Nano() int64 { 69 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 70 | } 71 | 72 | func (tv *Timeval) Nano() int64 { 73 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 74 | } 75 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/syscall_test.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 windows 6 | 7 | package windows_test 8 | 9 | import ( 10 | "syscall" 11 | "testing" 12 | 13 | "golang.org/x/sys/windows" 14 | ) 15 | 16 | func testSetGetenv(t *testing.T, key, value string) { 17 | err := windows.Setenv(key, value) 18 | if err != nil { 19 | t.Fatalf("Setenv failed to set %q: %v", value, err) 20 | } 21 | newvalue, found := windows.Getenv(key) 22 | if !found { 23 | t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value) 24 | } 25 | if newvalue != value { 26 | t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value) 27 | } 28 | } 29 | 30 | func TestEnv(t *testing.T) { 31 | testSetGetenv(t, "TESTENV", "AVALUE") 32 | // make sure TESTENV gets set to "", not deleted 33 | testSetGetenv(t, "TESTENV", "") 34 | } 35 | 36 | func TestGetProcAddressByOrdinal(t *testing.T) { 37 | // Attempt calling shlwapi.dll:IsOS, resolving it by ordinal, as 38 | // suggested in 39 | // https://msdn.microsoft.com/en-us/library/windows/desktop/bb773795.aspx 40 | h, err := windows.LoadLibrary("shlwapi.dll") 41 | if err != nil { 42 | t.Fatalf("Failed to load shlwapi.dll: %s", err) 43 | } 44 | procIsOS, err := windows.GetProcAddressByOrdinal(h, 437) 45 | if err != nil { 46 | t.Fatalf("Could not find shlwapi.dll:IsOS by ordinal: %s", err) 47 | } 48 | const OS_NT = 1 49 | r, _, _ := syscall.Syscall(procIsOS, 1, OS_NT, 0, 0) 50 | if r == 0 { 51 | t.Error("shlwapi.dll:IsOS(OS_NT) returned 0, expected non-zero value") 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/types_windows_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/types_windows_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | MaxSockets uint16 11 | MaxUdpDg uint16 12 | VendorInfo *byte 13 | Description [WSADESCRIPTION_LEN + 1]byte 14 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Proto *byte 21 | Port uint16 22 | } 23 | --------------------------------------------------------------------------------