summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-11-10 16:40:07 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-11-10 22:32:13 +1100
commit5c518eda0a994e49dec6f63c74ccd38b9e1b6e74 (patch)
treeb58d17f1df51a7c0eda2211d08f6baa8bfe58548 /vendor
parentdf72eee2013ce6fa1b1bf708cdc1d6289c7343b6 (diff)
bump gocui (this better work or so hope me god I'm switching back to go dep)
jks I'm that that close to the edge... but I am getting there haha
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/jesseduffield/gocui/keybinding.go5
-rw-r--r--vendor/github.com/jesseduffield/gocui/view.go11
-rw-r--r--vendor/github.com/jesseduffield/pty/types.go10
-rw-r--r--vendor/github.com/jesseduffield/pty/types_dragonfly.go17
-rw-r--r--vendor/github.com/jesseduffield/pty/types_freebsd.go15
-rw-r--r--vendor/github.com/jesseduffield/pty/types_openbsd.go14
-rw-r--r--vendor/github.com/jesseduffield/termbox-go/syscalls.go39
-rw-r--r--vendor/github.com/ulikunitz/xz/example.go40
-rw-r--r--vendor/golang.org/x/sys/unix/mkasm_darwin.go61
-rw-r--r--vendor/golang.org/x/sys/unix/mkpost.go106
-rw-r--r--vendor/golang.org/x/sys/unix/mksyscall.go407
-rw-r--r--vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go415
-rw-r--r--vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.go614
-rw-r--r--vendor/golang.org/x/sys/unix/mksyscall_solaris.go335
-rw-r--r--vendor/golang.org/x/sys/unix/mksysctl_openbsd.go355
-rw-r--r--vendor/golang.org/x/sys/unix/mksysnum.go190
-rw-r--r--vendor/golang.org/x/sys/unix/types_aix.go236
-rw-r--r--vendor/golang.org/x/sys/unix/types_darwin.go283
-rw-r--r--vendor/golang.org/x/sys/unix/types_dragonfly.go263
-rw-r--r--vendor/golang.org/x/sys/unix/types_freebsd.go356
-rw-r--r--vendor/golang.org/x/sys/unix/types_netbsd.go289
-rw-r--r--vendor/golang.org/x/sys/unix/types_openbsd.go282
-rw-r--r--vendor/golang.org/x/sys/unix/types_solaris.go266
-rw-r--r--vendor/golang.org/x/text/internal/language/compact/gen.go64
-rw-r--r--vendor/golang.org/x/text/internal/language/compact/gen_index.go113
-rw-r--r--vendor/golang.org/x/text/internal/language/compact/gen_parents.go54
-rw-r--r--vendor/golang.org/x/text/internal/language/gen.go1520
-rw-r--r--vendor/golang.org/x/text/internal/language/gen_common.go20
-rw-r--r--vendor/golang.org/x/text/language/gen.go305
-rw-r--r--vendor/golang.org/x/text/unicode/norm/maketables.go986
-rw-r--r--vendor/golang.org/x/text/unicode/norm/triegen.go117
-rw-r--r--vendor/modules.txt108
32 files changed, 7840 insertions, 56 deletions
diff --git a/vendor/github.com/jesseduffield/gocui/keybinding.go b/vendor/github.com/jesseduffield/gocui/keybinding.go
index 01a09ce8f..6b40a66a5 100644
--- a/vendor/github.com/jesseduffield/gocui/keybinding.go
+++ b/vendor/github.com/jesseduffield/gocui/keybinding.go
@@ -136,6 +136,7 @@ type Modifier termbox.Modifier
// Modifiers.
const (
- ModNone Modifier = Modifier(0)
- ModAlt = Modifier(termbox.ModAlt)
+ ModNone Modifier = Modifier(0)
+ ModAlt = Modifier(termbox.ModAlt)
+ ModMotion = Modifier(termbox.ModMotion)
)
diff --git a/vendor/github.com/jesseduffield/gocui/view.go b/vendor/github.com/jesseduffield/gocui/view.go
index cd4c12f19..7dbe1519a 100644
--- a/vendor/github.com/jesseduffield/gocui/view.go
+++ b/vendor/github.com/jesseduffield/gocui/view.go
@@ -650,3 +650,14 @@ func (v *View) GetClickedTabIndex(x int) int {
return 0
}
+
+func (v *View) SelectedLineIdx() int {
+ _, seletedLineIdx := v.SelectedPoint()
+ return seletedLineIdx
+}
+
+func (v *View) SelectedPoint() (int, int) {
+ cx, cy := v.Cursor()
+ ox, oy := v.Origin()
+ return cx + ox, cy + oy
+}
diff --git a/vendor/github.com/jesseduffield/pty/types.go b/vendor/github.com/jesseduffield/pty/types.go
new file mode 100644
index 000000000..5aecb6bcd
--- /dev/null
+++ b/vendor/github.com/jesseduffield/pty/types.go
@@ -0,0 +1,10 @@
+// +build ignore
+
+package pty
+
+import "C"
+
+type (
+ _C_int C.int
+ _C_uint C.uint
+)
diff --git a/vendor/github.com/jesseduffield/pty/types_dragonfly.go b/vendor/github.com/jesseduffield/pty/types_dragonfly.go
new file mode 100644
index 000000000..5c0493b85
--- /dev/null
+++ b/vendor/github.com/jesseduffield/pty/types_dragonfly.go
@@ -0,0 +1,17 @@
+// +build ignore
+
+package pty
+
+/*
+#define _KERNEL
+#include <sys/conf.h>
+#include <sys/param.h>
+#include <sys/filio.h>
+*/
+import "C"
+
+const (
+ _C_SPECNAMELEN = C.SPECNAMELEN /* max length of devicename */
+)
+
+type fiodgnameArg C.struct_fiodname_args
diff --git a/vendor/github.com/jesseduffield/pty/types_freebsd.go b/vendor/github.com/jesseduffield/pty/types_freebsd.go
new file mode 100644
index 000000000..ce3eb9518
--- /dev/null
+++ b/vendor/github.com/jesseduffield/pty/types_freebsd.go
@@ -0,0 +1,15 @@
+// +build ignore
+
+package pty
+
+/*
+#include <sys/param.h>
+#include <sys/filio.h>
+*/
+import "C"
+
+const (
+ _C_SPECNAMELEN = C.SPECNAMELEN /* max length of devicename */
+)
+
+type fiodgnameArg C.struct_fiodgname_arg
diff --git a/vendor/github.com/jesseduffield/pty/types_openbsd.go b/vendor/github.com/jesseduffield/pty/types_openbsd.go
new file mode 100644
index 000000000..47701b5f9
--- /dev/null
+++ b/vendor/github.com/jesseduffield/pty/types_openbsd.go
@@ -0,0 +1,14 @@
+// +build ignore
+
+package pty
+
+/*
+#include <sys/time.h>
+#include <stdlib.h>
+#include <sys/tty.h>
+*/
+import "C"
+
+type ptmget C.struct_ptmget
+
+var ioctl_PTMGET = C.PTMGET
diff --git a/vendor/github.com/jesseduffield/termbox-go/syscalls.go b/vendor/github.com/jesseduffield/termbox-go/syscalls.go
new file mode 100644
index 000000000..4f52bb9af
--- /dev/null
+++ b/vendor/github.com/jesseduffield/termbox-go/syscalls.go
@@ -0,0 +1,39 @@
+// +build ignore
+
+package termbox
+
+/*
+#include <termios.h>
+#include <sys/ioctl.h>
+*/
+import "C"
+
+type syscall_Termios C.struct_termios
+
+const (
+ syscall_IGNBRK = C.IGNBRK
+ syscall_BRKINT = C.BRKINT
+ syscall_PARMRK = C.PARMRK
+ syscall_ISTRIP = C.ISTRIP
+ syscall_INLCR = C.INLCR
+ syscall_IGNCR = C.IGNCR
+ syscall_ICRNL = C.ICRNL
+ syscall_IXON = C.IXON
+ syscall_OPOST = C.OPOST
+ syscall_ECHO = C.ECHO
+ syscall_ECHONL = C.ECHONL
+ syscall_ICANON = C.ICANON
+ syscall_ISIG = C.ISIG
+ syscall_IEXTEN = C.IEXTEN
+ syscall_CSIZE = C.CSIZE
+ syscall_PARENB = C.PARENB
+ syscall_CS8 = C.CS8
+ syscall_VMIN = C.VMIN
+ syscall_VTIME = C.VTIME
+
+ // on darwin change these to (on *bsd too?):
+ // C.TIOCGETA
+ // C.TIOCSETA
+ syscall_TCGETS = C.TCGETS
+ syscall_TCSETS = C.TCSETS
+)
diff --git a/vendor/github.com/ulikunitz/xz/example.go b/vendor/github.com/ulikunitz/xz/example.go
new file mode 100644
index 000000000..855e60aee
--- /dev/null
+++ b/vendor/github.com/ulikunitz/xz/example.go
@@ -0,0 +1,40 @@
+// Copyright 2014-2017 Ulrich Kunitz. 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
+
+package main
+
+import (
+ "bytes"
+ "io"
+ "log"
+ "os"
+
+ "github.com/ulikunitz/xz"
+)
+
+func main() {
+ const text = "The quick brown fox jumps over the lazy dog.\n"
+ var buf bytes.Buffer
+ // compress text
+ w, err := xz.NewWriter(&buf)
+ if err != nil {
+ log.Fatalf("xz.NewWriter error %s", err)
+ }
+ if _, err := io.WriteString(w, text); err != nil {
+ log.Fatalf("WriteString error %s", err)
+ }
+ if err := w.Close(); err != nil {
+ log.Fatalf("w.Close error %s", err)
+ }
+ // decompress buffer and write output to stdout
+ r, err := xz.NewReader(&buf)
+ if err != nil {
+ log.Fatalf("NewReader error %s", err)
+ }
+ if _, err = io.Copy(os.Stdout, r); err != nil {
+ log.Fatalf("io.Copy error %s", err)
+ }
+}
diff --git a/vendor/golang.org/x/sys/unix/mkasm_darwin.go b/vendor/golang.org/x/sys/unix/mkasm_darwin.go
new file mode 100644
index 000000000..4548b993d
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/mkasm_darwin.go
@@ -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)
+ }
+}
diff --git a/vendor/golang.org/x/sys/unix/mkpost.go b/vendor/golang.org/x/sys/unix/mkpost.go
new file mode 100644
index 000000000..9feddd00c
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/mkpost.go
@@ -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)
+}
diff --git a/vendor/golang.org/x/sys/unix/mksyscall.go b/vendor/golang.org/x/sys/unix/mksyscall.go
new file mode 100644
index 000000000..e4af9424e
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/mksyscall.go
@@ -0,0 +1,407 @@
+// 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]
+
+ // ClockGettime doesn't have a syscall number on Darwin, only generate libc wrappers.
+ if goos == "darwin" && !libc && funct == "ClockGettime" {
+ continue
+ }
+
+ // 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) {
<