mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-12 08:00:05 +01:00
Merge pull request #25 from metalmatze/color
Print colored output for fetched package
This commit is contained in:
commit
aa225e597c
289 changed files with 215085 additions and 2 deletions
48
Gopkg.lock
generated
48
Gopkg.lock
generated
|
|
@ -3,34 +3,78 @@
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
digest = "1:f3793f8a708522400cef1dba23385e901aede5519f68971fd69938ef330b07a1"
|
||||||
name = "github.com/alecthomas/template"
|
name = "github.com/alecthomas/template"
|
||||||
packages = [
|
packages = [
|
||||||
".",
|
".",
|
||||||
"parse"
|
"parse",
|
||||||
]
|
]
|
||||||
|
pruneopts = "NUT"
|
||||||
revision = "a0175ee3bccc567396460bf5acd36800cb10c49c"
|
revision = "a0175ee3bccc567396460bf5acd36800cb10c49c"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
digest = "1:fdd419e104ec26bb5bd63cc62637c640453ed2929a7453f3afadbd9a0223da66"
|
||||||
name = "github.com/alecthomas/units"
|
name = "github.com/alecthomas/units"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
|
pruneopts = "NUT"
|
||||||
revision = "2efee857e7cfd4f3d0138cc3cbb1b4966962b93a"
|
revision = "2efee857e7cfd4f3d0138cc3cbb1b4966962b93a"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
|
digest = "1:ade392a843b2035effb4b4a2efa2c3bab3eb29b992e98bacf9c898b0ecb54e45"
|
||||||
|
name = "github.com/fatih/color"
|
||||||
|
packages = ["."]
|
||||||
|
pruneopts = "NUT"
|
||||||
|
revision = "5b77d2a35fb0ede96d138fc9a99f5c9b6aef11b4"
|
||||||
|
version = "v1.7.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
digest = "1:08c231ec84231a7e23d67e4b58f975e1423695a32467a362ee55a803f9de8061"
|
||||||
|
name = "github.com/mattn/go-colorable"
|
||||||
|
packages = ["."]
|
||||||
|
pruneopts = "NUT"
|
||||||
|
revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072"
|
||||||
|
version = "v0.0.9"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
digest = "1:f4109742a922eca7b7a6a1f97f93cc5834e21a5f13a1e0c1cead73815ab75548"
|
||||||
|
name = "github.com/mattn/go-isatty"
|
||||||
|
packages = ["."]
|
||||||
|
pruneopts = "NUT"
|
||||||
|
revision = "369ecd8cea9851e459abb67eb171853e3986591e"
|
||||||
|
version = "v0.0.6"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
digest = "1:5cf3f025cbee5951a4ee961de067c8a89fc95a5adabead774f82822efabab121"
|
||||||
name = "github.com/pkg/errors"
|
name = "github.com/pkg/errors"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
|
pruneopts = "NUT"
|
||||||
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
|
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
|
||||||
version = "v0.8.0"
|
version = "v0.8.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
digest = "1:7a930dc8bf7a6f1ffb1a3b5ddb22cfd2cf4ef8a750c95a1f4f8166b5cbd07002"
|
||||||
|
name = "golang.org/x/sys"
|
||||||
|
packages = ["unix"]
|
||||||
|
pruneopts = "NUT"
|
||||||
|
revision = "10058d7d4faa7dd5ef860cbd31af00903076e7b8"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
digest = "1:22b2dee6f30bc8601f087449a2a819df8388e54e9547349c658f14d8f8c590f2"
|
||||||
name = "gopkg.in/alecthomas/kingpin.v2"
|
name = "gopkg.in/alecthomas/kingpin.v2"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
|
pruneopts = "NUT"
|
||||||
revision = "947dcec5ba9c011838740e680966fd7087a71d0d"
|
revision = "947dcec5ba9c011838740e680966fd7087a71d0d"
|
||||||
version = "v2.2.6"
|
version = "v2.2.6"
|
||||||
|
|
||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "4a98ea2be4c124f0dcabf8233d7d54c26546910b1e75cba346f1a9bbf8f377aa"
|
input-imports = [
|
||||||
|
"github.com/fatih/color",
|
||||||
|
"github.com/pkg/errors",
|
||||||
|
"gopkg.in/alecthomas/kingpin.v2",
|
||||||
|
]
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/fatih/color"
|
||||||
"github.com/jsonnet-bundler/jsonnet-bundler/spec"
|
"github.com/jsonnet-bundler/jsonnet-bundler/spec"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
@ -59,6 +60,8 @@ func Install(ctx context.Context, isLock bool, dependencySourceIdentifier string
|
||||||
return nil, errors.Wrap(err, "failed to install package")
|
return nil, errors.Wrap(err, "failed to install package")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
color.Green(">>> Installed %s version %s\n", dep.Name, dep.Version)
|
||||||
|
|
||||||
destPath := path.Join(dir, dep.Name)
|
destPath := path.Join(dir, dep.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to find destination path for package")
|
return nil, errors.Wrap(err, "failed to find destination path for package")
|
||||||
|
|
|
||||||
20
vendor/github.com/fatih/color/LICENSE.md
generated
vendored
Normal file
20
vendor/github.com/fatih/color/LICENSE.md
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2013 Fatih Arslan
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
603
vendor/github.com/fatih/color/color.go
generated
vendored
Normal file
603
vendor/github.com/fatih/color/color.go
generated
vendored
Normal file
|
|
@ -0,0 +1,603 @@
|
||||||
|
package color
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/mattn/go-colorable"
|
||||||
|
"github.com/mattn/go-isatty"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// NoColor defines if the output is colorized or not. It's dynamically set to
|
||||||
|
// false or true based on the stdout's file descriptor referring to a terminal
|
||||||
|
// or not. This is a global option and affects all colors. For more control
|
||||||
|
// over each color block use the methods DisableColor() individually.
|
||||||
|
NoColor = os.Getenv("TERM") == "dumb" ||
|
||||||
|
(!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()))
|
||||||
|
|
||||||
|
// Output defines the standard output of the print functions. By default
|
||||||
|
// os.Stdout is used.
|
||||||
|
Output = colorable.NewColorableStdout()
|
||||||
|
|
||||||
|
// Error defines a color supporting writer for os.Stderr.
|
||||||
|
Error = colorable.NewColorableStderr()
|
||||||
|
|
||||||
|
// colorsCache is used to reduce the count of created Color objects and
|
||||||
|
// allows to reuse already created objects with required Attribute.
|
||||||
|
colorsCache = make(map[Attribute]*Color)
|
||||||
|
colorsCacheMu sync.Mutex // protects colorsCache
|
||||||
|
)
|
||||||
|
|
||||||
|
// Color defines a custom color object which is defined by SGR parameters.
|
||||||
|
type Color struct {
|
||||||
|
params []Attribute
|
||||||
|
noColor *bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attribute defines a single SGR Code
|
||||||
|
type Attribute int
|
||||||
|
|
||||||
|
const escape = "\x1b"
|
||||||
|
|
||||||
|
// Base attributes
|
||||||
|
const (
|
||||||
|
Reset Attribute = iota
|
||||||
|
Bold
|
||||||
|
Faint
|
||||||
|
Italic
|
||||||
|
Underline
|
||||||
|
BlinkSlow
|
||||||
|
BlinkRapid
|
||||||
|
ReverseVideo
|
||||||
|
Concealed
|
||||||
|
CrossedOut
|
||||||
|
)
|
||||||
|
|
||||||
|
// Foreground text colors
|
||||||
|
const (
|
||||||
|
FgBlack Attribute = iota + 30
|
||||||
|
FgRed
|
||||||
|
FgGreen
|
||||||
|
FgYellow
|
||||||
|
FgBlue
|
||||||
|
FgMagenta
|
||||||
|
FgCyan
|
||||||
|
FgWhite
|
||||||
|
)
|
||||||
|
|
||||||
|
// Foreground Hi-Intensity text colors
|
||||||
|
const (
|
||||||
|
FgHiBlack Attribute = iota + 90
|
||||||
|
FgHiRed
|
||||||
|
FgHiGreen
|
||||||
|
FgHiYellow
|
||||||
|
FgHiBlue
|
||||||
|
FgHiMagenta
|
||||||
|
FgHiCyan
|
||||||
|
FgHiWhite
|
||||||
|
)
|
||||||
|
|
||||||
|
// Background text colors
|
||||||
|
const (
|
||||||
|
BgBlack Attribute = iota + 40
|
||||||
|
BgRed
|
||||||
|
BgGreen
|
||||||
|
BgYellow
|
||||||
|
BgBlue
|
||||||
|
BgMagenta
|
||||||
|
BgCyan
|
||||||
|
BgWhite
|
||||||
|
)
|
||||||
|
|
||||||
|
// Background Hi-Intensity text colors
|
||||||
|
const (
|
||||||
|
BgHiBlack Attribute = iota + 100
|
||||||
|
BgHiRed
|
||||||
|
BgHiGreen
|
||||||
|
BgHiYellow
|
||||||
|
BgHiBlue
|
||||||
|
BgHiMagenta
|
||||||
|
BgHiCyan
|
||||||
|
BgHiWhite
|
||||||
|
)
|
||||||
|
|
||||||
|
// New returns a newly created color object.
|
||||||
|
func New(value ...Attribute) *Color {
|
||||||
|
c := &Color{params: make([]Attribute, 0)}
|
||||||
|
c.Add(value...)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set sets the given parameters immediately. It will change the color of
|
||||||
|
// output with the given SGR parameters until color.Unset() is called.
|
||||||
|
func Set(p ...Attribute) *Color {
|
||||||
|
c := New(p...)
|
||||||
|
c.Set()
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unset resets all escape attributes and clears the output. Usually should
|
||||||
|
// be called after Set().
|
||||||
|
func Unset() {
|
||||||
|
if NoColor {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(Output, "%s[%dm", escape, Reset)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set sets the SGR sequence.
|
||||||
|
func (c *Color) Set() *Color {
|
||||||
|
if c.isNoColorSet() {
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(Output, c.format())
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Color) unset() {
|
||||||
|
if c.isNoColorSet() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Unset()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Color) setWriter(w io.Writer) *Color {
|
||||||
|
if c.isNoColorSet() {
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(w, c.format())
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Color) unsetWriter(w io.Writer) {
|
||||||
|
if c.isNoColorSet() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if NoColor {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(w, "%s[%dm", escape, Reset)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add is used to chain SGR parameters. Use as many as parameters to combine
|
||||||
|
// and create custom color objects. Example: Add(color.FgRed, color.Underline).
|
||||||
|
func (c *Color) Add(value ...Attribute) *Color {
|
||||||
|
c.params = append(c.params, value...)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Color) prepend(value Attribute) {
|
||||||
|
c.params = append(c.params, 0)
|
||||||
|
copy(c.params[1:], c.params[0:])
|
||||||
|
c.params[0] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fprint formats using the default formats for its operands and writes to w.
|
||||||
|
// Spaces are added between operands when neither is a string.
|
||||||
|
// It returns the number of bytes written and any write error encountered.
|
||||||
|
// On Windows, users should wrap w with colorable.NewColorable() if w is of
|
||||||
|
// type *os.File.
|
||||||
|
func (c *Color) Fprint(w io.Writer, a ...interface{}) (n int, err error) {
|
||||||
|
c.setWriter(w)
|
||||||
|
defer c.unsetWriter(w)
|
||||||
|
|
||||||
|
return fmt.Fprint(w, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print formats using the default formats for its operands and writes to
|
||||||
|
// standard output. Spaces are added between operands when neither is a
|
||||||
|
// string. It returns the number of bytes written and any write error
|
||||||
|
// encountered. This is the standard fmt.Print() method wrapped with the given
|
||||||
|
// color.
|
||||||
|
func (c *Color) Print(a ...interface{}) (n int, err error) {
|
||||||
|
c.Set()
|
||||||
|
defer c.unset()
|
||||||
|
|
||||||
|
return fmt.Fprint(Output, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fprintf formats according to a format specifier and writes to w.
|
||||||
|
// It returns the number of bytes written and any write error encountered.
|
||||||
|
// On Windows, users should wrap w with colorable.NewColorable() if w is of
|
||||||
|
// type *os.File.
|
||||||
|
func (c *Color) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
|
||||||
|
c.setWriter(w)
|
||||||
|
defer c.unsetWriter(w)
|
||||||
|
|
||||||
|
return fmt.Fprintf(w, format, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Printf formats according to a format specifier and writes to standard output.
|
||||||
|
// It returns the number of bytes written and any write error encountered.
|
||||||
|
// This is the standard fmt.Printf() method wrapped with the given color.
|
||||||
|
func (c *Color) Printf(format string, a ...interface{}) (n int, err error) {
|
||||||
|
c.Set()
|
||||||
|
defer c.unset()
|
||||||
|
|
||||||
|
return fmt.Fprintf(Output, format, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fprintln formats using the default formats for its operands and writes to w.
|
||||||
|
// Spaces are always added between operands and a newline is appended.
|
||||||
|
// On Windows, users should wrap w with colorable.NewColorable() if w is of
|
||||||
|
// type *os.File.
|
||||||
|
func (c *Color) Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
|
||||||
|
c.setWriter(w)
|
||||||
|
defer c.unsetWriter(w)
|
||||||
|
|
||||||
|
return fmt.Fprintln(w, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Println formats using the default formats for its operands and writes to
|
||||||
|
// standard output. Spaces are always added between operands and a newline is
|
||||||
|
// appended. It returns the number of bytes written and any write error
|
||||||
|
// encountered. This is the standard fmt.Print() method wrapped with the given
|
||||||
|
// color.
|
||||||
|
func (c *Color) Println(a ...interface{}) (n int, err error) {
|
||||||
|
c.Set()
|
||||||
|
defer c.unset()
|
||||||
|
|
||||||
|
return fmt.Fprintln(Output, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sprint is just like Print, but returns a string instead of printing it.
|
||||||
|
func (c *Color) Sprint(a ...interface{}) string {
|
||||||
|
return c.wrap(fmt.Sprint(a...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sprintln is just like Println, but returns a string instead of printing it.
|
||||||
|
func (c *Color) Sprintln(a ...interface{}) string {
|
||||||
|
return c.wrap(fmt.Sprintln(a...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sprintf is just like Printf, but returns a string instead of printing it.
|
||||||
|
func (c *Color) Sprintf(format string, a ...interface{}) string {
|
||||||
|
return c.wrap(fmt.Sprintf(format, a...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FprintFunc returns a new function that prints the passed arguments as
|
||||||
|
// colorized with color.Fprint().
|
||||||
|
func (c *Color) FprintFunc() func(w io.Writer, a ...interface{}) {
|
||||||
|
return func(w io.Writer, a ...interface{}) {
|
||||||
|
c.Fprint(w, a...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrintFunc returns a new function that prints the passed arguments as
|
||||||
|
// colorized with color.Print().
|
||||||
|
func (c *Color) PrintFunc() func(a ...interface{}) {
|
||||||
|
return func(a ...interface{}) {
|
||||||
|
c.Print(a...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FprintfFunc returns a new function that prints the passed arguments as
|
||||||
|
// colorized with color.Fprintf().
|
||||||
|
func (c *Color) FprintfFunc() func(w io.Writer, format string, a ...interface{}) {
|
||||||
|
return func(w io.Writer, format string, a ...interface{}) {
|
||||||
|
c.Fprintf(w, format, a...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrintfFunc returns a new function that prints the passed arguments as
|
||||||
|
// colorized with color.Printf().
|
||||||
|
func (c *Color) PrintfFunc() func(format string, a ...interface{}) {
|
||||||
|
return func(format string, a ...interface{}) {
|
||||||
|
c.Printf(format, a...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FprintlnFunc returns a new function that prints the passed arguments as
|
||||||
|
// colorized with color.Fprintln().
|
||||||
|
func (c *Color) FprintlnFunc() func(w io.Writer, a ...interface{}) {
|
||||||
|
return func(w io.Writer, a ...interface{}) {
|
||||||
|
c.Fprintln(w, a...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrintlnFunc returns a new function that prints the passed arguments as
|
||||||
|
// colorized with color.Println().
|
||||||
|
func (c *Color) PrintlnFunc() func(a ...interface{}) {
|
||||||
|
return func(a ...interface{}) {
|
||||||
|
c.Println(a...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SprintFunc returns a new function that returns colorized strings for the
|
||||||
|
// given arguments with fmt.Sprint(). Useful to put into or mix into other
|
||||||
|
// string. Windows users should use this in conjunction with color.Output, example:
|
||||||
|
//
|
||||||
|
// put := New(FgYellow).SprintFunc()
|
||||||
|
// fmt.Fprintf(color.Output, "This is a %s", put("warning"))
|
||||||
|
func (c *Color) SprintFunc() func(a ...interface{}) string {
|
||||||
|
return func(a ...interface{}) string {
|
||||||
|
return c.wrap(fmt.Sprint(a...))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SprintfFunc returns a new function that returns colorized strings for the
|
||||||
|
// given arguments with fmt.Sprintf(). Useful to put into or mix into other
|
||||||
|
// string. Windows users should use this in conjunction with color.Output.
|
||||||
|
func (c *Color) SprintfFunc() func(format string, a ...interface{}) string {
|
||||||
|
return func(format string, a ...interface{}) string {
|
||||||
|
return c.wrap(fmt.Sprintf(format, a...))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SprintlnFunc returns a new function that returns colorized strings for the
|
||||||
|
// given arguments with fmt.Sprintln(). Useful to put into or mix into other
|
||||||
|
// string. Windows users should use this in conjunction with color.Output.
|
||||||
|
func (c *Color) SprintlnFunc() func(a ...interface{}) string {
|
||||||
|
return func(a ...interface{}) string {
|
||||||
|
return c.wrap(fmt.Sprintln(a...))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// sequence returns a formatted SGR sequence to be plugged into a "\x1b[...m"
|
||||||
|
// an example output might be: "1;36" -> bold cyan
|
||||||
|
func (c *Color) sequence() string {
|
||||||
|
format := make([]string, len(c.params))
|
||||||
|
for i, v := range c.params {
|
||||||
|
format[i] = strconv.Itoa(int(v))
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Join(format, ";")
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrap wraps the s string with the colors attributes. The string is ready to
|
||||||
|
// be printed.
|
||||||
|
func (c *Color) wrap(s string) string {
|
||||||
|
if c.isNoColorSet() {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.format() + s + c.unformat()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Color) format() string {
|
||||||
|
return fmt.Sprintf("%s[%sm", escape, c.sequence())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Color) unformat() string {
|
||||||
|
return fmt.Sprintf("%s[%dm", escape, Reset)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DisableColor disables the color output. Useful to not change any existing
|
||||||
|
// code and still being able to output. Can be used for flags like
|
||||||
|
// "--no-color". To enable back use EnableColor() method.
|
||||||
|
func (c *Color) DisableColor() {
|
||||||
|
c.noColor = boolPtr(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableColor enables the color output. Use it in conjunction with
|
||||||
|
// DisableColor(). Otherwise this method has no side effects.
|
||||||
|
func (c *Color) EnableColor() {
|
||||||
|
c.noColor = boolPtr(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Color) isNoColorSet() bool {
|
||||||
|
// check first if we have user setted action
|
||||||
|
if c.noColor != nil {
|
||||||
|
return *c.noColor
|
||||||
|
}
|
||||||
|
|
||||||
|
// if not return the global option, which is disabled by default
|
||||||
|
return NoColor
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equals returns a boolean value indicating whether two colors are equal.
|
||||||
|
func (c *Color) Equals(c2 *Color) bool {
|
||||||
|
if len(c.params) != len(c2.params) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, attr := range c.params {
|
||||||
|
if !c2.attrExists(attr) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Color) attrExists(a Attribute) bool {
|
||||||
|
for _, attr := range c.params {
|
||||||
|
if attr == a {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func boolPtr(v bool) *bool {
|
||||||
|
return &v
|
||||||
|
}
|
||||||
|
|
||||||
|
func getCachedColor(p Attribute) *Color {
|
||||||
|
colorsCacheMu.Lock()
|
||||||
|
defer colorsCacheMu.Unlock()
|
||||||
|
|
||||||
|
c, ok := colorsCache[p]
|
||||||
|
if !ok {
|
||||||
|
c = New(p)
|
||||||
|
colorsCache[p] = c
|
||||||
|
}
|
||||||
|
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
func colorPrint(format string, p Attribute, a ...interface{}) {
|
||||||
|
c := getCachedColor(p)
|
||||||
|
|
||||||
|
if !strings.HasSuffix(format, "\n") {
|
||||||
|
format += "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(a) == 0 {
|
||||||
|
c.Print(format)
|
||||||
|
} else {
|
||||||
|
c.Printf(format, a...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func colorString(format string, p Attribute, a ...interface{}) string {
|
||||||
|
c := getCachedColor(p)
|
||||||
|
|
||||||
|
if len(a) == 0 {
|
||||||
|
return c.SprintFunc()(format)
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.SprintfFunc()(format, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Black is a convenient helper function to print with black foreground. A
|
||||||
|
// newline is appended to format by default.
|
||||||
|
func Black(format string, a ...interface{}) { colorPrint(format, FgBlack, a...) }
|
||||||
|
|
||||||
|
// Red is a convenient helper function to print with red foreground. A
|
||||||
|
// newline is appended to format by default.
|
||||||
|
func Red(format string, a ...interface{}) { colorPrint(format, FgRed, a...) }
|
||||||
|
|
||||||
|
// Green is a convenient helper function to print with green foreground. A
|
||||||
|
// newline is appended to format by default.
|
||||||
|
func Green(format string, a ...interface{}) { colorPrint(format, FgGreen, a...) }
|
||||||
|
|
||||||
|
// Yellow is a convenient helper function to print with yellow foreground.
|
||||||
|
// A newline is appended to format by default.
|
||||||
|
func Yellow(format string, a ...interface{}) { colorPrint(format, FgYellow, a...) }
|
||||||
|
|
||||||
|
// Blue is a convenient helper function to print with blue foreground. A
|
||||||
|
// newline is appended to format by default.
|
||||||
|
func Blue(format string, a ...interface{}) { colorPrint(format, FgBlue, a...) }
|
||||||
|
|
||||||
|
// Magenta is a convenient helper function to print with magenta foreground.
|
||||||
|
// A newline is appended to format by default.
|
||||||
|
func Magenta(format string, a ...interface{}) { colorPrint(format, FgMagenta, a...) }
|
||||||
|
|
||||||
|
// Cyan is a convenient helper function to print with cyan foreground. A
|
||||||
|
// newline is appended to format by default.
|
||||||
|
func Cyan(format string, a ...interface{}) { colorPrint(format, FgCyan, a...) }
|
||||||
|
|
||||||
|
// White is a convenient helper function to print with white foreground. A
|
||||||
|
// newline is appended to format by default.
|
||||||
|
func White(format string, a ...interface{}) { colorPrint(format, FgWhite, a...) }
|
||||||
|
|
||||||
|
// BlackString is a convenient helper function to return a string with black
|
||||||
|
// foreground.
|
||||||
|
func BlackString(format string, a ...interface{}) string { return colorString(format, FgBlack, a...) }
|
||||||
|
|
||||||
|
// RedString is a convenient helper function to return a string with red
|
||||||
|
// foreground.
|
||||||
|
func RedString(format string, a ...interface{}) string { return colorString(format, FgRed, a...) }
|
||||||
|
|
||||||
|
// GreenString is a convenient helper function to return a string with green
|
||||||
|
// foreground.
|
||||||
|
func GreenString(format string, a ...interface{}) string { return colorString(format, FgGreen, a...) }
|
||||||
|
|
||||||
|
// YellowString is a convenient helper function to return a string with yellow
|
||||||
|
// foreground.
|
||||||
|
func YellowString(format string, a ...interface{}) string { return colorString(format, FgYellow, a...) }
|
||||||
|
|
||||||
|
// BlueString is a convenient helper function to return a string with blue
|
||||||
|
// foreground.
|
||||||
|
func BlueString(format string, a ...interface{}) string { return colorString(format, FgBlue, a...) }
|
||||||
|
|
||||||
|
// MagentaString is a convenient helper function to return a string with magenta
|
||||||
|
// foreground.
|
||||||
|
func MagentaString(format string, a ...interface{}) string {
|
||||||
|
return colorString(format, FgMagenta, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CyanString is a convenient helper function to return a string with cyan
|
||||||
|
// foreground.
|
||||||
|
func CyanString(format string, a ...interface{}) string { return colorString(format, FgCyan, a...) }
|
||||||
|
|
||||||
|
// WhiteString is a convenient helper function to return a string with white
|
||||||
|
// foreground.
|
||||||
|
func WhiteString(format string, a ...interface{}) string { return colorString(format, FgWhite, a...) }
|
||||||
|
|
||||||
|
// HiBlack is a convenient helper function to print with hi-intensity black foreground. A
|
||||||
|
// newline is appended to format by default.
|
||||||
|
func HiBlack(format string, a ...interface{}) { colorPrint(format, FgHiBlack, a...) }
|
||||||
|
|
||||||
|
// HiRed is a convenient helper function to print with hi-intensity red foreground. A
|
||||||
|
// newline is appended to format by default.
|
||||||
|
func HiRed(format string, a ...interface{}) { colorPrint(format, FgHiRed, a...) }
|
||||||
|
|
||||||
|
// HiGreen is a convenient helper function to print with hi-intensity green foreground. A
|
||||||
|
// newline is appended to format by default.
|
||||||
|
func HiGreen(format string, a ...interface{}) { colorPrint(format, FgHiGreen, a...) }
|
||||||
|
|
||||||
|
// HiYellow is a convenient helper function to print with hi-intensity yellow foreground.
|
||||||
|
// A newline is appended to format by default.
|
||||||
|
func HiYellow(format string, a ...interface{}) { colorPrint(format, FgHiYellow, a...) }
|
||||||
|
|
||||||
|
// HiBlue is a convenient helper function to print with hi-intensity blue foreground. A
|
||||||
|
// newline is appended to format by default.
|
||||||
|
func HiBlue(format string, a ...interface{}) { colorPrint(format, FgHiBlue, a...) }
|
||||||
|
|
||||||
|
// HiMagenta is a convenient helper function to print with hi-intensity magenta foreground.
|
||||||
|
// A newline is appended to format by default.
|
||||||
|
func HiMagenta(format string, a ...interface{}) { colorPrint(format, FgHiMagenta, a...) }
|
||||||
|
|
||||||
|
// HiCyan is a convenient helper function to print with hi-intensity cyan foreground. A
|
||||||
|
// newline is appended to format by default.
|
||||||
|
func HiCyan(format string, a ...interface{}) { colorPrint(format, FgHiCyan, a...) }
|
||||||
|
|
||||||
|
// HiWhite is a convenient helper function to print with hi-intensity white foreground. A
|
||||||
|
// newline is appended to format by default.
|
||||||
|
func HiWhite(format string, a ...interface{}) { colorPrint(format, FgHiWhite, a...) }
|
||||||
|
|
||||||
|
// HiBlackString is a convenient helper function to return a string with hi-intensity black
|
||||||
|
// foreground.
|
||||||
|
func HiBlackString(format string, a ...interface{}) string {
|
||||||
|
return colorString(format, FgHiBlack, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HiRedString is a convenient helper function to return a string with hi-intensity red
|
||||||
|
// foreground.
|
||||||
|
func HiRedString(format string, a ...interface{}) string { return colorString(format, FgHiRed, a...) }
|
||||||
|
|
||||||
|
// HiGreenString is a convenient helper function to return a string with hi-intensity green
|
||||||
|
// foreground.
|
||||||
|
func HiGreenString(format string, a ...interface{}) string {
|
||||||
|
return colorString(format, FgHiGreen, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HiYellowString is a convenient helper function to return a string with hi-intensity yellow
|
||||||
|
// foreground.
|
||||||
|
func HiYellowString(format string, a ...interface{}) string {
|
||||||
|
return colorString(format, FgHiYellow, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HiBlueString is a convenient helper function to return a string with hi-intensity blue
|
||||||
|
// foreground.
|
||||||
|
func HiBlueString(format string, a ...interface{}) string { return colorString(format, FgHiBlue, a...) }
|
||||||
|
|
||||||
|
// HiMagentaString is a convenient helper function to return a string with hi-intensity magenta
|
||||||
|
// foreground.
|
||||||
|
func HiMagentaString(format string, a ...interface{}) string {
|
||||||
|
return colorString(format, FgHiMagenta, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HiCyanString is a convenient helper function to return a string with hi-intensity cyan
|
||||||
|
// foreground.
|
||||||
|
func HiCyanString(format string, a ...interface{}) string { return colorString(format, FgHiCyan, a...) }
|
||||||
|
|
||||||
|
// HiWhiteString is a convenient helper function to return a string with hi-intensity white
|
||||||
|
// foreground.
|
||||||
|
func HiWhiteString(format string, a ...interface{}) string {
|
||||||
|
return colorString(format, FgHiWhite, a...)
|
||||||
|
}
|
||||||
133
vendor/github.com/fatih/color/doc.go
generated
vendored
Normal file
133
vendor/github.com/fatih/color/doc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,133 @@
|
||||||
|
/*
|
||||||
|
Package color is an ANSI color package to output colorized or SGR defined
|
||||||
|
output to the standard output. The API can be used in several way, pick one
|
||||||
|
that suits you.
|
||||||
|
|
||||||
|
Use simple and default helper functions with predefined foreground colors:
|
||||||
|
|
||||||
|
color.Cyan("Prints text in cyan.")
|
||||||
|
|
||||||
|
// a newline will be appended automatically
|
||||||
|
color.Blue("Prints %s in blue.", "text")
|
||||||
|
|
||||||
|
// More default foreground colors..
|
||||||
|
color.Red("We have red")
|
||||||
|
color.Yellow("Yellow color too!")
|
||||||
|
color.Magenta("And many others ..")
|
||||||
|
|
||||||
|
// Hi-intensity colors
|
||||||
|
color.HiGreen("Bright green color.")
|
||||||
|
color.HiBlack("Bright black means gray..")
|
||||||
|
color.HiWhite("Shiny white color!")
|
||||||
|
|
||||||
|
However there are times where custom color mixes are required. Below are some
|
||||||
|
examples to create custom color objects and use the print functions of each
|
||||||
|
separate color object.
|
||||||
|
|
||||||
|
// Create a new color object
|
||||||
|
c := color.New(color.FgCyan).Add(color.Underline)
|
||||||
|
c.Println("Prints cyan text with an underline.")
|
||||||
|
|
||||||
|
// Or just add them to New()
|
||||||
|
d := color.New(color.FgCyan, color.Bold)
|
||||||
|
d.Printf("This prints bold cyan %s\n", "too!.")
|
||||||
|
|
||||||
|
|
||||||
|
// Mix up foreground and background colors, create new mixes!
|
||||||
|
red := color.New(color.FgRed)
|
||||||
|
|
||||||
|
boldRed := red.Add(color.Bold)
|
||||||
|
boldRed.Println("This will print text in bold red.")
|
||||||
|
|
||||||
|
whiteBackground := red.Add(color.BgWhite)
|
||||||
|
whiteBackground.Println("Red text with White background.")
|
||||||
|
|
||||||
|
// Use your own io.Writer output
|
||||||
|
color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
|
||||||
|
|
||||||
|
blue := color.New(color.FgBlue)
|
||||||
|
blue.Fprint(myWriter, "This will print text in blue.")
|
||||||
|
|
||||||
|
You can create PrintXxx functions to simplify even more:
|
||||||
|
|
||||||
|
// Create a custom print function for convenient
|
||||||
|
red := color.New(color.FgRed).PrintfFunc()
|
||||||
|
red("warning")
|
||||||
|
red("error: %s", err)
|
||||||
|
|
||||||
|
// Mix up multiple attributes
|
||||||
|
notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
|
||||||
|
notice("don't forget this...")
|
||||||
|
|
||||||
|
You can also FprintXxx functions to pass your own io.Writer:
|
||||||
|
|
||||||
|
blue := color.New(FgBlue).FprintfFunc()
|
||||||
|
blue(myWriter, "important notice: %s", stars)
|
||||||
|
|
||||||
|
// Mix up with multiple attributes
|
||||||
|
success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
|
||||||
|
success(myWriter, don't forget this...")
|
||||||
|
|
||||||
|
|
||||||
|
Or create SprintXxx functions to mix strings with other non-colorized strings:
|
||||||
|
|
||||||
|
yellow := New(FgYellow).SprintFunc()
|
||||||
|
red := New(FgRed).SprintFunc()
|
||||||
|
|
||||||
|
fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error"))
|
||||||
|
|
||||||
|
info := New(FgWhite, BgGreen).SprintFunc()
|
||||||
|
fmt.Printf("this %s rocks!\n", info("package"))
|
||||||
|
|
||||||
|
Windows support is enabled by default. All Print functions work as intended.
|
||||||
|
However only for color.SprintXXX functions, user should use fmt.FprintXXX and
|
||||||
|
set the output to color.Output:
|
||||||
|
|
||||||
|
fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
|
||||||
|
|
||||||
|
info := New(FgWhite, BgGreen).SprintFunc()
|
||||||
|
fmt.Fprintf(color.Output, "this %s rocks!\n", info("package"))
|
||||||
|
|
||||||
|
Using with existing code is possible. Just use the Set() method to set the
|
||||||
|
standard output to the given parameters. That way a rewrite of an existing
|
||||||
|
code is not required.
|
||||||
|
|
||||||
|
// Use handy standard colors.
|
||||||
|
color.Set(color.FgYellow)
|
||||||
|
|
||||||
|
fmt.Println("Existing text will be now in Yellow")
|
||||||
|
fmt.Printf("This one %s\n", "too")
|
||||||
|
|
||||||
|
color.Unset() // don't forget to unset
|
||||||
|
|
||||||
|
// You can mix up parameters
|
||||||
|
color.Set(color.FgMagenta, color.Bold)
|
||||||
|
defer color.Unset() // use it in your function
|
||||||
|
|
||||||
|
fmt.Println("All text will be now bold magenta.")
|
||||||
|
|
||||||
|
There might be a case where you want to disable color output (for example to
|
||||||
|
pipe the standard output of your app to somewhere else). `Color` has support to
|
||||||
|
disable colors both globally and for single color definition. For example
|
||||||
|
suppose you have a CLI app and a `--no-color` bool flag. You can easily disable
|
||||||
|
the color output with:
|
||||||
|
|
||||||
|
var flagNoColor = flag.Bool("no-color", false, "Disable color output")
|
||||||
|
|
||||||
|
if *flagNoColor {
|
||||||
|
color.NoColor = true // disables colorized output
|
||||||
|
}
|
||||||
|
|
||||||
|
It also has support for single color definitions (local). You can
|
||||||
|
disable/enable color output on the fly:
|
||||||
|
|
||||||
|
c := color.New(color.FgCyan)
|
||||||
|
c.Println("Prints cyan text")
|
||||||
|
|
||||||
|
c.DisableColor()
|
||||||
|
c.Println("This is printed without any color")
|
||||||
|
|
||||||
|
c.EnableColor()
|
||||||
|
c.Println("This prints again cyan...")
|
||||||
|
*/
|
||||||
|
package color
|
||||||
21
vendor/github.com/mattn/go-colorable/LICENSE
generated
vendored
Normal file
21
vendor/github.com/mattn/go-colorable/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 Yasuhiro Matsumoto
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
29
vendor/github.com/mattn/go-colorable/colorable_appengine.go
generated
vendored
Normal file
29
vendor/github.com/mattn/go-colorable/colorable_appengine.go
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// +build appengine
|
||||||
|
|
||||||
|
package colorable
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
_ "github.com/mattn/go-isatty"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewColorable return new instance of Writer which handle escape sequence.
|
||||||
|
func NewColorable(file *os.File) io.Writer {
|
||||||
|
if file == nil {
|
||||||
|
panic("nil passed instead of *os.File to NewColorable()")
|
||||||
|
}
|
||||||
|
|
||||||
|
return file
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
|
||||||
|
func NewColorableStdout() io.Writer {
|
||||||
|
return os.Stdout
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
|
||||||
|
func NewColorableStderr() io.Writer {
|
||||||
|
return os.Stderr
|
||||||
|
}
|
||||||
30
vendor/github.com/mattn/go-colorable/colorable_others.go
generated
vendored
Normal file
30
vendor/github.com/mattn/go-colorable/colorable_others.go
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
// +build !windows
|
||||||
|
// +build !appengine
|
||||||
|
|
||||||
|
package colorable
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
_ "github.com/mattn/go-isatty"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewColorable return new instance of Writer which handle escape sequence.
|
||||||
|
func NewColorable(file *os.File) io.Writer {
|
||||||
|
if file == nil {
|
||||||
|
panic("nil passed instead of *os.File to NewColorable()")
|
||||||
|
}
|
||||||
|
|
||||||
|
return file
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
|
||||||
|
func NewColorableStdout() io.Writer {
|
||||||
|
return os.Stdout
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
|
||||||
|
func NewColorableStderr() io.Writer {
|
||||||
|
return os.Stderr
|
||||||
|
}
|
||||||
884
vendor/github.com/mattn/go-colorable/colorable_windows.go
generated
vendored
Normal file
884
vendor/github.com/mattn/go-colorable/colorable_windows.go
generated
vendored
Normal file
|
|
@ -0,0 +1,884 @@
|
||||||
|
// +build windows
|
||||||
|
// +build !appengine
|
||||||
|
|
||||||
|
package colorable
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io"
|
||||||
|
"math"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/mattn/go-isatty"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
foregroundBlue = 0x1
|
||||||
|
foregroundGreen = 0x2
|
||||||
|
foregroundRed = 0x4
|
||||||
|
foregroundIntensity = 0x8
|
||||||
|
foregroundMask = (foregroundRed | foregroundBlue | foregroundGreen | foregroundIntensity)
|
||||||
|
backgroundBlue = 0x10
|
||||||
|
backgroundGreen = 0x20
|
||||||
|
backgroundRed = 0x40
|
||||||
|
backgroundIntensity = 0x80
|
||||||
|
backgroundMask = (backgroundRed | backgroundBlue | backgroundGreen | backgroundIntensity)
|
||||||
|
)
|
||||||
|
|
||||||
|
type wchar uint16
|
||||||
|
type short int16
|
||||||
|
type dword uint32
|
||||||
|
type word uint16
|
||||||
|
|
||||||
|
type coord struct {
|
||||||
|
x short
|
||||||
|
y short
|
||||||
|
}
|
||||||
|
|
||||||
|
type smallRect struct {
|
||||||
|
left short
|
||||||
|
top short
|
||||||
|
right short
|
||||||
|
bottom short
|
||||||
|
}
|
||||||
|
|
||||||
|
type consoleScreenBufferInfo struct {
|
||||||
|
size coord
|
||||||
|
cursorPosition coord
|
||||||
|
attributes word
|
||||||
|
window smallRect
|
||||||
|
maximumWindowSize coord
|
||||||
|
}
|
||||||
|
|
||||||
|
type consoleCursorInfo struct {
|
||||||
|
size dword
|
||||||
|
visible int32
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
||||||
|
procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
|
||||||
|
procSetConsoleTextAttribute = kernel32.NewProc("SetConsoleTextAttribute")
|
||||||
|
procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition")
|
||||||
|
procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW")
|
||||||
|
procFillConsoleOutputAttribute = kernel32.NewProc("FillConsoleOutputAttribute")
|
||||||
|
procGetConsoleCursorInfo = kernel32.NewProc("GetConsoleCursorInfo")
|
||||||
|
procSetConsoleCursorInfo = kernel32.NewProc("SetConsoleCursorInfo")
|
||||||
|
procSetConsoleTitle = kernel32.NewProc("SetConsoleTitleW")
|
||||||
|
)
|
||||||
|
|
||||||
|
// Writer provide colorable Writer to the console
|
||||||
|
type Writer struct {
|
||||||
|
out io.Writer
|
||||||
|
handle syscall.Handle
|
||||||
|
oldattr word
|
||||||
|
oldpos coord
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewColorable return new instance of Writer which handle escape sequence from File.
|
||||||
|
func NewColorable(file *os.File) io.Writer {
|
||||||
|
if file == nil {
|
||||||
|
panic("nil passed instead of *os.File to NewColorable()")
|
||||||
|
}
|
||||||
|
|
||||||
|
if isatty.IsTerminal(file.Fd()) {
|
||||||
|
var csbi consoleScreenBufferInfo
|
||||||
|
handle := syscall.Handle(file.Fd())
|
||||||
|
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
|
||||||
|
return &Writer{out: file, handle: handle, oldattr: csbi.attributes, oldpos: coord{0, 0}}
|
||||||
|
}
|
||||||
|
return file
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
|
||||||
|
func NewColorableStdout() io.Writer {
|
||||||
|
return NewColorable(os.Stdout)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
|
||||||
|
func NewColorableStderr() io.Writer {
|
||||||
|
return NewColorable(os.Stderr)
|
||||||
|
}
|
||||||
|
|
||||||
|
var color256 = map[int]int{
|
||||||
|
0: 0x000000,
|
||||||
|
1: 0x800000,
|
||||||
|
2: 0x008000,
|
||||||
|
3: 0x808000,
|
||||||
|
4: 0x000080,
|
||||||
|
5: 0x800080,
|
||||||
|
6: 0x008080,
|
||||||
|
7: 0xc0c0c0,
|
||||||
|
8: 0x808080,
|
||||||
|
9: 0xff0000,
|
||||||
|
10: 0x00ff00,
|
||||||
|
11: 0xffff00,
|
||||||
|
12: 0x0000ff,
|
||||||
|
13: 0xff00ff,
|
||||||
|
14: 0x00ffff,
|
||||||
|
15: 0xffffff,
|
||||||
|
16: 0x000000,
|
||||||
|
17: 0x00005f,
|
||||||
|
18: 0x000087,
|
||||||
|
19: 0x0000af,
|
||||||
|
20: 0x0000d7,
|
||||||
|
21: 0x0000ff,
|
||||||
|
22: 0x005f00,
|
||||||
|
23: 0x005f5f,
|
||||||
|
24: 0x005f87,
|
||||||
|
25: 0x005faf,
|
||||||
|
26: 0x005fd7,
|
||||||
|
27: 0x005fff,
|
||||||
|
28: 0x008700,
|
||||||
|
29: 0x00875f,
|
||||||
|
30: 0x008787,
|
||||||
|
31: 0x0087af,
|
||||||
|
32: 0x0087d7,
|
||||||
|
33: 0x0087ff,
|
||||||
|
34: 0x00af00,
|
||||||
|
35: 0x00af5f,
|
||||||
|
36: 0x00af87,
|
||||||
|
37: 0x00afaf,
|
||||||
|
38: 0x00afd7,
|
||||||
|
39: 0x00afff,
|
||||||
|
40: 0x00d700,
|
||||||
|
41: 0x00d75f,
|
||||||
|
42: 0x00d787,
|
||||||
|
43: 0x00d7af,
|
||||||
|
44: 0x00d7d7,
|
||||||
|
45: 0x00d7ff,
|
||||||
|
46: 0x00ff00,
|
||||||
|
47: 0x00ff5f,
|
||||||
|
48: 0x00ff87,
|
||||||
|
49: 0x00ffaf,
|
||||||
|
50: 0x00ffd7,
|
||||||
|
51: 0x00ffff,
|
||||||
|
52: 0x5f0000,
|
||||||
|
53: 0x5f005f,
|
||||||
|
54: 0x5f0087,
|
||||||
|
55: 0x5f00af,
|
||||||
|
56: 0x5f00d7,
|
||||||
|
57: 0x5f00ff,
|
||||||
|
58: 0x5f5f00,
|
||||||
|
59: 0x5f5f5f,
|
||||||
|
60: 0x5f5f87,
|
||||||
|
61: 0x5f5faf,
|
||||||
|
62: 0x5f5fd7,
|
||||||
|
63: 0x5f5fff,
|
||||||
|
64: 0x5f8700,
|
||||||
|
65: 0x5f875f,
|
||||||
|
66: 0x5f8787,
|
||||||
|
67: 0x5f87af,
|
||||||
|
68: 0x5f87d7,
|
||||||
|
69: 0x5f87ff,
|
||||||
|
70: 0x5faf00,
|
||||||
|
71: 0x5faf5f,
|
||||||
|
72: 0x5faf87,
|
||||||
|
73: 0x5fafaf,
|
||||||
|
74: 0x5fafd7,
|
||||||
|
75: 0x5fafff,
|
||||||
|
76: 0x5fd700,
|
||||||
|
77: 0x5fd75f,
|
||||||
|
78: 0x5fd787,
|
||||||
|
79: 0x5fd7af,
|
||||||
|
80: 0x5fd7d7,
|
||||||
|
81: 0x5fd7ff,
|
||||||
|
82: 0x5fff00,
|
||||||
|
83: 0x5fff5f,
|
||||||
|
84: 0x5fff87,
|
||||||
|
85: 0x5fffaf,
|
||||||
|
86: 0x5fffd7,
|
||||||
|
87: 0x5fffff,
|
||||||
|
88: 0x870000,
|
||||||
|
89: 0x87005f,
|
||||||
|
90: 0x870087,
|
||||||
|
91: 0x8700af,
|
||||||
|
92: 0x8700d7,
|
||||||
|
93: 0x8700ff,
|
||||||
|
94: 0x875f00,
|
||||||
|
95: 0x875f5f,
|
||||||
|
96: 0x875f87,
|
||||||
|
97: 0x875faf,
|
||||||
|
98: 0x875fd7,
|
||||||
|
99: 0x875fff,
|
||||||
|
100: 0x878700,
|
||||||
|
101: 0x87875f,
|
||||||
|
102: 0x878787,
|
||||||
|
103: 0x8787af,
|
||||||
|
104: 0x8787d7,
|
||||||
|
105: 0x8787ff,
|
||||||
|
106: 0x87af00,
|
||||||
|
107: 0x87af5f,
|
||||||
|
108: 0x87af87,
|
||||||
|
109: 0x87afaf,
|
||||||
|
110: 0x87afd7,
|
||||||
|
111: 0x87afff,
|
||||||
|
112: 0x87d700,
|
||||||
|
113: 0x87d75f,
|
||||||
|
114: 0x87d787,
|
||||||
|
115: 0x87d7af,
|
||||||
|
116: 0x87d7d7,
|
||||||
|
117: 0x87d7ff,
|
||||||
|
118: 0x87ff00,
|
||||||
|
119: 0x87ff5f,
|
||||||
|
120: 0x87ff87,
|
||||||
|
121: 0x87ffaf,
|
||||||
|
122: 0x87ffd7,
|
||||||
|
123: 0x87ffff,
|
||||||
|
124: 0xaf0000,
|
||||||
|
125: 0xaf005f,
|
||||||
|
126: 0xaf0087,
|
||||||
|
127: 0xaf00af,
|
||||||
|
128: 0xaf00d7,
|
||||||
|
129: 0xaf00ff,
|
||||||
|
130: 0xaf5f00,
|
||||||
|
131: 0xaf5f5f,
|
||||||
|
132: 0xaf5f87,
|
||||||
|
133: 0xaf5faf,
|
||||||
|
134: 0xaf5fd7,
|
||||||
|
135: 0xaf5fff,
|
||||||
|
136: 0xaf8700,
|
||||||
|
137: 0xaf875f,
|
||||||
|
138: 0xaf8787,
|
||||||
|
139: 0xaf87af,
|
||||||
|
140: 0xaf87d7,
|
||||||
|
141: 0xaf87ff,
|
||||||
|
142: 0xafaf00,
|
||||||
|
143: 0xafaf5f,
|
||||||
|
144: 0xafaf87,
|
||||||
|
145: 0xafafaf,
|
||||||
|
146: 0xafafd7,
|
||||||
|
147: 0xafafff,
|
||||||
|
148: 0xafd700,
|
||||||
|
149: 0xafd75f,
|
||||||
|
150: 0xafd787,
|
||||||
|
151: 0xafd7af,
|
||||||
|
152: 0xafd7d7,
|
||||||
|
153: 0xafd7ff,
|
||||||
|
154: 0xafff00,
|
||||||
|
155: 0xafff5f,
|
||||||
|
156: 0xafff87,
|
||||||
|
157: 0xafffaf,
|
||||||
|
158: 0xafffd7,
|
||||||
|
159: 0xafffff,
|
||||||
|
160: 0xd70000,
|
||||||
|
161: 0xd7005f,
|
||||||
|
162: 0xd70087,
|
||||||
|
163: 0xd700af,
|
||||||
|
164: 0xd700d7,
|
||||||
|
165: 0xd700ff,
|
||||||
|
166: 0xd75f00,
|
||||||
|
167: 0xd75f5f,
|
||||||
|
168: 0xd75f87,
|
||||||
|
169: 0xd75faf,
|
||||||
|
170: 0xd75fd7,
|
||||||
|
171: 0xd75fff,
|
||||||
|
172: 0xd78700,
|
||||||
|
173: 0xd7875f,
|
||||||
|
174: 0xd78787,
|
||||||
|
175: 0xd787af,
|
||||||
|
176: 0xd787d7,
|
||||||
|
177: 0xd787ff,
|
||||||
|
178: 0xd7af00,
|
||||||
|
179: 0xd7af5f,
|
||||||
|
180: 0xd7af87,
|
||||||
|
181: 0xd7afaf,
|
||||||
|
182: 0xd7afd7,
|
||||||
|
183: 0xd7afff,
|
||||||
|
184: 0xd7d700,
|
||||||
|
185: 0xd7d75f,
|
||||||
|
186: 0xd7d787,
|
||||||
|
187: 0xd7d7af,
|
||||||
|
188: 0xd7d7d7,
|
||||||
|
189: 0xd7d7ff,
|
||||||
|
190: 0xd7ff00,
|
||||||
|
191: 0xd7ff5f,
|
||||||
|
192: 0xd7ff87,
|
||||||
|
193: 0xd7ffaf,
|
||||||
|
194: 0xd7ffd7,
|
||||||
|
195: 0xd7ffff,
|
||||||
|
196: 0xff0000,
|
||||||
|
197: 0xff005f,
|
||||||
|
198: 0xff0087,
|
||||||
|
199: 0xff00af,
|
||||||
|
200: 0xff00d7,
|
||||||
|
201: 0xff00ff,
|
||||||
|
202: 0xff5f00,
|
||||||
|
203: 0xff5f5f,
|
||||||
|
204: 0xff5f87,
|
||||||
|
205: 0xff5faf,
|
||||||
|
206: 0xff5fd7,
|
||||||
|
207: 0xff5fff,
|
||||||
|
208: 0xff8700,
|
||||||
|
209: 0xff875f,
|
||||||
|
210: 0xff8787,
|
||||||
|
211: 0xff87af,
|
||||||
|
212: 0xff87d7,
|
||||||
|
213: 0xff87ff,
|
||||||
|
214: 0xffaf00,
|
||||||
|
215: 0xffaf5f,
|
||||||
|
216: 0xffaf87,
|
||||||
|
217: 0xffafaf,
|
||||||
|
218: 0xffafd7,
|
||||||
|
219: 0xffafff,
|
||||||
|
220: 0xffd700,
|
||||||
|
221: 0xffd75f,
|
||||||
|
222: 0xffd787,
|
||||||
|
223: 0xffd7af,
|
||||||
|
224: 0xffd7d7,
|
||||||
|
225: 0xffd7ff,
|
||||||
|
226: 0xffff00,
|
||||||
|
227: 0xffff5f,
|
||||||
|
228: 0xffff87,
|
||||||
|
229: 0xffffaf,
|
||||||
|
230: 0xffffd7,
|
||||||
|
231: 0xffffff,
|
||||||
|
232: 0x080808,
|
||||||
|
233: 0x121212,
|
||||||
|
234: 0x1c1c1c,
|
||||||
|
235: 0x262626,
|
||||||
|
236: 0x303030,
|
||||||
|
237: 0x3a3a3a,
|
||||||
|
238: 0x444444,
|
||||||
|
239: 0x4e4e4e,
|
||||||
|
240: 0x585858,
|
||||||
|
241: 0x626262,
|
||||||
|
242: 0x6c6c6c,
|
||||||
|
243: 0x767676,
|
||||||
|
244: 0x808080,
|
||||||
|
245: 0x8a8a8a,
|
||||||
|
246: 0x949494,
|
||||||
|
247: 0x9e9e9e,
|
||||||
|
248: 0xa8a8a8,
|
||||||
|
249: 0xb2b2b2,
|
||||||
|
250: 0xbcbcbc,
|
||||||
|
251: 0xc6c6c6,
|
||||||
|
252: 0xd0d0d0,
|
||||||
|
253: 0xdadada,
|
||||||
|
254: 0xe4e4e4,
|
||||||
|
255: 0xeeeeee,
|
||||||
|
}
|
||||||
|
|
||||||
|
// `\033]0;TITLESTR\007`
|
||||||
|
func doTitleSequence(er *bytes.Reader) error {
|
||||||
|
var c byte
|
||||||
|
var err error
|
||||||
|
|
||||||
|
c, err = er.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if c != '0' && c != '2' {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
c, err = er.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if c != ';' {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
title := make([]byte, 0, 80)
|
||||||
|
for {
|
||||||
|
c, err = er.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if c == 0x07 || c == '\n' {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
title = append(title, c)
|
||||||
|
}
|
||||||
|
if len(title) > 0 {
|
||||||
|
title8, err := syscall.UTF16PtrFromString(string(title))
|
||||||
|
if err == nil {
|
||||||
|
procSetConsoleTitle.Call(uintptr(unsafe.Pointer(title8)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write write data on console
|
||||||
|
func (w *Writer) Write(data []byte) (n int, err error) {
|
||||||
|
var csbi consoleScreenBufferInfo
|
||||||
|
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
||||||
|
|
||||||
|
er := bytes.NewReader(data)
|
||||||
|
var bw [1]byte
|
||||||
|
loop:
|
||||||
|
for {
|
||||||
|
c1, err := er.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
break loop
|
||||||
|
}
|
||||||
|
if c1 != 0x1b {
|
||||||
|
bw[0] = c1
|
||||||
|
w.out.Write(bw[:])
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
c2, err := er.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
break loop
|
||||||
|
}
|
||||||
|
|
||||||
|
if c2 == ']' {
|
||||||
|
if err := doTitleSequence(er); err != nil {
|
||||||
|
break loop
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if c2 != 0x5b {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
var m byte
|
||||||
|
for {
|
||||||
|
c, err := er.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
break loop
|
||||||
|
}
|
||||||
|
if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' {
|
||||||
|
m = c
|
||||||
|
break
|
||||||
|
}
|
||||||
|
buf.Write([]byte(string(c)))
|
||||||
|
}
|
||||||
|
|
||||||
|
switch m {
|
||||||
|
case 'A':
|
||||||
|
n, err = strconv.Atoi(buf.String())
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
||||||
|
csbi.cursorPosition.y -= short(n)
|
||||||
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
||||||
|
case 'B':
|
||||||
|
n, err = strconv.Atoi(buf.String())
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
||||||
|
csbi.cursorPosition.y += short(n)
|
||||||
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
||||||
|
case 'C':
|
||||||
|
n, err = strconv.Atoi(buf.String())
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
||||||
|
csbi.cursorPosition.x += short(n)
|
||||||
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
||||||
|
case 'D':
|
||||||
|
n, err = strconv.Atoi(buf.String())
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
||||||
|
csbi.cursorPosition.x -= short(n)
|
||||||
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
||||||
|
case 'E':
|
||||||
|
n, err = strconv.Atoi(buf.String())
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
||||||
|
csbi.cursorPosition.x = 0
|
||||||
|
csbi.cursorPosition.y += short(n)
|
||||||
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
||||||
|
case 'F':
|
||||||
|
n, err = strconv.Atoi(buf.String())
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
||||||
|
csbi.cursorPosition.x = 0
|
||||||
|
csbi.cursorPosition.y -= short(n)
|
||||||
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
||||||
|
case 'G':
|
||||||
|
n, err = strconv.Atoi(buf.String())
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
||||||
|
csbi.cursorPosition.x = short(n - 1)
|
||||||
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
||||||
|
case 'H', 'f':
|
||||||
|
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
||||||
|
if buf.Len() > 0 {
|
||||||
|
token := strings.Split(buf.String(), ";")
|
||||||
|
switch len(token) {
|
||||||
|
case 1:
|
||||||
|
n1, err := strconv.Atoi(token[0])
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
csbi.cursorPosition.y = short(n1 - 1)
|
||||||
|
case 2:
|
||||||
|
n1, err := strconv.Atoi(token[0])
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
n2, err := strconv.Atoi(token[1])
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
csbi.cursorPosition.x = short(n2 - 1)
|
||||||
|
csbi.cursorPosition.y = short(n1 - 1)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
csbi.cursorPosition.y = 0
|
||||||
|
}
|
||||||
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
||||||
|
case 'J':
|
||||||
|
n := 0
|
||||||
|
if buf.Len() > 0 {
|
||||||
|
n, err = strconv.Atoi(buf.String())
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var count, written dword
|
||||||
|
var cursor coord
|
||||||
|
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
||||||
|
switch n {
|
||||||
|
case 0:
|
||||||
|
cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y}
|
||||||
|
count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.size.y-csbi.cursorPosition.y)*csbi.size.x)
|
||||||
|
case 1:
|
||||||
|
cursor = coord{x: csbi.window.left, y: csbi.window.top}
|
||||||
|
count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.window.top-csbi.cursorPosition.y)*csbi.size.x)
|
||||||
|
case 2:
|
||||||
|
cursor = coord{x: csbi.window.left, y: csbi.window.top}
|
||||||
|
count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.size.y-csbi.cursorPosition.y)*csbi.size.x)
|
||||||
|
}
|
||||||
|
procFillConsoleOutputCharacter.Call(uintptr(w.handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
||||||
|
procFillConsoleOutputAttribute.Call(uintptr(w.handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
||||||
|
case 'K':
|
||||||
|
n := 0
|
||||||
|
if buf.Len() > 0 {
|
||||||
|
n, err = strconv.Atoi(buf.String())
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
||||||
|
var cursor coord
|
||||||
|
var count, written dword
|
||||||
|
switch n {
|
||||||
|
case 0:
|
||||||
|
cursor = coord{x: csbi.cursorPosition.x + 1, y: csbi.cursorPosition.y}
|
||||||
|
count = dword(csbi.size.x - csbi.cursorPosition.x - 1)
|
||||||
|
case 1:
|
||||||
|
cursor = coord{x: csbi.window.left, y: csbi.window.top + csbi.cursorPosition.y}
|
||||||
|
count = dword(csbi.size.x - csbi.cursorPosition.x)
|
||||||
|
case 2:
|
||||||
|
cursor = coord{x: csbi.window.left, y: csbi.window.top + csbi.cursorPosition.y}
|
||||||
|
count = dword(csbi.size.x)
|
||||||
|
}
|
||||||
|
procFillConsoleOutputCharacter.Call(uintptr(w.handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
||||||
|
procFillConsoleOutputAttribute.Call(uintptr(w.handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
||||||
|
case 'm':
|
||||||
|
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
||||||
|
attr := csbi.attributes
|
||||||
|
cs := buf.String()
|
||||||
|
if cs == "" {
|
||||||
|
procSetConsoleTextAttribute.Call(uintptr(w.handle), uintptr(w.oldattr))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
token := strings.Split(cs, ";")
|
||||||
|
for i := 0; i < len(token); i++ {
|
||||||
|
ns := token[i]
|
||||||
|
if n, err = strconv.Atoi(ns); err == nil {
|
||||||
|
switch {
|
||||||
|
case n == 0 || n == 100:
|
||||||
|
attr = w.oldattr
|
||||||
|
case 1 <= n && n <= 5:
|
||||||
|
attr |= foregroundIntensity
|
||||||
|
case n == 7:
|
||||||
|
attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4)
|
||||||
|
case n == 22 || n == 25:
|
||||||
|
attr |= foregroundIntensity
|
||||||
|
case n == 27:
|
||||||
|
attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4)
|
||||||
|
case 30 <= n && n <= 37:
|
||||||
|
attr &= backgroundMask
|
||||||
|
if (n-30)&1 != 0 {
|
||||||
|
attr |= foregroundRed
|
||||||
|
}
|
||||||
|
if (n-30)&2 != 0 {
|
||||||
|
attr |= foregroundGreen
|
||||||
|
}
|
||||||
|
if (n-30)&4 != 0 {
|
||||||
|
attr |= foregroundBlue
|
||||||
|
}
|
||||||
|
case n == 38: // set foreground color.
|
||||||
|
if i < len(token)-2 && (token[i+1] == "5" || token[i+1] == "05") {
|
||||||
|
if n256, err := strconv.Atoi(token[i+2]); err == nil {
|
||||||
|
if n256foreAttr == nil {
|
||||||
|
n256setup()
|
||||||
|
}
|
||||||
|
attr &= backgroundMask
|
||||||
|
attr |= n256foreAttr[n256]
|
||||||
|
i += 2
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
attr = attr & (w.oldattr & backgroundMask)
|
||||||
|
}
|
||||||
|
case n == 39: // reset foreground color.
|
||||||
|
attr &= backgroundMask
|
||||||
|
attr |= w.oldattr & foregroundMask
|
||||||
|
case 40 <= n && n <= 47:
|
||||||
|
attr &= foregroundMask
|
||||||
|
if (n-40)&1 != 0 {
|
||||||
|
attr |= backgroundRed
|
||||||
|
}
|
||||||
|
if (n-40)&2 != 0 {
|
||||||
|
attr |= backgroundGreen
|
||||||
|
}
|
||||||
|
if (n-40)&4 != 0 {
|
||||||
|
attr |= backgroundBlue
|
||||||
|
}
|
||||||
|
case n == 48: // set background color.
|
||||||
|
if i < len(token)-2 && token[i+1] == "5" {
|
||||||
|
if n256, err := strconv.Atoi(token[i+2]); err == nil {
|
||||||
|
if n256backAttr == nil {
|
||||||
|
n256setup()
|
||||||
|
}
|
||||||
|
attr &= foregroundMask
|
||||||
|
attr |= n256backAttr[n256]
|
||||||
|
i += 2
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
attr = attr & (w.oldattr & foregroundMask)
|
||||||
|
}
|
||||||
|
case n == 49: // reset foreground color.
|
||||||
|
attr &= foregroundMask
|
||||||
|
attr |= w.oldattr & backgroundMask
|
||||||
|
case 90 <= n && n <= 97:
|
||||||
|
attr = (attr & backgroundMask)
|
||||||
|
attr |= foregroundIntensity
|
||||||
|
if (n-90)&1 != 0 {
|
||||||
|
attr |= foregroundRed
|
||||||
|
}
|
||||||
|
if (n-90)&2 != 0 {
|
||||||
|
attr |= foregroundGreen
|
||||||
|
}
|
||||||
|
if (n-90)&4 != 0 {
|
||||||
|
attr |= foregroundBlue
|
||||||
|
}
|
||||||
|
case 100 <= n && n <= 107:
|
||||||
|
attr = (attr & foregroundMask)
|
||||||
|
attr |= backgroundIntensity
|
||||||
|
if (n-100)&1 != 0 {
|
||||||
|
attr |= backgroundRed
|
||||||
|
}
|
||||||
|
if (n-100)&2 != 0 {
|
||||||
|
attr |= backgroundGreen
|
||||||
|
}
|
||||||
|
if (n-100)&4 != 0 {
|
||||||
|
attr |= backgroundBlue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
procSetConsoleTextAttribute.Call(uintptr(w.handle), uintptr(attr))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 'h':
|
||||||
|
var ci consoleCursorInfo
|
||||||
|
cs := buf.String()
|
||||||
|
if cs == "5>" {
|
||||||
|
procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
||||||
|
ci.visible = 0
|
||||||
|
procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
||||||
|
} else if cs == "?25" {
|
||||||
|
procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
||||||
|
ci.visible = 1
|
||||||
|
procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
||||||
|
}
|
||||||
|
case 'l':
|
||||||
|
var ci consoleCursorInfo
|
||||||
|
cs := buf.String()
|
||||||
|
if cs == "5>" {
|
||||||
|
procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
||||||
|
ci.visible = 1
|
||||||
|
procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
||||||
|
} else if cs == "?25" {
|
||||||
|
procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
||||||
|
ci.visible = 0
|
||||||
|
procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
||||||
|
}
|
||||||
|
case 's':
|
||||||
|
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
||||||
|
w.oldpos = csbi.cursorPosition
|
||||||
|
case 'u':
|
||||||
|
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&w.oldpos)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return len(data), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type consoleColor struct {
|
||||||
|
rgb int
|
||||||
|
red bool
|
||||||
|
green bool
|
||||||
|
blue bool
|
||||||
|
intensity bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c consoleColor) foregroundAttr() (attr word) {
|
||||||
|
if c.red {
|
||||||
|
attr |= foregroundRed
|
||||||
|
}
|
||||||
|
if c.green {
|
||||||
|
attr |= foregroundGreen
|
||||||
|
}
|
||||||
|
if c.blue {
|
||||||
|
attr |= foregroundBlue
|
||||||
|
}
|
||||||
|
if c.intensity {
|
||||||
|
attr |= foregroundIntensity
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c consoleColor) backgroundAttr() (attr word) {
|
||||||
|
if c.red {
|
||||||
|
attr |= backgroundRed
|
||||||
|
}
|
||||||
|
if c.green {
|
||||||
|
attr |= backgroundGreen
|
||||||
|
}
|
||||||
|
if c.blue {
|
||||||
|
attr |= backgroundBlue
|
||||||
|
}
|
||||||
|
if c.intensity {
|
||||||
|
attr |= backgroundIntensity
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var color16 = []consoleColor{
|
||||||
|
{0x000000, false, false, false, false},
|
||||||
|
{0x000080, false, false, true, false},
|
||||||
|
{0x008000, false, true, false, false},
|
||||||
|
{0x008080, false, true, true, false},
|
||||||
|
{0x800000, true, false, false, false},
|
||||||
|
{0x800080, true, false, true, false},
|
||||||
|
{0x808000, true, true, false, false},
|
||||||
|
{0xc0c0c0, true, true, true, false},
|
||||||
|
{0x808080, false, false, false, true},
|
||||||
|
{0x0000ff, false, false, true, true},
|
||||||
|
{0x00ff00, false, true, false, true},
|
||||||
|
{0x00ffff, false, true, true, true},
|
||||||
|
{0xff0000, true, false, false, true},
|
||||||
|
{0xff00ff, true, false, true, true},
|
||||||
|
{0xffff00, true, true, false, true},
|
||||||
|
{0xffffff, true, true, true, true},
|
||||||
|
}
|
||||||
|
|
||||||
|
type hsv struct {
|
||||||
|
h, s, v float32
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a hsv) dist(b hsv) float32 {
|
||||||
|
dh := a.h - b.h
|
||||||
|
switch {
|
||||||
|
case dh > 0.5:
|
||||||
|
dh = 1 - dh
|
||||||
|
case dh < -0.5:
|
||||||
|
dh = -1 - dh
|
||||||
|
}
|
||||||
|
ds := a.s - b.s
|
||||||
|
dv := a.v - b.v
|
||||||
|
return float32(math.Sqrt(float64(dh*dh + ds*ds + dv*dv)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func toHSV(rgb int) hsv {
|
||||||
|
r, g, b := float32((rgb&0xFF0000)>>16)/256.0,
|
||||||
|
float32((rgb&0x00FF00)>>8)/256.0,
|
||||||
|
float32(rgb&0x0000FF)/256.0
|
||||||
|
min, max := minmax3f(r, g, b)
|
||||||
|
h := max - min
|
||||||
|
if h > 0 {
|
||||||
|
if max == r {
|
||||||
|
h = (g - b) / h
|
||||||
|
if h < 0 {
|
||||||
|
h += 6
|
||||||
|
}
|
||||||
|
} else if max == g {
|
||||||
|
h = 2 + (b-r)/h
|
||||||
|
} else {
|
||||||
|
h = 4 + (r-g)/h
|
||||||
|
}
|
||||||
|
}
|
||||||
|
h /= 6.0
|
||||||
|
s := max - min
|
||||||
|
if max != 0 {
|
||||||
|
s /= max
|
||||||
|
}
|
||||||
|
v := max
|
||||||
|
return hsv{h: h, s: s, v: v}
|
||||||
|
}
|
||||||
|
|
||||||
|
type hsvTable []hsv
|
||||||
|
|
||||||
|
func toHSVTable(rgbTable []consoleColor) hsvTable {
|
||||||
|
t := make(hsvTable, len(rgbTable))
|
||||||
|
for i, c := range rgbTable {
|
||||||
|
t[i] = toHSV(c.rgb)
|
||||||
|
}
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t hsvTable) find(rgb int) consoleColor {
|
||||||
|
hsv := toHSV(rgb)
|
||||||
|
n := 7
|
||||||
|
l := float32(5.0)
|
||||||
|
for i, p := range t {
|
||||||
|
d := hsv.dist(p)
|
||||||
|
if d < l {
|
||||||
|
l, n = d, i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return color16[n]
|
||||||
|
}
|
||||||
|
|
||||||
|
func minmax3f(a, b, c float32) (min, max float32) {
|
||||||
|
if a < b {
|
||||||
|
if b < c {
|
||||||
|
return a, c
|
||||||
|
} else if a < c {
|
||||||
|
return a, b
|
||||||
|
} else {
|
||||||
|
return c, b
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if a < c {
|
||||||
|
return b, c
|
||||||
|
} else if b < c {
|
||||||
|
return b, a
|
||||||
|
} else {
|
||||||
|
return c, a
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var n256foreAttr []word
|
||||||
|
var n256backAttr []word
|
||||||
|
|
||||||
|
func n256setup() {
|
||||||
|
n256foreAttr = make([]word, 256)
|
||||||
|
n256backAttr = make([]word, 256)
|
||||||
|
t := toHSVTable(color16)
|
||||||
|
for i, rgb := range color256 {
|
||||||
|
c := t.find(rgb)
|
||||||
|
n256foreAttr[i] = c.foregroundAttr()
|
||||||
|
n256backAttr[i] = c.backgroundAttr()
|
||||||
|
}
|
||||||
|
}
|
||||||
55
vendor/github.com/mattn/go-colorable/noncolorable.go
generated
vendored
Normal file
55
vendor/github.com/mattn/go-colorable/noncolorable.go
generated
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
package colorable
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NonColorable hold writer but remove escape sequence.
|
||||||
|
type NonColorable struct {
|
||||||
|
out io.Writer
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewNonColorable return new instance of Writer which remove escape sequence from Writer.
|
||||||
|
func NewNonColorable(w io.Writer) io.Writer {
|
||||||
|
return &NonColorable{out: w}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write write data on console
|
||||||
|
func (w *NonColorable) Write(data []byte) (n int, err error) {
|
||||||
|
er := bytes.NewReader(data)
|
||||||
|
var bw [1]byte
|
||||||
|
loop:
|
||||||
|
for {
|
||||||
|
c1, err := er.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
break loop
|
||||||
|
}
|
||||||
|
if c1 != 0x1b {
|
||||||
|
bw[0] = c1
|
||||||
|
w.out.Write(bw[:])
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
c2, err := er.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
break loop
|
||||||
|
}
|
||||||
|
if c2 != 0x5b {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
for {
|
||||||
|
c, err := er.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
break loop
|
||||||
|
}
|
||||||
|
if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
buf.Write([]byte(string(c)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return len(data), nil
|
||||||
|
}
|
||||||
9
vendor/github.com/mattn/go-isatty/LICENSE
generated
vendored
Normal file
9
vendor/github.com/mattn/go-isatty/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
Copyright (c) Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
|
||||||
|
|
||||||
|
MIT License (Expat)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
2
vendor/github.com/mattn/go-isatty/doc.go
generated
vendored
Normal file
2
vendor/github.com/mattn/go-isatty/doc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
// Package isatty implements interface to isatty
|
||||||
|
package isatty
|
||||||
17
vendor/github.com/mattn/go-isatty/isatty_android.go
generated
vendored
Normal file
17
vendor/github.com/mattn/go-isatty/isatty_android.go
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
// +build android
|
||||||
|
|
||||||
|
package isatty
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
const ioctlReadTermios = syscall.TCGETS
|
||||||
|
|
||||||
|
// IsTerminal return true if the file descriptor is terminal.
|
||||||
|
func IsTerminal(fd uintptr) bool {
|
||||||
|
var termios syscall.Termios
|
||||||
|
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
|
||||||
|
return err == 0
|
||||||
|
}
|
||||||
24
vendor/github.com/mattn/go-isatty/isatty_bsd.go
generated
vendored
Normal file
24
vendor/github.com/mattn/go-isatty/isatty_bsd.go
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
// +build darwin freebsd openbsd netbsd dragonfly
|
||||||
|
// +build !appengine
|
||||||
|
|
||||||
|
package isatty
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
const ioctlReadTermios = syscall.TIOCGETA
|
||||||
|
|
||||||
|
// IsTerminal return true if the file descriptor is terminal.
|
||||||
|
func IsTerminal(fd uintptr) bool {
|
||||||
|
var termios syscall.Termios
|
||||||
|
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
|
||||||
|
return err == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
|
||||||
|
// terminal. This is also always false on this environment.
|
||||||
|
func IsCygwinTerminal(fd uintptr) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
19
vendor/github.com/mattn/go-isatty/isatty_linux.go
generated
vendored
Normal file
19
vendor/github.com/mattn/go-isatty/isatty_linux.go
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
// +build linux
|
||||||
|
// +build !appengine
|
||||||
|
// +build !android
|
||||||
|
|
||||||
|
package isatty
|
||||||
|
|
||||||
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
// IsTerminal return true if the file descriptor is terminal.
|
||||||
|
func IsTerminal(fd uintptr) bool {
|
||||||
|
_, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
|
||||||
|
// terminal. This is also always false on this environment.
|
||||||
|
func IsCygwinTerminal(fd uintptr) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
15
vendor/github.com/mattn/go-isatty/isatty_others.go
generated
vendored
Normal file
15
vendor/github.com/mattn/go-isatty/isatty_others.go
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
// +build appengine js
|
||||||
|
|
||||||
|
package isatty
|
||||||
|
|
||||||
|
// IsTerminal returns true if the file descriptor is terminal which
|
||||||
|
// is always false on js and appengine classic which is a sandboxed PaaS.
|
||||||
|
func IsTerminal(fd uintptr) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
|
||||||
|
// terminal. This is also always false on this environment.
|
||||||
|
func IsCygwinTerminal(fd uintptr) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
22
vendor/github.com/mattn/go-isatty/isatty_solaris.go
generated
vendored
Normal file
22
vendor/github.com/mattn/go-isatty/isatty_solaris.go
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
// +build solaris
|
||||||
|
// +build !appengine
|
||||||
|
|
||||||
|
package isatty
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IsTerminal returns true if the given file descriptor is a terminal.
|
||||||
|
// see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c
|
||||||
|
func IsTerminal(fd uintptr) bool {
|
||||||
|
var termio unix.Termio
|
||||||
|
err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio)
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
|
||||||
|
// terminal. This is also always false on this environment.
|
||||||
|
func IsCygwinTerminal(fd uintptr) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
94
vendor/github.com/mattn/go-isatty/isatty_windows.go
generated
vendored
Normal file
94
vendor/github.com/mattn/go-isatty/isatty_windows.go
generated
vendored
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
// +build windows
|
||||||
|
// +build !appengine
|
||||||
|
|
||||||
|
package isatty
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
"unicode/utf16"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
fileNameInfo uintptr = 2
|
||||||
|
fileTypePipe = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
||||||
|
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
|
||||||
|
procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx")
|
||||||
|
procGetFileType = kernel32.NewProc("GetFileType")
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// Check if GetFileInformationByHandleEx is available.
|
||||||
|
if procGetFileInformationByHandleEx.Find() != nil {
|
||||||
|
procGetFileInformationByHandleEx = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsTerminal return true if the file descriptor is terminal.
|
||||||
|
func IsTerminal(fd uintptr) bool {
|
||||||
|
var st uint32
|
||||||
|
r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0)
|
||||||
|
return r != 0 && e == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check pipe name is used for cygwin/msys2 pty.
|
||||||
|
// Cygwin/MSYS2 PTY has a name like:
|
||||||
|
// \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master
|
||||||
|
func isCygwinPipeName(name string) bool {
|
||||||
|
token := strings.Split(name, "-")
|
||||||
|
if len(token) < 5 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if token[0] != `\msys` && token[0] != `\cygwin` {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if token[1] == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.HasPrefix(token[2], "pty") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if token[3] != `from` && token[3] != `to` {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if token[4] != "master" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
|
||||||
|
// terminal.
|
||||||
|
func IsCygwinTerminal(fd uintptr) bool {
|
||||||
|
if procGetFileInformationByHandleEx == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cygwin/msys's pty is a pipe.
|
||||||
|
ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0)
|
||||||
|
if ft != fileTypePipe || e != 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf [2 + syscall.MAX_PATH]uint16
|
||||||
|
r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(),
|
||||||
|
4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)),
|
||||||
|
uintptr(len(buf)*2), 0, 0)
|
||||||
|
if r == 0 || e != 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
l := *(*uint32)(unsafe.Pointer(&buf))
|
||||||
|
return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2])))
|
||||||
|
}
|
||||||
3
vendor/golang.org/x/sys/AUTHORS
generated
vendored
Normal file
3
vendor/golang.org/x/sys/AUTHORS
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# This source code refers to The Go Authors for copyright purposes.
|
||||||
|
# The master list of authors is in the main Go distribution,
|
||||||
|
# visible at http://tip.golang.org/AUTHORS.
|
||||||
3
vendor/golang.org/x/sys/CONTRIBUTORS
generated
vendored
Normal file
3
vendor/golang.org/x/sys/CONTRIBUTORS
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# This source code was written by the Go contributors.
|
||||||
|
# The master list of contributors is in the main Go distribution,
|
||||||
|
# visible at http://tip.golang.org/CONTRIBUTORS.
|
||||||
27
vendor/golang.org/x/sys/LICENSE
generated
vendored
Normal file
27
vendor/golang.org/x/sys/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
22
vendor/golang.org/x/sys/PATENTS
generated
vendored
Normal file
22
vendor/golang.org/x/sys/PATENTS
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
Additional IP Rights Grant (Patents)
|
||||||
|
|
||||||
|
"This implementation" means the copyrightable works distributed by
|
||||||
|
Google as part of the Go project.
|
||||||
|
|
||||||
|
Google hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||||
|
no-charge, royalty-free, irrevocable (except as stated in this section)
|
||||||
|
patent license to make, have made, use, offer to sell, sell, import,
|
||||||
|
transfer and otherwise run, modify and propagate the contents of this
|
||||||
|
implementation of Go, where such license applies only to those patent
|
||||||
|
claims, both currently owned or controlled by Google and acquired in
|
||||||
|
the future, licensable by Google that are necessarily infringed by this
|
||||||
|
implementation of Go. This grant does not include claims that would be
|
||||||
|
infringed only as a consequence of further modification of this
|
||||||
|
implementation. If you or your agent or exclusive licensee institute or
|
||||||
|
order or agree to the institution of patent litigation against any
|
||||||
|
entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||||
|
that this implementation of Go or any code incorporated within this
|
||||||
|
implementation of Go constitutes direct or contributory patent
|
||||||
|
infringement, or inducement of patent infringement, then any patent
|
||||||
|
rights granted to you under this License for this implementation of Go
|
||||||
|
shall terminate as of the date such litigation is filed.
|
||||||
124
vendor/golang.org/x/sys/unix/affinity_linux.go
generated
vendored
Normal file
124
vendor/golang.org/x/sys/unix/affinity_linux.go
generated
vendored
Normal file
|
|
@ -0,0 +1,124 @@
|
||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// CPU affinity functions
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
const cpuSetSize = _CPU_SETSIZE / _NCPUBITS
|
||||||
|
|
||||||
|
// CPUSet represents a CPU affinity mask.
|
||||||
|
type CPUSet [cpuSetSize]cpuMask
|
||||||
|
|
||||||
|
func schedAffinity(trap uintptr, pid int, set *CPUSet) error {
|
||||||
|
_, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(*set)), uintptr(unsafe.Pointer(set)))
|
||||||
|
if e != 0 {
|
||||||
|
return errnoErr(e)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SchedGetaffinity gets the CPU affinity mask of the thread specified by pid.
|
||||||
|
// If pid is 0 the calling thread is used.
|
||||||
|
func SchedGetaffinity(pid int, set *CPUSet) error {
|
||||||
|
return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SchedSetaffinity sets the CPU affinity mask of the thread specified by pid.
|
||||||
|
// If pid is 0 the calling thread is used.
|
||||||
|
func SchedSetaffinity(pid int, set *CPUSet) error {
|
||||||
|
return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zero clears the set s, so that it contains no CPUs.
|
||||||
|
func (s *CPUSet) Zero() {
|
||||||
|
for i := range s {
|
||||||
|
s[i] = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func cpuBitsIndex(cpu int) int {
|
||||||
|
return cpu / _NCPUBITS
|
||||||
|
}
|
||||||
|
|
||||||
|
func cpuBitsMask(cpu int) cpuMask {
|
||||||
|
return cpuMask(1 << (uint(cpu) % _NCPUBITS))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set adds cpu to the set s.
|
||||||
|
func (s *CPUSet) Set(cpu int) {
|
||||||
|
i := cpuBitsIndex(cpu)
|
||||||
|
if i < len(s) {
|
||||||
|
s[i] |= cpuBitsMask(cpu)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear removes cpu from the set s.
|
||||||
|
func (s *CPUSet) Clear(cpu int) {
|
||||||
|
i := cpuBitsIndex(cpu)
|
||||||
|
if i < len(s) {
|
||||||
|
s[i] &^= cpuBitsMask(cpu)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsSet reports whether cpu is in the set s.
|
||||||
|
func (s *CPUSet) IsSet(cpu int) bool {
|
||||||
|
i := cpuBitsIndex(cpu)
|
||||||
|
if i < len(s) {
|
||||||
|
return s[i]&cpuBitsMask(cpu) != 0
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count returns the number of CPUs in the set s.
|
||||||
|
func (s *CPUSet) Count() int {
|
||||||
|
c := 0
|
||||||
|
for _, b := range s {
|
||||||
|
c += onesCount64(uint64(b))
|
||||||
|
}
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
// onesCount64 is a copy of Go 1.9's math/bits.OnesCount64.
|
||||||
|
// Once this package can require Go 1.9, we can delete this
|
||||||
|
// and update the caller to use bits.OnesCount64.
|
||||||
|
func onesCount64(x uint64) int {
|
||||||
|
const m0 = 0x5555555555555555 // 01010101 ...
|
||||||
|
const m1 = 0x3333333333333333 // 00110011 ...
|
||||||
|
const m2 = 0x0f0f0f0f0f0f0f0f // 00001111 ...
|
||||||
|
const m3 = 0x00ff00ff00ff00ff // etc.
|
||||||
|
const m4 = 0x0000ffff0000ffff
|
||||||
|
|
||||||
|
// Implementation: Parallel summing of adjacent bits.
|
||||||
|
// See "Hacker's Delight", Chap. 5: Counting Bits.
|
||||||
|
// The following pattern shows the general approach:
|
||||||
|
//
|
||||||
|
// x = x>>1&(m0&m) + x&(m0&m)
|
||||||
|
// x = x>>2&(m1&m) + x&(m1&m)
|
||||||
|
// x = x>>4&(m2&m) + x&(m2&m)
|
||||||
|
// x = x>>8&(m3&m) + x&(m3&m)
|
||||||
|
// x = x>>16&(m4&m) + x&(m4&m)
|
||||||
|
// x = x>>32&(m5&m) + x&(m5&m)
|
||||||
|
// return int(x)
|
||||||
|
//
|
||||||
|
// Masking (& operations) can be left away when there's no
|
||||||
|
// danger that a field's sum will carry over into the next
|
||||||
|
// field: Since the result cannot be > 64, 8 bits is enough
|
||||||
|
// and we can ignore the masks for the shifts by 8 and up.
|
||||||
|
// Per "Hacker's Delight", the first line can be simplified
|
||||||
|
// more, but it saves at best one instruction, so we leave
|
||||||
|
// it alone for clarity.
|
||||||
|
const m = 1<<64 - 1
|
||||||
|
x = x>>1&(m0&m) + x&(m0&m)
|
||||||
|
x = x>>2&(m1&m) + x&(m1&m)
|
||||||
|
x = (x>>4 + x) & (m2 & m)
|
||||||
|
x += x >> 8
|
||||||
|
x += x >> 16
|
||||||
|
x += x >> 32
|
||||||
|
return int(x) & (1<<7 - 1)
|
||||||
|
}
|
||||||
14
vendor/golang.org/x/sys/unix/aliases.go
generated
vendored
Normal file
14
vendor/golang.org/x/sys/unix/aliases.go
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
// +build go1.9
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
type Signal = syscall.Signal
|
||||||
|
type Errno = syscall.Errno
|
||||||
|
type SysProcAttr = syscall.SysProcAttr
|
||||||
17
vendor/golang.org/x/sys/unix/asm_aix_ppc64.s
generated
vendored
Normal file
17
vendor/golang.org/x/sys/unix/asm_aix_ppc64.s
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for ppc64, AIX are implemented in runtime/syscall_aix.go
|
||||||
|
//
|
||||||
|
|
||||||
|
TEXT ·syscall6(SB),NOSPLIT,$0-88
|
||||||
|
JMP syscall·syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·rawSyscall6(SB),NOSPLIT,$0-88
|
||||||
|
JMP syscall·rawSyscall6(SB)
|
||||||
29
vendor/golang.org/x/sys/unix/asm_darwin_386.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_darwin_386.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for 386, Darwin
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
29
vendor/golang.org/x/sys/unix/asm_darwin_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_darwin_amd64.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for AMD64, Darwin
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
30
vendor/golang.org/x/sys/unix/asm_darwin_arm.s
generated
vendored
Normal file
30
vendor/golang.org/x/sys/unix/asm_darwin_arm.s
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
// +build arm,darwin
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for ARM, Darwin
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
B syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·RawSyscall6(SB)
|
||||||
30
vendor/golang.org/x/sys/unix/asm_darwin_arm64.s
generated
vendored
Normal file
30
vendor/golang.org/x/sys/unix/asm_darwin_arm64.s
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
// +build arm64,darwin
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for AMD64, Darwin
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
B syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
B syscall·RawSyscall6(SB)
|
||||||
29
vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for AMD64, DragonFly
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
29
vendor/golang.org/x/sys/unix/asm_freebsd_386.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_freebsd_386.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for 386, FreeBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
29
vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for AMD64, FreeBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
29
vendor/golang.org/x/sys/unix/asm_freebsd_arm.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_freebsd_arm.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2012 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for ARM, FreeBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
B syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·RawSyscall6(SB)
|
||||||
29
vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for ARM64, FreeBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
65
vendor/golang.org/x/sys/unix/asm_linux_386.s
generated
vendored
Normal file
65
vendor/golang.org/x/sys/unix/asm_linux_386.s
generated
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for 386, Linux
|
||||||
|
//
|
||||||
|
|
||||||
|
// See ../runtime/sys_linux_386.s for the reason why we always use int 0x80
|
||||||
|
// instead of the glibc-specific "CALL 0x10(GS)".
|
||||||
|
#define INVOKE_SYSCALL INT $0x80
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
|
||||||
|
CALL runtime·entersyscall(SB)
|
||||||
|
MOVL trap+0(FP), AX // syscall entry
|
||||||
|
MOVL a1+4(FP), BX
|
||||||
|
MOVL a2+8(FP), CX
|
||||||
|
MOVL a3+12(FP), DX
|
||||||
|
MOVL $0, SI
|
||||||
|
MOVL $0, DI
|
||||||
|
INVOKE_SYSCALL
|
||||||
|
MOVL AX, r1+16(FP)
|
||||||
|
MOVL DX, r2+20(FP)
|
||||||
|
CALL runtime·exitsyscall(SB)
|
||||||
|
RET
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
|
||||||
|
MOVL trap+0(FP), AX // syscall entry
|
||||||
|
MOVL a1+4(FP), BX
|
||||||
|
MOVL a2+8(FP), CX
|
||||||
|
MOVL a3+12(FP), DX
|
||||||
|
MOVL $0, SI
|
||||||
|
MOVL $0, DI
|
||||||
|
INVOKE_SYSCALL
|
||||||
|
MOVL AX, r1+16(FP)
|
||||||
|
MOVL DX, r2+20(FP)
|
||||||
|
RET
|
||||||
|
|
||||||
|
TEXT ·socketcall(SB),NOSPLIT,$0-36
|
||||||
|
JMP syscall·socketcall(SB)
|
||||||
|
|
||||||
|
TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
|
||||||
|
JMP syscall·rawsocketcall(SB)
|
||||||
|
|
||||||
|
TEXT ·seek(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·seek(SB)
|
||||||
57
vendor/golang.org/x/sys/unix/asm_linux_amd64.s
generated
vendored
Normal file
57
vendor/golang.org/x/sys/unix/asm_linux_amd64.s
generated
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for AMD64, Linux
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
|
||||||
|
CALL runtime·entersyscall(SB)
|
||||||
|
MOVQ a1+8(FP), DI
|
||||||
|
MOVQ a2+16(FP), SI
|
||||||
|
MOVQ a3+24(FP), DX
|
||||||
|
MOVQ $0, R10
|
||||||
|
MOVQ $0, R8
|
||||||
|
MOVQ $0, R9
|
||||||
|
MOVQ trap+0(FP), AX // syscall entry
|
||||||
|
SYSCALL
|
||||||
|
MOVQ AX, r1+32(FP)
|
||||||
|
MOVQ DX, r2+40(FP)
|
||||||
|
CALL runtime·exitsyscall(SB)
|
||||||
|
RET
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
|
||||||
|
MOVQ a1+8(FP), DI
|
||||||
|
MOVQ a2+16(FP), SI
|
||||||
|
MOVQ a3+24(FP), DX
|
||||||
|
MOVQ $0, R10
|
||||||
|
MOVQ $0, R8
|
||||||
|
MOVQ $0, R9
|
||||||
|
MOVQ trap+0(FP), AX // syscall entry
|
||||||
|
SYSCALL
|
||||||
|
MOVQ AX, r1+32(FP)
|
||||||
|
MOVQ DX, r2+40(FP)
|
||||||
|
RET
|
||||||
|
|
||||||
|
TEXT ·gettimeofday(SB),NOSPLIT,$0-16
|
||||||
|
JMP syscall·gettimeofday(SB)
|
||||||
56
vendor/golang.org/x/sys/unix/asm_linux_arm.s
generated
vendored
Normal file
56
vendor/golang.org/x/sys/unix/asm_linux_arm.s
generated
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for arm, Linux
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
|
||||||
|
BL runtime·entersyscall(SB)
|
||||||
|
MOVW trap+0(FP), R7
|
||||||
|
MOVW a1+4(FP), R0
|
||||||
|
MOVW a2+8(FP), R1
|
||||||
|
MOVW a3+12(FP), R2
|
||||||
|
MOVW $0, R3
|
||||||
|
MOVW $0, R4
|
||||||
|
MOVW $0, R5
|
||||||
|
SWI $0
|
||||||
|
MOVW R0, r1+16(FP)
|
||||||
|
MOVW $0, R0
|
||||||
|
MOVW R0, r2+20(FP)
|
||||||
|
BL runtime·exitsyscall(SB)
|
||||||
|
RET
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·RawSyscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
|
||||||
|
MOVW trap+0(FP), R7 // syscall entry
|
||||||
|
MOVW a1+4(FP), R0
|
||||||
|
MOVW a2+8(FP), R1
|
||||||
|
MOVW a3+12(FP), R2
|
||||||
|
SWI $0
|
||||||
|
MOVW R0, r1+16(FP)
|
||||||
|
MOVW $0, R0
|
||||||
|
MOVW R0, r2+20(FP)
|
||||||
|
RET
|
||||||
|
|
||||||
|
TEXT ·seek(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·seek(SB)
|
||||||
52
vendor/golang.org/x/sys/unix/asm_linux_arm64.s
generated
vendored
Normal file
52
vendor/golang.org/x/sys/unix/asm_linux_arm64.s
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build linux
|
||||||
|
// +build arm64
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
|
||||||
|
BL runtime·entersyscall(SB)
|
||||||
|
MOVD a1+8(FP), R0
|
||||||
|
MOVD a2+16(FP), R1
|
||||||
|
MOVD a3+24(FP), R2
|
||||||
|
MOVD $0, R3
|
||||||
|
MOVD $0, R4
|
||||||
|
MOVD $0, R5
|
||||||
|
MOVD trap+0(FP), R8 // syscall entry
|
||||||
|
SVC
|
||||||
|
MOVD R0, r1+32(FP) // r1
|
||||||
|
MOVD R1, r2+40(FP) // r2
|
||||||
|
BL runtime·exitsyscall(SB)
|
||||||
|
RET
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
B syscall·RawSyscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
|
||||||
|
MOVD a1+8(FP), R0
|
||||||
|
MOVD a2+16(FP), R1
|
||||||
|
MOVD a3+24(FP), R2
|
||||||
|
MOVD $0, R3
|
||||||
|
MOVD $0, R4
|
||||||
|
MOVD $0, R5
|
||||||
|
MOVD trap+0(FP), R8 // syscall entry
|
||||||
|
SVC
|
||||||
|
MOVD R0, r1+32(FP)
|
||||||
|
MOVD R1, r2+40(FP)
|
||||||
|
RET
|
||||||
56
vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
generated
vendored
Normal file
56
vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
generated
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build linux
|
||||||
|
// +build mips64 mips64le
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for mips64, Linux
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
|
||||||
|
JAL runtime·entersyscall(SB)
|
||||||
|
MOVV a1+8(FP), R4
|
||||||
|
MOVV a2+16(FP), R5
|
||||||
|
MOVV a3+24(FP), R6
|
||||||
|
MOVV R0, R7
|
||||||
|
MOVV R0, R8
|
||||||
|
MOVV R0, R9
|
||||||
|
MOVV trap+0(FP), R2 // syscall entry
|
||||||
|
SYSCALL
|
||||||
|
MOVV R2, r1+32(FP)
|
||||||
|
MOVV R3, r2+40(FP)
|
||||||
|
JAL runtime·exitsyscall(SB)
|
||||||
|
RET
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
|
||||||
|
MOVV a1+8(FP), R4
|
||||||
|
MOVV a2+16(FP), R5
|
||||||
|
MOVV a3+24(FP), R6
|
||||||
|
MOVV R0, R7
|
||||||
|
MOVV R0, R8
|
||||||
|
MOVV R0, R9
|
||||||
|
MOVV trap+0(FP), R2 // syscall entry
|
||||||
|
SYSCALL
|
||||||
|
MOVV R2, r1+32(FP)
|
||||||
|
MOVV R3, r2+40(FP)
|
||||||
|
RET
|
||||||
54
vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
generated
vendored
Normal file
54
vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
generated
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build linux
|
||||||
|
// +build mips mipsle
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for mips, Linux
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
|
||||||
|
JAL runtime·entersyscall(SB)
|
||||||
|
MOVW a1+4(FP), R4
|
||||||
|
MOVW a2+8(FP), R5
|
||||||
|
MOVW a3+12(FP), R6
|
||||||
|
MOVW R0, R7
|
||||||
|
MOVW trap+0(FP), R2 // syscall entry
|
||||||
|
SYSCALL
|
||||||
|
MOVW R2, r1+16(FP) // r1
|
||||||
|
MOVW R3, r2+20(FP) // r2
|
||||||
|
JAL runtime·exitsyscall(SB)
|
||||||
|
RET
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
|
||||||
|
MOVW a1+4(FP), R4
|
||||||
|
MOVW a2+8(FP), R5
|
||||||
|
MOVW a3+12(FP), R6
|
||||||
|
MOVW trap+0(FP), R2 // syscall entry
|
||||||
|
SYSCALL
|
||||||
|
MOVW R2, r1+16(FP)
|
||||||
|
MOVW R3, r2+20(FP)
|
||||||
|
RET
|
||||||
44
vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
generated
vendored
Normal file
44
vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build linux
|
||||||
|
// +build ppc64 ppc64le
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for ppc64, Linux
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
|
||||||
|
BL runtime·entersyscall(SB)
|
||||||
|
MOVD a1+8(FP), R3
|
||||||
|
MOVD a2+16(FP), R4
|
||||||
|
MOVD a3+24(FP), R5
|
||||||
|
MOVD R0, R6
|
||||||
|
MOVD R0, R7
|
||||||
|
MOVD R0, R8
|
||||||
|
MOVD trap+0(FP), R9 // syscall entry
|
||||||
|
SYSCALL R9
|
||||||
|
MOVD R3, r1+32(FP)
|
||||||
|
MOVD R4, r2+40(FP)
|
||||||
|
BL runtime·exitsyscall(SB)
|
||||||
|
RET
|
||||||
|
|
||||||
|
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
|
||||||
|
MOVD a1+8(FP), R3
|
||||||
|
MOVD a2+16(FP), R4
|
||||||
|
MOVD a3+24(FP), R5
|
||||||
|
MOVD R0, R6
|
||||||
|
MOVD R0, R7
|
||||||
|
MOVD R0, R8
|
||||||
|
MOVD trap+0(FP), R9 // syscall entry
|
||||||
|
SYSCALL R9
|
||||||
|
MOVD R3, r1+32(FP)
|
||||||
|
MOVD R4, r2+40(FP)
|
||||||
|
RET
|
||||||
56
vendor/golang.org/x/sys/unix/asm_linux_s390x.s
generated
vendored
Normal file
56
vendor/golang.org/x/sys/unix/asm_linux_s390x.s
generated
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build s390x
|
||||||
|
// +build linux
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for s390x, Linux
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
BR syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
BR syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
|
||||||
|
BL runtime·entersyscall(SB)
|
||||||
|
MOVD a1+8(FP), R2
|
||||||
|
MOVD a2+16(FP), R3
|
||||||
|
MOVD a3+24(FP), R4
|
||||||
|
MOVD $0, R5
|
||||||
|
MOVD $0, R6
|
||||||
|
MOVD $0, R7
|
||||||
|
MOVD trap+0(FP), R1 // syscall entry
|
||||||
|
SYSCALL
|
||||||
|
MOVD R2, r1+32(FP)
|
||||||
|
MOVD R3, r2+40(FP)
|
||||||
|
BL runtime·exitsyscall(SB)
|
||||||
|
RET
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
BR syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
BR syscall·RawSyscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
|
||||||
|
MOVD a1+8(FP), R2
|
||||||
|
MOVD a2+16(FP), R3
|
||||||
|
MOVD a3+24(FP), R4
|
||||||
|
MOVD $0, R5
|
||||||
|
MOVD $0, R6
|
||||||
|
MOVD $0, R7
|
||||||
|
MOVD trap+0(FP), R1 // syscall entry
|
||||||
|
SYSCALL
|
||||||
|
MOVD R2, r1+32(FP)
|
||||||
|
MOVD R3, r2+40(FP)
|
||||||
|
RET
|
||||||
29
vendor/golang.org/x/sys/unix/asm_netbsd_386.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_netbsd_386.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for 386, NetBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
29
vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for AMD64, NetBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
29
vendor/golang.org/x/sys/unix/asm_netbsd_arm.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_netbsd_arm.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2013 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for ARM, NetBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
B syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·RawSyscall6(SB)
|
||||||
29
vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for ARM64, NetBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
B syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
B syscall·RawSyscall6(SB)
|
||||||
29
vendor/golang.org/x/sys/unix/asm_openbsd_386.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_openbsd_386.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for 386, OpenBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
29
vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for AMD64, OpenBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
29
vendor/golang.org/x/sys/unix/asm_openbsd_arm.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_openbsd_arm.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for ARM, OpenBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
B syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·RawSyscall6(SB)
|
||||||
17
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
generated
vendored
Normal file
17
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
|
||||||
|
//
|
||||||
|
|
||||||
|
TEXT ·sysvicall6(SB),NOSPLIT,$0-88
|
||||||
|
JMP syscall·sysvicall6(SB)
|
||||||
|
|
||||||
|
TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88
|
||||||
|
JMP syscall·rawSysvicall6(SB)
|
||||||
35
vendor/golang.org/x/sys/unix/bluetooth_linux.go
generated
vendored
Normal file
35
vendor/golang.org/x/sys/unix/bluetooth_linux.go
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Bluetooth sockets and messages
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Bluetooth Protocols
|
||||||
|
const (
|
||||||
|
BTPROTO_L2CAP = 0
|
||||||
|
BTPROTO_HCI = 1
|
||||||
|
BTPROTO_SCO = 2
|
||||||
|
BTPROTO_RFCOMM = 3
|
||||||
|
BTPROTO_BNEP = 4
|
||||||
|
BTPROTO_CMTP = 5
|
||||||
|
BTPROTO_HIDP = 6
|
||||||
|
BTPROTO_AVDTP = 7
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
HCI_CHANNEL_RAW = 0
|
||||||
|
HCI_CHANNEL_USER = 1
|
||||||
|
HCI_CHANNEL_MONITOR = 2
|
||||||
|
HCI_CHANNEL_CONTROL = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
// Socketoption Level
|
||||||
|
const (
|
||||||
|
SOL_BLUETOOTH = 0x112
|
||||||
|
SOL_HCI = 0x0
|
||||||
|
SOL_L2CAP = 0x6
|
||||||
|
SOL_RFCOMM = 0x12
|
||||||
|
SOL_SCO = 0x11
|
||||||
|
)
|
||||||
195
vendor/golang.org/x/sys/unix/cap_freebsd.go
generated
vendored
Normal file
195
vendor/golang.org/x/sys/unix/cap_freebsd.go
generated
vendored
Normal file
|
|
@ -0,0 +1,195 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build freebsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Go implementation of C mostly found in /usr/src/sys/kern/subr_capability.c
|
||||||
|
|
||||||
|
const (
|
||||||
|
// This is the version of CapRights this package understands. See C implementation for parallels.
|
||||||
|
capRightsGoVersion = CAP_RIGHTS_VERSION_00
|
||||||
|
capArSizeMin = CAP_RIGHTS_VERSION_00 + 2
|
||||||
|
capArSizeMax = capRightsGoVersion + 2
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
bit2idx = []int{
|
||||||
|
-1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func capidxbit(right uint64) int {
|
||||||
|
return int((right >> 57) & 0x1f)
|
||||||
|
}
|
||||||
|
|
||||||
|
func rightToIndex(right uint64) (int, error) {
|
||||||
|
idx := capidxbit(right)
|
||||||
|
if idx < 0 || idx >= len(bit2idx) {
|
||||||
|
return -2, fmt.Errorf("index for right 0x%x out of range", right)
|
||||||
|
}
|
||||||
|
return bit2idx[idx], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func caprver(right uint64) int {
|
||||||
|
return int(right >> 62)
|
||||||
|
}
|
||||||
|
|
||||||
|
func capver(rights *CapRights) int {
|
||||||
|
return caprver(rights.Rights[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
func caparsize(rights *CapRights) int {
|
||||||
|
return capver(rights) + 2
|
||||||
|
}
|
||||||
|
|
||||||
|
// CapRightsSet sets the permissions in setrights in rights.
|
||||||
|
func CapRightsSet(rights *CapRights, setrights []uint64) error {
|
||||||
|
// This is essentially a copy of cap_rights_vset()
|
||||||
|
if capver(rights) != CAP_RIGHTS_VERSION_00 {
|
||||||
|
return fmt.Errorf("bad rights version %d", capver(rights))
|
||||||
|
}
|
||||||
|
|
||||||
|
n := caparsize(rights)
|
||||||
|
if n < capArSizeMin || n > capArSizeMax {
|
||||||
|
return errors.New("bad rights size")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, right := range setrights {
|
||||||
|
if caprver(right) != CAP_RIGHTS_VERSION_00 {
|
||||||
|
return errors.New("bad right version")
|
||||||
|
}
|
||||||
|
i, err := rightToIndex(right)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if i >= n {
|
||||||
|
return errors.New("index overflow")
|
||||||
|
}
|
||||||
|
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
||||||
|
return errors.New("index mismatch")
|
||||||
|
}
|
||||||
|
rights.Rights[i] |= right
|
||||||
|
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
||||||
|
return errors.New("index mismatch (after assign)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CapRightsClear clears the permissions in clearrights from rights.
|
||||||
|
func CapRightsClear(rights *CapRights, clearrights []uint64) error {
|
||||||
|
// This is essentially a copy of cap_rights_vclear()
|
||||||
|
if capver(rights) != CAP_RIGHTS_VERSION_00 {
|
||||||
|
return fmt.Errorf("bad rights version %d", capver(rights))
|
||||||
|
}
|
||||||
|
|
||||||
|
n := caparsize(rights)
|
||||||
|
if n < capArSizeMin || n > capArSizeMax {
|
||||||
|
return errors.New("bad rights size")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, right := range clearrights {
|
||||||
|
if caprver(right) != CAP_RIGHTS_VERSION_00 {
|
||||||
|
return errors.New("bad right version")
|
||||||
|
}
|
||||||
|
i, err := rightToIndex(right)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if i >= n {
|
||||||
|
return errors.New("index overflow")
|
||||||
|
}
|
||||||
|
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
||||||
|
return errors.New("index mismatch")
|
||||||
|
}
|
||||||
|
rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF)
|
||||||
|
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
||||||
|
return errors.New("index mismatch (after assign)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CapRightsIsSet checks whether all the permissions in setrights are present in rights.
|
||||||
|
func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) {
|
||||||
|
// This is essentially a copy of cap_rights_is_vset()
|
||||||
|
if capver(rights) != CAP_RIGHTS_VERSION_00 {
|
||||||
|
return false, fmt.Errorf("bad rights version %d", capver(rights))
|
||||||
|
}
|
||||||
|
|
||||||
|
n := caparsize(rights)
|
||||||
|
if n < capArSizeMin || n > capArSizeMax {
|
||||||
|
return false, errors.New("bad rights size")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, right := range setrights {
|
||||||
|
if caprver(right) != CAP_RIGHTS_VERSION_00 {
|
||||||
|
return false, errors.New("bad right version")
|
||||||
|
}
|
||||||
|
i, err := rightToIndex(right)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
if i >= n {
|
||||||
|
return false, errors.New("index overflow")
|
||||||
|
}
|
||||||
|
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
||||||
|
return false, errors.New("index mismatch")
|
||||||
|
}
|
||||||
|
if (rights.Rights[i] & right) != right {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func capright(idx uint64, bit uint64) uint64 {
|
||||||
|
return ((1 << (57 + idx)) | bit)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CapRightsInit returns a pointer to an initialised CapRights structure filled with rights.
|
||||||
|
// See man cap_rights_init(3) and rights(4).
|
||||||
|
func CapRightsInit(rights []uint64) (*CapRights, error) {
|
||||||
|
var r CapRights
|
||||||
|
r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0)
|
||||||
|
r.Rights[1] = capright(1, 0)
|
||||||
|
|
||||||
|
err := CapRightsSet(&r, rights)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &r, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CapRightsLimit reduces the operations permitted on fd to at most those contained in rights.
|
||||||
|
// The capability rights on fd can never be increased by CapRightsLimit.
|
||||||
|
// See man cap_rights_limit(2) and rights(4).
|
||||||
|
func CapRightsLimit(fd uintptr, rights *CapRights) error {
|
||||||
|
return capRightsLimit(int(fd), rights)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CapRightsGet returns a CapRights structure containing the operations permitted on fd.
|
||||||
|
// See man cap_rights_get(3) and rights(4).
|
||||||
|
func CapRightsGet(fd uintptr) (*CapRights, error) {
|
||||||
|
r, err := CapRightsInit(nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
err = capRightsGet(capRightsGoVersion, int(fd), r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return r, nil
|
||||||
|
}
|
||||||
13
vendor/golang.org/x/sys/unix/constants.go
generated
vendored
Normal file
13
vendor/golang.org/x/sys/unix/constants.go
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
R_OK = 0x4
|
||||||
|
W_OK = 0x2
|
||||||
|
X_OK = 0x1
|
||||||
|
)
|
||||||
27
vendor/golang.org/x/sys/unix/dev_aix_ppc.go
generated
vendored
Normal file
27
vendor/golang.org/x/sys/unix/dev_aix_ppc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix
|
||||||
|
// +build ppc
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used by AIX.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of a Linux device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
return uint32((dev >> 16) & 0xffff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of a Linux device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
return uint32(dev & 0xffff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns a Linux device number generated from the given major and minor
|
||||||
|
// components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
return uint64(((major) << 16) | (minor))
|
||||||
|
}
|
||||||
29
vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix
|
||||||
|
// +build ppc64
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used AIX.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of a Linux device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
return uint32((dev & 0x3fffffff00000000) >> 32)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of a Linux device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
return uint32((dev & 0x00000000ffffffff) >> 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns a Linux device number generated from the given major and minor
|
||||||
|
// components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
var DEVNO64 uint64
|
||||||
|
DEVNO64 = 0x8000000000000000
|
||||||
|
return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64)
|
||||||
|
}
|
||||||
24
vendor/golang.org/x/sys/unix/dev_darwin.go
generated
vendored
Normal file
24
vendor/golang.org/x/sys/unix/dev_darwin.go
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used in Darwin's sys/types.h header.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of a Darwin device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
return uint32((dev >> 24) & 0xff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of a Darwin device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
return uint32(dev & 0xffffff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns a Darwin device number generated from the given major and minor
|
||||||
|
// components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
return (uint64(major) << 24) | uint64(minor)
|
||||||
|
}
|
||||||
30
vendor/golang.org/x/sys/unix/dev_dragonfly.go
generated
vendored
Normal file
30
vendor/golang.org/x/sys/unix/dev_dragonfly.go
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used in Dragonfly's sys/types.h header.
|
||||||
|
//
|
||||||
|
// The information below is extracted and adapted from sys/types.h:
|
||||||
|
//
|
||||||
|
// Minor gives a cookie instead of an index since in order to avoid changing the
|
||||||
|
// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
|
||||||
|
// devices that don't use them.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of a DragonFlyBSD device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
return uint32((dev >> 8) & 0xff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of a DragonFlyBSD device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
return uint32(dev & 0xffff00ff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns a DragonFlyBSD device number generated from the given major and
|
||||||
|
// minor components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
return (uint64(major) << 8) | uint64(minor)
|
||||||
|
}
|
||||||
30
vendor/golang.org/x/sys/unix/dev_freebsd.go
generated
vendored
Normal file
30
vendor/golang.org/x/sys/unix/dev_freebsd.go
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used in FreeBSD's sys/types.h header.
|
||||||
|
//
|
||||||
|
// The information below is extracted and adapted from sys/types.h:
|
||||||
|
//
|
||||||
|
// Minor gives a cookie instead of an index since in order to avoid changing the
|
||||||
|
// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
|
||||||
|
// devices that don't use them.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of a FreeBSD device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
return uint32((dev >> 8) & 0xff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of a FreeBSD device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
return uint32(dev & 0xffff00ff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns a FreeBSD device number generated from the given major and
|
||||||
|
// minor components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
return (uint64(major) << 8) | uint64(minor)
|
||||||
|
}
|
||||||
42
vendor/golang.org/x/sys/unix/dev_linux.go
generated
vendored
Normal file
42
vendor/golang.org/x/sys/unix/dev_linux.go
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used by the Linux kernel and glibc.
|
||||||
|
//
|
||||||
|
// The information below is extracted and adapted from bits/sysmacros.h in the
|
||||||
|
// glibc sources:
|
||||||
|
//
|
||||||
|
// dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's
|
||||||
|
// default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major
|
||||||
|
// number and m is a hex digit of the minor number. This is backward compatible
|
||||||
|
// with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also
|
||||||
|
// backward compatible with the Linux kernel, which for some architectures uses
|
||||||
|
// 32-bit dev_t, encoded as mmmM MMmm.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of a Linux device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
major := uint32((dev & 0x00000000000fff00) >> 8)
|
||||||
|
major |= uint32((dev & 0xfffff00000000000) >> 32)
|
||||||
|
return major
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of a Linux device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
minor := uint32((dev & 0x00000000000000ff) >> 0)
|
||||||
|
minor |= uint32((dev & 0x00000ffffff00000) >> 12)
|
||||||
|
return minor
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns a Linux device number generated from the given major and minor
|
||||||
|
// components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
dev := (uint64(major) & 0x00000fff) << 8
|
||||||
|
dev |= (uint64(major) & 0xfffff000) << 32
|
||||||
|
dev |= (uint64(minor) & 0x000000ff) << 0
|
||||||
|
dev |= (uint64(minor) & 0xffffff00) << 12
|
||||||
|
return dev
|
||||||
|
}
|
||||||
29
vendor/golang.org/x/sys/unix/dev_netbsd.go
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/dev_netbsd.go
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used in NetBSD's sys/types.h header.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of a NetBSD device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
return uint32((dev & 0x000fff00) >> 8)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of a NetBSD device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
minor := uint32((dev & 0x000000ff) >> 0)
|
||||||
|
minor |= uint32((dev & 0xfff00000) >> 12)
|
||||||
|
return minor
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns a NetBSD device number generated from the given major and minor
|
||||||
|
// components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
dev := (uint64(major) << 8) & 0x000fff00
|
||||||
|
dev |= (uint64(minor) << 12) & 0xfff00000
|
||||||
|
dev |= (uint64(minor) << 0) & 0x000000ff
|
||||||
|
return dev
|
||||||
|
}
|
||||||
29
vendor/golang.org/x/sys/unix/dev_openbsd.go
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/dev_openbsd.go
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used in OpenBSD's sys/types.h header.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of an OpenBSD device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
return uint32((dev & 0x0000ff00) >> 8)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of an OpenBSD device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
minor := uint32((dev & 0x000000ff) >> 0)
|
||||||
|
minor |= uint32((dev & 0xffff0000) >> 8)
|
||||||
|
return minor
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns an OpenBSD device number generated from the given major and minor
|
||||||
|
// components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
dev := (uint64(major) << 8) & 0x0000ff00
|
||||||
|
dev |= (uint64(minor) << 8) & 0xffff0000
|
||||||
|
dev |= (uint64(minor) << 0) & 0x000000ff
|
||||||
|
return dev
|
||||||
|
}
|
||||||
17
vendor/golang.org/x/sys/unix/dirent.go
generated
vendored
Normal file
17
vendor/golang.org/x/sys/unix/dirent.go
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
// ParseDirent parses up to max directory entries in buf,
|
||||||
|
// appending the names to names. It returns the number of
|
||||||
|
// bytes consumed from buf, the number of entries added
|
||||||
|
// to names, and the new names slice.
|
||||||
|
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
||||||
|
return syscall.ParseDirent(buf, max, names)
|
||||||
|
}
|
||||||
9
vendor/golang.org/x/sys/unix/endian_big.go
generated
vendored
Normal file
9
vendor/golang.org/x/sys/unix/endian_big.go
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// +build ppc64 s390x mips mips64
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const isBigEndian = true
|
||||||
9
vendor/golang.org/x/sys/unix/endian_little.go
generated
vendored
Normal file
9
vendor/golang.org/x/sys/unix/endian_little.go
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const isBigEndian = false
|
||||||
31
vendor/golang.org/x/sys/unix/env_unix.go
generated
vendored
Normal file
31
vendor/golang.org/x/sys/unix/env_unix.go
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
// Copyright 2010 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
// Unix environment variables.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func Getenv(key string) (value string, found bool) {
|
||||||
|
return syscall.Getenv(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Setenv(key, value string) error {
|
||||||
|
return syscall.Setenv(key, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Clearenv() {
|
||||||
|
syscall.Clearenv()
|
||||||
|
}
|
||||||
|
|
||||||
|
func Environ() []string {
|
||||||
|
return syscall.Environ()
|
||||||
|
}
|
||||||
|
|
||||||
|
func Unsetenv(key string) error {
|
||||||
|
return syscall.Unsetenv(key)
|
||||||
|
}
|
||||||
227
vendor/golang.org/x/sys/unix/errors_freebsd_386.go
generated
vendored
Normal file
227
vendor/golang.org/x/sys/unix/errors_freebsd_386.go
generated
vendored
Normal file
|
|
@ -0,0 +1,227 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
|
||||||
|
// them here for backwards compatibility.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
IFF_SMART = 0x20
|
||||||
|
IFT_1822 = 0x2
|
||||||
|
IFT_A12MPPSWITCH = 0x82
|
||||||
|
IFT_AAL2 = 0xbb
|
||||||
|
IFT_AAL5 = 0x31
|
||||||
|
IFT_ADSL = 0x5e
|
||||||
|
IFT_AFLANE8023 = 0x3b
|
||||||
|
IFT_AFLANE8025 = 0x3c
|
||||||
|
IFT_ARAP = 0x58
|
||||||
|
IFT_ARCNET = 0x23
|
||||||
|
IFT_ARCNETPLUS = 0x24
|
||||||
|
IFT_ASYNC = 0x54
|
||||||
|
IFT_ATM = 0x25
|
||||||
|
IFT_ATMDXI = 0x69
|
||||||
|
IFT_ATMFUNI = 0x6a
|
||||||
|
IFT_ATMIMA = 0x6b
|
||||||
|
IFT_ATMLOGICAL = 0x50
|
||||||
|
IFT_ATMRADIO = 0xbd
|
||||||
|
IFT_ATMSUBINTERFACE = 0x86
|
||||||
|
IFT_ATMVCIENDPT = 0xc2
|
||||||
|
IFT_ATMVIRTUAL = 0x95
|
||||||
|
IFT_BGPPOLICYACCOUNTING = 0xa2
|
||||||
|
IFT_BSC = 0x53
|
||||||
|
IFT_CCTEMUL = 0x3d
|
||||||
|
IFT_CEPT = 0x13
|
||||||
|
IFT_CES = 0x85
|
||||||
|
IFT_CHANNEL = 0x46
|
||||||
|
IFT_CNR = 0x55
|
||||||
|
IFT_COFFEE = 0x84
|
||||||
|
IFT_COMPOSITELINK = 0x9b
|
||||||
|
IFT_DCN = 0x8d
|
||||||
|
IFT_DIGITALPOWERLINE = 0x8a
|
||||||
|
IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
|
||||||
|
IFT_DLSW = 0x4a
|
||||||
|
IFT_DOCSCABLEDOWNSTREAM = 0x80
|
||||||
|
IFT_DOCSCABLEMACLAYER = 0x7f
|
||||||
|
IFT_DOCSCABLEUPSTREAM = 0x81
|
||||||
|
IFT_DS0 = 0x51
|
||||||
|
IFT_DS0BUNDLE = 0x52
|
||||||
|
IFT_DS1FDL = 0xaa
|
||||||
|
IFT_DS3 = 0x1e
|
||||||
|
IFT_DTM = 0x8c
|
||||||
|
IFT_DVBASILN = 0xac
|
||||||
|
IFT_DVBASIOUT = 0xad
|
||||||
|
IFT_DVBRCCDOWNSTREAM = 0x93
|
||||||
|
IFT_DVBRCCMACLAYER = 0x92
|
||||||
|
IFT_DVBRCCUPSTREAM = 0x94
|
||||||
|
IFT_ENC = 0xf4
|
||||||
|
IFT_EON = 0x19
|
||||||
|
IFT_EPLRS = 0x57
|
||||||
|
IFT_ESCON = 0x49
|
||||||
|
IFT_ETHER = 0x6
|
||||||
|
IFT_FAITH = 0xf2
|
||||||
|
IFT_FAST = 0x7d
|
||||||
|
IFT_FASTETHER = 0x3e
|
||||||
|
IFT_FASTETHERFX = 0x45
|
||||||
|
IFT_FDDI = 0xf
|
||||||
|
IFT_FIBRECHANNEL = 0x38
|
||||||
|
IFT_FRAMERELAYINTERCONNECT = 0x3a
|
||||||
|
IFT_FRAMERELAYMPI = 0x5c
|
||||||
|
IFT_FRDLCIENDPT = 0xc1
|
||||||
|
IFT_FRELAY = 0x20
|
||||||
|
IFT_FRELAYDCE = 0x2c
|
||||||
|
IFT_FRF16MFRBUNDLE = 0xa3
|
||||||
|
IFT_FRFORWARD = 0x9e
|
||||||
|
IFT_G703AT2MB = 0x43
|
||||||
|
IFT_G703AT64K = 0x42
|
||||||
|
IFT_GIF = 0xf0
|
||||||
|
IFT_GIGABITETHERNET = 0x75
|
||||||
|
IFT_GR303IDT = 0xb2
|
||||||
|
IFT_GR303RDT = 0xb1
|
||||||
|
IFT_H323GATEKEEPER = 0xa4
|
||||||
|
IFT_H323PROXY = 0xa5
|
||||||
|
IFT_HDH1822 = 0x3
|
||||||
|
IFT_HDLC = 0x76
|
||||||
|
IFT_HDSL2 = 0xa8
|
||||||
|
IFT_HIPERLAN2 = 0xb7
|
||||||
|
IFT_HIPPI = 0x2f
|
||||||
|
IFT_HIPPIINTERFACE = 0x39
|
||||||
|
IFT_HOSTPAD = 0x5a
|
||||||
|
IFT_HSSI = 0x2e
|
||||||
|
IFT_HY = 0xe
|
||||||
|
IFT_IBM370PARCHAN = 0x48
|
||||||
|
IFT_IDSL = 0x9a
|
||||||
|
IFT_IEEE80211 = 0x47
|
||||||
|
IFT_IEEE80212 = 0x37
|
||||||
|
IFT_IEEE8023ADLAG = 0xa1
|
||||||
|
IFT_IFGSN = 0x91
|
||||||
|
IFT_IMT = 0xbe
|
||||||
|
IFT_INTERLEAVE = 0x7c
|
||||||
|
IFT_IP = 0x7e
|
||||||
|
IFT_IPFORWARD = 0x8e
|
||||||
|
IFT_IPOVERATM = 0x72
|
||||||
|
IFT_IPOVERCDLC = 0x6d
|
||||||
|
IFT_IPOVERCLAW = 0x6e
|
||||||
|
IFT_IPSWITCH = 0x4e
|
||||||
|
IFT_IPXIP = 0xf9
|
||||||
|
IFT_ISDN = 0x3f
|
||||||
|
IFT_ISDNBASIC = 0x14
|
||||||
|
IFT_ISDNPRIMARY = 0x15
|
||||||
|
IFT_ISDNS = 0x4b
|
||||||
|
IFT_ISDNU = 0x4c
|
||||||
|
IFT_ISO88022LLC = 0x29
|
||||||
|
IFT_ISO88023 = 0x7
|
||||||
|
IFT_ISO88024 = 0x8
|
||||||
|
IFT_ISO88025 = 0x9
|
||||||
|
IFT_ISO88025CRFPINT = 0x62
|
||||||
|
IFT_ISO88025DTR = 0x56
|
||||||
|
IFT_ISO88025FIBER = 0x73
|
||||||
|
IFT_ISO88026 = 0xa
|
||||||
|
IFT_ISUP = 0xb3
|
||||||
|
IFT_L3IPXVLAN = 0x89
|
||||||
|
IFT_LAPB = 0x10
|
||||||
|
IFT_LAPD = 0x4d
|
||||||
|
IFT_LAPF = 0x77
|
||||||
|
IFT_LOCALTALK = 0x2a
|
||||||
|
IFT_LOOP = 0x18
|
||||||
|
IFT_MEDIAMAILOVERIP = 0x8b
|
||||||
|
IFT_MFSIGLINK = 0xa7
|
||||||
|
IFT_MIOX25 = 0x26
|
||||||
|
IFT_MODEM = 0x30
|
||||||
|
IFT_MPC = 0x71
|
||||||
|
IFT_MPLS = 0xa6
|
||||||
|
IFT_MPLSTUNNEL = 0x96
|
||||||
|
IFT_MSDSL = 0x8f
|
||||||
|
IFT_MVL = 0xbf
|
||||||
|
IFT_MYRINET = 0x63
|
||||||
|
IFT_NFAS = 0xaf
|
||||||
|
IFT_NSIP = 0x1b
|
||||||
|
IFT_OPTICALCHANNEL = 0xc3
|
||||||
|
IFT_OPTICALTRANSPORT = 0xc4
|
||||||
|
IFT_OTHER = 0x1
|
||||||
|
IFT_P10 = 0xc
|
||||||
|
IFT_P80 = 0xd
|
||||||
|
IFT_PARA = 0x22
|
||||||
|
IFT_PFLOG = 0xf6
|
||||||
|
IFT_PFSYNC = 0xf7
|
||||||
|
IFT_PLC = 0xae
|
||||||
|
IFT_POS = 0xab
|
||||||
|
IFT_PPPMULTILINKBUNDLE = 0x6c
|
||||||
|
IFT_PROPBWAP2MP = 0xb8
|
||||||
|
IFT_PROPCNLS = 0x59
|
||||||
|
IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
|
||||||
|
IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
|
||||||
|
IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
|
||||||
|
IFT_PROPMUX = 0x36
|
||||||
|
IFT_PROPWIRELESSP2P = 0x9d
|
||||||
|
IFT_PTPSERIAL = 0x16
|
||||||
|
IFT_PVC = 0xf1
|
||||||
|
IFT_QLLC = 0x44
|
||||||
|
IFT_RADIOMAC = 0xbc
|
||||||
|
IFT_RADSL = 0x5f
|
||||||
|
IFT_REACHDSL = 0xc0
|
||||||
|
IFT_RFC1483 = 0x9f
|
||||||
|
IFT_RS232 = 0x21
|
||||||
|
IFT_RSRB = 0x4f
|
||||||
|
IFT_SDLC = 0x11
|
||||||
|
IFT_SDSL = 0x60
|
||||||
|
IFT_SHDSL = 0xa9
|
||||||
|
IFT_SIP = 0x1f
|
||||||
|
IFT_SLIP = 0x1c
|
||||||
|
IFT_SMDSDXI = 0x2b
|
||||||
|
IFT_SMDSICIP = 0x34
|
||||||
|
IFT_SONET = 0x27
|
||||||
|
IFT_SONETOVERHEADCHANNEL = 0xb9
|
||||||
|
IFT_SONETPATH = 0x32
|
||||||
|
IFT_SONETVT = 0x33
|
||||||
|
IFT_SRP = 0x97
|
||||||
|
IFT_SS7SIGLINK = 0x9c
|
||||||
|
IFT_STACKTOSTACK = 0x6f
|
||||||
|
IFT_STARLAN = 0xb
|
||||||
|
IFT_STF = 0xd7
|
||||||
|
IFT_T1 = 0x12
|
||||||
|
IFT_TDLC = 0x74
|
||||||
|
IFT_TERMPAD = 0x5b
|
||||||
|
IFT_TR008 = 0xb0
|
||||||
|
IFT_TRANSPHDLC = 0x7b
|
||||||
|
IFT_TUNNEL = 0x83
|
||||||
|
IFT_ULTRA = 0x1d
|
||||||
|
IFT_USB = 0xa0
|
||||||
|
IFT_V11 = 0x40
|
||||||
|
IFT_V35 = 0x2d
|
||||||
|
IFT_V36 = 0x41
|
||||||
|
IFT_V37 = 0x78
|
||||||
|
IFT_VDSL = 0x61
|
||||||
|
IFT_VIRTUALIPADDRESS = 0x70
|
||||||
|
IFT_VOICEEM = 0x64
|
||||||
|
IFT_VOICEENCAP = 0x67
|
||||||
|
IFT_VOICEFXO = 0x65
|
||||||
|
IFT_VOICEFXS = 0x66
|
||||||
|
IFT_VOICEOVERATM = 0x98
|
||||||
|
IFT_VOICEOVERFRAMERELAY = 0x99
|
||||||
|
IFT_VOICEOVERIP = 0x68
|
||||||
|
IFT_X213 = 0x5d
|
||||||
|
IFT_X25 = 0x5
|
||||||
|
IFT_X25DDN = 0x4
|
||||||
|
IFT_X25HUNTGROUP = 0x7a
|
||||||
|
IFT_X25MLP = 0x79
|
||||||
|
IFT_X25PLE = 0x28
|
||||||
|
IFT_XETHER = 0x1a
|
||||||
|
IPPROTO_MAXID = 0x34
|
||||||
|
IPV6_FAITH = 0x1d
|
||||||
|
IP_FAITH = 0x16
|
||||||
|
MAP_NORESERVE = 0x40
|
||||||
|
MAP_RENAME = 0x20
|
||||||
|
NET_RT_MAXID = 0x6
|
||||||
|
RTF_PRCLONING = 0x10000
|
||||||
|
RTM_OLDADD = 0x9
|
||||||
|
RTM_OLDDEL = 0xa
|
||||||
|
SIOCADDRT = 0x8030720a
|
||||||
|
SIOCALIFADDR = 0x8118691b
|
||||||
|
SIOCDELRT = 0x8030720b
|
||||||
|
SIOCDLIFADDR = 0x8118691d
|
||||||
|
SIOCGLIFADDR = 0xc118691c
|
||||||
|
SIOCGLIFPHYADDR = 0xc118694b
|
||||||
|
SIOCSLIFPHYADDR = 0x8118694a
|
||||||
|
)
|
||||||
227
vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go
generated
vendored
Normal file
227
vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,227 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
|
||||||
|
// them here for backwards compatibility.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
IFF_SMART = 0x20
|
||||||
|
IFT_1822 = 0x2
|
||||||
|
IFT_A12MPPSWITCH = 0x82
|
||||||
|
IFT_AAL2 = 0xbb
|
||||||
|
IFT_AAL5 = 0x31
|
||||||
|
IFT_ADSL = 0x5e
|
||||||
|
IFT_AFLANE8023 = 0x3b
|
||||||
|
IFT_AFLANE8025 = 0x3c
|
||||||
|
IFT_ARAP = 0x58
|
||||||
|
IFT_ARCNET = 0x23
|
||||||
|
IFT_ARCNETPLUS = 0x24
|
||||||
|
IFT_ASYNC = 0x54
|
||||||
|
IFT_ATM = 0x25
|
||||||
|
IFT_ATMDXI = 0x69
|
||||||
|
IFT_ATMFUNI = 0x6a
|
||||||
|
IFT_ATMIMA = 0x6b
|
||||||
|
IFT_ATMLOGICAL = 0x50
|
||||||
|
IFT_ATMRADIO = 0xbd
|
||||||
|
IFT_ATMSUBINTERFACE = 0x86
|
||||||
|
IFT_ATMVCIENDPT = 0xc2
|
||||||
|
IFT_ATMVIRTUAL = 0x95
|
||||||
|
IFT_BGPPOLICYACCOUNTING = 0xa2
|
||||||
|
IFT_BSC = 0x53
|
||||||
|
IFT_CCTEMUL = 0x3d
|
||||||
|
IFT_CEPT = 0x13
|
||||||
|
IFT_CES = 0x85
|
||||||
|
IFT_CHANNEL = 0x46
|
||||||
|
IFT_CNR = 0x55
|
||||||
|
IFT_COFFEE = 0x84
|
||||||
|
IFT_COMPOSITELINK = 0x9b
|
||||||
|
IFT_DCN = 0x8d
|
||||||
|
IFT_DIGITALPOWERLINE = 0x8a
|
||||||
|
IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
|
||||||
|
IFT_DLSW = 0x4a
|
||||||
|
IFT_DOCSCABLEDOWNSTREAM = 0x80
|
||||||
|
IFT_DOCSCABLEMACLAYER = 0x7f
|
||||||
|
IFT_DOCSCABLEUPSTREAM = 0x81
|
||||||
|
IFT_DS0 = 0x51
|
||||||
|
IFT_DS0BUNDLE = 0x52
|
||||||
|
IFT_DS1FDL = 0xaa
|
||||||
|
IFT_DS3 = 0x1e
|
||||||
|
IFT_DTM = 0x8c
|
||||||
|
IFT_DVBASILN = 0xac
|
||||||
|
IFT_DVBASIOUT = 0xad
|
||||||
|
IFT_DVBRCCDOWNSTREAM = 0x93
|
||||||
|
IFT_DVBRCCMACLAYER = 0x92
|
||||||
|
IFT_DVBRCCUPSTREAM = 0x94
|
||||||
|
IFT_ENC = 0xf4
|
||||||
|
IFT_EON = 0x19
|
||||||
|
IFT_EPLRS = 0x57
|
||||||
|
IFT_ESCON = 0x49
|
||||||
|
IFT_ETHER = 0x6
|
||||||
|
IFT_FAITH = 0xf2
|
||||||
|
IFT_FAST = 0x7d
|
||||||
|
IFT_FASTETHER = 0x3e
|
||||||
|
IFT_FASTETHERFX = 0x45
|
||||||
|
IFT_FDDI = 0xf
|
||||||
|
IFT_FIBRECHANNEL = 0x38
|
||||||
|
IFT_FRAMERELAYINTERCONNECT = 0x3a
|
||||||
|
IFT_FRAMERELAYMPI = 0x5c
|
||||||
|
IFT_FRDLCIENDPT = 0xc1
|
||||||
|
IFT_FRELAY = 0x20
|
||||||
|
IFT_FRELAYDCE = 0x2c
|
||||||
|
IFT_FRF16MFRBUNDLE = 0xa3
|
||||||
|
IFT_FRFORWARD = 0x9e
|
||||||
|
IFT_G703AT2MB = 0x43
|
||||||
|
IFT_G703AT64K = 0x42
|
||||||
|
IFT_GIF = 0xf0
|
||||||
|
IFT_GIGABITETHERNET = 0x75
|
||||||
|
IFT_GR303IDT = 0xb2
|
||||||
|
IFT_GR303RDT = 0xb1
|
||||||
|
IFT_H323GATEKEEPER = 0xa4
|
||||||
|
IFT_H323PROXY = 0xa5
|
||||||
|
IFT_HDH1822 = 0x3
|
||||||
|
IFT_HDLC = 0x76
|
||||||
|
IFT_HDSL2 = 0xa8
|
||||||
|
IFT_HIPERLAN2 = 0xb7
|
||||||
|
IFT_HIPPI = 0x2f
|
||||||
|
IFT_HIPPIINTERFACE = 0x39
|
||||||
|
IFT_HOSTPAD = 0x5a
|
||||||
|
IFT_HSSI = 0x2e
|
||||||
|
IFT_HY = 0xe
|
||||||
|
IFT_IBM370PARCHAN = 0x48
|
||||||
|
IFT_IDSL = 0x9a
|
||||||
|
IFT_IEEE80211 = 0x47
|
||||||
|
IFT_IEEE80212 = 0x37
|
||||||
|
IFT_IEEE8023ADLAG = 0xa1
|
||||||
|
IFT_IFGSN = 0x91
|
||||||
|
IFT_IMT = 0xbe
|
||||||
|
IFT_INTERLEAVE = 0x7c
|
||||||
|
IFT_IP = 0x7e
|
||||||
|
IFT_IPFORWARD = 0x8e
|
||||||
|
IFT_IPOVERATM = 0x72
|
||||||
|
IFT_IPOVERCDLC = 0x6d
|
||||||
|
IFT_IPOVERCLAW = 0x6e
|
||||||
|
IFT_IPSWITCH = 0x4e
|
||||||
|
IFT_IPXIP = 0xf9
|
||||||
|
IFT_ISDN = 0x3f
|
||||||
|
IFT_ISDNBASIC = 0x14
|
||||||
|
IFT_ISDNPRIMARY = 0x15
|
||||||
|
IFT_ISDNS = 0x4b
|
||||||
|
IFT_ISDNU = 0x4c
|
||||||
|
IFT_ISO88022LLC = 0x29
|
||||||
|
IFT_ISO88023 = 0x7
|
||||||
|
IFT_ISO88024 = 0x8
|
||||||
|
IFT_ISO88025 = 0x9
|
||||||
|
IFT_ISO88025CRFPINT = 0x62
|
||||||
|
IFT_ISO88025DTR = 0x56
|
||||||
|
IFT_ISO88025FIBER = 0x73
|
||||||
|
IFT_ISO88026 = 0xa
|
||||||
|
IFT_ISUP = 0xb3
|
||||||
|
IFT_L3IPXVLAN = 0x89
|
||||||
|
IFT_LAPB = 0x10
|
||||||
|
IFT_LAPD = 0x4d
|
||||||
|
IFT_LAPF = 0x77
|
||||||
|
IFT_LOCALTALK = 0x2a
|
||||||
|
IFT_LOOP = 0x18
|
||||||
|
IFT_MEDIAMAILOVERIP = 0x8b
|
||||||
|
IFT_MFSIGLINK = 0xa7
|
||||||
|
IFT_MIOX25 = 0x26
|
||||||
|
IFT_MODEM = 0x30
|
||||||
|
IFT_MPC = 0x71
|
||||||
|
IFT_MPLS = 0xa6
|
||||||
|
IFT_MPLSTUNNEL = 0x96
|
||||||
|
IFT_MSDSL = 0x8f
|
||||||
|
IFT_MVL = 0xbf
|
||||||
|
IFT_MYRINET = 0x63
|
||||||
|
IFT_NFAS = 0xaf
|
||||||
|
IFT_NSIP = 0x1b
|
||||||
|
IFT_OPTICALCHANNEL = 0xc3
|
||||||
|
IFT_OPTICALTRANSPORT = 0xc4
|
||||||
|
IFT_OTHER = 0x1
|
||||||
|
IFT_P10 = 0xc
|
||||||
|
IFT_P80 = 0xd
|
||||||
|
IFT_PARA = 0x22
|
||||||
|
IFT_PFLOG = 0xf6
|
||||||
|
IFT_PFSYNC = 0xf7
|
||||||
|
IFT_PLC = 0xae
|
||||||
|
IFT_POS = 0xab
|
||||||
|
IFT_PPPMULTILINKBUNDLE = 0x6c
|
||||||
|
IFT_PROPBWAP2MP = 0xb8
|
||||||
|
IFT_PROPCNLS = 0x59
|
||||||
|
IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
|
||||||
|
IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
|
||||||
|
IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
|
||||||
|
IFT_PROPMUX = 0x36
|
||||||
|
IFT_PROPWIRELESSP2P = 0x9d
|
||||||
|
IFT_PTPSERIAL = 0x16
|
||||||
|
IFT_PVC = 0xf1
|
||||||
|
IFT_QLLC = 0x44
|
||||||
|
IFT_RADIOMAC = 0xbc
|
||||||
|
IFT_RADSL = 0x5f
|
||||||
|
IFT_REACHDSL = 0xc0
|
||||||
|
IFT_RFC1483 = 0x9f
|
||||||
|
IFT_RS232 = 0x21
|
||||||
|
IFT_RSRB = 0x4f
|
||||||
|
IFT_SDLC = 0x11
|
||||||
|
IFT_SDSL = 0x60
|
||||||
|
IFT_SHDSL = 0xa9
|
||||||
|
IFT_SIP = 0x1f
|
||||||
|
IFT_SLIP = 0x1c
|
||||||
|
IFT_SMDSDXI = 0x2b
|
||||||
|
IFT_SMDSICIP = 0x34
|
||||||
|
IFT_SONET = 0x27
|
||||||
|
IFT_SONETOVERHEADCHANNEL = 0xb9
|
||||||
|
IFT_SONETPATH = 0x32
|
||||||
|
IFT_SONETVT = 0x33
|
||||||
|
IFT_SRP = 0x97
|
||||||
|
IFT_SS7SIGLINK = 0x9c
|
||||||
|
IFT_STACKTOSTACK = 0x6f
|
||||||
|
IFT_STARLAN = 0xb
|
||||||
|
IFT_STF = 0xd7
|
||||||
|
IFT_T1 = 0x12
|
||||||
|
IFT_TDLC = 0x74
|
||||||
|
IFT_TERMPAD = 0x5b
|
||||||
|
IFT_TR008 = 0xb0
|
||||||
|
IFT_TRANSPHDLC = 0x7b
|
||||||
|
IFT_TUNNEL = 0x83
|
||||||
|
IFT_ULTRA = 0x1d
|
||||||
|
IFT_USB = 0xa0
|
||||||
|
IFT_V11 = 0x40
|
||||||
|
IFT_V35 = 0x2d
|
||||||
|
IFT_V36 = 0x41
|
||||||
|
IFT_V37 = 0x78
|
||||||
|
IFT_VDSL = 0x61
|
||||||
|
IFT_VIRTUALIPADDRESS = 0x70
|
||||||
|
IFT_VOICEEM = 0x64
|
||||||
|
IFT_VOICEENCAP = 0x67
|
||||||
|
IFT_VOICEFXO = 0x65
|
||||||
|
IFT_VOICEFXS = 0x66
|
||||||
|
IFT_VOICEOVERATM = 0x98
|
||||||
|
IFT_VOICEOVERFRAMERELAY = 0x99
|
||||||
|
IFT_VOICEOVERIP = 0x68
|
||||||
|
IFT_X213 = 0x5d
|
||||||
|
IFT_X25 = 0x5
|
||||||
|
IFT_X25DDN = 0x4
|
||||||
|
IFT_X25HUNTGROUP = 0x7a
|
||||||
|
IFT_X25MLP = 0x79
|
||||||
|
IFT_X25PLE = 0x28
|
||||||
|
IFT_XETHER = 0x1a
|
||||||
|
IPPROTO_MAXID = 0x34
|
||||||
|
IPV6_FAITH = 0x1d
|
||||||
|
IP_FAITH = 0x16
|
||||||
|
MAP_NORESERVE = 0x40
|
||||||
|
MAP_RENAME = 0x20
|
||||||
|
NET_RT_MAXID = 0x6
|
||||||
|
RTF_PRCLONING = 0x10000
|
||||||
|
RTM_OLDADD = 0x9
|
||||||
|
RTM_OLDDEL = 0xa
|
||||||
|
SIOCADDRT = 0x8040720a
|
||||||
|
SIOCALIFADDR = 0x8118691b
|
||||||
|
SIOCDELRT = 0x8040720b
|
||||||
|
SIOCDLIFADDR = 0x8118691d
|
||||||
|
SIOCGLIFADDR = 0xc118691c
|
||||||
|
SIOCGLIFPHYADDR = 0xc118694b
|
||||||
|
SIOCSLIFPHYADDR = 0x8118694a
|
||||||
|
)
|
||||||
226
vendor/golang.org/x/sys/unix/errors_freebsd_arm.go
generated
vendored
Normal file
226
vendor/golang.org/x/sys/unix/errors_freebsd_arm.go
generated
vendored
Normal file
|
|
@ -0,0 +1,226 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
IFT_1822 = 0x2
|
||||||
|
IFT_A12MPPSWITCH = 0x82
|
||||||
|
IFT_AAL2 = 0xbb
|
||||||
|
IFT_AAL5 = 0x31
|
||||||
|
IFT_ADSL = 0x5e
|
||||||
|
IFT_AFLANE8023 = 0x3b
|
||||||
|
IFT_AFLANE8025 = 0x3c
|
||||||
|
IFT_ARAP = 0x58
|
||||||
|
IFT_ARCNET = 0x23
|
||||||
|
IFT_ARCNETPLUS = 0x24
|
||||||
|
IFT_ASYNC = 0x54
|
||||||
|
IFT_ATM = 0x25
|
||||||
|
IFT_ATMDXI = 0x69
|
||||||
|
IFT_ATMFUNI = 0x6a
|
||||||
|
IFT_ATMIMA = 0x6b
|
||||||
|
IFT_ATMLOGICAL = 0x50
|
||||||
|
IFT_ATMRADIO = 0xbd
|
||||||
|
IFT_ATMSUBINTERFACE = 0x86
|
||||||
|
IFT_ATMVCIENDPT = 0xc2
|
||||||
|
IFT_ATMVIRTUAL = 0x95
|
||||||
|
IFT_BGPPOLICYACCOUNTING = 0xa2
|
||||||
|
IFT_BSC = 0x53
|
||||||
|
IFT_CCTEMUL = 0x3d
|
||||||
|
IFT_CEPT = 0x13
|
||||||
|
IFT_CES = 0x85
|
||||||
|
IFT_CHANNEL = 0x46
|
||||||
|
IFT_CNR = 0x55
|
||||||
|
IFT_COFFEE = 0x84
|
||||||
|
IFT_COMPOSITELINK = 0x9b
|
||||||
|
IFT_DCN = 0x8d
|
||||||
|
IFT_DIGITALPOWERLINE = 0x8a
|
||||||
|
IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
|
||||||
|
IFT_DLSW = 0x4a
|
||||||
|
IFT_DOCSCABLEDOWNSTREAM = 0x80
|
||||||
|
IFT_DOCSCABLEMACLAYER = 0x7f
|
||||||
|
IFT_DOCSCABLEUPSTREAM = 0x81
|
||||||
|
IFT_DS0 = 0x51
|
||||||
|
IFT_DS0BUNDLE = 0x52
|
||||||
|
IFT_DS1FDL = 0xaa
|
||||||
|
IFT_DS3 = 0x1e
|
||||||
|
IFT_DTM = 0x8c
|
||||||
|
IFT_DVBASILN = 0xac
|
||||||
|
IFT_DVBASIOUT = 0xad
|
||||||
|
IFT_DVBRCCDOWNSTREAM = 0x93
|
||||||
|
IFT_DVBRCCMACLAYER = 0x92
|
||||||
|
IFT_DVBRCCUPSTREAM = 0x94
|
||||||
|
IFT_ENC = 0xf4
|
||||||
|
IFT_EON = 0x19
|
||||||
|
IFT_EPLRS = 0x57
|
||||||
|
IFT_ESCON = 0x49
|
||||||
|
IFT_ETHER = 0x6
|
||||||
|
IFT_FAST = 0x7d
|
||||||
|
IFT_FASTETHER = 0x3e
|
||||||
|
IFT_FASTETHERFX = 0x45
|
||||||
|
IFT_FDDI = 0xf
|
||||||
|
IFT_FIBRECHANNEL = 0x38
|
||||||
|
IFT_FRAMERELAYINTERCONNECT = 0x3a
|
||||||
|
IFT_FRAMERELAYMPI = 0x5c
|
||||||
|
IFT_FRDLCIENDPT = 0xc1
|
||||||
|
IFT_FRELAY = 0x20
|
||||||
|
IFT_FRELAYDCE = 0x2c
|
||||||
|
IFT_FRF16MFRBUNDLE = 0xa3
|
||||||
|
IFT_FRFORWARD = 0x9e
|
||||||
|
IFT_G703AT2MB = 0x43
|
||||||
|
IFT_G703AT64K = 0x42
|
||||||
|
IFT_GIF = 0xf0
|
||||||
|
IFT_GIGABITETHERNET = 0x75
|
||||||
|
IFT_GR303IDT = 0xb2
|
||||||
|
IFT_GR303RDT = 0xb1
|
||||||
|
IFT_H323GATEKEEPER = 0xa4
|
||||||
|
IFT_H323PROXY = 0xa5
|
||||||
|
IFT_HDH1822 = 0x3
|
||||||
|
IFT_HDLC = 0x76
|
||||||
|
IFT_HDSL2 = 0xa8
|
||||||
|
IFT_HIPERLAN2 = 0xb7
|
||||||
|
IFT_HIPPI = 0x2f
|
||||||
|
IFT_HIPPIINTERFACE = 0x39
|
||||||
|
IFT_HOSTPAD = 0x5a
|
||||||
|
IFT_HSSI = 0x2e
|
||||||
|
IFT_HY = 0xe
|
||||||
|
IFT_IBM370PARCHAN = 0x48
|
||||||
|
IFT_IDSL = 0x9a
|
||||||
|
IFT_IEEE80211 = 0x47
|
||||||
|
IFT_IEEE80212 = 0x37
|
||||||
|
IFT_IEEE8023ADLAG = 0xa1
|
||||||
|
IFT_IFGSN = 0x91
|
||||||
|
IFT_IMT = 0xbe
|
||||||
|
IFT_INTERLEAVE = 0x7c
|
||||||
|
IFT_IP = 0x7e
|
||||||
|
IFT_IPFORWARD = 0x8e
|
||||||
|
IFT_IPOVERATM = 0x72
|
||||||
|
IFT_IPOVERCDLC = 0x6d
|
||||||
|
IFT_IPOVERCLAW = 0x6e
|
||||||
|
IFT_IPSWITCH = 0x4e
|
||||||
|
IFT_ISDN = 0x3f
|
||||||
|
IFT_ISDNBASIC = 0x14
|
||||||
|
IFT_ISDNPRIMARY = 0x15
|
||||||
|
IFT_ISDNS = 0x4b
|
||||||
|
IFT_ISDNU = 0x4c
|
||||||
|
IFT_ISO88022LLC = 0x29
|
||||||
|
IFT_ISO88023 = 0x7
|
||||||
|
IFT_ISO88024 = 0x8
|
||||||
|
IFT_ISO88025 = 0x9
|
||||||
|
IFT_ISO88025CRFPINT = 0x62
|
||||||
|
IFT_ISO88025DTR = 0x56
|
||||||
|
IFT_ISO88025FIBER = 0x73
|
||||||
|
IFT_ISO88026 = 0xa
|
||||||
|
IFT_ISUP = 0xb3
|
||||||
|
IFT_L3IPXVLAN = 0x89
|
||||||
|
IFT_LAPB = 0x10
|
||||||
|
IFT_LAPD = 0x4d
|
||||||
|
IFT_LAPF = 0x77
|
||||||
|
IFT_LOCALTALK = 0x2a
|
||||||
|
IFT_LOOP = 0x18
|
||||||
|
IFT_MEDIAMAILOVERIP = 0x8b
|
||||||
|
IFT_MFSIGLINK = 0xa7
|
||||||
|
IFT_MIOX25 = 0x26
|
||||||
|
IFT_MODEM = 0x30
|
||||||
|
IFT_MPC = 0x71
|
||||||
|
IFT_MPLS = 0xa6
|
||||||
|
IFT_MPLSTUNNEL = 0x96
|
||||||
|
IFT_MSDSL = 0x8f
|
||||||
|
IFT_MVL = 0xbf
|
||||||
|
IFT_MYRINET = 0x63
|
||||||
|
IFT_NFAS = 0xaf
|
||||||
|
IFT_NSIP = 0x1b
|
||||||
|
IFT_OPTICALCHANNEL = 0xc3
|
||||||
|
IFT_OPTICALTRANSPORT = 0xc4
|
||||||
|
IFT_OTHER = 0x1
|
||||||
|
IFT_P10 = 0xc
|
||||||
|
IFT_P80 = 0xd
|
||||||
|
IFT_PARA = 0x22
|
||||||
|
IFT_PFLOG = 0xf6
|
||||||
|
IFT_PFSYNC = 0xf7
|
||||||
|
IFT_PLC = 0xae
|
||||||
|
IFT_POS = 0xab
|
||||||
|
IFT_PPPMULTILINKBUNDLE = 0x6c
|
||||||
|
IFT_PROPBWAP2MP = 0xb8
|
||||||
|
IFT_PROPCNLS = 0x59
|
||||||
|
IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
|
||||||
|
IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
|
||||||
|
IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
|
||||||
|
IFT_PROPMUX = 0x36
|
||||||
|
IFT_PROPWIRELESSP2P = 0x9d
|
||||||
|
IFT_PTPSERIAL = 0x16
|
||||||
|
IFT_PVC = 0xf1
|
||||||
|
IFT_QLLC = 0x44
|
||||||
|
IFT_RADIOMAC = 0xbc
|
||||||
|
IFT_RADSL = 0x5f
|
||||||
|
IFT_REACHDSL = 0xc0
|
||||||
|
IFT_RFC1483 = 0x9f
|
||||||
|
IFT_RS232 = 0x21
|
||||||
|
IFT_RSRB = 0x4f
|
||||||
|
IFT_SDLC = 0x11
|
||||||
|
IFT_SDSL = 0x60
|
||||||
|
IFT_SHDSL = 0xa9
|
||||||
|
IFT_SIP = 0x1f
|
||||||
|
IFT_SLIP = 0x1c
|
||||||
|
IFT_SMDSDXI = 0x2b
|
||||||
|
IFT_SMDSICIP = 0x34
|
||||||
|
IFT_SONET = 0x27
|
||||||
|
IFT_SONETOVERHEADCHANNEL = 0xb9
|
||||||
|
IFT_SONETPATH = 0x32
|
||||||
|
IFT_SONETVT = 0x33
|
||||||
|
IFT_SRP = 0x97
|
||||||
|
IFT_SS7SIGLINK = 0x9c
|
||||||
|
IFT_STACKTOSTACK = 0x6f
|
||||||
|
IFT_STARLAN = 0xb
|
||||||
|
IFT_STF = 0xd7
|
||||||
|
IFT_T1 = 0x12
|
||||||
|
IFT_TDLC = 0x74
|
||||||
|
IFT_TERMPAD = 0x5b
|
||||||
|
IFT_TR008 = 0xb0
|
||||||
|
IFT_TRANSPHDLC = 0x7b
|
||||||
|
IFT_TUNNEL = 0x83
|
||||||
|
IFT_ULTRA = 0x1d
|
||||||
|
IFT_USB = 0xa0
|
||||||
|
IFT_V11 = 0x40
|
||||||
|
IFT_V35 = 0x2d
|
||||||
|
IFT_V36 = 0x41
|
||||||
|
IFT_V37 = 0x78
|
||||||
|
IFT_VDSL = 0x61
|
||||||
|
IFT_VIRTUALIPADDRESS = 0x70
|
||||||
|
IFT_VOICEEM = 0x64
|
||||||
|
IFT_VOICEENCAP = 0x67
|
||||||
|
IFT_VOICEFXO = 0x65
|
||||||
|
IFT_VOICEFXS = 0x66
|
||||||
|
IFT_VOICEOVERATM = 0x98
|
||||||
|
IFT_VOICEOVERFRAMERELAY = 0x99
|
||||||
|
IFT_VOICEOVERIP = 0x68
|
||||||
|
IFT_X213 = 0x5d
|
||||||
|
IFT_X25 = 0x5
|
||||||
|
IFT_X25DDN = 0x4
|
||||||
|
IFT_X25HUNTGROUP = 0x7a
|
||||||
|
IFT_X25MLP = 0x79
|
||||||
|
IFT_X25PLE = 0x28
|
||||||
|
IFT_XETHER = 0x1a
|
||||||
|
|
||||||
|
// missing constants on FreeBSD-11.1-RELEASE, copied from old values in ztypes_freebsd_arm.go
|
||||||
|
IFF_SMART = 0x20
|
||||||
|
IFT_FAITH = 0xf2
|
||||||
|
IFT_IPXIP = 0xf9
|
||||||
|
IPPROTO_MAXID = 0x34
|
||||||
|
IPV6_FAITH = 0x1d
|
||||||
|
IP_FAITH = 0x16
|
||||||
|
MAP_NORESERVE = 0x40
|
||||||
|
MAP_RENAME = 0x20
|
||||||
|
NET_RT_MAXID = 0x6
|
||||||
|
RTF_PRCLONING = 0x10000
|
||||||
|
RTM_OLDADD = 0x9
|
||||||
|
RTM_OLDDEL = 0xa
|
||||||
|
SIOCADDRT = 0x8030720a
|
||||||
|
SIOCALIFADDR = 0x8118691b
|
||||||
|
SIOCDELRT = 0x8030720b
|
||||||
|
SIOCDLIFADDR = 0x8118691d
|
||||||
|
SIOCGLIFADDR = 0xc118691c
|
||||||
|
SIOCGLIFPHYADDR = 0xc118694b
|
||||||
|
SIOCSLIFPHYADDR = 0x8118694a
|
||||||
|
)
|
||||||
32
vendor/golang.org/x/sys/unix/fcntl.go
generated
vendored
Normal file
32
vendor/golang.org/x/sys/unix/fcntl.go
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build dragonfly freebsd linux netbsd openbsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
|
||||||
|
// systems by flock_linux_32bit.go to be SYS_FCNTL64.
|
||||||
|
var fcntl64Syscall uintptr = SYS_FCNTL
|
||||||
|
|
||||||
|
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
|
||||||
|
func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
|
||||||
|
valptr, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg))
|
||||||
|
var err error
|
||||||
|
if errno != 0 {
|
||||||
|
err = errno
|
||||||
|
}
|
||||||
|
return int(valptr), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
||||||
|
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
||||||
|
_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
|
||||||
|
if errno == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return errno
|
||||||
|
}
|
||||||
18
vendor/golang.org/x/sys/unix/fcntl_darwin.go
generated
vendored
Normal file
18
vendor/golang.org/x/sys/unix/fcntl_darwin.go
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
|
||||||
|
func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
|
||||||
|
return fcntl(int(fd), cmd, arg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
||||||
|
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
||||||
|
_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk))))
|
||||||
|
return err
|
||||||
|
}
|
||||||
13
vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
generated
vendored
Normal file
13
vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
// +build linux,386 linux,arm linux,mips linux,mipsle
|
||||||
|
|
||||||
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// On 32-bit Linux systems, the fcntl syscall that matches Go's
|
||||||
|
// Flock_t type is SYS_FCNTL64, not SYS_FCNTL.
|
||||||
|
fcntl64Syscall = SYS_FCNTL64
|
||||||
|
}
|
||||||
62
vendor/golang.org/x/sys/unix/gccgo.go
generated
vendored
Normal file
62
vendor/golang.org/x/sys/unix/gccgo.go
generated
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build gccgo
|
||||||
|
// +build !aix
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
// We can't use the gc-syntax .s files for gccgo. On the plus side
|
||||||
|
// much of the functionality can be written directly in Go.
|
||||||
|
|
||||||
|
//extern gccgoRealSyscallNoError
|
||||||
|
func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr)
|
||||||
|
|
||||||
|
//extern gccgoRealSyscall
|
||||||
|
func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
|
||||||
|
|
||||||
|
func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
|
||||||
|
syscall.Entersyscall()
|
||||||
|
r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
|
||||||
|
syscall.Exitsyscall()
|
||||||
|
return r, 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||||
|
syscall.Entersyscall()
|
||||||
|
r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
|
||||||
|
syscall.Exitsyscall()
|
||||||
|
return r, 0, syscall.Errno(errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||||
|
syscall.Entersyscall()
|
||||||
|
r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
|
||||||
|
syscall.Exitsyscall()
|
||||||
|
return r, 0, syscall.Errno(errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||||
|
syscall.Entersyscall()
|
||||||
|
r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
|
||||||
|
syscall.Exitsyscall()
|
||||||
|
return r, 0, syscall.Errno(errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
|
||||||
|
r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
|
||||||
|
return r, 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||||
|
r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
|
||||||
|
return r, 0, syscall.Errno(errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
|
||||||
|
r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
|
||||||
|
return r, 0, syscall.Errno(errno)
|
||||||
|
}
|
||||||
39
vendor/golang.org/x/sys/unix/gccgo_c.c
generated
vendored
Normal file
39
vendor/golang.org/x/sys/unix/gccgo_c.c
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build gccgo
|
||||||
|
// +build !aix
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define _STRINGIFY2_(x) #x
|
||||||
|
#define _STRINGIFY_(x) _STRINGIFY2_(x)
|
||||||
|
#define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
|
||||||
|
|
||||||
|
// Call syscall from C code because the gccgo support for calling from
|
||||||
|
// Go to C does not support varargs functions.
|
||||||
|
|
||||||
|
struct ret {
|
||||||
|
uintptr_t r;
|
||||||
|
uintptr_t err;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ret
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
struct ret r;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||||
|
r.err = errno;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
uintptr_t
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||||
|
}
|
||||||
20
vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
generated
vendored
Normal file
20
vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build gccgo,linux,amd64
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
//extern gettimeofday
|
||||||
|
func realGettimeofday(*Timeval, *byte) int32
|
||||||
|
|
||||||
|
func gettimeofday(tv *Timeval) (err syscall.Errno) {
|
||||||
|
r := realGettimeofday(tv, nil)
|
||||||
|
if r < 0 {
|
||||||
|
return syscall.GetErrno()
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
30
vendor/golang.org/x/sys/unix/ioctl.go
generated
vendored
Normal file
30
vendor/golang.org/x/sys/unix/ioctl.go
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "runtime"
|
||||||
|
|
||||||
|
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
|
||||||
|
//
|
||||||
|
// To change fd's window size, the req argument should be TIOCSWINSZ.
|
||||||
|
func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
||||||
|
// TODO: if we get the chance, remove the req parameter and
|
||||||
|
// hardcode TIOCSWINSZ.
|
||||||
|
err := ioctlSetWinsize(fd, req, value)
|
||||||
|
runtime.KeepAlive(value)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlSetTermios performs an ioctl on fd with a *Termios.
|
||||||
|
//
|
||||||
|
// The req value will usually be TCSETA or TIOCSETA.
|
||||||
|
func IoctlSetTermios(fd int, req uint, value *Termios) error {
|
||||||
|
// TODO: if we get the chance, remove the req parameter.
|
||||||
|
err := ioctlSetTermios(fd, req, value)
|
||||||
|
runtime.KeepAlive(value)
|
||||||
|
return err
|
||||||
|
}
|
||||||
61
vendor/golang.org/x/sys/unix/mkasm_darwin.go
generated
vendored
Normal file
61
vendor/golang.org/x/sys/unix/mkasm_darwin.go
generated
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
// mkasm_darwin.go generates assembly trampolines to call libSystem routines from Go.
|
||||||
|
//This program must be run after mksyscall.go.
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
in1, err := ioutil.ReadFile("syscall_darwin.go")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("can't open syscall_darwin.go: %s", err)
|
||||||
|
}
|
||||||
|
arch := os.Args[1]
|
||||||
|
in2, err := ioutil.ReadFile(fmt.Sprintf("syscall_darwin_%s.go", arch))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("can't open syscall_darwin_%s.go: %s", arch, err)
|
||||||
|
}
|
||||||
|
in3, err := ioutil.ReadFile(fmt.Sprintf("zsyscall_darwin_%s.go", arch))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("can't open zsyscall_darwin_%s.go: %s", arch, err)
|
||||||
|
}
|
||||||
|
in := string(in1) + string(in2) + string(in3)
|
||||||
|
|
||||||
|
trampolines := map[string]bool{}
|
||||||
|
|
||||||
|
var out bytes.Buffer
|
||||||
|
|
||||||
|
fmt.Fprintf(&out, "// go run mkasm_darwin.go %s\n", strings.Join(os.Args[1:], " "))
|
||||||
|
fmt.Fprintf(&out, "// Code generated by the command above; DO NOT EDIT.\n")
|
||||||
|
fmt.Fprintf(&out, "\n")
|
||||||
|
fmt.Fprintf(&out, "// +build go1.12\n")
|
||||||
|
fmt.Fprintf(&out, "\n")
|
||||||
|
fmt.Fprintf(&out, "#include \"textflag.h\"\n")
|
||||||
|
for _, line := range strings.Split(in, "\n") {
|
||||||
|
if !strings.HasPrefix(line, "func ") || !strings.HasSuffix(line, "_trampoline()") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fn := line[5 : len(line)-13]
|
||||||
|
if !trampolines[fn] {
|
||||||
|
trampolines[fn] = true
|
||||||
|
fmt.Fprintf(&out, "TEXT ·%s_trampoline(SB),NOSPLIT,$0-0\n", fn)
|
||||||
|
fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = ioutil.WriteFile(fmt.Sprintf("zsyscall_darwin_%s.s", arch), out.Bytes(), 0644)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("can't write zsyscall_darwin_%s.s: %s", arch, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
106
vendor/golang.org/x/sys/unix/mkpost.go
generated
vendored
Normal file
106
vendor/golang.org/x/sys/unix/mkpost.go
generated
vendored
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
// mkpost processes the output of cgo -godefs to
|
||||||
|
// modify the generated types. It is used to clean up
|
||||||
|
// the sys API in an architecture specific manner.
|
||||||
|
//
|
||||||
|
// mkpost is run after cgo -godefs; see README.md.
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"go/format"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"regexp"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Get the OS and architecture (using GOARCH_TARGET if it exists)
|
||||||
|
goos := os.Getenv("GOOS")
|
||||||
|
goarch := os.Getenv("GOARCH_TARGET")
|
||||||
|
if goarch == "" {
|
||||||
|
goarch = os.Getenv("GOARCH")
|
||||||
|
}
|
||||||
|
// Check that we are using the Docker-based build system if we should be.
|
||||||
|
if goos == "linux" {
|
||||||
|
if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
|
||||||
|
os.Stderr.WriteString("In the Docker-based build system, mkpost should not be called directly.\n")
|
||||||
|
os.Stderr.WriteString("See README.md\n")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := ioutil.ReadAll(os.Stdin)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intentionally export __val fields in Fsid and Sigset_t
|
||||||
|
valRegex := regexp.MustCompile(`type (Fsid|Sigset_t) struct {(\s+)X__val(\s+\S+\s+)}`)
|
||||||
|
b = valRegex.ReplaceAll(b, []byte("type $1 struct {${2}Val$3}"))
|
||||||
|
|
||||||
|
// Intentionally export __fds_bits field in FdSet
|
||||||
|
fdSetRegex := regexp.MustCompile(`type (FdSet) struct {(\s+)X__fds_bits(\s+\S+\s+)}`)
|
||||||
|
b = fdSetRegex.ReplaceAll(b, []byte("type $1 struct {${2}Bits$3}"))
|
||||||
|
|
||||||
|
// If we have empty Ptrace structs, we should delete them. Only s390x emits
|
||||||
|
// nonempty Ptrace structs.
|
||||||
|
ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`)
|
||||||
|
b = ptraceRexexp.ReplaceAll(b, nil)
|
||||||
|
|
||||||
|
// Replace the control_regs union with a blank identifier for now.
|
||||||
|
controlRegsRegex := regexp.MustCompile(`(Control_regs)\s+\[0\]uint64`)
|
||||||
|
b = controlRegsRegex.ReplaceAll(b, []byte("_ [0]uint64"))
|
||||||
|
|
||||||
|
// Remove fields that are added by glibc
|
||||||
|
// Note that this is unstable as the identifers are private.
|
||||||
|
removeFieldsRegex := regexp.MustCompile(`X__glibc\S*`)
|
||||||
|
b = removeFieldsRegex.ReplaceAll(b, []byte("_"))
|
||||||
|
|
||||||
|
// Convert [65]int8 to [65]byte in Utsname members to simplify
|
||||||
|
// conversion to string; see golang.org/issue/20753
|
||||||
|
convertUtsnameRegex := regexp.MustCompile(`((Sys|Node|Domain)name|Release|Version|Machine)(\s+)\[(\d+)\]u?int8`)
|
||||||
|
b = convertUtsnameRegex.ReplaceAll(b, []byte("$1$3[$4]byte"))
|
||||||
|
|
||||||
|
// Convert [1024]int8 to [1024]byte in Ptmget members
|
||||||
|
convertPtmget := regexp.MustCompile(`([SC]n)(\s+)\[(\d+)\]u?int8`)
|
||||||
|
b = convertPtmget.ReplaceAll(b, []byte("$1[$3]byte"))
|
||||||
|
|
||||||
|
// Remove spare fields (e.g. in Statx_t)
|
||||||
|
spareFieldsRegex := regexp.MustCompile(`X__spare\S*`)
|
||||||
|
b = spareFieldsRegex.ReplaceAll(b, []byte("_"))
|
||||||
|
|
||||||
|
// Remove cgo padding fields
|
||||||
|
removePaddingFieldsRegex := regexp.MustCompile(`Pad_cgo_\d+`)
|
||||||
|
b = removePaddingFieldsRegex.ReplaceAll(b, []byte("_"))
|
||||||
|
|
||||||
|
// Remove padding, hidden, or unused fields
|
||||||
|
removeFieldsRegex = regexp.MustCompile(`\b(X_\S+|Padding)`)
|
||||||
|
b = removeFieldsRegex.ReplaceAll(b, []byte("_"))
|
||||||
|
|
||||||
|
// Remove the first line of warning from cgo
|
||||||
|
b = b[bytes.IndexByte(b, '\n')+1:]
|
||||||
|
// Modify the command in the header to include:
|
||||||
|
// mkpost, our own warning, and a build tag.
|
||||||
|
replacement := fmt.Sprintf(`$1 | go run mkpost.go
|
||||||
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
|
// +build %s,%s`, goarch, goos)
|
||||||
|
cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`)
|
||||||
|
b = cgoCommandRegex.ReplaceAll(b, []byte(replacement))
|
||||||
|
|
||||||
|
// gofmt
|
||||||
|
b, err = format.Source(b)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
os.Stdout.Write(b)
|
||||||
|
}
|
||||||
402
vendor/golang.org/x/sys/unix/mksyscall.go
generated
vendored
Normal file
402
vendor/golang.org/x/sys/unix/mksyscall.go
generated
vendored
Normal file
|
|
@ -0,0 +1,402 @@
|
||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
/*
|
||||||
|
This program reads a file containing function prototypes
|
||||||
|
(like syscall_darwin.go) and generates system call bodies.
|
||||||
|
The prototypes are marked by lines beginning with "//sys"
|
||||||
|
and read like func declarations if //sys is replaced by func, but:
|
||||||
|
* The parameter lists must give a name for each argument.
|
||||||
|
This includes return parameters.
|
||||||
|
* The parameter lists must give a type for each argument:
|
||||||
|
the (x, y, z int) shorthand is not allowed.
|
||||||
|
* If the return parameter is an error number, it must be named errno.
|
||||||
|
|
||||||
|
A line beginning with //sysnb is like //sys, except that the
|
||||||
|
goroutine will not be suspended during the execution of the system
|
||||||
|
call. This must only be used for system calls which can never
|
||||||
|
block, as otherwise the system call could cause all goroutines to
|
||||||
|
hang.
|
||||||
|
*/
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
b32 = flag.Bool("b32", false, "32bit big-endian")
|
||||||
|
l32 = flag.Bool("l32", false, "32bit little-endian")
|
||||||
|
plan9 = flag.Bool("plan9", false, "plan9")
|
||||||
|
openbsd = flag.Bool("openbsd", false, "openbsd")
|
||||||
|
netbsd = flag.Bool("netbsd", false, "netbsd")
|
||||||
|
dragonfly = flag.Bool("dragonfly", false, "dragonfly")
|
||||||
|
arm = flag.Bool("arm", false, "arm") // 64-bit value should use (even, odd)-pair
|
||||||
|
tags = flag.String("tags", "", "build tags")
|
||||||
|
filename = flag.String("output", "", "output file name (standard output if omitted)")
|
||||||
|
)
|
||||||
|
|
||||||
|
// cmdLine returns this programs's commandline arguments
|
||||||
|
func cmdLine() string {
|
||||||
|
return "go run mksyscall.go " + strings.Join(os.Args[1:], " ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// buildTags returns build tags
|
||||||
|
func buildTags() string {
|
||||||
|
return *tags
|
||||||
|
}
|
||||||
|
|
||||||
|
// Param is function parameter
|
||||||
|
type Param struct {
|
||||||
|
Name string
|
||||||
|
Type string
|
||||||
|
}
|
||||||
|
|
||||||
|
// usage prints the program usage
|
||||||
|
func usage() {
|
||||||
|
fmt.Fprintf(os.Stderr, "usage: go run mksyscall.go [-b32 | -l32] [-tags x,y] [file ...]\n")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseParamList parses parameter list and returns a slice of parameters
|
||||||
|
func parseParamList(list string) []string {
|
||||||
|
list = strings.TrimSpace(list)
|
||||||
|
if list == "" {
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
return regexp.MustCompile(`\s*,\s*`).Split(list, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseParam splits a parameter into name and type
|
||||||
|
func parseParam(p string) Param {
|
||||||
|
ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p)
|
||||||
|
if ps == nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
return Param{ps[1], ps[2]}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Get the OS and architecture (using GOARCH_TARGET if it exists)
|
||||||
|
goos := os.Getenv("GOOS")
|
||||||
|
if goos == "" {
|
||||||
|
fmt.Fprintln(os.Stderr, "GOOS not defined in environment")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
goarch := os.Getenv("GOARCH_TARGET")
|
||||||
|
if goarch == "" {
|
||||||
|
goarch = os.Getenv("GOARCH")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that we are using the Docker-based build system if we should
|
||||||
|
if goos == "linux" {
|
||||||
|
if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
|
||||||
|
fmt.Fprintf(os.Stderr, "In the Docker-based build system, mksyscall should not be called directly.\n")
|
||||||
|
fmt.Fprintf(os.Stderr, "See README.md\n")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flag.Usage = usage
|
||||||
|
flag.Parse()
|
||||||
|
if len(flag.Args()) <= 0 {
|
||||||
|
fmt.Fprintf(os.Stderr, "no files to parse provided\n")
|
||||||
|
usage()
|
||||||
|
}
|
||||||
|
|
||||||
|
endianness := ""
|
||||||
|
if *b32 {
|
||||||
|
endianness = "big-endian"
|
||||||
|
} else if *l32 {
|
||||||
|
endianness = "little-endian"
|
||||||
|
}
|
||||||
|
|
||||||
|
libc := false
|
||||||
|
if goos == "darwin" && strings.Contains(buildTags(), ",go1.12") {
|
||||||
|
libc = true
|
||||||
|
}
|
||||||
|
trampolines := map[string]bool{}
|
||||||
|
|
||||||
|
text := ""
|
||||||
|
for _, path := range flag.Args() {
|
||||||
|
file, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
s := bufio.NewScanner(file)
|
||||||
|
for s.Scan() {
|
||||||
|
t := s.Text()
|
||||||
|
t = strings.TrimSpace(t)
|
||||||
|
t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `)
|
||||||
|
nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t)
|
||||||
|
if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Line must be of the form
|
||||||
|
// func Open(path string, mode int, perm int) (fd int, errno error)
|
||||||
|
// Split into name, in params, out params.
|
||||||
|
f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$`).FindStringSubmatch(t)
|
||||||
|
if f == nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
funct, inps, outps, sysname := f[2], f[3], f[4], f[5]
|
||||||
|
|
||||||
|
// Split argument lists on comma.
|
||||||
|
in := parseParamList(inps)
|
||||||
|
out := parseParamList(outps)
|
||||||
|
|
||||||
|
// Try in vain to keep people from editing this file.
|
||||||
|
// The theory is that they jump into the middle of the file
|
||||||
|
// without reading the header.
|
||||||
|
text += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"
|
||||||
|
|
||||||
|
// Go function header.
|
||||||
|
outDecl := ""
|
||||||
|
if len(out) > 0 {
|
||||||
|
outDecl = fmt.Sprintf(" (%s)", strings.Join(out, ", "))
|
||||||
|
}
|
||||||
|
text += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outDecl)
|
||||||
|
|
||||||
|
// Check if err return available
|
||||||
|
errvar := ""
|
||||||
|
for _, param := range out {
|
||||||
|
p := parseParam(param)
|
||||||
|
if p.Type == "error" {
|
||||||
|
errvar = p.Name
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare arguments to Syscall.
|
||||||
|
var args []string
|
||||||
|
n := 0
|
||||||
|
for _, param := range in {
|
||||||
|
p := parseParam(param)
|
||||||
|
if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil {
|
||||||
|
args = append(args, "uintptr(unsafe.Pointer("+p.Name+"))")
|
||||||
|
} else if p.Type == "string" && errvar != "" {
|
||||||
|
text += fmt.Sprintf("\tvar _p%d *byte\n", n)
|
||||||
|
text += fmt.Sprintf("\t_p%d, %s = BytePtrFromString(%s)\n", n, errvar, p.Name)
|
||||||
|
text += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar)
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n))
|
||||||
|
n++
|
||||||
|
} else if p.Type == "string" {
|
||||||
|
fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n")
|
||||||
|
text += fmt.Sprintf("\tvar _p%d *byte\n", n)
|
||||||
|
text += fmt.Sprintf("\t_p%d, _ = BytePtrFromString(%s)\n", n, p.Name)
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n))
|
||||||
|
n++
|
||||||
|
} else if regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type) != nil {
|
||||||
|
// Convert slice into pointer, length.
|
||||||
|
// Have to be careful not to take address of &a[0] if len == 0:
|
||||||
|
// pass dummy pointer in that case.
|
||||||
|
// Used to pass nil, but some OSes or simulators reject write(fd, nil, 0).
|
||||||
|
text += fmt.Sprintf("\tvar _p%d unsafe.Pointer\n", n)
|
||||||
|
text += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = unsafe.Pointer(&%s[0])\n\t}", p.Name, n, p.Name)
|
||||||
|
text += fmt.Sprintf(" else {\n\t\t_p%d = unsafe.Pointer(&_zero)\n\t}\n", n)
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(_p%d)", n), fmt.Sprintf("uintptr(len(%s))", p.Name))
|
||||||
|
n++
|
||||||
|
} else if p.Type == "int64" && (*openbsd || *netbsd) {
|
||||||
|
args = append(args, "0")
|
||||||
|
if endianness == "big-endian" {
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
} else if endianness == "little-endian" {
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
|
||||||
|
} else {
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
}
|
||||||
|
} else if p.Type == "int64" && *dragonfly {
|
||||||
|
if regexp.MustCompile(`^(?i)extp(read|write)`).FindStringSubmatch(funct) == nil {
|
||||||
|
args = append(args, "0")
|
||||||
|
}
|
||||||
|
if endianness == "big-endian" {
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
} else if endianness == "little-endian" {
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
|
||||||
|
} else {
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
}
|
||||||
|
} else if (p.Type == "int64" || p.Type == "uint64") && endianness != "" {
|
||||||
|
if len(args)%2 == 1 && *arm {
|
||||||
|
// arm abi specifies 64-bit argument uses
|
||||||
|
// (even, odd) pair
|
||||||
|
args = append(args, "0")
|
||||||
|
}
|
||||||
|
if endianness == "big-endian" {
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
} else {
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine which form to use; pad args with zeros.
|
||||||
|
asm := "Syscall"
|
||||||
|
if nonblock != nil {
|
||||||
|
if errvar == "" && goos == "linux" {
|
||||||
|
asm = "RawSyscallNoError"
|
||||||
|
} else {
|
||||||
|
asm = "RawSyscall"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if errvar == "" && goos == "linux" {
|
||||||
|
asm = "SyscallNoError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) <= 3 {
|
||||||
|
for len(args) < 3 {
|
||||||
|
args = append(args, "0")
|
||||||
|
}
|
||||||
|
} else if len(args) <= 6 {
|
||||||
|
asm += "6"
|
||||||
|
for len(args) < 6 {
|
||||||
|
args = append(args, "0")
|
||||||
|
}
|
||||||
|
} else if len(args) <= 9 {
|
||||||
|
asm += "9"
|
||||||
|
for len(args) < 9 {
|
||||||
|
args = append(args, "0")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s:%s too many arguments to system call\n", path, funct)
|
||||||
|
}
|
||||||
|
|
||||||
|
// System call number.
|
||||||
|
if sysname == "" {
|
||||||
|
sysname = "SYS_" + funct
|
||||||
|
sysname = regexp.MustCompile(`([a-z])([A-Z])`).ReplaceAllString(sysname, `${1}_$2`)
|
||||||
|
sysname = strings.ToUpper(sysname)
|
||||||
|
}
|
||||||
|
|
||||||
|
var libcFn string
|
||||||
|
if libc {
|
||||||
|
asm = "syscall_" + strings.ToLower(asm[:1]) + asm[1:] // internal syscall call
|
||||||
|
sysname = strings.TrimPrefix(sysname, "SYS_") // remove SYS_
|
||||||
|
sysname = strings.ToLower(sysname) // lowercase
|
||||||
|
if sysname == "getdirentries64" {
|
||||||
|
// Special case - libSystem name and
|
||||||
|
// raw syscall name don't match.
|
||||||
|
sysname = "__getdirentries64"
|
||||||
|
}
|
||||||
|
libcFn = sysname
|
||||||
|
sysname = "funcPC(libc_" + sysname + "_trampoline)"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actual call.
|
||||||
|
arglist := strings.Join(args, ", ")
|
||||||
|
call := fmt.Sprintf("%s(%s, %s)", asm, sysname, arglist)
|
||||||
|
|
||||||
|
// Assign return values.
|
||||||
|
body := ""
|
||||||
|
ret := []string{"_", "_", "_"}
|
||||||
|
doErrno := false
|
||||||
|
for i := 0; i < len(out); i++ {
|
||||||
|
p := parseParam(out[i])
|
||||||
|
reg := ""
|
||||||
|
if p.Name == "err" && !*plan9 {
|
||||||
|
reg = "e1"
|
||||||
|
ret[2] = reg
|
||||||
|
doErrno = true
|
||||||
|
} else if p.Name == "err" && *plan9 {
|
||||||
|
ret[0] = "r0"
|
||||||
|
ret[2] = "e1"
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
reg = fmt.Sprintf("r%d", i)
|
||||||
|
ret[i] = reg
|
||||||
|
}
|
||||||
|
if p.Type == "bool" {
|
||||||
|
reg = fmt.Sprintf("%s != 0", reg)
|
||||||
|
}
|
||||||
|
if p.Type == "int64" && endianness != "" {
|
||||||
|
// 64-bit number in r1:r0 or r0:r1.
|
||||||
|
if i+2 > len(out) {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s:%s not enough registers for int64 return\n", path, funct)
|
||||||
|
}
|
||||||
|
if endianness == "big-endian" {
|
||||||
|
reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i, i+1)
|
||||||
|
} else {
|
||||||
|
reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i+1, i)
|
||||||
|
}
|
||||||
|
ret[i] = fmt.Sprintf("r%d", i)
|
||||||
|
ret[i+1] = fmt.Sprintf("r%d", i+1)
|
||||||
|
}
|
||||||
|
if reg != "e1" || *plan9 {
|
||||||
|
body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ret[0] == "_" && ret[1] == "_" && ret[2] == "_" {
|
||||||
|
text += fmt.Sprintf("\t%s\n", call)
|
||||||
|
} else {
|
||||||
|
if errvar == "" && goos == "linux" {
|
||||||
|
// raw syscall without error on Linux, see golang.org/issue/22924
|
||||||
|
text += fmt.Sprintf("\t%s, %s := %s\n", ret[0], ret[1], call)
|
||||||
|
} else {
|
||||||
|
text += fmt.Sprintf("\t%s, %s, %s := %s\n", ret[0], ret[1], ret[2], call)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text += body
|
||||||
|
|
||||||
|
if *plan9 && ret[2] == "e1" {
|
||||||
|
text += "\tif int32(r0) == -1 {\n"
|
||||||
|
text += "\t\terr = e1\n"
|
||||||
|
text += "\t}\n"
|
||||||
|
} else if doErrno {
|
||||||
|
text += "\tif e1 != 0 {\n"
|
||||||
|
text += "\t\terr = errnoErr(e1)\n"
|
||||||
|
text += "\t}\n"
|
||||||
|
}
|
||||||
|
text += "\treturn\n"
|
||||||
|
text += "}\n\n"
|
||||||
|
|
||||||
|
if libc && !trampolines[libcFn] {
|
||||||
|
// some system calls share a trampoline, like read and readlen.
|
||||||
|
trampolines[libcFn] = true
|
||||||
|
// Declare assembly trampoline.
|
||||||
|
text += fmt.Sprintf("func libc_%s_trampoline()\n", libcFn)
|
||||||
|
// Assembly trampoline calls the libc_* function, which this magic
|
||||||
|
// redirects to use the function from libSystem.
|
||||||
|
text += fmt.Sprintf("//go:linkname libc_%s libc_%s\n", libcFn, libcFn)
|
||||||
|
text += fmt.Sprintf("//go:cgo_import_dynamic libc_%s %s \"/usr/lib/libSystem.B.dylib\"\n", libcFn, libcFn)
|
||||||
|
text += "\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := s.Err(); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
file.Close()
|
||||||
|
}
|
||||||
|
fmt.Printf(srcTemplate, cmdLine(), buildTags(), text)
|
||||||
|
}
|
||||||
|
|
||||||
|
const srcTemplate = `// %s
|
||||||
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
|
// +build %s
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ syscall.Errno
|
||||||
|
|
||||||
|
%s
|
||||||
|
`
|
||||||
404
vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go
generated
vendored
Normal file
404
vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,404 @@
|
||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
/*
|
||||||
|
This program reads a file containing function prototypes
|
||||||
|
(like syscall_aix.go) and generates system call bodies.
|
||||||
|
The prototypes are marked by lines beginning with "//sys"
|
||||||
|
and read like func declarations if //sys is replaced by func, but:
|
||||||
|
* The parameter lists must give a name for each argument.
|
||||||
|
This includes return parameters.
|
||||||
|
* The parameter lists must give a type for each argument:
|
||||||
|
the (x, y, z int) shorthand is not allowed.
|
||||||
|
* If the return parameter is an error number, it must be named err.
|
||||||
|
* If go func name needs to be different than its libc name,
|
||||||
|
* or the function is not in libc, name could be specified
|
||||||
|
* at the end, after "=" sign, like
|
||||||
|
//sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
|
||||||
|
*/
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
b32 = flag.Bool("b32", false, "32bit big-endian")
|
||||||
|
l32 = flag.Bool("l32", false, "32bit little-endian")
|
||||||
|
aix = flag.Bool("aix", false, "aix")
|
||||||
|
tags = flag.String("tags", "", "build tags")
|
||||||
|
)
|
||||||
|
|
||||||
|
// cmdLine returns this programs's commandline arguments
|
||||||
|
func cmdLine() string {
|
||||||
|
return "go run mksyscall_aix_ppc.go " + strings.Join(os.Args[1:], " ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// buildTags returns build tags
|
||||||
|
func buildTags() string {
|
||||||
|
return *tags
|
||||||
|
}
|
||||||
|
|
||||||
|
// Param is function parameter
|
||||||
|
type Param struct {
|
||||||
|
Name string
|
||||||
|
Type string
|
||||||
|
}
|
||||||
|
|
||||||
|
// usage prints the program usage
|
||||||
|
func usage() {
|
||||||
|
fmt.Fprintf(os.Stderr, "usage: go run mksyscall_aix_ppc.go [-b32 | -l32] [-tags x,y] [file ...]\n")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseParamList parses parameter list and returns a slice of parameters
|
||||||
|
func parseParamList(list string) []string {
|
||||||
|
list = strings.TrimSpace(list)
|
||||||
|
if list == "" {
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
return regexp.MustCompile(`\s*,\s*`).Split(list, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseParam splits a parameter into name and type
|
||||||
|
func parseParam(p string) Param {
|
||||||
|
ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p)
|
||||||
|
if ps == nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
return Param{ps[1], ps[2]}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
flag.Usage = usage
|
||||||
|
flag.Parse()
|
||||||
|
if len(flag.Args()) <= 0 {
|
||||||
|
fmt.Fprintf(os.Stderr, "no files to parse provided\n")
|
||||||
|
usage()
|
||||||
|
}
|
||||||
|
|
||||||
|
endianness := ""
|
||||||
|
if *b32 {
|
||||||
|
endianness = "big-endian"
|
||||||
|
} else if *l32 {
|
||||||
|
endianness = "little-endian"
|
||||||
|
}
|
||||||
|
|
||||||
|
pack := ""
|
||||||
|
text := ""
|
||||||
|
cExtern := "/*\n#include <stdint.h>\n#include <stddef.h>\n"
|
||||||
|
for _, path := range flag.Args() {
|
||||||
|
file, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
s := bufio.NewScanner(file)
|
||||||
|
for s.Scan() {
|
||||||
|
t := s.Text()
|
||||||
|
t = strings.TrimSpace(t)
|
||||||
|
t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `)
|
||||||
|
if p := regexp.MustCompile(`^package (\S+)$`).FindStringSubmatch(t); p != nil && pack == "" {
|
||||||
|
pack = p[1]
|
||||||
|
}
|
||||||
|
nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t)
|
||||||
|
if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Line must be of the form
|
||||||
|
// func Open(path string, mode int, perm int) (fd int, err error)
|
||||||
|
// Split into name, in params, out params.
|
||||||
|
f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$`).FindStringSubmatch(t)
|
||||||
|
if f == nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
funct, inps, outps, modname, sysname := f[2], f[3], f[4], f[5], f[6]
|
||||||
|
|
||||||
|
// Split argument lists on comma.
|
||||||
|
in := parseParamList(inps)
|
||||||
|
out := parseParamList(outps)
|
||||||
|
|
||||||
|
inps = strings.Join(in, ", ")
|
||||||
|
outps = strings.Join(out, ", ")
|
||||||
|
|
||||||
|
// Try in vain to keep people from editing this file.
|
||||||
|
// The theory is that they jump into the middle of the file
|
||||||
|
// without reading the header.
|
||||||
|
text += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"
|
||||||
|
|
||||||
|
// Check if value return, err return available
|
||||||
|
errvar := ""
|
||||||
|
retvar := ""
|
||||||
|
rettype := ""
|
||||||
|
for _, param := range out {
|
||||||
|
p := parseParam(param)
|
||||||
|
if p.Type == "error" {
|
||||||
|
errvar = p.Name
|
||||||
|
} else {
|
||||||
|
retvar = p.Name
|
||||||
|
rettype = p.Type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// System call name.
|
||||||
|
if sysname == "" {
|
||||||
|
sysname = funct
|
||||||
|
}
|
||||||
|
sysname = regexp.MustCompile(`([a-z])([A-Z])`).ReplaceAllString(sysname, `${1}_$2`)
|
||||||
|
sysname = strings.ToLower(sysname) // All libc functions are lowercase.
|
||||||
|
|
||||||
|
cRettype := ""
|
||||||
|
if rettype == "unsafe.Pointer" {
|
||||||
|
cRettype = "uintptr_t"
|
||||||
|
} else if rettype == "uintptr" {
|
||||||
|
cRettype = "uintptr_t"
|
||||||
|
} else if regexp.MustCompile(`^_`).FindStringSubmatch(rettype) != nil {
|
||||||
|
cRettype = "uintptr_t"
|
||||||
|
} else if rettype == "int" {
|
||||||
|
cRettype = "int"
|
||||||
|
} else if rettype == "int32" {
|
||||||
|
cRettype = "int"
|
||||||
|
} else if rettype == "int64" {
|
||||||
|
cRettype = "long long"
|
||||||
|
} else if rettype == "uint32" {
|
||||||
|
cRettype = "unsigned int"
|
||||||
|
} else if rettype == "uint64" {
|
||||||
|
cRettype = "unsigned long long"
|
||||||
|
} else {
|
||||||
|
cRettype = "int"
|
||||||
|
}
|
||||||
|
if sysname == "exit" {
|
||||||
|
cRettype = "void"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Change p.Types to c
|
||||||
|
var cIn []string
|
||||||
|
for _, param := range in {
|
||||||
|
p := parseParam(param)
|
||||||
|
if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil {
|
||||||
|
cIn = append(cIn, "uintptr_t")
|
||||||
|
} else if p.Type == "string" {
|
||||||
|
cIn = append(cIn, "uintptr_t")
|
||||||
|
} else if regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type) != nil {
|
||||||
|
cIn = append(cIn, "uintptr_t", "size_t")
|
||||||
|
} else if p.Type == "unsafe.Pointer" {
|
||||||
|
cIn = append(cIn, "uintptr_t")
|
||||||
|
} else if p.Type == "uintptr" {
|
||||||
|
cIn = append(cIn, "uintptr_t")
|
||||||
|
} else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil {
|
||||||
|
cIn = append(cIn, "uintptr_t")
|
||||||
|
} else if p.Type == "int" {
|
||||||
|
cIn = append(cIn, "int")
|
||||||
|
} else if p.Type == "int32" {
|
||||||
|
cIn = append(cIn, "int")
|
||||||
|
} else if p.Type == "int64" {
|
||||||
|
cIn = append(cIn, "long long")
|
||||||
|
} else if p.Type == "uint32" {
|
||||||
|
cIn = append(cIn, "unsigned int")
|
||||||
|
} else if p.Type == "uint64" {
|
||||||
|
cIn = append(cIn, "unsigned long long")
|
||||||
|
} else {
|
||||||
|
cIn = append(cIn, "int")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if funct != "fcntl" && funct != "FcntlInt" && funct != "readlen" && funct != "writelen" {
|
||||||
|
// Imports of system calls from libc
|
||||||
|
cExtern += fmt.Sprintf("%s %s", cRettype, sysname)
|
||||||
|
cIn := strings.Join(cIn, ", ")
|
||||||
|
cExtern += fmt.Sprintf("(%s);\n", cIn)
|
||||||
|
}
|
||||||
|
|
||||||
|
// So file name.
|
||||||
|
if *aix {
|
||||||
|
if modname == "" {
|
||||||
|
modname = "libc.a/shr_64.o"
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s: only syscall using libc are available\n", funct)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
strconvfunc := "C.CString"
|
||||||
|
|
||||||
|
// Go function header.
|
||||||
|
if outps != "" {
|
||||||
|
outps = fmt.Sprintf(" (%s)", outps)
|
||||||
|
}
|
||||||
|
if text != "" {
|
||||||
|
text += "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
text += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outps)
|
||||||
|
|
||||||
|
// Prepare arguments to Syscall.
|
||||||
|
var args []string
|
||||||
|
n := 0
|
||||||
|
argN := 0
|
||||||
|
for _, param := range in {
|
||||||
|
p := parseParam(param)
|
||||||
|
if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil {
|
||||||
|
args = append(args, "C.uintptr_t(uintptr(unsafe.Pointer("+p.Name+")))")
|
||||||
|
} else if p.Type == "string" && errvar != "" {
|
||||||
|
text += fmt.Sprintf("\t_p%d := uintptr(unsafe.Pointer(%s(%s)))\n", n, strconvfunc, p.Name)
|
||||||
|
args = append(args, fmt.Sprintf("C.uintptr_t(_p%d)", n))
|
||||||
|
n++
|
||||||
|
} else if p.Type == "string" {
|
||||||
|
fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n")
|
||||||
|
text += fmt.Sprintf("\t_p%d := uintptr(unsafe.Pointer(%s(%s)))\n", n, strconvfunc, p.Name)
|
||||||
|
args = append(args, fmt.Sprintf("C.uintptr_t(_p%d)", n))
|
||||||
|
n++
|
||||||
|
} else if m := regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type); m != nil {
|
||||||
|
// Convert slice into pointer, length.
|
||||||
|
// Have to be careful not to take address of &a[0] if len == 0:
|
||||||
|
// pass nil in that case.
|
||||||
|
text += fmt.Sprintf("\tvar _p%d *%s\n", n, m[1])
|
||||||
|
text += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = &%s[0]\n\t}\n", p.Name, n, p.Name)
|
||||||
|
args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(unsafe.Pointer(_p%d)))", n))
|
||||||
|
n++
|
||||||
|
text += fmt.Sprintf("\tvar _p%d int\n", n)
|
||||||
|
text += fmt.Sprintf("\t_p%d = len(%s)\n", n, p.Name)
|
||||||
|
args = append(args, fmt.Sprintf("C.size_t(_p%d)", n))
|
||||||
|
n++
|
||||||
|
} else if p.Type == "int64" && endianness != "" {
|
||||||
|
if endianness == "big-endian" {
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
} else {
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
|
||||||
|
}
|
||||||
|
n++
|
||||||
|
} else if p.Type == "bool" {
|
||||||
|
text += fmt.Sprintf("\tvar _p%d uint32\n", n)
|
||||||
|
text += fmt.Sprintf("\tif %s {\n\t\t_p%d = 1\n\t} else {\n\t\t_p%d = 0\n\t}\n", p.Name, n, n)
|
||||||
|
args = append(args, fmt.Sprintf("_p%d", n))
|
||||||
|
} else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil {
|
||||||
|
args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(%s))", p.Name))
|
||||||
|
} else if p.Type == "unsafe.Pointer" {
|
||||||
|
args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(%s))", p.Name))
|
||||||
|
} else if p.Type == "int" {
|
||||||
|
if (argN == 2) && ((funct == "readlen") || (funct == "writelen")) {
|
||||||
|
args = append(args, fmt.Sprintf("C.size_t(%s)", p.Name))
|
||||||
|
} else if argN == 0 && funct == "fcntl" {
|
||||||
|
args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name))
|
||||||
|
} else if (argN == 2) && ((funct == "fcntl") || (funct == "FcntlInt")) {
|
||||||
|
args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name))
|
||||||
|
} else {
|
||||||
|
args = append(args, fmt.Sprintf("C.int(%s)", p.Name))
|
||||||
|
}
|
||||||
|
} else if p.Type == "int32" {
|
||||||
|
args = append(args, fmt.Sprintf("C.int(%s)", p.Name))
|
||||||
|
} else if p.Type == "int64" {
|
||||||
|
args = append(args, fmt.Sprintf("C.longlong(%s)", p.Name))
|
||||||
|
} else if p.Type == "uint32" {
|
||||||
|
args = append(args, fmt.Sprintf("C.uint(%s)", p.Name))
|
||||||
|
} else if p.Type == "uint64" {
|
||||||
|
args = append(args, fmt.Sprintf("C.ulonglong(%s)", p.Name))
|
||||||
|
} else if p.Type == "uintptr" {
|
||||||
|
args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name))
|
||||||
|
} else {
|
||||||
|
args = append(args, fmt.Sprintf("C.int(%s)", p.Name))
|
||||||
|
}
|
||||||
|
argN++
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actual call.
|
||||||
|
arglist := strings.Join(args, ", ")
|
||||||
|
call := ""
|
||||||
|
if sysname == "exit" {
|
||||||
|
if errvar != "" {
|
||||||
|
call += "er :="
|
||||||
|
} else {
|
||||||
|
call += ""
|
||||||
|
}
|
||||||
|
} else if errvar != "" {
|
||||||
|
call += "r0,er :="
|
||||||
|
} else if retvar != "" {
|
||||||
|
call += "r0,_ :="
|
||||||
|
} else {
|
||||||
|
call += ""
|
||||||
|
}
|
||||||
|
call += fmt.Sprintf("C.%s(%s)", sysname, arglist)
|
||||||
|
|
||||||
|
// Assign return values.
|
||||||
|
body := ""
|
||||||
|
for i := 0; i < len(out); i++ {
|
||||||
|
p := parseParam(out[i])
|
||||||
|
reg := ""
|
||||||
|
if p.Name == "err" {
|
||||||
|
reg = "e1"
|
||||||
|
} else {
|
||||||
|
reg = "r0"
|
||||||
|
}
|
||||||
|
if reg != "e1" {
|
||||||
|
body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// verify return
|
||||||
|
if sysname != "exit" && errvar != "" {
|
||||||
|
if regexp.MustCompile(`^uintptr`).FindStringSubmatch(cRettype) != nil {
|
||||||
|
body += "\tif (uintptr(r0) ==^uintptr(0) && er != nil) {\n"
|
||||||
|
body += fmt.Sprintf("\t\t%s = er\n", errvar)
|
||||||
|
body += "\t}\n"
|
||||||
|
} else {
|
||||||
|
body += "\tif (r0 ==-1 && er != nil) {\n"
|
||||||
|
body += fmt.Sprintf("\t\t%s = er\n", errvar)
|
||||||
|
body += "\t}\n"
|
||||||
|
}
|
||||||
|
} else if errvar != "" {
|
||||||
|
body += "\tif (er != nil) {\n"
|
||||||
|
body += fmt.Sprintf("\t\t%s = er\n", errvar)
|
||||||
|
body += "\t}\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
text += fmt.Sprintf("\t%s\n", call)
|
||||||
|
text += body
|
||||||
|
|
||||||
|
text += "\treturn\n"
|
||||||
|
text += "}\n"
|
||||||
|
}
|
||||||
|
if err := s.Err(); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
file.Close()
|
||||||
|
}
|
||||||
|
imp := ""
|
||||||
|
if pack != "unix" {
|
||||||
|
imp = "import \"golang.org/x/sys/unix\"\n"
|
||||||
|
|
||||||
|
}
|
||||||
|
fmt.Printf(srcTemplate, cmdLine(), buildTags(), pack, cExtern, imp, text)
|
||||||
|
}
|
||||||
|
|
||||||
|
const srcTemplate = `// %s
|
||||||
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
|
// +build %s
|
||||||
|
|
||||||
|
package %s
|
||||||
|
|
||||||
|
|
||||||
|
%s
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
%s
|
||||||
|
|
||||||
|
%s
|
||||||
|
`
|
||||||
602
vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.go
generated
vendored
Normal file
602
vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,602 @@
|
||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
/*
|
||||||
|
This program reads a file containing function prototypes
|
||||||
|
(like syscall_aix.go) and generates system call bodies.
|
||||||
|
The prototypes are marked by lines beginning with "//sys"
|
||||||
|
and read like func declarations if //sys is replaced by func, but:
|
||||||
|
* The parameter lists must give a name for each argument.
|
||||||
|
This includes return parameters.
|
||||||
|
* The parameter lists must give a type for each argument:
|
||||||
|
the (x, y, z int) shorthand is not allowed.
|
||||||
|
* If the return parameter is an error number, it must be named err.
|
||||||
|
* If go func name needs to be different than its libc name,
|
||||||
|
* or the function is not in libc, name could be specified
|
||||||
|
* at the end, after "=" sign, like
|
||||||
|
//sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
|
||||||
|
|
||||||
|
|
||||||
|
This program will generate three files and handle both gc and gccgo implementation:
|
||||||
|
- zsyscall_aix_ppc64.go: the common part of each implementation (error handler, pointer creation)
|
||||||
|
- zsyscall_aix_ppc64_gc.go: gc part with //go_cgo_import_dynamic and a call to syscall6
|
||||||
|
- zsyscall_aix_ppc64_gccgo.go: gccgo part with C function and conversion to C type.
|
||||||
|
|
||||||
|
The generated code looks like this
|
||||||
|
|
||||||
|
zsyscall_aix_ppc64.go
|
||||||
|
func asyscall(...) (n int, err error) {
|
||||||
|
// Pointer Creation
|
||||||
|
r1, e1 := callasyscall(...)
|
||||||
|
// Type Conversion
|
||||||
|
// Error Handler
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
zsyscall_aix_ppc64_gc.go
|
||||||
|
//go:cgo_import_dynamic libc_asyscall asyscall "libc.a/shr_64.o"
|
||||||
|
//go:linkname libc_asyscall libc_asyscall
|
||||||
|
var asyscall syscallFunc
|
||||||
|
|
||||||
|
func callasyscall(...) (r1 uintptr, e1 Errno) {
|
||||||
|
r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_asyscall)), "nb_args", ... )
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
zsyscall_aix_ppc64_ggcgo.go
|
||||||
|
|
||||||
|
// int asyscall(...)
|
||||||
|
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
func callasyscall(...) (r1 uintptr, e1 Errno) {
|
||||||
|
r1 = uintptr(C.asyscall(...))
|
||||||
|
e1 = syscall.GetErrno()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
b32 = flag.Bool("b32", false, "32bit big-endian")
|
||||||
|
l32 = flag.Bool("l32", false, "32bit little-endian")
|
||||||
|
aix = flag.Bool("aix", false, "aix")
|
||||||
|
tags = flag.String("tags", "", "build tags")
|
||||||
|
)
|
||||||
|
|
||||||
|
// cmdLine returns this programs's commandline arguments
|
||||||
|
func cmdLine() string {
|
||||||
|
return "go run mksyscall_aix_ppc64.go " + strings.Join(os.Args[1:], " ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// buildTags returns build tags
|
||||||
|
func buildTags() string {
|
||||||
|
return *tags
|
||||||
|
}
|
||||||
|
|
||||||
|
// Param is function parameter
|
||||||
|
type Param struct {
|
||||||
|
Name string
|
||||||
|
Type string
|
||||||
|
}
|
||||||
|
|
||||||
|
// usage prints the program usage
|
||||||
|
func usage() {
|
||||||
|
fmt.Fprintf(os.Stderr, "usage: go run mksyscall_aix_ppc64.go [-b32 | -l32] [-tags x,y] [file ...]\n")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseParamList parses parameter list and returns a slice of parameters
|
||||||
|
func parseParamList(list string) []string {
|
||||||
|
list = strings.TrimSpace(list)
|
||||||
|
if list == "" {
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
return regexp.MustCompile(`\s*,\s*`).Split(list, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseParam splits a parameter into name and type
|
||||||
|
func parseParam(p string) Param {
|
||||||
|
ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p)
|
||||||
|
if ps == nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
return Param{ps[1], ps[2]}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
flag.Usage = usage
|
||||||
|
flag.Parse()
|
||||||
|
if len(flag.Args()) <= 0 {
|
||||||
|
fmt.Fprintf(os.Stderr, "no files to parse provided\n")
|
||||||
|
usage()
|
||||||
|
}
|
||||||
|
|
||||||
|
endianness := ""
|
||||||
|
if *b32 {
|
||||||
|
endianness = "big-endian"
|
||||||
|
} else if *l32 {
|
||||||
|
endianness = "little-endian"
|
||||||
|
}
|
||||||
|
|
||||||
|
pack := ""
|
||||||
|
// GCCGO
|
||||||
|
textgccgo := ""
|
||||||
|
cExtern := "/*\n#include <stdint.h>\n"
|
||||||
|
// GC
|
||||||
|
textgc := ""
|
||||||
|
dynimports := ""
|
||||||
|
linknames := ""
|
||||||
|
var vars []string
|
||||||
|
// COMMON
|
||||||
|
textcommon := ""
|
||||||
|
for _, path := range flag.Args() {
|
||||||
|
file, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
s := bufio.NewScanner(file)
|
||||||
|
for s.Scan() {
|
||||||
|
t := s.Text()
|
||||||
|
t = strings.TrimSpace(t)
|
||||||
|
t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `)
|
||||||
|
if p := regexp.MustCompile(`^package (\S+)$`).FindStringSubmatch(t); p != nil && pack == "" {
|
||||||
|
pack = p[1]
|
||||||
|
}
|
||||||
|
nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t)
|
||||||
|
if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Line must be of the form
|
||||||
|
// func Open(path string, mode int, perm int) (fd int, err error)
|
||||||
|
// Split into name, in params, out params.
|
||||||
|
f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$`).FindStringSubmatch(t)
|
||||||
|
if f == nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
funct, inps, outps, modname, sysname := f[2], f[3], f[4], f[5], f[6]
|
||||||
|
|
||||||
|
// Split argument lists on comma.
|
||||||
|
in := parseParamList(inps)
|
||||||
|
out := parseParamList(outps)
|
||||||
|
|
||||||
|
inps = strings.Join(in, ", ")
|
||||||
|
outps = strings.Join(out, ", ")
|
||||||
|
|
||||||
|
if sysname == "" {
|
||||||
|
sysname = funct
|
||||||
|
}
|
||||||
|
|
||||||
|
onlyCommon := false
|
||||||
|
if funct == "readlen" || funct == "writelen" || funct == "FcntlInt" || funct == "FcntlFlock" {
|
||||||
|
// This function call another syscall which is already implemented.
|
||||||
|
// Therefore, the gc and gccgo part must not be generated.
|
||||||
|
onlyCommon = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try in vain to keep people from editing this file.
|
||||||
|
// The theory is that they jump into the middle of the file
|
||||||
|
// without reading the header.
|
||||||
|
|
||||||
|
textcommon += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"
|
||||||
|
if !onlyCommon {
|
||||||
|
textgccgo += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"
|
||||||
|
textgc += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if value return, err return available
|
||||||
|
errvar := ""
|
||||||
|
rettype := ""
|
||||||
|
for _, param := range out {
|
||||||
|
p := parseParam(param)
|
||||||
|
if p.Type == "error" {
|
||||||
|
errvar = p.Name
|
||||||
|
} else {
|
||||||
|
rettype = p.Type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sysname = regexp.MustCompile(`([a-z])([A-Z])`).ReplaceAllString(sysname, `${1}_$2`)
|
||||||
|
sysname = strings.ToLower(sysname) // All libc functions are lowercase.
|
||||||
|
|
||||||
|
// GCCGO Prototype return type
|
||||||
|
cRettype := ""
|
||||||
|
if rettype == "unsafe.Pointer" {
|
||||||
|
cRettype = "uintptr_t"
|
||||||
|
} else if rettype == "uintptr" {
|
||||||
|
cRettype = "uintptr_t"
|
||||||
|
} else if regexp.MustCompile(`^_`).FindStringSubmatch(rettype) != nil {
|
||||||
|
cRettype = "uintptr_t"
|
||||||
|
} else if rettype == "int" {
|
||||||
|
cRettype = "int"
|
||||||
|
} else if rettype == "int32" {
|
||||||
|
cRettype = "int"
|
||||||
|
} else if rettype == "int64" {
|
||||||
|
cRettype = "long long"
|
||||||
|
} else if rettype == "uint32" {
|
||||||
|
cRettype = "unsigned int"
|
||||||
|
} else if rettype == "uint64" {
|
||||||
|
cRettype = "unsigned long long"
|
||||||
|
} else {
|
||||||
|
cRettype = "int"
|
||||||
|
}
|
||||||
|
if sysname == "exit" {
|
||||||
|
cRettype = "void"
|
||||||
|
}
|
||||||
|
|
||||||
|
// GCCGO Prototype arguments type
|
||||||
|
var cIn []string
|
||||||
|
for i, param := range in {
|
||||||
|
p := parseParam(param)
|
||||||
|
if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil {
|
||||||
|
cIn = append(cIn, "uintptr_t")
|
||||||
|
} else if p.Type == "string" {
|
||||||
|
cIn = append(cIn, "uintptr_t")
|
||||||
|
} else if regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type) != nil {
|
||||||
|
cIn = append(cIn, "uintptr_t", "size_t")
|
||||||
|
} else if p.Type == "unsafe.Pointer" {
|
||||||
|
cIn = append(cIn, "uintptr_t")
|
||||||
|
} else if p.Type == "uintptr" {
|
||||||
|
cIn = append(cIn, "uintptr_t")
|
||||||
|
} else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil {
|
||||||
|
cIn = append(cIn, "uintptr_t")
|
||||||
|
} else if p.Type == "int" {
|
||||||
|
if (i == 0 || i == 2) && funct == "fcntl" {
|
||||||
|
// These fcntl arguments needs to be uintptr to be able to call FcntlInt and FcntlFlock
|
||||||
|
cIn = append(cIn, "uintptr_t")
|
||||||
|
} else {
|
||||||
|
cIn = append(cIn, "int")
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if p.Type == "int32" {
|
||||||
|
cIn = append(cIn, "int")
|
||||||
|
} else if p.Type == "int64" {
|
||||||
|
cIn = append(cIn, "long long")
|
||||||
|
} else if p.Type == "uint32" {
|
||||||
|
cIn = append(cIn, "unsigned int")
|
||||||
|
} else if p.Type == "uint64" {
|
||||||
|
cIn = append(cIn, "unsigned long long")
|
||||||
|
} else {
|
||||||
|
cIn = append(cIn, "int")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !onlyCommon {
|
||||||
|
// GCCGO Prototype Generation
|
||||||
|
// Imports of system calls from libc
|
||||||
|
cExtern += fmt.Sprintf("%s %s", cRettype, sysname)
|
||||||
|
cIn := strings.Join(cIn, ", ")
|
||||||
|
cExtern += fmt.Sprintf("(%s);\n", cIn)
|
||||||
|
}
|
||||||
|
// GC Library name
|
||||||
|
if modname == "" {
|
||||||
|
modname = "libc.a/shr_64.o"
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s: only syscall using libc are available\n", funct)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
sysvarname := fmt.Sprintf("libc_%s", sysname)
|
||||||
|
|
||||||
|
if !onlyCommon {
|
||||||
|
// GC Runtime import of function to allow cross-platform builds.
|
||||||
|
dynimports += fmt.Sprintf("//go:cgo_import_dynamic %s %s \"%s\"\n", sysvarname, sysname, modname)
|
||||||
|
// GC Link symbol to proc address variable.
|
||||||
|
linknames += fmt.Sprintf("//go:linkname %s %s\n", sysvarname, sysvarname)
|
||||||
|
// GC Library proc address variable.
|
||||||
|
vars = append(vars, sysvarname)
|
||||||
|
}
|
||||||
|
|
||||||
|
strconvfunc := "BytePtrFromString"
|
||||||
|
strconvtype := "*byte"
|
||||||
|
|
||||||
|
// Go function header.
|
||||||
|
if outps != "" {
|
||||||
|
outps = fmt.Sprintf(" (%s)", outps)
|
||||||
|
}
|
||||||
|
if textcommon != "" {
|
||||||
|
textcommon += "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
textcommon += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outps)
|
||||||
|
|
||||||
|
// Prepare arguments tocall.
|
||||||
|
var argscommon []string // Arguments in the common part
|
||||||
|
var argscall []string // Arguments for call prototype
|
||||||
|
var argsgc []string // Arguments for gc call (with syscall6)
|
||||||
|
var argsgccgo []string // Arguments for gccgo call (with C.name_of_syscall)
|
||||||
|
n := 0
|
||||||
|
argN := 0
|
||||||
|
for _, param := range in {
|
||||||
|
p := parseParam(param)
|
||||||
|
if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil {
|
||||||
|
argscommon = append(argscommon, fmt.Sprintf("uintptr(unsafe.Pointer(%s))", p.Name))
|
||||||
|
argscall = append(argscall, fmt.Sprintf("%s uintptr", p.Name))
|
||||||
|
argsgc = append(argsgc, p.Name)
|
||||||
|
argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(%s)", p.Name))
|
||||||
|
} else if p.Type == "string" && errvar != "" {
|
||||||
|
textcommon += fmt.Sprintf("\tvar _p%d %s\n", n, strconvtype)
|
||||||
|
textcommon += fmt.Sprintf("\t_p%d, %s = %s(%s)\n", n, errvar, strconvfunc, p.Name)
|
||||||
|
textcommon += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar)
|
||||||
|
|
||||||
|
argscommon = append(argscommon, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n))
|
||||||
|
argscall = append(argscall, fmt.Sprintf("_p%d uintptr ", n))
|
||||||
|
argsgc = append(argsgc, fmt.Sprintf("_p%d", n))
|
||||||
|
argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(_p%d)", n))
|
||||||
|
n++
|
||||||
|
} else if p.Type == "string" {
|
||||||
|
fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n")
|
||||||
|
textcommon += fmt.Sprintf("\tvar _p%d %s\n", n, strconvtype)
|
||||||
|
textcommon += fmt.Sprintf("\t_p%d, %s = %s(%s)\n", n, errvar, strconvfunc, p.Name)
|
||||||
|
textcommon += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar)
|
||||||
|
|
||||||
|
argscommon = append(argscommon, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n))
|
||||||
|
argscall = append(argscall, fmt.Sprintf("_p%d uintptr", n))
|
||||||
|
argsgc = append(argsgc, fmt.Sprintf("_p%d", n))
|
||||||
|
argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(_p%d)", n))
|
||||||
|
n++
|
||||||
|
} else if m := regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type); m != nil {
|
||||||
|
// Convert slice into pointer, length.
|
||||||
|
// Have to be careful not to take address of &a[0] if len == 0:
|
||||||
|
// pass nil in that case.
|
||||||
|
textcommon += fmt.Sprintf("\tvar _p%d *%s\n", n, m[1])
|
||||||
|
textcommon += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = &%s[0]\n\t}\n", p.Name, n, p.Name)
|
||||||
|
argscommon = append(argscommon, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n), fmt.Sprintf("len(%s)", p.Name))
|
||||||
|
argscall = append(argscall, fmt.Sprintf("_p%d uintptr", n), fmt.Sprintf("_lenp%d int", n))
|
||||||
|
argsgc = append(argsgc, fmt.Sprintf("_p%d", n), fmt.Sprintf("uintptr(_lenp%d)", n))
|
||||||
|
argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(_p%d)", n), fmt.Sprintf("C.size_t(_lenp%d)", n))
|
||||||
|
n++
|
||||||
|
} else if p.Type == "int64" && endianness != "" {
|
||||||
|
fmt.Fprintf(os.Stderr, path+":"+funct+" uses int64 with 32 bits mode. Case not yet implemented\n")
|
||||||
|
} else if p.Type == "bool" {
|
||||||
|
fmt.Fprintf(os.Stderr, path+":"+funct+" uses bool. Case not yet implemented\n")
|
||||||
|
} else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil || p.Type == "unsafe.Pointer" {
|
||||||
|
argscommon = append(argscommon, fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
argscall = append(argscall, fmt.Sprintf("%s uintptr", p.Name))
|
||||||
|
argsgc = append(argsgc, p.Name)
|
||||||
|
argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(%s)", p.Name))
|
||||||
|
} else if p.Type == "int" {
|
||||||
|
if (argN == 0 || argN == 2) && ((funct == "fcntl") || (funct == "FcntlInt") || (funct == "FcntlFlock")) {
|
||||||
|
// These fcntl arguments need to be uintptr to be able to call FcntlInt and FcntlFlock
|
||||||
|
argscommon = append(argscommon, fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
argscall = append(argscall, fmt.Sprintf("%s uintptr", p.Name))
|
||||||
|
argsgc = append(argsgc, p.Name)
|
||||||
|
argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(%s)", p.Name))
|
||||||
|
|
||||||
|
} else {
|
||||||
|
argscommon = append(argscommon, p.Name)
|
||||||
|
argscall = append(argscall, fmt.Sprintf("%s int", p.Name))
|
||||||
|
argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
argsgccgo = append(argsgccgo, fmt.Sprintf("C.int(%s)", p.Name))
|
||||||
|
}
|
||||||
|
} else if p.Type == "int32" {
|
||||||
|
argscommon = append(argscommon, p.Name)
|
||||||
|
argscall = append(argscall, fmt.Sprintf("%s int32", p.Name))
|
||||||
|
argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
argsgccgo = append(argsgccgo, fmt.Sprintf("C.int(%s)", p.Name))
|
||||||
|
} else if p.Type == "int64" {
|
||||||
|
argscommon = append(argscommon, p.Name)
|
||||||
|
argscall = append(argscall, fmt.Sprintf("%s int64", p.Name))
|
||||||
|
argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
argsgccgo = append(argsgccgo, fmt.Sprintf("C.longlong(%s)", p.Name))
|
||||||
|
} else if p.Type == "uint32" {
|
||||||
|
argscommon = append(argscommon, p.Name)
|
||||||
|
argscall = append(argscall, fmt.Sprintf("%s uint32", p.Name))
|
||||||
|
argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
argsgccgo = append(argsgccgo, fmt.Sprintf("C.uint(%s)", p.Name))
|
||||||
|
} else if p.Type == "uint64" {
|
||||||
|
argscommon = append(argscommon, p.Name)
|
||||||
|
argscall = append(argscall, fmt.Sprintf("%s uint64", p.Name))
|
||||||
|
argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
argsgccgo = append(argsgccgo, fmt.Sprintf("C.ulonglong(%s)", p.Name))
|
||||||
|
} else if p.Type == "uintptr" {
|
||||||
|
argscommon = append(argscommon, p.Name)
|
||||||
|
argscall = append(argscall, fmt.Sprintf("%s uintptr", p.Name))
|
||||||
|
argsgc = append(argsgc, p.Name)
|
||||||
|
argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(%s)", p.Name))
|
||||||
|
} else {
|
||||||
|
argscommon = append(argscommon, fmt.Sprintf("int(%s)", p.Name))
|
||||||
|
argscall = append(argscall, fmt.Sprintf("%s int", p.Name))
|
||||||
|
argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
argsgccgo = append(argsgccgo, fmt.Sprintf("C.int(%s)", p.Name))
|
||||||
|
}
|
||||||
|
argN++
|
||||||
|
}
|
||||||
|
nargs := len(argsgc)
|
||||||
|
|
||||||
|
// COMMON function generation
|
||||||
|
argscommonlist := strings.Join(argscommon, ", ")
|
||||||
|
callcommon := fmt.Sprintf("call%s(%s)", sysname, argscommonlist)
|
||||||
|
ret := []string{"_", "_"}
|
||||||
|
body := ""
|
||||||
|
doErrno := false
|
||||||
|
for i := 0; i < len(out); i++ {
|
||||||
|
p := parseParam(out[i])
|
||||||
|
reg := ""
|
||||||
|
if p.Name == "err" {
|
||||||
|
reg = "e1"
|
||||||
|
ret[1] = reg
|
||||||
|
doErrno = true
|
||||||
|
} else {
|
||||||
|
reg = "r0"
|
||||||
|
ret[0] = reg
|
||||||
|
}
|
||||||
|
if p.Type == "bool" {
|
||||||
|
reg = fmt.Sprintf("%s != 0", reg)
|
||||||
|
}
|
||||||
|
if reg != "e1" {
|
||||||
|
body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ret[0] == "_" && ret[1] == "_" {
|
||||||
|
textcommon += fmt.Sprintf("\t%s\n", callcommon)
|
||||||
|
} else {
|
||||||
|
textcommon += fmt.Sprintf("\t%s, %s := %s\n", ret[0], ret[1], callcommon)
|
||||||
|
}
|
||||||
|
textcommon += body
|
||||||
|
|
||||||
|
if doErrno {
|
||||||
|
textcommon += "\tif e1 != 0 {\n"
|
||||||
|
textcommon += "\t\terr = errnoErr(e1)\n"
|
||||||
|
textcommon += "\t}\n"
|
||||||
|
}
|
||||||
|
textcommon += "\treturn\n"
|
||||||
|
textcommon += "}\n"
|
||||||
|
|
||||||
|
if onlyCommon {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// CALL Prototype
|
||||||
|
callProto := fmt.Sprintf("func call%s(%s) (r1 uintptr, e1 Errno) {\n", sysname, strings.Join(argscall, ", "))
|
||||||
|
|
||||||
|
// GC function generation
|
||||||
|
asm := "syscall6"
|
||||||
|
if nonblock != nil {
|
||||||
|
asm = "rawSyscall6"
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(argsgc) <= 6 {
|
||||||
|
for len(argsgc) < 6 {
|
||||||
|
argsgc = append(argsgc, "0")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s: too many arguments to system call", funct)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
argsgclist := strings.Join(argsgc, ", ")
|
||||||
|
callgc := fmt.Sprintf("%s(uintptr(unsafe.Pointer(&%s)), %d, %s)", asm, sysvarname, nargs, argsgclist)
|
||||||
|
|
||||||
|
textgc += callProto
|
||||||
|
textgc += fmt.Sprintf("\tr1, _, e1 = %s\n", callgc)
|
||||||
|
textgc += "\treturn\n}\n"
|
||||||
|
|
||||||
|
// GCCGO function generation
|
||||||
|
argsgccgolist := strings.Join(argsgccgo, ", ")
|
||||||
|
callgccgo := fmt.Sprintf("C.%s(%s)", sysname, argsgccgolist)
|
||||||
|
textgccgo += callProto
|
||||||
|
textgccgo += fmt.Sprintf("\tr1 = uintptr(%s)\n", callgccgo)
|
||||||
|
textgccgo += "\te1 = syscall.GetErrno()\n"
|
||||||
|
textgccgo += "\treturn\n}\n"
|
||||||
|
}
|
||||||
|
if err := s.Err(); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
file.Close()
|
||||||
|
}
|
||||||
|
imp := ""
|
||||||
|
if pack != "unix" {
|
||||||
|
imp = "import \"golang.org/x/sys/unix\"\n"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print zsyscall_aix_ppc64.go
|
||||||
|
err := ioutil.WriteFile("zsyscall_aix_ppc64.go",
|
||||||
|
[]byte(fmt.Sprintf(srcTemplate1, cmdLine(), buildTags(), pack, imp, textcommon)),
|
||||||
|
0644)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print zsyscall_aix_ppc64_gc.go
|
||||||
|
vardecls := "\t" + strings.Join(vars, ",\n\t")
|
||||||
|
vardecls += " syscallFunc"
|
||||||
|
err = ioutil.WriteFile("zsyscall_aix_ppc64_gc.go",
|
||||||
|
[]byte(fmt.Sprintf(srcTemplate2, cmdLine(), buildTags(), pack, imp, dynimports, linknames, vardecls, textgc)),
|
||||||
|
0644)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print zsyscall_aix_ppc64_gccgo.go
|
||||||
|
err = ioutil.WriteFile("zsyscall_aix_ppc64_gccgo.go",
|
||||||
|
[]byte(fmt.Sprintf(srcTemplate3, cmdLine(), buildTags(), pack, cExtern, imp, textgccgo)),
|
||||||
|
0644)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const srcTemplate1 = `// %s
|
||||||
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
|
// +build %s
|
||||||
|
|
||||||
|
package %s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
%s
|
||||||
|
|
||||||
|
%s
|
||||||
|
`
|
||||||
|
const srcTemplate2 = `// %s
|
||||||
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
|
// +build %s
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
package %s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
%s
|
||||||
|
%s
|
||||||
|
%s
|
||||||
|
type syscallFunc uintptr
|
||||||
|
|
||||||
|
var (
|
||||||
|
%s
|
||||||
|
)
|
||||||
|
|
||||||
|
// Implemented in runtime/syscall_aix.go.
|
||||||
|
func rawSyscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
|
||||||
|
func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
|
||||||
|
|
||||||
|
%s
|
||||||
|
`
|
||||||
|
const srcTemplate3 = `// %s
|
||||||
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
|
// +build %s
|
||||||
|
// +build gccgo
|
||||||
|
|
||||||
|
package %s
|
||||||
|
|
||||||
|
%s
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
%s
|
||||||
|
|
||||||
|
%s
|
||||||
|
`
|
||||||
335
vendor/golang.org/x/sys/unix/mksyscall_solaris.go
generated
vendored
Normal file
335
vendor/golang.org/x/sys/unix/mksyscall_solaris.go
generated
vendored
Normal file
|
|
@ -0,0 +1,335 @@
|
||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
/*
|
||||||
|
This program reads a file containing function prototypes
|
||||||
|
(like syscall_solaris.go) and generates system call bodies.
|
||||||
|
The prototypes are marked by lines beginning with "//sys"
|
||||||
|
and read like func declarations if //sys is replaced by func, but:
|
||||||
|
* The parameter lists must give a name for each argument.
|
||||||
|
This includes return parameters.
|
||||||
|
* The parameter lists must give a type for each argument:
|
||||||
|
the (x, y, z int) shorthand is not allowed.
|
||||||
|
* If the return parameter is an error number, it must be named err.
|
||||||
|
* If go func name needs to be different than its libc name,
|
||||||
|
* or the function is not in libc, name could be specified
|
||||||
|
* at the end, after "=" sign, like
|
||||||
|
//sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
b32 = flag.Bool("b32", false, "32bit big-endian")
|
||||||
|
l32 = flag.Bool("l32", false, "32bit little-endian")
|
||||||
|
tags = flag.String("tags", "", "build tags")
|
||||||
|
)
|
||||||
|
|
||||||
|
// cmdLine returns this programs's commandline arguments
|
||||||
|
func cmdLine() string {
|
||||||
|
return "go run mksyscall_solaris.go " + strings.Join(os.Args[1:], " ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// buildTags returns build tags
|
||||||
|
func buildTags() string {
|
||||||
|
return *tags
|
||||||
|
}
|
||||||
|
|
||||||
|
// Param is function parameter
|
||||||
|
type Param struct {
|
||||||
|
Name string
|
||||||
|
Type string
|
||||||
|
}
|
||||||
|
|
||||||
|
// usage prints the program usage
|
||||||
|
func usage() {
|
||||||
|
fmt.Fprintf(os.Stderr, "usage: go run mksyscall_solaris.go [-b32 | -l32] [-tags x,y] [file ...]\n")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseParamList parses parameter list and returns a slice of parameters
|
||||||
|
func parseParamList(list string) []string {
|
||||||
|
list = strings.TrimSpace(list)
|
||||||
|
if list == "" {
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
return regexp.MustCompile(`\s*,\s*`).Split(list, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseParam splits a parameter into name and type
|
||||||
|
func parseParam(p string) Param {
|
||||||
|
ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p)
|
||||||
|
if ps == nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
return Param{ps[1], ps[2]}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
flag.Usage = usage
|
||||||
|
flag.Parse()
|
||||||
|
if len(flag.Args()) <= 0 {
|
||||||
|
fmt.Fprintf(os.Stderr, "no files to parse provided\n")
|
||||||
|
usage()
|
||||||
|
}
|
||||||
|
|
||||||
|
endianness := ""
|
||||||
|
if *b32 {
|
||||||
|
endianness = "big-endian"
|
||||||
|
} else if *l32 {
|
||||||
|
endianness = "little-endian"
|
||||||
|
}
|
||||||
|
|
||||||
|
pack := ""
|
||||||
|
text := ""
|
||||||
|
dynimports := ""
|
||||||
|
linknames := ""
|
||||||
|
var vars []string
|
||||||
|
for _, path := range flag.Args() {
|
||||||
|
file, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
s := bufio.NewScanner(file)
|
||||||
|
for s.Scan() {
|
||||||
|
t := s.Text()
|
||||||
|
t = strings.TrimSpace(t)
|
||||||
|
t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `)
|
||||||
|
if p := regexp.MustCompile(`^package (\S+)$`).FindStringSubmatch(t); p != nil && pack == "" {
|
||||||
|
pack = p[1]
|
||||||
|
}
|
||||||
|
nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t)
|
||||||
|
if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Line must be of the form
|
||||||
|
// func Open(path string, mode int, perm int) (fd int, err error)
|
||||||
|
// Split into name, in params, out params.
|
||||||
|
f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$`).FindStringSubmatch(t)
|
||||||
|
if f == nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
funct, inps, outps, modname, sysname := f[2], f[3], f[4], f[5], f[6]
|
||||||
|
|
||||||
|
// Split argument lists on comma.
|
||||||
|
in := parseParamList(inps)
|
||||||
|
out := parseParamList(outps)
|
||||||
|
|
||||||
|
inps = strings.Join(in, ", ")
|
||||||
|
outps = strings.Join(out, ", ")
|
||||||
|
|
||||||
|
// Try in vain to keep people from editing this file.
|
||||||
|
// The theory is that they jump into the middle of the file
|
||||||
|
// without reading the header.
|
||||||
|
text += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"
|
||||||
|
|
||||||
|
// So file name.
|
||||||
|
if modname == "" {
|
||||||
|
modname = "libc"
|
||||||
|
}
|
||||||
|
|
||||||
|
// System call name.
|
||||||
|
if sysname == "" {
|
||||||
|
sysname = funct
|
||||||
|
}
|
||||||
|
|
||||||
|
// System call pointer variable name.
|
||||||
|
sysvarname := fmt.Sprintf("proc%s", sysname)
|
||||||
|
|
||||||
|
strconvfunc := "BytePtrFromString"
|
||||||
|
strconvtype := "*byte"
|
||||||
|
|
||||||
|
sysname = strings.ToLower(sysname) // All libc functions are lowercase.
|
||||||
|
|
||||||
|
// Runtime import of function to allow cross-platform builds.
|
||||||
|
dynimports += fmt.Sprintf("//go:cgo_import_dynamic libc_%s %s \"%s.so\"\n", sysname, sysname, modname)
|
||||||
|
// Link symbol to proc address variable.
|
||||||
|
linknames += fmt.Sprintf("//go:linkname %s libc_%s\n", sysvarname, sysname)
|
||||||
|
// Library proc address variable.
|
||||||
|
vars = append(vars, sysvarname)
|
||||||
|
|
||||||
|
// Go function header.
|
||||||
|
outlist := strings.Join(out, ", ")
|
||||||
|
if outlist != "" {
|
||||||
|
outlist = fmt.Sprintf(" (%s)", outlist)
|
||||||
|
}
|
||||||
|
if text != "" {
|
||||||
|
text += "\n"
|
||||||
|
}
|
||||||
|
text += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outlist)
|
||||||
|
|
||||||
|
// Check if err return available
|
||||||
|
errvar := ""
|
||||||
|
for _, param := range out {
|
||||||
|
p := parseParam(param)
|
||||||
|
if p.Type == "error" {
|
||||||
|
errvar = p.Name
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare arguments to Syscall.
|
||||||
|
var args []string
|
||||||
|
n := 0
|
||||||
|
for _, param := range in {
|
||||||
|
p := parseParam(param)
|
||||||
|
if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil {
|
||||||
|
args = append(args, "uintptr(unsafe.Pointer("+p.Name+"))")
|
||||||
|
} else if p.Type == "string" && errvar != "" {
|
||||||
|
text += fmt.Sprintf("\tvar _p%d %s\n", n, strconvtype)
|
||||||
|
text += fmt.Sprintf("\t_p%d, %s = %s(%s)\n", n, errvar, strconvfunc, p.Name)
|
||||||
|
text += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar)
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n))
|
||||||
|
n++
|
||||||
|
} else if p.Type == "string" {
|
||||||
|
fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n")
|
||||||
|
text += fmt.Sprintf("\tvar _p%d %s\n", n, strconvtype)
|
||||||
|
text += fmt.Sprintf("\t_p%d, _ = %s(%s)\n", n, strconvfunc, p.Name)
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n))
|
||||||
|
n++
|
||||||
|
} else if s := regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type); s != nil {
|
||||||
|
// Convert slice into pointer, length.
|
||||||
|
// Have to be careful not to take address of &a[0] if len == 0:
|
||||||
|
// pass nil in that case.
|
||||||
|
text += fmt.Sprintf("\tvar _p%d *%s\n", n, s[1])
|
||||||
|
text += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = &%s[0]\n\t}\n", p.Name, n, p.Name)
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n), fmt.Sprintf("uintptr(len(%s))", p.Name))
|
||||||
|
n++
|
||||||
|
} else if p.Type == "int64" && endianness != "" {
|
||||||
|
if endianness == "big-endian" {
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
} else {
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
|
||||||
|
}
|
||||||
|
} else if p.Type == "bool" {
|
||||||
|
text += fmt.Sprintf("\tvar _p%d uint32\n", n)
|
||||||
|
text += fmt.Sprintf("\tif %s {\n\t\t_p%d = 1\n\t} else {\n\t\t_p%d = 0\n\t}\n", p.Name, n, n)
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(_p%d)", n))
|
||||||
|
n++
|
||||||
|
} else {
|
||||||
|
args = append(args, fmt.Sprintf("uintptr(%s)", p.Name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nargs := len(args)
|
||||||
|
|
||||||
|
// Determine which form to use; pad args with zeros.
|
||||||
|
asm := "sysvicall6"
|
||||||
|
if nonblock != nil {
|
||||||
|
asm = "rawSysvicall6"
|
||||||
|
}
|
||||||
|
if len(args) <= 6 {
|
||||||
|
for len(args) < 6 {
|
||||||
|
args = append(args, "0")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s: too many arguments to system call\n", path)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actual call.
|
||||||
|
arglist := strings.Join(args, ", ")
|
||||||
|
call := fmt.Sprintf("%s(uintptr(unsafe.Pointer(&%s)), %d, %s)", asm, sysvarname, nargs, arglist)
|
||||||
|
|
||||||
|
// Assign return values.
|
||||||
|
body := ""
|
||||||
|
ret := []string{"_", "_", "_"}
|
||||||
|
doErrno := false
|
||||||
|
for i := 0; i < len(out); i++ {
|
||||||
|
p := parseParam(out[i])
|
||||||
|
reg := ""
|
||||||
|
if p.Name == "err" {
|
||||||
|
reg = "e1"
|
||||||
|
ret[2] = reg
|
||||||
|
doErrno = true
|
||||||
|
} else {
|
||||||
|
reg = fmt.Sprintf("r%d", i)
|
||||||
|
ret[i] = reg
|
||||||
|
}
|
||||||
|
if p.Type == "bool" {
|
||||||
|
reg = fmt.Sprintf("%d != 0", reg)
|
||||||
|
}
|
||||||
|
if p.Type == "int64" && endianness != "" {
|
||||||
|
// 64-bit number in r1:r0 or r0:r1.
|
||||||
|
if i+2 > len(out) {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s: not enough registers for int64 return\n", path)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
if endianness == "big-endian" {
|
||||||
|
reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i, i+1)
|
||||||
|
} else {
|
||||||
|
reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i+1, i)
|
||||||
|
}
|
||||||
|
ret[i] = fmt.Sprintf("r%d", i)
|
||||||
|
ret[i+1] = fmt.Sprintf("r%d", i+1)
|
||||||
|
}
|
||||||
|
if reg != "e1" {
|
||||||
|
body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ret[0] == "_" && ret[1] == "_" && ret[2] == "_" {
|
||||||
|
text += fmt.Sprintf("\t%s\n", call)
|
||||||
|
} else {
|
||||||
|
text += fmt.Sprintf("\t%s, %s, %s := %s\n", ret[0], ret[1], ret[2], call)
|
||||||
|
}
|
||||||
|
text += body
|
||||||
|
|
||||||
|
if doErrno {
|
||||||
|
text += "\tif e1 != 0 {\n"
|
||||||
|
text += "\t\terr = e1\n"
|
||||||
|
text += "\t}\n"
|
||||||
|
}
|
||||||
|
text += "\treturn\n"
|
||||||
|
text += "}\n"
|
||||||
|
}
|
||||||
|
if err := s.Err(); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
file.Close()
|
||||||
|
}
|
||||||
|
imp := ""
|
||||||
|
if pack != "unix" {
|
||||||
|
imp = "import \"golang.org/x/sys/unix\"\n"
|
||||||
|
|
||||||
|
}
|
||||||
|
vardecls := "\t" + strings.Join(vars, ",\n\t")
|
||||||
|
vardecls += " syscallFunc"
|
||||||
|
fmt.Printf(srcTemplate, cmdLine(), buildTags(), pack, imp, dynimports, linknames, vardecls, text)
|
||||||
|
}
|
||||||
|
|
||||||
|
const srcTemplate = `// %s
|
||||||
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
|
// +build %s
|
||||||
|
|
||||||
|
package %s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
%s
|
||||||
|
%s
|
||||||
|
%s
|
||||||
|
var (
|
||||||
|
%s
|
||||||
|
)
|
||||||
|
|
||||||
|
%s
|
||||||
|
`
|
||||||
190
vendor/golang.org/x/sys/unix/mksysnum.go
generated
vendored
Normal file
190
vendor/golang.org/x/sys/unix/mksysnum.go
generated
vendored
Normal file
|
|
@ -0,0 +1,190 @@
|
||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
// Generate system call table for DragonFly, NetBSD,
|
||||||
|
// FreeBSD, OpenBSD or Darwin from master list
|
||||||
|
// (for example, /usr/src/sys/kern/syscalls.master or
|
||||||
|
// sys/syscall.h).
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
goos, goarch string
|
||||||
|
)
|
||||||
|
|
||||||
|
// cmdLine returns this programs's commandline arguments
|
||||||
|
func cmdLine() string {
|
||||||
|
return "go run mksysnum.go " + strings.Join(os.Args[1:], " ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// buildTags returns build tags
|
||||||
|
func buildTags() string {
|
||||||
|
return fmt.Sprintf("%s,%s", goarch, goos)
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkErr(err error) {
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// source string and substring slice for regexp
|
||||||
|
type re struct {
|
||||||
|
str string // source string
|
||||||
|
sub []string // matched sub-string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Match performs regular expression match
|
||||||
|
func (r *re) Match(exp string) bool {
|
||||||
|
r.sub = regexp.MustCompile(exp).FindStringSubmatch(r.str)
|
||||||
|
if r.sub != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// fetchFile fetches a text file from URL
|
||||||
|
func fetchFile(URL string) io.Reader {
|
||||||
|
resp, err := http.Get(URL)
|
||||||
|
checkErr(err)
|
||||||
|
defer resp.Body.Close()
|
||||||
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
|
checkErr(err)
|
||||||
|
return strings.NewReader(string(body))
|
||||||
|
}
|
||||||
|
|
||||||
|
// readFile reads a text file from path
|
||||||
|
func readFile(path string) io.Reader {
|
||||||
|
file, err := os.Open(os.Args[1])
|
||||||
|
checkErr(err)
|
||||||
|
return file
|
||||||
|
}
|
||||||
|
|
||||||
|
func format(name, num, proto string) string {
|
||||||
|
name = strings.ToUpper(name)
|
||||||
|
// There are multiple entries for enosys and nosys, so comment them out.
|
||||||
|
nm := re{str: name}
|
||||||
|
if nm.Match(`^SYS_E?NOSYS$`) {
|
||||||
|
name = fmt.Sprintf("// %s", name)
|
||||||
|
}
|
||||||
|
if name == `SYS_SYS_EXIT` {
|
||||||
|
name = `SYS_EXIT`
|
||||||
|
}
|
||||||
|
return fmt.Sprintf(" %s = %s; // %s\n", name, num, proto)
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Get the OS (using GOOS_TARGET if it exist)
|
||||||
|
goos = os.Getenv("GOOS_TARGET")
|
||||||
|
if goos == "" {
|
||||||
|
goos = os.Getenv("GOOS")
|
||||||
|
}
|
||||||
|
// Get the architecture (using GOARCH_TARGET if it exists)
|
||||||
|
goarch = os.Getenv("GOARCH_TARGET")
|
||||||
|
if goarch == "" {
|
||||||
|
goarch = os.Getenv("GOARCH")
|
||||||
|
}
|
||||||
|
// Check if GOOS and GOARCH environment variables are defined
|
||||||
|
if goarch == "" || goos == "" {
|
||||||
|
fmt.Fprintf(os.Stderr, "GOARCH or GOOS not defined in environment\n")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
file := strings.TrimSpace(os.Args[1])
|
||||||
|
var syscalls io.Reader
|
||||||
|
if strings.HasPrefix(file, "https://") || strings.HasPrefix(file, "http://") {
|
||||||
|
// Download syscalls.master file
|
||||||
|
syscalls = fetchFile(file)
|
||||||
|
} else {
|
||||||
|
syscalls = readFile(file)
|
||||||
|
}
|
||||||
|
|
||||||
|
var text, line string
|
||||||
|
s := bufio.NewScanner(syscalls)
|
||||||
|
for s.Scan() {
|
||||||
|
t := re{str: line}
|
||||||
|
if t.Match(`^(.*)\\$`) {
|
||||||
|
// Handle continuation
|
||||||
|
line = t.sub[1]
|
||||||
|
line += strings.TrimLeft(s.Text(), " \t")
|
||||||
|
} else {
|
||||||
|
// New line
|
||||||
|
line = s.Text()
|
||||||
|
}
|
||||||
|
t = re{str: line}
|
||||||
|
if t.Match(`\\$`) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
t = re{str: line}
|
||||||
|
|
||||||
|
switch goos {
|
||||||
|
case "dragonfly":
|
||||||
|
if t.Match(`^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$`) {
|
||||||
|
num, proto := t.sub[1], t.sub[2]
|
||||||
|
name := fmt.Sprintf("SYS_%s", t.sub[3])
|
||||||
|
text += format(name, num, proto)
|
||||||
|
}
|
||||||
|
case "freebsd":
|
||||||
|
if t.Match(`^([0-9]+)\s+\S+\s+(?:NO)?STD\s+({ \S+\s+(\w+).*)$`) {
|
||||||
|
num, proto := t.sub[1], t.sub[2]
|
||||||
|
name := fmt.Sprintf("SYS_%s", t.sub[3])
|
||||||
|
text += format(name, num, proto)
|
||||||
|
}
|
||||||
|
case "openbsd":
|
||||||
|
if t.Match(`^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$`) {
|
||||||
|
num, proto, name := t.sub[1], t.sub[3], t.sub[4]
|
||||||
|
text += format(name, num, proto)
|
||||||
|
}
|
||||||
|
case "netbsd":
|
||||||
|
if t.Match(`^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$`) {
|
||||||
|
num, proto, compat := t.sub[1], t.sub[6], t.sub[8]
|
||||||
|
name := t.sub[7] + "_" + t.sub[9]
|
||||||
|
if t.sub[11] != "" {
|
||||||
|
name = t.sub[7] + "_" + t.sub[11]
|
||||||
|
}
|
||||||
|
name = strings.ToUpper(name)
|
||||||
|
if compat == "" || compat == "13" || compat == "30" || compat == "50" {
|
||||||
|
text += fmt.Sprintf(" %s = %s; // %s\n", name, num, proto)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "darwin":
|
||||||
|
if t.Match(`^#define\s+SYS_(\w+)\s+([0-9]+)`) {
|
||||||
|
name, num := t.sub[1], t.sub[2]
|
||||||
|
name = strings.ToUpper(name)
|
||||||
|
text += fmt.Sprintf(" SYS_%s = %s;\n", name, num)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
fmt.Fprintf(os.Stderr, "unrecognized GOOS=%s\n", goos)
|
||||||
|
os.Exit(1)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err := s.Err()
|
||||||
|
checkErr(err)
|
||||||
|
|
||||||
|
fmt.Printf(template, cmdLine(), buildTags(), text)
|
||||||
|
}
|
||||||
|
|
||||||
|
const template = `// %s
|
||||||
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
|
// +build %s
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const(
|
||||||
|
%s)`
|
||||||
166
vendor/golang.org/x/sys/unix/openbsd_pledge.go
generated
vendored
Normal file
166
vendor/golang.org/x/sys/unix/openbsd_pledge.go
generated
vendored
Normal file
|
|
@ -0,0 +1,166 @@
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build openbsd
|
||||||
|
// +build 386 amd64 arm
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Pledge implements the pledge syscall.
|
||||||
|
//
|
||||||
|
// The pledge syscall does not accept execpromises on OpenBSD releases
|
||||||
|
// before 6.3.
|
||||||
|
//
|
||||||
|
// execpromises must be empty when Pledge is called on OpenBSD
|
||||||
|
// releases predating 6.3, otherwise an error will be returned.
|
||||||
|
//
|
||||||
|
// For more information see pledge(2).
|
||||||
|
func Pledge(promises, execpromises string) error {
|
||||||
|
maj, min, err := majmin()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = pledgeAvailable(maj, min, execpromises)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
pptr, err := syscall.BytePtrFromString(promises)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// This variable will hold either a nil unsafe.Pointer or
|
||||||
|
// an unsafe.Pointer to a string (execpromises).
|
||||||
|
var expr unsafe.Pointer
|
||||||
|
|
||||||
|
// If we're running on OpenBSD > 6.2, pass execpromises to the syscall.
|
||||||
|
if maj > 6 || (maj == 6 && min > 2) {
|
||||||
|
exptr, err := syscall.BytePtrFromString(execpromises)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
expr = unsafe.Pointer(exptr)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(unsafe.Pointer(pptr)), uintptr(expr), 0)
|
||||||
|
if e != 0 {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PledgePromises implements the pledge syscall.
|
||||||
|
//
|
||||||
|
// This changes the promises and leaves the execpromises untouched.
|
||||||
|
//
|
||||||
|
// For more information see pledge(2).
|
||||||
|
func PledgePromises(promises string) error {
|
||||||
|
maj, min, err := majmin()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = pledgeAvailable(maj, min, "")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// This variable holds the execpromises and is always nil.
|
||||||
|
var expr unsafe.Pointer
|
||||||
|
|
||||||
|
pptr, err := syscall.BytePtrFromString(promises)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(unsafe.Pointer(pptr)), uintptr(expr), 0)
|
||||||
|
if e != 0 {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PledgeExecpromises implements the pledge syscall.
|
||||||
|
//
|
||||||
|
// This changes the execpromises and leaves the promises untouched.
|
||||||
|
//
|
||||||
|
// For more information see pledge(2).
|
||||||
|
func PledgeExecpromises(execpromises string) error {
|
||||||
|
maj, min, err := majmin()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = pledgeAvailable(maj, min, execpromises)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// This variable holds the promises and is always nil.
|
||||||
|
var pptr unsafe.Pointer
|
||||||
|
|
||||||
|
exptr, err := syscall.BytePtrFromString(execpromises)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(pptr), uintptr(unsafe.Pointer(exptr)), 0)
|
||||||
|
if e != 0 {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// majmin returns major and minor version number for an OpenBSD system.
|
||||||
|
func majmin() (major int, minor int, err error) {
|
||||||
|
var v Utsname
|
||||||
|
err = Uname(&v)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
major, err = strconv.Atoi(string(v.Release[0]))
|
||||||
|
if err != nil {
|
||||||
|
err = errors.New("cannot parse major version number returned by uname")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
minor, err = strconv.Atoi(string(v.Release[2]))
|
||||||
|
if err != nil {
|
||||||
|
err = errors.New("cannot parse minor version number returned by uname")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// pledgeAvailable checks for availability of the pledge(2) syscall
|
||||||
|
// based on the running OpenBSD version.
|
||||||
|
func pledgeAvailable(maj, min int, execpromises string) error {
|
||||||
|
// If OpenBSD <= 5.9, pledge is not available.
|
||||||
|
if (maj == 5 && min != 9) || maj < 5 {
|
||||||
|
return fmt.Errorf("pledge syscall is not available on OpenBSD %d.%d", maj, min)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If OpenBSD <= 6.2 and execpromises is not empty,
|
||||||
|
// return an error - execpromises is not available before 6.3
|
||||||
|
if (maj < 6 || (maj == 6 && min <= 2)) && execpromises != "" {
|
||||||
|
return fmt.Errorf("cannot use execpromises on OpenBSD %d.%d", maj, min)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
44
vendor/golang.org/x/sys/unix/openbsd_unveil.go
generated
vendored
Normal file
44
vendor/golang.org/x/sys/unix/openbsd_unveil.go
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build openbsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Unveil implements the unveil syscall.
|
||||||
|
// For more information see unveil(2).
|
||||||
|
// Note that the special case of blocking further
|
||||||
|
// unveil calls is handled by UnveilBlock.
|
||||||
|
func Unveil(path string, flags string) error {
|
||||||
|
pathPtr, err := syscall.BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
flagsPtr, err := syscall.BytePtrFromString(flags)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(unsafe.Pointer(pathPtr)), uintptr(unsafe.Pointer(flagsPtr)), 0)
|
||||||
|
if e != 0 {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnveilBlock blocks future unveil calls.
|
||||||
|
// For more information see unveil(2).
|
||||||
|
func UnveilBlock() error {
|
||||||
|
// Both pointers must be nil.
|
||||||
|
var pathUnsafe, flagsUnsafe unsafe.Pointer
|
||||||
|
_, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(pathUnsafe), uintptr(flagsUnsafe), 0)
|
||||||
|
if e != 0 {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
15
vendor/golang.org/x/sys/unix/pagesize_unix.go
generated
vendored
Normal file
15
vendor/golang.org/x/sys/unix/pagesize_unix.go
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
// For Unix, get the pagesize from the runtime.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func Getpagesize() int {
|
||||||
|
return syscall.Getpagesize()
|
||||||
|
}
|
||||||
30
vendor/golang.org/x/sys/unix/race.go
generated
vendored
Normal file
30
vendor/golang.org/x/sys/unix/race.go
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright 2012 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build darwin,race linux,race freebsd,race
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
const raceenabled = true
|
||||||
|
|
||||||
|
func raceAcquire(addr unsafe.Pointer) {
|
||||||
|
runtime.RaceAcquire(addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func raceReleaseMerge(addr unsafe.Pointer) {
|
||||||
|
runtime.RaceReleaseMerge(addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func raceReadRange(addr unsafe.Pointer, len int) {
|
||||||
|
runtime.RaceReadRange(addr, len)
|
||||||
|
}
|
||||||
|
|
||||||
|
func raceWriteRange(addr unsafe.Pointer, len int) {
|
||||||
|
runtime.RaceWriteRange(addr, len)
|
||||||
|
}
|
||||||
25
vendor/golang.org/x/sys/unix/race0.go
generated
vendored
Normal file
25
vendor/golang.org/x/sys/unix/race0.go
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright 2012 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
const raceenabled = false
|
||||||
|
|
||||||
|
func raceAcquire(addr unsafe.Pointer) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func raceReleaseMerge(addr unsafe.Pointer) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func raceReadRange(addr unsafe.Pointer, len int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func raceWriteRange(addr unsafe.Pointer, len int) {
|
||||||
|
}
|
||||||
36
vendor/golang.org/x/sys/unix/sockcmsg_linux.go
generated
vendored
Normal file
36
vendor/golang.org/x/sys/unix/sockcmsg_linux.go
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
// Copyright 2011 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Socket control messages
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
// UnixCredentials encodes credentials into a socket control message
|
||||||
|
// for sending to another process. This can be used for
|
||||||
|
// authentication.
|
||||||
|
func UnixCredentials(ucred *Ucred) []byte {
|
||||||
|
b := make([]byte, CmsgSpace(SizeofUcred))
|
||||||
|
h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
|
||||||
|
h.Level = SOL_SOCKET
|
||||||
|
h.Type = SCM_CREDENTIALS
|
||||||
|
h.SetLen(CmsgLen(SizeofUcred))
|
||||||
|
*((*Ucred)(cmsgData(h))) = *ucred
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseUnixCredentials decodes a socket control message that contains
|
||||||
|
// credentials in a Ucred structure. To receive such a message, the
|
||||||
|
// SO_PASSCRED option must be enabled on the socket.
|
||||||
|
func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) {
|
||||||
|
if m.Header.Level != SOL_SOCKET {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
if m.Header.Type != SCM_CREDENTIALS {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0]))
|
||||||
|
return &ucred, nil
|
||||||
|
}
|
||||||
117
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
generated
vendored
Normal file
117
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
generated
vendored
Normal file
|
|
@ -0,0 +1,117 @@
|
||||||
|
// Copyright 2011 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
// Socket control messages
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Round the length of a raw sockaddr up to align it properly.
|
||||||
|
func cmsgAlignOf(salen int) int {
|
||||||
|
salign := SizeofPtr
|
||||||
|
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "darwin", "dragonfly", "solaris":
|
||||||
|
// NOTE: It seems like 64-bit Darwin, DragonFly BSD and
|
||||||
|
// Solaris kernels still require 32-bit aligned access to
|
||||||
|
// network subsystem.
|
||||||
|
if SizeofPtr == 8 {
|
||||||
|
salign = 4
|
||||||
|
}
|
||||||
|
case "netbsd", "openbsd":
|
||||||
|
// NetBSD and OpenBSD armv7 require 64-bit alignment.
|
||||||
|
if runtime.GOARCH == "arm" {
|
||||||
|
salign = 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (salen + salign - 1) & ^(salign - 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CmsgLen returns the value to store in the Len field of the Cmsghdr
|
||||||
|
// structure, taking into account any necessary alignment.
|
||||||
|
func CmsgLen(datalen int) int {
|
||||||
|
return cmsgAlignOf(SizeofCmsghdr) + datalen
|
||||||
|
}
|
||||||
|
|
||||||
|
// CmsgSpace returns the number of bytes an ancillary element with
|
||||||
|
// payload of the passed data length occupies.
|
||||||
|
func CmsgSpace(datalen int) int {
|
||||||
|
return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen)
|
||||||
|
}
|
||||||
|
|
||||||
|
func cmsgData(h *Cmsghdr) unsafe.Pointer {
|
||||||
|
return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SocketControlMessage represents a socket control message.
|
||||||
|
type SocketControlMessage struct {
|
||||||
|
Header Cmsghdr
|
||||||
|
Data []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseSocketControlMessage parses b as an array of socket control
|
||||||
|
// messages.
|
||||||
|
func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) {
|
||||||
|
var msgs []SocketControlMessage
|
||||||
|
i := 0
|
||||||
|
for i+CmsgLen(0) <= len(b) {
|
||||||
|
h, dbuf, err := socketControlMessageHeaderAndData(b[i:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
m := SocketControlMessage{Header: *h, Data: dbuf}
|
||||||
|
msgs = append(msgs, m)
|
||||||
|
i += cmsgAlignOf(int(h.Len))
|
||||||
|
}
|
||||||
|
return msgs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) {
|
||||||
|
h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
|
||||||
|
if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) {
|
||||||
|
return nil, nil, EINVAL
|
||||||
|
}
|
||||||
|
return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnixRights encodes a set of open file descriptors into a socket
|
||||||
|
// control message for sending to another process.
|
||||||
|
func UnixRights(fds ...int) []byte {
|
||||||
|
datalen := len(fds) * 4
|
||||||
|
b := make([]byte, CmsgSpace(datalen))
|
||||||
|
h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
|
||||||
|
h.Level = SOL_SOCKET
|
||||||
|
h.Type = SCM_RIGHTS
|
||||||
|
h.SetLen(CmsgLen(datalen))
|
||||||
|
data := cmsgData(h)
|
||||||
|
for _, fd := range fds {
|
||||||
|
*(*int32)(data) = int32(fd)
|
||||||
|
data = unsafe.Pointer(uintptr(data) + 4)
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseUnixRights decodes a socket control message that contains an
|
||||||
|
// integer array of open file descriptors from another process.
|
||||||
|
func ParseUnixRights(m *SocketControlMessage) ([]int, error) {
|
||||||
|
if m.Header.Level != SOL_SOCKET {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
if m.Header.Type != SCM_RIGHTS {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
fds := make([]int, len(m.Data)>>2)
|
||||||
|
for i, j := 0, 0; i < len(m.Data); i += 4 {
|
||||||
|
fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i])))
|
||||||
|
j++
|
||||||
|
}
|
||||||
|
return fds, nil
|
||||||
|
}
|
||||||
26
vendor/golang.org/x/sys/unix/str.go
generated
vendored
Normal file
26
vendor/golang.org/x/sys/unix/str.go
generated
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
func itoa(val int) string { // do it here rather than with fmt to avoid dependency
|
||||||
|
if val < 0 {
|
||||||
|
return "-" + uitoa(uint(-val))
|
||||||
|
}
|
||||||
|
return uitoa(uint(val))
|
||||||
|
}
|
||||||
|
|
||||||
|
func uitoa(val uint) string {
|
||||||
|
var buf [32]byte // big enough for int64
|
||||||
|
i := len(buf) - 1
|
||||||
|
for val >= 10 {
|
||||||
|
buf[i] = byte(val%10 + '0')
|
||||||
|
i--
|
||||||
|
val /= 10
|
||||||
|
}
|
||||||
|
buf[i] = byte(val + '0')
|
||||||
|
return string(buf[i:])
|
||||||
|
}
|
||||||
54
vendor/golang.org/x/sys/unix/syscall.go
generated
vendored
Normal file
54
vendor/golang.org/x/sys/unix/syscall.go
generated
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
// Package unix contains an interface to the low-level operating system
|
||||||
|
// primitives. OS details vary depending on the underlying system, and
|
||||||
|
// by default, godoc will display OS-specific documentation for the current
|
||||||
|
// system. If you want godoc to display OS documentation for another
|
||||||
|
// system, set $GOOS and $GOARCH to the desired system. For example, if
|
||||||
|
// you want to view documentation for freebsd/arm on linux/amd64, set $GOOS
|
||||||
|
// to freebsd and $GOARCH to arm.
|
||||||
|
//
|
||||||
|
// The primary use of this package is inside other packages that provide a more
|
||||||
|
// portable interface to the system, such as "os", "time" and "net". Use
|
||||||
|
// those packages rather than this one if you can.
|
||||||
|
//
|
||||||
|
// For details of the functions and data types in this package consult
|
||||||
|
// the manuals for the appropriate operating system.
|
||||||
|
//
|
||||||
|
// These calls return err == nil to indicate success; otherwise
|
||||||
|
// err represents an operating system error describing the failure and
|
||||||
|
// holds a value of type syscall.Errno.
|
||||||
|
package unix // import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
import "strings"
|
||||||
|
|
||||||
|
// ByteSliceFromString returns a NUL-terminated slice of bytes
|
||||||
|
// containing the text of s. If s contains a NUL byte at any
|
||||||
|
// location, it returns (nil, EINVAL).
|
||||||
|
func ByteSliceFromString(s string) ([]byte, error) {
|
||||||
|
if strings.IndexByte(s, 0) != -1 {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
a := make([]byte, len(s)+1)
|
||||||
|
copy(a, s)
|
||||||
|
return a, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BytePtrFromString returns a pointer to a NUL-terminated array of
|
||||||
|
// bytes containing the text of s. If s contains a NUL byte at any
|
||||||
|
// location, it returns (nil, EINVAL).
|
||||||
|
func BytePtrFromString(s string) (*byte, error) {
|
||||||
|
a, err := ByteSliceFromString(s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &a[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Single-word zero for use when we need a valid pointer to 0 bytes.
|
||||||
|
// See mkunix.pl.
|
||||||
|
var _zero uintptr
|
||||||
547
vendor/golang.org/x/sys/unix/syscall_aix.go
generated
vendored
Normal file
547
vendor/golang.org/x/sys/unix/syscall_aix.go
generated
vendored
Normal file
|
|
@ -0,0 +1,547 @@
|
||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix
|
||||||
|
|
||||||
|
// Aix system calls.
|
||||||
|
// This file is compiled as ordinary Go code,
|
||||||
|
// but it is also input to mksyscall,
|
||||||
|
// which parses the //sys lines and generates system call stubs.
|
||||||
|
// Note that sometimes we use a lowercase //sys name and
|
||||||
|
// wrap it in our own nicer implementation.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wrapped
|
||||||
|
*/
|
||||||
|
|
||||||
|
//sys utimes(path string, times *[2]Timeval) (err error)
|
||||||
|
func Utimes(path string, tv []Timeval) error {
|
||||||
|
if len(tv) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error)
|
||||||
|
func UtimesNano(path string, ts []Timespec) error {
|
||||||
|
if len(ts) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error {
|
||||||
|
if ts == nil {
|
||||||
|
return utimensat(dirfd, path, nil, flags)
|
||||||
|
}
|
||||||
|
if len(ts) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
if sa.Port < 0 || sa.Port > 0xFFFF {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Family = AF_INET
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
|
||||||
|
p[0] = byte(sa.Port >> 8)
|
||||||
|
p[1] = byte(sa.Port)
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.raw.Addr[i] = sa.Addr[i]
|
||||||
|
}
|
||||||
|
return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
if sa.Port < 0 || sa.Port > 0xFFFF {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Family = AF_INET6
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
|
||||||
|
p[0] = byte(sa.Port >> 8)
|
||||||
|
p[1] = byte(sa.Port)
|
||||||
|
sa.raw.Scope_id = sa.ZoneId
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.raw.Addr[i] = sa.Addr[i]
|
||||||
|
}
|
||||||
|
return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
name := sa.Name
|
||||||
|
n := len(name)
|
||||||
|
if n > len(sa.raw.Path) {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
if n == len(sa.raw.Path) && name[0] != '@' {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Family = AF_UNIX
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
sa.raw.Path[i] = uint8(name[i])
|
||||||
|
}
|
||||||
|
// length is family (uint16), name, NUL.
|
||||||
|
sl := _Socklen(2)
|
||||||
|
if n > 0 {
|
||||||
|
sl += _Socklen(n) + 1
|
||||||
|
}
|
||||||
|
if sa.raw.Path[0] == '@' {
|
||||||
|
sa.raw.Path[0] = 0
|
||||||
|
// Don't count trailing NUL for abstract address.
|
||||||
|
sl--
|
||||||
|
}
|
||||||
|
|
||||||
|
return unsafe.Pointer(&sa.raw), sl, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Getsockname(fd int) (sa Sockaddr, err error) {
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
var len _Socklen = SizeofSockaddrAny
|
||||||
|
if err = getsockname(fd, &rsa, &len); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return anyToSockaddr(fd, &rsa)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys getcwd(buf []byte) (err error)
|
||||||
|
|
||||||
|
const ImplementsGetwd = true
|
||||||
|
|
||||||
|
func Getwd() (ret string, err error) {
|
||||||
|
for len := uint64(4096); ; len *= 2 {
|
||||||
|
b := make([]byte, len)
|
||||||
|
err := getcwd(b)
|
||||||
|
if err == nil {
|
||||||
|
i := 0
|
||||||
|
for b[i] != 0 {
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
return string(b[0:i]), nil
|
||||||
|
}
|
||||||
|
if err != ERANGE {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Getcwd(buf []byte) (n int, err error) {
|
||||||
|
err = getcwd(buf)
|
||||||
|
if err == nil {
|
||||||
|
i := 0
|
||||||
|
for buf[i] != 0 {
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
n = i + 1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Getgroups() (gids []int, err error) {
|
||||||
|
n, err := getgroups(0, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if n == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sanity check group count. Max is 16 on BSD.
|
||||||
|
if n < 0 || n > 1000 {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
a := make([]_Gid_t, n)
|
||||||
|
n, err = getgroups(n, &a[0])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
gids = make([]int, n)
|
||||||
|
for i, v := range a[0:n] {
|
||||||
|
gids[i] = int(v)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Setgroups(gids []int) (err error) {
|
||||||
|
if len(gids) == 0 {
|
||||||
|
return setgroups(0, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
a := make([]_Gid_t, len(gids))
|
||||||
|
for i, v := range gids {
|
||||||
|
a[i] = _Gid_t(v)
|
||||||
|
}
|
||||||
|
return setgroups(len(a), &a[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Socket
|
||||||
|
*/
|
||||||
|
|
||||||
|
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||||
|
|
||||||
|
func Accept(fd int) (nfd int, sa Sockaddr, err error) {
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
var len _Socklen = SizeofSockaddrAny
|
||||||
|
nfd, err = accept(fd, &rsa, &len)
|
||||||
|
if nfd == -1 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
sa, err = anyToSockaddr(fd, &rsa)
|
||||||
|
if err != nil {
|
||||||
|
Close(nfd)
|
||||||
|
nfd = 0
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
|
||||||
|
// Recvmsg not implemented on AIX
|
||||||
|
sa := new(SockaddrUnix)
|
||||||
|
return -1, -1, -1, sa, ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
|
||||||
|
_, err = SendmsgN(fd, p, oob, to, flags)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
|
||||||
|
// SendmsgN not implemented on AIX
|
||||||
|
return -1, ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
|
switch rsa.Addr.Family {
|
||||||
|
|
||||||
|
case AF_UNIX:
|
||||||
|
pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
|
||||||
|
sa := new(SockaddrUnix)
|
||||||
|
|
||||||
|
// Some versions of AIX have a bug in getsockname (see IV78655).
|
||||||
|
// We can't rely on sa.Len being set correctly.
|
||||||
|
n := SizeofSockaddrUnix - 3 // subtract leading Family, Len, terminating NUL.
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
if pp.Path[i] == 0 {
|
||||||
|
n = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
|
||||||
|
sa.Name = string(bytes)
|
||||||
|
return sa, nil
|
||||||
|
|
||||||
|
case AF_INET:
|
||||||
|
pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
|
||||||
|
sa := new(SockaddrInet4)
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&pp.Port))
|
||||||
|
sa.Port = int(p[0])<<8 + int(p[1])
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.Addr[i] = pp.Addr[i]
|
||||||
|
}
|
||||||
|
return sa, nil
|
||||||
|
|
||||||
|
case AF_INET6:
|
||||||
|
pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
|
||||||
|
sa := new(SockaddrInet6)
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&pp.Port))
|
||||||
|
sa.Port = int(p[0])<<8 + int(p[1])
|
||||||
|
sa.ZoneId = pp.Scope_id
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.Addr[i] = pp.Addr[i]
|
||||||
|
}
|
||||||
|
return sa, nil
|
||||||
|
}
|
||||||
|
return nil, EAFNOSUPPORT
|
||||||
|
}
|
||||||
|
|
||||||
|
func Gettimeofday(tv *Timeval) (err error) {
|
||||||
|
err = gettimeofday(tv, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
if raceenabled {
|
||||||
|
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||||
|
}
|
||||||
|
return sendfile(outfd, infd, offset, count)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
return -1, ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys getdirent(fd int, buf []byte) (n int, err error)
|
||||||
|
func ReadDirent(fd int, buf []byte) (n int, err error) {
|
||||||
|
return getdirent(fd, buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys wait4(pid Pid_t, status *_C_int, options int, rusage *Rusage) (wpid Pid_t, err error)
|
||||||
|
func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
|
||||||
|
var status _C_int
|
||||||
|
var r Pid_t
|
||||||
|
err = ERESTART
|
||||||
|
// AIX wait4 may return with ERESTART errno, while the processus is still
|
||||||
|
// active.
|
||||||
|
for err == ERESTART {
|
||||||
|
r, err = wait4(Pid_t(pid), &status, options, rusage)
|
||||||
|
}
|
||||||
|
wpid = int(r)
|
||||||
|
if wstatus != nil {
|
||||||
|
*wstatus = WaitStatus(status)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wait
|
||||||
|
*/
|
||||||
|
|
||||||
|
type WaitStatus uint32
|
||||||
|
|
||||||
|
func (w WaitStatus) Stopped() bool { return w&0x40 != 0 }
|
||||||
|
func (w WaitStatus) StopSignal() Signal {
|
||||||
|
if !w.Stopped() {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return Signal(w>>8) & 0xFF
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) Exited() bool { return w&0xFF == 0 }
|
||||||
|
func (w WaitStatus) ExitStatus() int {
|
||||||
|
if !w.Exited() {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return int((w >> 8) & 0xFF)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) Signaled() bool { return w&0x40 == 0 && w&0xFF != 0 }
|
||||||
|
func (w WaitStatus) Signal() Signal {
|
||||||
|
if !w.Signaled() {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return Signal(w>>16) & 0xFF
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) Continued() bool { return w&0x01000000 != 0 }
|
||||||
|
|
||||||
|
func (w WaitStatus) CoreDump() bool { return w&0x200 != 0 }
|
||||||
|
|
||||||
|
func (w WaitStatus) TrapCause() int { return -1 }
|
||||||
|
|
||||||
|
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
||||||
|
|
||||||
|
// ioctl itself should not be exposed directly, but additional get/set
|
||||||
|
// functions for specific types are permissible.
|
||||||
|
|
||||||
|
// IoctlSetInt performs an ioctl operation which sets an integer value
|
||||||
|
// on fd, using the specified request number.
|
||||||
|
func IoctlSetInt(fd int, req uint, value int) error {
|
||||||
|
return ioctl(fd, req, uintptr(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
|
||||||
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func ioctlSetTermios(fd int, req uint, value *Termios) error {
|
||||||
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlGetInt performs an ioctl operation which gets an integer value
|
||||||
|
// from fd, using the specified request number.
|
||||||
|
func IoctlGetInt(fd int, req uint) (int, error) {
|
||||||
|
var value int
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
|
||||||
|
var value Winsize
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
|
||||||
|
var value Termios
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// fcntl must never be called with cmd=F_DUP2FD because it doesn't work on AIX
|
||||||
|
// There is no way to create a custom fcntl and to keep //sys fcntl easily,
|
||||||
|
// Therefore, the programmer must call dup2 instead of fcntl in this case.
|
||||||
|
|
||||||
|
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
|
||||||
|
//sys FcntlInt(fd uintptr, cmd int, arg int) (r int,err error) = fcntl
|
||||||
|
|
||||||
|
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
||||||
|
//sys FcntlFlock(fd uintptr, cmd int, lk *Flock_t) (err error) = fcntl
|
||||||
|
|
||||||
|
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Direct access
|
||||||
|
*/
|
||||||
|
|
||||||
|
//sys Acct(path string) (err error)
|
||||||
|
//sys Chdir(path string) (err error)
|
||||||
|
//sys Chroot(path string) (err error)
|
||||||
|
//sys Close(fd int) (err error)
|
||||||
|
//sys Dup(oldfd int) (fd int, err error)
|
||||||
|
//sys Exit(code int)
|
||||||
|
//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
|
||||||
|
//sys Fchdir(fd int) (err error)
|
||||||
|
//sys Fchmod(fd int, mode uint32) (err error)
|
||||||
|
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
|
||||||
|
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
|
||||||
|
//sys Fdatasync(fd int) (err error)
|
||||||
|
//sys Fsync(fd int) (err error)
|
||||||
|
// readdir_r
|
||||||
|
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||||
|
|
||||||
|
//sys Getpgrp() (pid int)
|
||||||
|
|
||||||
|
//sysnb Getpid() (pid int)
|
||||||
|
//sysnb Getppid() (ppid int)
|
||||||
|
//sys Getpriority(which int, who int) (prio int, err error)
|
||||||
|
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||||
|
//sysnb Getsid(pid int) (sid int, err error)
|
||||||
|
//sysnb Kill(pid int, sig Signal) (err error)
|
||||||
|
//sys Klogctl(typ int, buf []byte) (n int, err error) = syslog
|
||||||
|
//sys Mkdir(dirfd int, path string, mode uint32) (err error)
|
||||||
|
//sys Mkdirat(dirfd int, path string, mode uint32) (err error)
|
||||||
|
//sys Mkfifo(path string, mode uint32) (err error)
|
||||||
|
//sys Mknod(path string, mode uint32, dev int) (err error)
|
||||||
|
//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
|
||||||
|
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
||||||
|
//sys Open(path string, mode int, perm uint32) (fd int, err error) = open64
|
||||||
|
//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
|
||||||
|
//sys read(fd int, p []byte) (n int, err error)
|
||||||
|
//sys Readlink(path string, buf []byte) (n int, err error)
|
||||||
|
//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error)
|
||||||
|
//sys Setdomainname(p []byte) (err error)
|
||||||
|
//sys Sethostname(p []byte) (err error)
|
||||||
|
//sysnb Setpgid(pid int, pgid int) (err error)
|
||||||
|
//sysnb Setsid() (pid int, err error)
|
||||||
|
//sysnb Settimeofday(tv *Timeval) (err error)
|
||||||
|
|
||||||
|
//sys Setuid(uid int) (err error)
|
||||||
|
//sys Setgid(uid int) (err error)
|
||||||
|
|
||||||
|
//sys Setpriority(which int, who int, prio int) (err error)
|
||||||
|
//sys Statx(dirfd int, path string, flags int, mask int, stat *Statx_t) (err error)
|
||||||
|
//sys Sync()
|
||||||
|
//sysnb Times(tms *Tms) (ticks uintptr, err error)
|
||||||
|
//sysnb Umask(mask int) (oldmask int)
|
||||||
|
//sysnb Uname(buf *Utsname) (err error)
|
||||||
|
//TODO umount
|
||||||
|
// //sys Unmount(target string, flags int) (err error) = umount
|
||||||
|
//sys Unlink(path string) (err error)
|
||||||
|
//sys Unlinkat(dirfd int, path string, flags int) (err error)
|
||||||
|
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
|
||||||
|
//sys write(fd int, p []byte) (n int, err error)
|
||||||
|
//sys readlen(fd int, p *byte, np int) (n int, err error) = read
|
||||||
|
//sys writelen(fd int, p *byte, np int) (n int, err error) = write
|
||||||
|
|
||||||
|
//sys Dup2(oldfd int, newfd int) (err error)
|
||||||
|
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = posix_fadvise64
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
|
//sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = fstatat
|
||||||
|
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
|
//sysnb Getegid() (egid int)
|
||||||
|
//sysnb Geteuid() (euid int)
|
||||||
|
//sysnb Getgid() (gid int)
|
||||||
|
//sysnb Getuid() (uid int)
|
||||||
|
//sys Lchown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Listen(s int, n int) (err error)
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Pause() (err error)
|
||||||
|
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = pread64
|
||||||
|
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = pwrite64
|
||||||
|
//TODO Select
|
||||||
|
// //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
|
||||||
|
//sys Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error)
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error)
|
||||||
|
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||||
|
//sys Shutdown(fd int, how int) (err error)
|
||||||
|
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
|
||||||
|
//sys Stat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Statfs(path string, buf *Statfs_t) (err error)
|
||||||
|
//sys Truncate(path string, length int64) (err error)
|
||||||
|
|
||||||
|
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
|
||||||
|
//sysnb setgroups(n int, list *_Gid_t) (err error)
|
||||||
|
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
|
||||||
|
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
|
||||||
|
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||||
|
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||||
|
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||||
|
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
|
||||||
|
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||||
|
|
||||||
|
var mapper = &mmapper{
|
||||||
|
active: make(map[*byte][]byte),
|
||||||
|
mmap: mmap,
|
||||||
|
munmap: munmap,
|
||||||
|
}
|
||||||
|
|
||||||
|
func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
|
||||||
|
return mapper.Mmap(fd, offset, length, prot, flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Munmap(b []byte) (err error) {
|
||||||
|
return mapper.Munmap(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys Madvise(b []byte, advice int) (err error)
|
||||||
|
//sys Mprotect(b []byte, prot int) (err error)
|
||||||
|
//sys Mlock(b []byte) (err error)
|
||||||
|
//sys Mlockall(flags int) (err error)
|
||||||
|
//sys Msync(b []byte, flags int) (err error)
|
||||||
|
//sys Munlock(b []byte) (err error)
|
||||||
|
//sys Munlockall() (err error)
|
||||||
|
|
||||||
|
//sysnb pipe(p *[2]_C_int) (err error)
|
||||||
|
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err = pipe(&pp)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
|
||||||
|
|
||||||
|
func Poll(fds []PollFd, timeout int) (n int, err error) {
|
||||||
|
if len(fds) == 0 {
|
||||||
|
return poll(nil, 0, timeout)
|
||||||
|
}
|
||||||
|
return poll(&fds[0], len(fds), timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys gettimeofday(tv *Timeval, tzp *Timezone) (err error)
|
||||||
|
//sysnb Time(t *Time_t) (tt Time_t, err error)
|
||||||
|
//sys Utime(path string, buf *Utimbuf) (err error)
|
||||||
34
vendor/golang.org/x/sys/unix/syscall_aix_ppc.go
generated
vendored
Normal file
34
vendor/golang.org/x/sys/unix/syscall_aix_ppc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix
|
||||||
|
// +build ppc
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64
|
||||||
|
//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64
|
||||||
|
//sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64
|
||||||
|
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
|
||||||
|
|
||||||
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
|
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTimeval(sec, usec int64) Timeval {
|
||||||
|
return Timeval{Sec: int32(sec), Usec: int32(usec)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
34
vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go
generated
vendored
Normal file
34
vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix
|
||||||
|
// +build ppc64
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
|
||||||
|
//sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
|
||||||
|
//sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek
|
||||||
|
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64
|
||||||
|
|
||||||
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
|
return Timespec{Sec: sec, Nsec: nsec}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTimeval(sec, usec int64) Timeval {
|
||||||
|
return Timeval{Sec: int64(sec), Usec: int32(usec)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
624
vendor/golang.org/x/sys/unix/syscall_bsd.go
generated
vendored
Normal file
624
vendor/golang.org/x/sys/unix/syscall_bsd.go
generated
vendored
Normal file
|
|
@ -0,0 +1,624 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd netbsd openbsd
|
||||||
|
|
||||||
|
// BSD system call wrappers shared by *BSD based systems
|
||||||
|
// including OS X (Darwin) and FreeBSD. Like the other
|
||||||
|
// syscall_*.go files it is compiled as Go code but also
|
||||||
|
// used as input to mksyscall which parses the //sys
|
||||||
|
// lines and generates system call stubs.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wrapped
|
||||||
|
*/
|
||||||
|
|
||||||
|
//sysnb getgroups(ngid int, gid *_Gid_t) (n int, err error)
|
||||||
|
//sysnb setgroups(ngid int, gid *_Gid_t) (err error)
|
||||||
|
|
||||||
|
func Getgroups() (gids []int, err error) {
|
||||||
|
n, err := getgroups(0, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if n == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sanity check group count. Max is 16 on BSD.
|
||||||
|
if n < 0 || n > 1000 {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
a := make([]_Gid_t, n)
|
||||||
|
n, err = getgroups(n, &a[0])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
gids = make([]int, n)
|
||||||
|
for i, v := range a[0:n] {
|
||||||
|
gids[i] = int(v)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Setgroups(gids []int) (err error) {
|
||||||
|
if len(gids) == 0 {
|
||||||
|
return setgroups(0, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
a := make([]_Gid_t, len(gids))
|
||||||
|
for i, v := range gids {
|
||||||
|
a[i] = _Gid_t(v)
|
||||||
|
}
|
||||||
|
return setgroups(len(a), &a[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
func ReadDirent(fd int, buf []byte) (n int, err error) {
|
||||||
|
// Final argument is (basep *uintptr) and the syscall doesn't take nil.
|
||||||
|
// 64 bits should be enough. (32 bits isn't even on 386). Since the
|
||||||
|
// actual system call is getdirentries64, 64 is a good guess.
|
||||||
|
// TODO(rsc): Can we use a single global basep for all calls?
|
||||||
|
var base = (*uintptr)(unsafe.Pointer(new(uint64)))
|
||||||
|
return Getdirentries(fd, buf, base)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait status is 7 bits at bottom, either 0 (exited),
|
||||||
|
// 0x7F (stopped), or a signal number that caused an exit.
|
||||||
|
// The 0x80 bit is whether there was a core dump.
|
||||||
|
// An extra number (exit code, signal causing a stop)
|
||||||
|
// is in the high bits.
|
||||||
|
|
||||||
|
type WaitStatus uint32
|
||||||
|
|
||||||
|
const (
|
||||||
|
mask = 0x7F
|
||||||
|
core = 0x80
|
||||||
|
shift = 8
|
||||||
|
|
||||||
|
exited = 0
|
||||||
|
stopped = 0x7F
|
||||||
|
)
|
||||||
|
|
||||||
|
func (w WaitStatus) Exited() bool { return w&mask == exited }
|
||||||
|
|
||||||
|
func (w WaitStatus) ExitStatus() int {
|
||||||
|
if w&mask != exited {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return int(w >> shift)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 }
|
||||||
|
|
||||||
|
func (w WaitStatus) Signal() syscall.Signal {
|
||||||
|
sig := syscall.Signal(w & mask)
|
||||||
|
if sig == stopped || sig == 0 {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return sig
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 }
|
||||||
|
|
||||||
|
func (w WaitStatus) Stopped() bool { return w&mask == stopped && syscall.Signal(w>>shift) != SIGSTOP }
|
||||||
|
|
||||||
|
func (w WaitStatus) Continued() bool { return w&mask == stopped && syscall.Signal(w>>shift) == SIGSTOP }
|
||||||
|
|
||||||
|
func (w WaitStatus) StopSignal() syscall.Signal {
|
||||||
|
if !w.Stopped() {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return syscall.Signal(w>>shift) & 0xFF
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WaitStatus) TrapCause() int { return -1 }
|
||||||
|
|
||||||
|
//sys wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error)
|
||||||
|
|
||||||
|
func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
|
||||||
|
var status _C_int
|
||||||
|
wpid, err = wait4(pid, &status, options, rusage)
|
||||||
|
if wstatus != nil {
|
||||||
|
*wstatus = WaitStatus(status)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
|
||||||
|
//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||||
|
//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
|
||||||
|
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
|
||||||
|
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
|
//sys Shutdown(s int, how int) (err error)
|
||||||
|
|
||||||
|
func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
if sa.Port < 0 || sa.Port > 0xFFFF {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Len = SizeofSockaddrInet4
|
||||||
|
sa.raw.Family = AF_INET
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
|
||||||
|
p[0] = byte(sa.Port >> 8)
|
||||||
|
p[1] = byte(sa.Port)
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.raw.Addr[i] = sa.Addr[i]
|
||||||
|
}
|
||||||
|
return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
if sa.Port < 0 || sa.Port > 0xFFFF {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Len = SizeofSockaddrInet6
|
||||||
|
sa.raw.Family = AF_INET6
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
|
||||||
|
p[0] = byte(sa.Port >> 8)
|
||||||
|
p[1] = byte(sa.Port)
|
||||||
|
sa.raw.Scope_id = sa.ZoneId
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.raw.Addr[i] = sa.Addr[i]
|
||||||
|
}
|
||||||
|
return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
name := sa.Name
|
||||||
|
n := len(name)
|
||||||
|
if n >= len(sa.raw.Path) || n == 0 {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Len = byte(3 + n) // 2 for Family, Len; 1 for NUL
|
||||||
|
sa.raw.Family = AF_UNIX
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
sa.raw.Path[i] = int8(name[i])
|
||||||
|
}
|
||||||
|
return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sa *SockaddrDatalink) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
if sa.Index == 0 {
|
||||||
|
return nil, 0, EINVAL
|
||||||
|
}
|
||||||
|
sa.raw.Len = sa.Len
|
||||||
|
sa.raw.Family = AF_LINK
|
||||||
|
sa.raw.Index = sa.Index
|
||||||
|
sa.raw.Type = sa.Type
|
||||||
|
sa.raw.Nlen = sa.Nlen
|
||||||
|
sa.raw.Alen = sa.Alen
|
||||||
|
sa.raw.Slen = sa.Slen
|
||||||
|
for i := 0; i < len(sa.raw.Data); i++ {
|
||||||
|
sa.raw.Data[i] = sa.Data[i]
|
||||||
|
}
|
||||||
|
return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
|
switch rsa.Addr.Family {
|
||||||
|
case AF_LINK:
|
||||||
|
pp := (*RawSockaddrDatalink)(unsafe.Pointer(rsa))
|
||||||
|
sa := new(SockaddrDatalink)
|
||||||
|
sa.Len = pp.Len
|
||||||
|
sa.Family = pp.Family
|
||||||
|
sa.Index = pp.Index
|
||||||
|
sa.Type = pp.Type
|
||||||
|
sa.Nlen = pp.Nlen
|
||||||
|
sa.Alen = pp.Alen
|
||||||
|
sa.Slen = pp.Slen
|
||||||
|
for i := 0; i < len(sa.Data); i++ {
|
||||||
|
sa.Data[i] = pp.Data[i]
|
||||||
|
}
|
||||||
|
return sa, nil
|
||||||
|
|
||||||
|
case AF_UNIX:
|
||||||
|
pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
|
||||||
|
if pp.Len < 2 || pp.Len > SizeofSockaddrUnix {
|
||||||
|
return nil, EINVAL
|
||||||
|
}
|
||||||
|
sa := new(SockaddrUnix)
|
||||||
|
|
||||||
|
// Some BSDs include the trailing NUL in the length, whereas
|
||||||
|
// others do not. Work around this by subtracting the leading
|
||||||
|
// family and len. The path is then scanned to see if a NUL
|
||||||
|
// terminator still exists within the length.
|
||||||
|
n := int(pp.Len) - 2 // subtract leading Family, Len
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
if pp.Path[i] == 0 {
|
||||||
|
// found early NUL; assume Len included the NUL
|
||||||
|
// or was overestimating.
|
||||||
|
n = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
|
||||||
|
sa.Name = string(bytes)
|
||||||
|
return sa, nil
|
||||||
|
|
||||||
|
case AF_INET:
|
||||||
|
pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
|
||||||
|
sa := new(SockaddrInet4)
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&pp.Port))
|
||||||
|
sa.Port = int(p[0])<<8 + int(p[1])
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.Addr[i] = pp.Addr[i]
|
||||||
|
}
|
||||||
|
return sa, nil
|
||||||
|
|
||||||
|
case AF_INET6:
|
||||||
|
pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
|
||||||
|
sa := new(SockaddrInet6)
|
||||||
|
p := (*[2]byte)(unsafe.Pointer(&pp.Port))
|
||||||
|
sa.Port = int(p[0])<<8 + int(p[1])
|
||||||
|
sa.ZoneId = pp.Scope_id
|
||||||
|
for i := 0; i < len(sa.Addr); i++ {
|
||||||
|
sa.Addr[i] = pp.Addr[i]
|
||||||
|
}
|
||||||
|
return sa, nil
|
||||||
|
}
|
||||||
|
return nil, EAFNOSUPPORT
|
||||||
|
}
|
||||||
|
|
||||||
|
func Accept(fd int) (nfd int, sa Sockaddr, err error) {
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
var len _Socklen = SizeofSockaddrAny
|
||||||
|
nfd, err = accept(fd, &rsa, &len)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if runtime.GOOS == "darwin" && len == 0 {
|
||||||
|
// Accepted socket has no address.
|
||||||
|
// This is likely due to a bug in xnu kernels,
|
||||||
|
// where instead of ECONNABORTED error socket
|
||||||
|
// is accepted, but has no address.
|
||||||
|
Close(nfd)
|
||||||
|
return 0, nil, ECONNABORTED
|
||||||
|
}
|
||||||
|
sa, err = anyToSockaddr(fd, &rsa)
|
||||||
|
if err != nil {
|
||||||
|
Close(nfd)
|
||||||
|
nfd = 0
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Getsockname(fd int) (sa Sockaddr, err error) {
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
var len _Socklen = SizeofSockaddrAny
|
||||||
|
if err = getsockname(fd, &rsa, &len); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// TODO(jsing): DragonFly has a "bug" (see issue 3349), which should be
|
||||||
|
// reported upstream.
|
||||||
|
if runtime.GOOS == "dragonfly" && rsa.Addr.Family == AF_UNSPEC && rsa.Addr.Len == 0 {
|
||||||
|
rsa.Addr.Family = AF_UNIX
|
||||||
|
rsa.Addr.Len = SizeofSockaddrUnix
|
||||||
|
}
|
||||||
|
return anyToSockaddr(fd, &rsa)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||||
|
|
||||||
|
// GetsockoptString returns the string value of the socket option opt for the
|
||||||
|
// socket associated with fd at the given socket level.
|
||||||
|
func GetsockoptString(fd, level, opt int) (string, error) {
|
||||||
|
buf := make([]byte, 256)
|
||||||
|
vallen := _Socklen(len(buf))
|
||||||
|
err := getsockopt(fd, level, opt, unsafe.Pointer(&buf[0]), &vallen)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return string(buf[:vallen-1]), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||||
|
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
|
||||||
|
func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
|
||||||
|
var msg Msghdr
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
msg.Name = (*byte)(unsafe.Pointer(&rsa))
|
||||||
|
msg.Namelen = uint32(SizeofSockaddrAny)
|
||||||
|
var iov Iovec
|
||||||
|
if len(p) > 0 {
|
||||||
|
iov.Base = (*byte)(unsafe.Pointer(&p[0]))
|
||||||
|
iov.SetLen(len(p))
|
||||||
|
}
|
||||||
|
var dummy byte
|
||||||
|
if len(oob) > 0 {
|
||||||
|
// receive at least one normal byte
|
||||||
|
if len(p) == 0 {
|
||||||
|
iov.Base = &dummy
|
||||||
|
iov.SetLen(1)
|
||||||
|
}
|
||||||
|
msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
|
||||||
|
msg.SetControllen(len(oob))
|
||||||
|
}
|
||||||
|
msg.Iov = &iov
|
||||||
|
msg.Iovlen = 1
|
||||||
|
if n, err = recvmsg(fd, &msg, flags); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
oobn = int(msg.Controllen)
|
||||||
|
recvflags = int(msg.Flags)
|
||||||
|
// source address is only specified if the socket is unconnected
|
||||||
|
if rsa.Addr.Family != AF_UNSPEC {
|
||||||
|
from, err = anyToSockaddr(fd, &rsa)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
|
|
||||||
|
func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
|
||||||
|
_, err = SendmsgN(fd, p, oob, to, flags)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
|
||||||
|
var ptr unsafe.Pointer
|
||||||
|
var salen _Socklen
|
||||||
|
if to != nil {
|
||||||
|
ptr, salen, err = to.sockaddr()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var msg Msghdr
|
||||||
|
msg.Name = (*byte)(unsafe.Pointer(ptr))
|
||||||
|
msg.Namelen = uint32(salen)
|
||||||
|
var iov Iovec
|
||||||
|
if len(p) > 0 {
|
||||||
|
iov.Base = (*byte)(unsafe.Pointer(&p[0]))
|
||||||
|
iov.SetLen(len(p))
|
||||||
|
}
|
||||||
|
var dummy byte
|
||||||
|
if len(oob) > 0 {
|
||||||
|
// send at least one normal byte
|
||||||
|
if len(p) == 0 {
|
||||||
|
iov.Base = &dummy
|
||||||
|
iov.SetLen(1)
|
||||||
|
}
|
||||||
|
msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
|
||||||
|
msg.SetControllen(len(oob))
|
||||||
|
}
|
||||||
|
msg.Iov = &iov
|
||||||
|
msg.Iovlen = 1
|
||||||
|
if n, err = sendmsg(fd, &msg, flags); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if len(oob) > 0 && len(p) == 0 {
|
||||||
|
n = 0
|
||||||
|
}
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error)
|
||||||
|
|
||||||
|
func Kevent(kq int, changes, events []Kevent_t, timeout *Timespec) (n int, err error) {
|
||||||
|
var change, event unsafe.Pointer
|
||||||
|
if len(changes) > 0 {
|
||||||
|
change = unsafe.Pointer(&changes[0])
|
||||||
|
}
|
||||||
|
if len(events) > 0 {
|
||||||
|
event = unsafe.Pointer(&events[0])
|
||||||
|
}
|
||||||
|
return kevent(kq, change, len(changes), event, len(events), timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
|
||||||
|
|
||||||
|
// sysctlmib translates name to mib number and appends any additional args.
|
||||||
|
func sysctlmib(name string, args ...int) ([]_C_int, error) {
|
||||||
|
// Translate name to mib number.
|
||||||
|
mib, err := nametomib(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, a := range args {
|
||||||
|
mib = append(mib, _C_int(a))
|
||||||
|
}
|
||||||
|
|
||||||
|
return mib, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Sysctl(name string) (string, error) {
|
||||||
|
return SysctlArgs(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SysctlArgs(name string, args ...int) (string, error) {
|
||||||
|
buf, err := SysctlRaw(name, args...)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
n := len(buf)
|
||||||
|
|
||||||
|
// Throw away terminating NUL.
|
||||||
|
if n > 0 && buf[n-1] == '\x00' {
|
||||||
|
n--
|
||||||
|
}
|
||||||
|
return string(buf[0:n]), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SysctlUint32(name string) (uint32, error) {
|
||||||
|
return SysctlUint32Args(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SysctlUint32Args(name string, args ...int) (uint32, error) {
|
||||||
|
mib, err := sysctlmib(name, args...)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
n := uintptr(4)
|
||||||
|
buf := make([]byte, 4)
|
||||||
|
if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if n != 4 {
|
||||||
|
return 0, EIO
|
||||||
|
}
|
||||||
|
return *(*uint32)(unsafe.Pointer(&buf[0])), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SysctlUint64(name string, args ...int) (uint64, error) {
|
||||||
|
mib, err := sysctlmib(name, args...)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
n := uintptr(8)
|
||||||
|
buf := make([]byte, 8)
|
||||||
|
if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if n != 8 {
|
||||||
|
return 0, EIO
|
||||||
|
}
|
||||||
|
return *(*uint64)(unsafe.Pointer(&buf[0])), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SysctlRaw(name string, args ...int) ([]byte, error) {
|
||||||
|
mib, err := sysctlmib(name, args...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find size.
|
||||||
|
n := uintptr(0)
|
||||||
|
if err := sysctl(mib, nil, &n, nil, 0); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if n == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read into buffer of that size.
|
||||||
|
buf := make([]byte, n)
|
||||||
|
if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// The actual call may return less than the original reported required
|
||||||
|
// size so ensure we deal with that.
|
||||||
|
return buf[:n], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys utimes(path string, timeval *[2]Timeval) (err error)
|
||||||
|
|
||||||
|
func Utimes(path string, tv []Timeval) error {
|
||||||
|
if tv == nil {
|
||||||
|
return utimes(path, nil)
|
||||||
|
}
|
||||||
|
if len(tv) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
|
}
|
||||||
|
|
||||||
|
func UtimesNano(path string, ts []Timespec) error {
|
||||||
|
if ts == nil {
|
||||||
|
err := utimensat(AT_FDCWD, path, nil, 0)
|
||||||
|
if err != ENOSYS {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return utimes(path, nil)
|
||||||
|
}
|
||||||
|
if len(ts) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
// Darwin setattrlist can set nanosecond timestamps
|
||||||
|
err := setattrlistTimes(path, ts, 0)
|
||||||
|
if err != ENOSYS {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
|
||||||
|
if err != ENOSYS {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Not as efficient as it could be because Timespec and
|
||||||
|
// Timeval have different types in the different OSes
|
||||||
|
tv := [2]Timeval{
|
||||||
|
NsecToTimeval(TimespecToNsec(ts[0])),
|
||||||
|
NsecToTimeval(TimespecToNsec(ts[1])),
|
||||||
|
}
|
||||||
|
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
|
}
|
||||||
|
|
||||||
|
func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error {
|
||||||
|
if ts == nil {
|
||||||
|
return utimensat(dirfd, path, nil, flags)
|
||||||
|
}
|
||||||
|
if len(ts) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
err := setattrlistTimes(path, ts, flags)
|
||||||
|
if err != ENOSYS {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys futimes(fd int, timeval *[2]Timeval) (err error)
|
||||||
|
|
||||||
|
func Futimes(fd int, tv []Timeval) error {
|
||||||
|
if tv == nil {
|
||||||
|
return futimes(fd, nil)
|
||||||
|
}
|
||||||
|
if len(tv) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
|
||||||
|
|
||||||
|
//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
|
||||||
|
|
||||||
|
func Poll(fds []PollFd, timeout int) (n int, err error) {
|
||||||
|
if len(fds) == 0 {
|
||||||
|
return poll(nil, 0, timeout)
|
||||||
|
}
|
||||||
|
return poll(&fds[0], len(fds), timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: wrap
|
||||||
|
// Acct(name nil-string) (err error)
|
||||||
|
// Gethostuuid(uuid *byte, timeout *Timespec) (err error)
|
||||||
|
// Ptrace(req int, pid int, addr uintptr, data int) (ret uintptr, err error)
|
||||||
|
|
||||||
|
var mapper = &mmapper{
|
||||||
|
active: make(map[*byte][]byte),
|
||||||
|
mmap: mmap,
|
||||||
|
munmap: munmap,
|
||||||
|
}
|
||||||
|
|
||||||
|
func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
|
||||||
|
return mapper.Mmap(fd, offset, length, prot, flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Munmap(b []byte) (err error) {
|
||||||
|
return mapper.Munmap(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys Madvise(b []byte, behav int) (err error)
|
||||||
|
//sys Mlock(b []byte) (err error)
|
||||||
|
//sys Mlockall(flags int) (err error)
|
||||||
|
//sys Mprotect(b []byte, prot int) (err error)
|
||||||
|
//sys Msync(b []byte, flags int) (err error)
|
||||||
|
//sys Munlock(b []byte) (err error)
|
||||||
|
//sys Munlockall() (err error)
|
||||||
689
vendor/golang.org/x/sys/unix/syscall_darwin.go
generated
vendored
Normal file
689
vendor/golang.org/x/sys/unix/syscall_darwin.go
generated
vendored
Normal file
|
|
@ -0,0 +1,689 @@
|
||||||
|
// Copyright 2009,2010 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Darwin system calls.
|
||||||
|
// This file is compiled as ordinary Go code,
|
||||||
|
// but it is also input to mksyscall,
|
||||||
|
// which parses the //sys lines and generates system call stubs.
|
||||||
|
// Note that sometimes we use a lowercase //sys name and wrap
|
||||||
|
// it in our own nicer implementation, either here or in
|
||||||
|
// syscall_bsd.go or syscall_unix.go.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
const ImplementsGetwd = true
|
||||||
|
|
||||||
|
func Getwd() (string, error) {
|
||||||
|
buf := make([]byte, 2048)
|
||||||
|
attrs, err := getAttrList(".", attrList{CommonAttr: attrCmnFullpath}, buf, 0)
|
||||||
|
if err == nil && len(attrs) == 1 && len(attrs[0]) >= 2 {
|
||||||
|
wd := string(attrs[0])
|
||||||
|
// Sanity check that it's an absolute path and ends
|
||||||
|
// in a null byte, which we then strip.
|
||||||
|
if wd[0] == '/' && wd[len(wd)-1] == 0 {
|
||||||
|
return wd[:len(wd)-1], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If pkg/os/getwd.go gets ENOTSUP, it will fall back to the
|
||||||
|
// slow algorithm.
|
||||||
|
return "", ENOTSUP
|
||||||
|
}
|
||||||
|
|
||||||
|
// SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
|
||||||
|
type SockaddrDatalink struct {
|
||||||
|
Len uint8
|
||||||
|
Family uint8
|
||||||
|
Index uint16
|
||||||
|
Type uint8
|
||||||
|
Nlen uint8
|
||||||
|
Alen uint8
|
||||||
|
Slen uint8
|
||||||
|
Data [12]int8
|
||||||
|
raw RawSockaddrDatalink
|
||||||
|
}
|
||||||
|
|
||||||
|
// Translate "kern.hostname" to []_C_int{0,1,2,3}.
|
||||||
|
func nametomib(name string) (mib []_C_int, err error) {
|
||||||
|
const siz = unsafe.Sizeof(mib[0])
|
||||||
|
|
||||||
|
// NOTE(rsc): It seems strange to set the buffer to have
|
||||||
|
// size CTL_MAXNAME+2 but use only CTL_MAXNAME
|
||||||
|
// as the size. I don't know why the +2 is here, but the
|
||||||
|
// kernel uses +2 for its own implementation of this function.
|
||||||
|
// I am scared that if we don't include the +2 here, the kernel
|
||||||
|
// will silently write 2 words farther than we specify
|
||||||
|
// and we'll get memory corruption.
|
||||||
|
var buf [CTL_MAXNAME + 2]_C_int
|
||||||
|
n := uintptr(CTL_MAXNAME) * siz
|
||||||
|
|
||||||
|
p := (*byte)(unsafe.Pointer(&buf[0]))
|
||||||
|
bytes, err := ByteSliceFromString(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Magic sysctl: "setting" 0.3 to a string name
|
||||||
|
// lets you read back the array of integers form.
|
||||||
|
if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return buf[0 : n/siz], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
|
||||||
|
func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
|
||||||
|
func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
|
||||||
|
|
||||||
|
const (
|
||||||
|
attrBitMapCount = 5
|
||||||
|
attrCmnFullpath = 0x08000000
|
||||||
|
)
|
||||||
|
|
||||||
|
type attrList struct {
|
||||||
|
bitmapCount uint16
|
||||||
|
_ uint16
|
||||||
|
CommonAttr uint32
|
||||||
|
VolAttr uint32
|
||||||
|
DirAttr uint32
|
||||||
|
FileAttr uint32
|
||||||
|
Forkattr uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (attrs [][]byte, err error) {
|
||||||
|
if len(attrBuf) < 4 {
|
||||||
|
return nil, errors.New("attrBuf too small")
|
||||||
|
}
|
||||||
|
attrList.bitmapCount = attrBitMapCount
|
||||||
|
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := getattrlist(_p0, unsafe.Pointer(&attrList), unsafe.Pointer(&attrBuf[0]), uintptr(len(attrBuf)), int(options)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
size := *(*uint32)(unsafe.Pointer(&attrBuf[0]))
|
||||||
|
|
||||||
|
// dat is the section of attrBuf that contains valid data,
|
||||||
|
// without the 4 byte length header. All attribute offsets
|
||||||
|
// are relative to dat.
|
||||||
|
dat := attrBuf
|
||||||
|
if int(size) < len(attrBuf) {
|
||||||
|
dat = dat[:size]
|
||||||
|
}
|
||||||
|
dat = dat[4:] // remove length prefix
|
||||||
|
|
||||||
|
for i := uint32(0); int(i) < len(dat); {
|
||||||
|
header := dat[i:]
|
||||||
|
if len(header) < 8 {
|
||||||
|
return attrs, errors.New("truncated attribute header")
|
||||||
|
}
|
||||||
|
datOff := *(*int32)(unsafe.Pointer(&header[0]))
|
||||||
|
attrLen := *(*uint32)(unsafe.Pointer(&header[4]))
|
||||||
|
if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) {
|
||||||
|
return attrs, errors.New("truncated results; attrBuf too small")
|
||||||
|
}
|
||||||
|
end := uint32(datOff) + attrLen
|
||||||
|
attrs = append(attrs, dat[datOff:end])
|
||||||
|
i = end
|
||||||
|
if r := i % 4; r != 0 {
|
||||||
|
i += (4 - r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error)
|
||||||
|
|
||||||
|
//sysnb pipe() (r int, w int, err error)
|
||||||
|
|
||||||
|
func Pipe(p []int) (err error) {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
p[0], p[1], err = pipe()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
|
||||||
|
var _p0 unsafe.Pointer
|
||||||
|
var bufsize uintptr
|
||||||
|
if len(buf) > 0 {
|
||||||
|
_p0 = unsafe.Pointer(&buf[0])
|
||||||
|
bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
|
||||||
|
}
|
||||||
|
return getfsstat(_p0, bufsize, flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func xattrPointer(dest []byte) *byte {
|
||||||
|
// It's only when dest is set to NULL that the OS X implementations of
|
||||||
|
// getxattr() and listxattr() return the current sizes of the named attributes.
|
||||||
|
// An empty byte array is not sufficient. To maintain the same behaviour as the
|
||||||
|
// linux implementation, we wrap around the system calls and pass in NULL when
|
||||||
|
// dest is empty.
|
||||||
|
var destp *byte
|
||||||
|
if len(dest) > 0 {
|
||||||
|
destp = &dest[0]
|
||||||
|
}
|
||||||
|
return destp
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error)
|
||||||
|
|
||||||
|
func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
|
||||||
|
return getxattr(path, attr, xattrPointer(dest), len(dest), 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) {
|
||||||
|
return getxattr(link, attr, xattrPointer(dest), len(dest), 0, XATTR_NOFOLLOW)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error)
|
||||||
|
|
||||||
|
func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) {
|
||||||
|
return fgetxattr(fd, attr, xattrPointer(dest), len(dest), 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error)
|
||||||
|
|
||||||
|
func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||||
|
// The parameters for the OS X implementation vary slightly compared to the
|
||||||
|
// linux system call, specifically the position parameter:
|
||||||
|
//
|
||||||
|
// linux:
|
||||||
|
// int setxattr(
|
||||||
|
// const char *path,
|
||||||
|
// const char *name,
|
||||||
|
// const void *value,
|
||||||
|
// size_t size,
|
||||||
|
// int flags
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// darwin:
|
||||||
|
// int setxattr(
|
||||||
|
// const char *path,
|
||||||
|
// const char *name,
|
||||||
|
// void *value,
|
||||||
|
// size_t size,
|
||||||
|
// u_int32_t position,
|
||||||
|
// int options
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// position specifies the offset within the extended attribute. In the
|
||||||
|
// current implementation, only the resource fork extended attribute makes
|
||||||
|
// use of this argument. For all others, position is reserved. We simply
|
||||||
|
// default to setting it to zero.
|
||||||
|
return setxattr(path, attr, xattrPointer(data), len(data), 0, flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Lsetxattr(link string, attr string, data []byte, flags int) (err error) {
|
||||||
|
return setxattr(link, attr, xattrPointer(data), len(data), 0, flags|XATTR_NOFOLLOW)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error)
|
||||||
|
|
||||||
|
func Fsetxattr(fd int, attr string, data []byte, flags int) (err error) {
|
||||||
|
return fsetxattr(fd, attr, xattrPointer(data), len(data), 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys removexattr(path string, attr string, options int) (err error)
|
||||||
|
|
||||||
|
func Removexattr(path string, attr string) (err error) {
|
||||||
|
// We wrap around and explicitly zero out the options provided to the OS X
|
||||||
|
// implementation of removexattr, we do so for interoperability with the
|
||||||
|
// linux variant.
|
||||||
|
return removexattr(path, attr, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Lremovexattr(link string, attr string) (err error) {
|
||||||
|
return removexattr(link, attr, XATTR_NOFOLLOW)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys fremovexattr(fd int, attr string, options int) (err error)
|
||||||
|
|
||||||
|
func Fremovexattr(fd int, attr string) (err error) {
|
||||||
|
return fremovexattr(fd, attr, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys listxattr(path string, dest *byte, size int, options int) (sz int, err error)
|
||||||
|
|
||||||
|
func Listxattr(path string, dest []byte) (sz int, err error) {
|
||||||
|
return listxattr(path, xattrPointer(dest), len(dest), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Llistxattr(link string, dest []byte) (sz int, err error) {
|
||||||
|
return listxattr(link, xattrPointer(dest), len(dest), XATTR_NOFOLLOW)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys flistxattr(fd int, dest *byte, size int, options int) (sz int, err error)
|
||||||
|
|
||||||
|
func Flistxattr(fd int, dest []byte) (sz int, err error) {
|
||||||
|
return flistxattr(fd, xattrPointer(dest), len(dest), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func setattrlistTimes(path string, times []Timespec, flags int) error {
|
||||||
|
_p0, err := BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var attrList attrList
|
||||||
|
attrList.bitmapCount = ATTR_BIT_MAP_COUNT
|
||||||
|
attrList.CommonAttr = ATTR_CMN_MODTIME | ATTR_CMN_ACCTIME
|
||||||
|
|
||||||
|
// order is mtime, atime: the opposite of Chtimes
|
||||||
|
attributes := [2]Timespec{times[1], times[0]}
|
||||||
|
options := 0
|
||||||
|
if flags&AT_SYMLINK_NOFOLLOW != 0 {
|
||||||
|
options |= FSOPT_NOFOLLOW
|
||||||
|
}
|
||||||
|
return setattrlist(
|
||||||
|
_p0,
|
||||||
|
unsafe.Pointer(&attrList),
|
||||||
|
unsafe.Pointer(&attributes),
|
||||||
|
unsafe.Sizeof(attributes),
|
||||||
|
options)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error)
|
||||||
|
|
||||||
|
func utimensat(dirfd int, path string, times *[2]Timespec, flags int) error {
|
||||||
|
// Darwin doesn't support SYS_UTIMENSAT
|
||||||
|
return ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wrapped
|
||||||
|
*/
|
||||||
|
|
||||||
|
//sys kill(pid int, signum int, posix int) (err error)
|
||||||
|
|
||||||
|
func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) }
|
||||||
|
|
||||||
|
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
||||||
|
|
||||||
|
// ioctl itself should not be exposed directly, but additional get/set
|
||||||
|
// functions for specific types are permissible.
|
||||||
|
|
||||||
|
// IoctlSetInt performs an ioctl operation which sets an integer value
|
||||||
|
// on fd, using the specified request number.
|
||||||
|
func IoctlSetInt(fd int, req uint, value int) error {
|
||||||
|
return ioctl(fd, req, uintptr(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
|
||||||
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func ioctlSetTermios(fd int, req uint, value *Termios) error {
|
||||||
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlGetInt performs an ioctl operation which gets an integer value
|
||||||
|
// from fd, using the specified request number.
|
||||||
|
func IoctlGetInt(fd int, req uint) (int, error) {
|
||||||
|
var value int
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
|
||||||
|
var value Winsize
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
|
||||||
|
var value Termios
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func Uname(uname *Utsname) error {
|
||||||
|
mib := []_C_int{CTL_KERN, KERN_OSTYPE}
|
||||||
|
n := unsafe.Sizeof(uname.Sysname)
|
||||||
|
if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
|
||||||
|
n = unsafe.Sizeof(uname.Nodename)
|
||||||
|
if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
|
||||||
|
n = unsafe.Sizeof(uname.Release)
|
||||||
|
if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
mib = []_C_int{CTL_KERN, KERN_VERSION}
|
||||||
|
n = unsafe.Sizeof(uname.Version)
|
||||||
|
if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// The version might have newlines or tabs in it, convert them to
|
||||||
|
// spaces.
|
||||||
|
for i, b := range uname.Version {
|
||||||
|
if b == '\n' || b == '\t' {
|
||||||
|
if i == len(uname.Version)-1 {
|
||||||
|
uname.Version[i] = 0
|
||||||
|
} else {
|
||||||
|
uname.Version[i] = ' '
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mib = []_C_int{CTL_HW, HW_MACHINE}
|
||||||
|
n = unsafe.Sizeof(uname.Machine)
|
||||||
|
if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
if raceenabled {
|
||||||
|
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||||
|
}
|
||||||
|
var length = int64(count)
|
||||||
|
err = sendfile(infd, outfd, *offset, &length, nil, 0)
|
||||||
|
written = int(length)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Exposed directly
|
||||||
|
*/
|
||||||
|
//sys Access(path string, mode uint32) (err error)
|
||||||
|
//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
|
||||||
|
//sys Chdir(path string) (err error)
|
||||||
|
//sys Chflags(path string, flags int) (err error)
|
||||||
|
//sys Chmod(path string, mode uint32) (err error)
|
||||||
|
//sys Chown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Chroot(path string) (err error)
|
||||||
|
//sys ClockGettime(clockid int32, time *Timespec) (err error)
|
||||||
|
//sys Close(fd int) (err error)
|
||||||
|
//sys Dup(fd int) (nfd int, err error)
|
||||||
|
//sys Dup2(from int, to int) (err error)
|
||||||
|
//sys Exchangedata(path1 string, path2 string, options int) (err error)
|
||||||
|
//sys Exit(code int)
|
||||||
|
//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
|
||||||
|
//sys Fchdir(fd int) (err error)
|
||||||
|
//sys Fchflags(fd int, flags int) (err error)
|
||||||
|
//sys Fchmod(fd int, mode uint32) (err error)
|
||||||
|
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
|
||||||
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
|
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
|
||||||
|
//sys Flock(fd int, how int) (err error)
|
||||||
|
//sys Fpathconf(fd int, name int) (val int, err error)
|
||||||
|
//sys Fsync(fd int) (err error)
|
||||||
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
|
//sys Getdtablesize() (size int)
|
||||||
|
//sysnb Getegid() (egid int)
|
||||||
|
//sysnb Geteuid() (uid int)
|
||||||
|
//sysnb Getgid() (gid int)
|
||||||
|
//sysnb Getpgid(pid int) (pgid int, err error)
|
||||||
|
//sysnb Getpgrp() (pgrp int)
|
||||||
|
//sysnb Getpid() (pid int)
|
||||||
|
//sysnb Getppid() (ppid int)
|
||||||
|
//sys Getpriority(which int, who int) (prio int, err error)
|
||||||
|
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
|
||||||
|
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||||
|
//sysnb Getsid(pid int) (sid int, err error)
|
||||||
|
//sysnb Getuid() (uid int)
|
||||||
|
//sysnb Issetugid() (tainted bool)
|
||||||
|
//sys Kqueue() (fd int, err error)
|
||||||
|
//sys Lchown(path string, uid int, gid int) (err error)
|
||||||
|
//sys Link(path string, link string) (err error)
|
||||||
|
//sys Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error)
|
||||||
|
//sys Listen(s int, backlog int) (err error)
|
||||||
|
//sys Mkdir(path string, mode uint32) (err error)
|
||||||
|
//sys Mkdirat(dirfd int, path string, mode uint32) (err error)
|
||||||
|
//sys Mkfifo(path string, mode uint32) (err error)
|
||||||
|
//sys Mknod(path string, mode uint32, dev int) (err error)
|
||||||
|
//sys Open(path string, mode int, perm uint32) (fd int, err error)
|
||||||
|
//sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
|
||||||
|
//sys Pathconf(path string, name int) (val int, err error)
|
||||||
|
//sys Pread(fd int, p []byte, offset int64) (n int, err error)
|
||||||
|
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
|
||||||
|
//sys read(fd int, p []byte) (n int, err error)
|
||||||
|
//sys Readlink(path string, buf []byte) (n int, err error)
|
||||||
|
//sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error)
|
||||||
|
//sys Rename(from string, to string) (err error)
|
||||||
|
//sys Renameat(fromfd int, from string, tofd int, to string) (err error)
|
||||||
|
//sys Revoke(path string) (err error)
|
||||||
|
//sys Rmdir(path string) (err error)
|
||||||
|
//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
|
||||||
|
//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
|
||||||
|
//sys Setegid(egid int) (err error)
|
||||||
|
//sysnb Seteuid(euid int) (err error)
|
||||||
|
//sysnb Setgid(gid int) (err error)
|
||||||
|
//sys Setlogin(name string) (err error)
|
||||||
|
//sysnb Setpgid(pid int, pgid int) (err error)
|
||||||
|
//sys Setpriority(which int, who int, prio int) (err error)
|
||||||
|
//sys Setprivexec(flag int) (err error)
|
||||||
|
//sysnb Setregid(rgid int, egid int) (err error)
|
||||||
|
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||||
|
//sysnb Setrlimit(which int, lim *Rlimit) (err error)
|
||||||
|
//sysnb Setsid() (pid int, err error)
|
||||||
|
//sysnb Settimeofday(tp *Timeval) (err error)
|
||||||
|
//sysnb Setuid(uid int) (err error)
|
||||||
|
//sys Symlink(path string, link string) (err error)
|
||||||
|
//sys Symlinkat(oldpath string, newdirfd int, newpath string) (err error)
|
||||||
|
//sys Sync() (err error)
|
||||||
|
//sys Truncate(path string, length int64) (err error)
|
||||||
|
//sys Umask(newmask int) (oldmask int)
|
||||||
|
//sys Undelete(path string) (err error)
|
||||||
|
//sys Unlink(path string) (err error)
|
||||||
|
//sys Unlinkat(dirfd int, path string, flags int) (err error)
|
||||||
|
//sys Unmount(path string, flags int) (err error)
|
||||||
|
//sys write(fd int, p []byte) (n int, err error)
|
||||||
|
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
|
||||||
|
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||||
|
//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
|
||||||
|
//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unimplemented
|
||||||
|
*/
|
||||||
|
// Profil
|
||||||
|
// Sigaction
|
||||||
|
// Sigprocmask
|
||||||
|
// Getlogin
|
||||||
|
// Sigpending
|
||||||
|
// Sigaltstack
|
||||||
|
// Ioctl
|
||||||
|
// Reboot
|
||||||
|
// Execve
|
||||||
|
// Vfork
|
||||||
|
// Sbrk
|
||||||
|
// Sstk
|
||||||
|
// Ovadvise
|
||||||
|
// Mincore
|
||||||
|
// Setitimer
|
||||||
|
// Swapon
|
||||||
|
// Select
|
||||||
|
// Sigsuspend
|
||||||
|
// Readv
|
||||||
|
// Writev
|
||||||
|
// Nfssvc
|
||||||
|
// Getfh
|
||||||
|
// Quotactl
|
||||||
|
// Mount
|
||||||
|
// Csops
|
||||||
|
// Waitid
|
||||||
|
// Add_profil
|
||||||
|
// Kdebug_trace
|
||||||
|
// Sigreturn
|
||||||
|
// Atsocket
|
||||||
|
// Kqueue_from_portset_np
|
||||||
|
// Kqueue_portset
|
||||||
|
// Getattrlist
|
||||||
|
// Setattrlist
|
||||||
|
// Getdirentriesattr
|
||||||
|
// Searchfs
|
||||||
|
// Delete
|
||||||
|
// Copyfile
|
||||||
|
// Watchevent
|
||||||
|
// Waitevent
|
||||||
|
// Modwatch
|
||||||
|
// Fsctl
|
||||||
|
// Initgroups
|
||||||
|
// Posix_spawn
|
||||||
|
// Nfsclnt
|
||||||
|
// Fhopen
|
||||||
|
// Minherit
|
||||||
|
// Semsys
|
||||||
|
// Msgsys
|
||||||
|
// Shmsys
|
||||||
|
// Semctl
|
||||||
|
// Semget
|
||||||
|
// Semop
|
||||||
|
// Msgctl
|
||||||
|
// Msgget
|
||||||
|
// Msgsnd
|
||||||
|
// Msgrcv
|
||||||
|
// Shmat
|
||||||
|
// Shmctl
|
||||||
|
// Shmdt
|
||||||
|
// Shmget
|
||||||
|
// Shm_open
|
||||||
|
// Shm_unlink
|
||||||
|
// Sem_open
|
||||||
|
// Sem_close
|
||||||
|
// Sem_unlink
|
||||||
|
// Sem_wait
|
||||||
|
// Sem_trywait
|
||||||
|
// Sem_post
|
||||||
|
// Sem_getvalue
|
||||||
|
// Sem_init
|
||||||
|
// Sem_destroy
|
||||||
|
// Open_extended
|
||||||
|
// Umask_extended
|
||||||
|
// Stat_extended
|
||||||
|
// Lstat_extended
|
||||||
|
// Fstat_extended
|
||||||
|
// Chmod_extended
|
||||||
|
// Fchmod_extended
|
||||||
|
// Access_extended
|
||||||
|
// Settid
|
||||||
|
// Gettid
|
||||||
|
// Setsgroups
|
||||||
|
// Getsgroups
|
||||||
|
// Setwgroups
|
||||||
|
// Getwgroups
|
||||||
|
// Mkfifo_extended
|
||||||
|
// Mkdir_extended
|
||||||
|
// Identitysvc
|
||||||
|
// Shared_region_check_np
|
||||||
|
// Shared_region_map_np
|
||||||
|
// __pthread_mutex_destroy
|
||||||
|
// __pthread_mutex_init
|
||||||
|
// __pthread_mutex_lock
|
||||||
|
// __pthread_mutex_trylock
|
||||||
|
// __pthread_mutex_unlock
|
||||||
|
// __pthread_cond_init
|
||||||
|
// __pthread_cond_destroy
|
||||||
|
// __pthread_cond_broadcast
|
||||||
|
// __pthread_cond_signal
|
||||||
|
// Setsid_with_pid
|
||||||
|
// __pthread_cond_timedwait
|
||||||
|
// Aio_fsync
|
||||||
|
// Aio_return
|
||||||
|
// Aio_suspend
|
||||||
|
// Aio_cancel
|
||||||
|
// Aio_error
|
||||||
|
// Aio_read
|
||||||
|
// Aio_write
|
||||||
|
// Lio_listio
|
||||||
|
// __pthread_cond_wait
|
||||||
|
// Iopolicysys
|
||||||
|
// __pthread_kill
|
||||||
|
// __pthread_sigmask
|
||||||
|
// __sigwait
|
||||||
|
// __disable_threadsignal
|
||||||
|
// __pthread_markcancel
|
||||||
|
// __pthread_canceled
|
||||||
|
// __semwait_signal
|
||||||
|
// Proc_info
|
||||||
|
// sendfile
|
||||||
|
// Stat64_extended
|
||||||
|
// Lstat64_extended
|
||||||
|
// Fstat64_extended
|
||||||
|
// __pthread_chdir
|
||||||
|
// __pthread_fchdir
|
||||||
|
// Audit
|
||||||
|
// Auditon
|
||||||
|
// Getauid
|
||||||
|
// Setauid
|
||||||
|
// Getaudit
|
||||||
|
// Setaudit
|
||||||
|
// Getaudit_addr
|
||||||
|
// Setaudit_addr
|
||||||
|
// Auditctl
|
||||||
|
// Bsdthread_create
|
||||||
|
// Bsdthread_terminate
|
||||||
|
// Stack_snapshot
|
||||||
|
// Bsdthread_register
|
||||||
|
// Workq_open
|
||||||
|
// Workq_ops
|
||||||
|
// __mac_execve
|
||||||
|
// __mac_syscall
|
||||||
|
// __mac_get_file
|
||||||
|
// __mac_set_file
|
||||||
|
// __mac_get_link
|
||||||
|
// __mac_set_link
|
||||||
|
// __mac_get_proc
|
||||||
|
// __mac_set_proc
|
||||||
|
// __mac_get_fd
|
||||||
|
// __mac_set_fd
|
||||||
|
// __mac_get_pid
|
||||||
|
// __mac_get_lcid
|
||||||
|
// __mac_get_lctx
|
||||||
|
// __mac_set_lctx
|
||||||
|
// Setlcid
|
||||||
|
// Read_nocancel
|
||||||
|
// Write_nocancel
|
||||||
|
// Open_nocancel
|
||||||
|
// Close_nocancel
|
||||||
|
// Wait4_nocancel
|
||||||
|
// Recvmsg_nocancel
|
||||||
|
// Sendmsg_nocancel
|
||||||
|
// Recvfrom_nocancel
|
||||||
|
// Accept_nocancel
|
||||||
|
// Fcntl_nocancel
|
||||||
|
// Select_nocancel
|
||||||
|
// Fsync_nocancel
|
||||||
|
// Connect_nocancel
|
||||||
|
// Sigsuspend_nocancel
|
||||||
|
// Readv_nocancel
|
||||||
|
// Writev_nocancel
|
||||||
|
// Sendto_nocancel
|
||||||
|
// Pread_nocancel
|
||||||
|
// Pwrite_nocancel
|
||||||
|
// Waitid_nocancel
|
||||||
|
// Poll_nocancel
|
||||||
|
// Msgsnd_nocancel
|
||||||
|
// Msgrcv_nocancel
|
||||||
|
// Sem_wait_nocancel
|
||||||
|
// Aio_suspend_nocancel
|
||||||
|
// __sigwait_nocancel
|
||||||
|
// __semwait_signal_nocancel
|
||||||
|
// __mac_mount
|
||||||
|
// __mac_get_mount
|
||||||
|
// __mac_getfsstat
|
||||||
63
vendor/golang.org/x/sys/unix/syscall_darwin_386.go
generated
vendored
Normal file
63
vendor/golang.org/x/sys/unix/syscall_darwin_386.go
generated
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build 386,darwin
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
|
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTimeval(sec, usec int64) Timeval {
|
||||||
|
return Timeval{Sec: int32(sec), Usec: int32(usec)}
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
|
||||||
|
func Gettimeofday(tv *Timeval) (err error) {
|
||||||
|
// The tv passed to gettimeofday must be non-nil
|
||||||
|
// but is otherwise unused. The answers come back
|
||||||
|
// in the two registers.
|
||||||
|
sec, usec, err := gettimeofday(tv)
|
||||||
|
tv.Sec = int32(sec)
|
||||||
|
tv.Usec = int32(usec)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint32(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
|
||||||
|
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
|
||||||
|
// of darwin/386 the syscall is called sysctl instead of __sysctl.
|
||||||
|
const SYS___SYSCTL = SYS_SYSCTL
|
||||||
|
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
|
||||||
|
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
|
||||||
|
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
|
||||||
|
//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64
|
||||||
|
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
||||||
|
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
||||||
|
//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
|
||||||
63
vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
generated
vendored
Normal file
63
vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build amd64,darwin
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
|
return Timespec{Sec: sec, Nsec: nsec}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTimeval(sec, usec int64) Timeval {
|
||||||
|
return Timeval{Sec: sec, Usec: int32(usec)}
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
|
||||||
|
func Gettimeofday(tv *Timeval) (err error) {
|
||||||
|
// The tv passed to gettimeofday must be non-nil
|
||||||
|
// but is otherwise unused. The answers come back
|
||||||
|
// in the two registers.
|
||||||
|
sec, usec, err := gettimeofday(tv)
|
||||||
|
tv.Sec = sec
|
||||||
|
tv.Usec = usec
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint64(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
|
||||||
|
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
|
||||||
|
// of darwin/amd64 the syscall is called sysctl instead of __sysctl.
|
||||||
|
const SYS___SYSCTL = SYS_SYSCTL
|
||||||
|
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
|
||||||
|
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
|
||||||
|
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
|
||||||
|
//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64
|
||||||
|
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
||||||
|
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
||||||
|
//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
|
||||||
64
vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
generated
vendored
Normal file
64
vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
generated
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
|
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTimeval(sec, usec int64) Timeval {
|
||||||
|
return Timeval{Sec: int32(sec), Usec: int32(usec)}
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
|
||||||
|
func Gettimeofday(tv *Timeval) (err error) {
|
||||||
|
// The tv passed to gettimeofday must be non-nil
|
||||||
|
// but is otherwise unused. The answers come back
|
||||||
|
// in the two registers.
|
||||||
|
sec, usec, err := gettimeofday(tv)
|
||||||
|
tv.Sec = int32(sec)
|
||||||
|
tv.Usec = int32(usec)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint32(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
|
||||||
|
|
||||||
|
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
|
||||||
|
// of darwin/arm the syscall is called sysctl instead of __sysctl.
|
||||||
|
const SYS___SYSCTL = SYS_SYSCTL
|
||||||
|
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
|
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
|
||||||
|
//sys Fstatfs(fd int, stat *Statfs_t) (err error)
|
||||||
|
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Stat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Statfs(path string, stat *Statfs_t) (err error)
|
||||||
|
|
||||||
|
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
||||||
|
return 0, ENOSYS
|
||||||
|
}
|
||||||
66
vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
generated
vendored
Normal file
66
vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build arm64,darwin
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
|
return Timespec{Sec: sec, Nsec: nsec}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTimeval(sec, usec int64) Timeval {
|
||||||
|
return Timeval{Sec: sec, Usec: int32(usec)}
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
|
||||||
|
func Gettimeofday(tv *Timeval) (err error) {
|
||||||
|
// The tv passed to gettimeofday must be non-nil
|
||||||
|
// but is otherwise unused. The answers come back
|
||||||
|
// in the two registers.
|
||||||
|
sec, usec, err := gettimeofday(tv)
|
||||||
|
tv.Sec = sec
|
||||||
|
tv.Usec = usec
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetKevent(k *Kevent_t, fd, mode, flags int) {
|
||||||
|
k.Ident = uint64(fd)
|
||||||
|
k.Filter = int16(mode)
|
||||||
|
k.Flags = uint16(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iov *Iovec) SetLen(length int) {
|
||||||
|
iov.Len = uint64(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (msghdr *Msghdr) SetControllen(length int) {
|
||||||
|
msghdr.Controllen = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
|
cmsg.Len = uint32(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
|
||||||
|
|
||||||
|
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
|
||||||
|
// of darwin/arm64 the syscall is called sysctl instead of __sysctl.
|
||||||
|
const SYS___SYSCTL = SYS_SYSCTL
|
||||||
|
|
||||||
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
|
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
|
||||||
|
//sys Fstatfs(fd int, stat *Statfs_t) (err error)
|
||||||
|
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT
|
||||||
|
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Stat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Statfs(path string, stat *Statfs_t) (err error)
|
||||||
|
|
||||||
|
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
||||||
|
return 0, ENOSYS
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue