Browse Source

fix windows build

tags/v0.2.0
AJ ONeal 8 months ago
parent
commit
9ca2168113
100 changed files with 16163 additions and 4419 deletions
  1. 2
    3
      go.mod
  2. 2
    10
      go.sum
  3. 8
    8
      installer/install_windows.go
  4. 10
    10
      vendor/golang.org/x/sys/unix/README.md
  5. 29
    0
      vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s
  6. 0
    12
      vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
  7. 54
    0
      vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
  8. 29
    0
      vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s
  9. 29
    0
      vendor/golang.org/x/sys/unix/asm_openbsd_arm64.s
  10. 87
    2
      vendor/golang.org/x/sys/unix/dirent.go
  11. 1
    1
      vendor/golang.org/x/sys/unix/fcntl.go
  12. 18
    0
      vendor/golang.org/x/sys/unix/fcntl_darwin.go
  13. 63
    40
      vendor/golang.org/x/sys/unix/mkall.sh
  14. 61
    0
      vendor/golang.org/x/sys/unix/mkasm_darwin.go
  15. 30
    21
      vendor/golang.org/x/sys/unix/mkerrors.sh
  16. 29
    5
      vendor/golang.org/x/sys/unix/mkpost.go
  17. 407
    0
      vendor/golang.org/x/sys/unix/mksyscall.go
  18. 0
    341
      vendor/golang.org/x/sys/unix/mksyscall.pl
  19. 415
    0
      vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go
  20. 0
    384
      vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.pl
  21. 614
    0
      vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.go
  22. 0
    579
      vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.pl
  23. 335
    0
      vendor/golang.org/x/sys/unix/mksyscall_solaris.go
  24. 0
    294
      vendor/golang.org/x/sys/unix/mksyscall_solaris.pl
  25. 355
    0
      vendor/golang.org/x/sys/unix/mksysctl_openbsd.go
  26. 0
    265
      vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl
  27. 190
    0
      vendor/golang.org/x/sys/unix/mksysnum.go
  28. 0
    39
      vendor/golang.org/x/sys/unix/mksysnum_darwin.pl
  29. 0
    50
      vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl
  30. 0
    50
      vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl
  31. 0
    58
      vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl
  32. 0
    50
      vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl
  33. 85
    17
      vendor/golang.org/x/sys/unix/pledge_openbsd.go
  34. 12
    0
      vendor/golang.org/x/sys/unix/readdirent_getdents.go
  35. 19
    0
      vendor/golang.org/x/sys/unix/readdirent_getdirentries.go
  36. 22
    6
      vendor/golang.org/x/sys/unix/sockcmsg_unix.go
  37. 0
    1
      vendor/golang.org/x/sys/unix/syscall.go
  38. 46
    20
      vendor/golang.org/x/sys/unix/syscall_aix.go
  39. 16
    0
      vendor/golang.org/x/sys/unix/syscall_aix_ppc.go
  40. 47
    0
      vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go
  41. 3
    9
      vendor/golang.org/x/sys/unix/syscall_bsd.go
  42. 55
    37
      vendor/golang.org/x/sys/unix/syscall_darwin.go
  43. 9
    14
      vendor/golang.org/x/sys/unix/syscall_darwin_386.go
  44. 9
    14
      vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
  45. 12
    14
      vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
  46. 12
    14
      vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
  47. 31
    0
      vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go
  48. 33
    0
      vendor/golang.org/x/sys/unix/syscall_dragonfly.go
  49. 393
    14
      vendor/golang.org/x/sys/unix/syscall_freebsd.go
  50. 52
    0
      vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go
  51. 258
    18
      vendor/golang.org/x/sys/unix/syscall_linux.go
  52. 1
    0
      vendor/golang.org/x/sys/unix/syscall_linux_386.go
  53. 17
    2
      vendor/golang.org/x/sys/unix/syscall_linux_amd64.go
  54. 28
    0
      vendor/golang.org/x/sys/unix/syscall_linux_arm.go
  55. 17
    6
      vendor/golang.org/x/sys/unix/syscall_linux_arm64.go
  56. 9
    1
      vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go
  57. 1
    0
      vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go
  58. 1
    0
      vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go
  59. 20
    6
      vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go
  60. 1
    0
      vendor/golang.org/x/sys/unix/syscall_linux_s390x.go
  61. 1
    0
      vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go
  62. 60
    2
      vendor/golang.org/x/sys/unix/syscall_netbsd.go
  63. 33
    0
      vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go
  64. 78
    14
      vendor/golang.org/x/sys/unix/syscall_openbsd.go
  65. 4
    0
      vendor/golang.org/x/sys/unix/syscall_openbsd_386.go
  66. 4
    0
      vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go
  67. 37
    0
      vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go
  68. 24
    0
      vendor/golang.org/x/sys/unix/syscall_solaris.go
  69. 53
    16
      vendor/golang.org/x/sys/unix/syscall_unix.go
  70. 1
    1
      vendor/golang.org/x/sys/unix/syscall_unix_gc.go
  71. 24
    0
      vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go
  72. 14
    13
      vendor/golang.org/x/sys/unix/types_aix.go
  73. 6
    0
      vendor/golang.org/x/sys/unix/types_darwin.go
  74. 66
    51
      vendor/golang.org/x/sys/unix/types_freebsd.go
  75. 3
    0
      vendor/golang.org/x/sys/unix/types_netbsd.go
  76. 11
    0
      vendor/golang.org/x/sys/unix/types_openbsd.go
  77. 42
    0
      vendor/golang.org/x/sys/unix/unveil_openbsd.go
  78. 12
    3
      vendor/golang.org/x/sys/unix/xattr_bsd.go
  79. 2
    0
      vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go
  80. 3
    1
      vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go
  81. 1794
    0
      vendor/golang.org/x/sys/unix/zerrors_freebsd_arm64.go
  82. 297
    8
      vendor/golang.org/x/sys/unix/zerrors_linux_386.go
  83. 297
    8
      vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
  84. 297
    8
      vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
  85. 297
    8
      vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
  86. 297
    8
      vendor/golang.org/x/sys/unix/zerrors_linux_mips.go
  87. 297
    8
      vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
  88. 297
    8
      vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
  89. 297
    8
      vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go
  90. 299
    8
      vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
  91. 299
    8
      vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
  92. 297
    8
      vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go
  93. 297
    8
      vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
  94. 2666
    1776
      vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
  95. 1762
    0
      vendor/golang.org/x/sys/unix/zerrors_netbsd_arm64.go
  96. 1789
    0
      vendor/golang.org/x/sys/unix/zerrors_openbsd_arm64.go
  97. 44
    10
      vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go
  98. 42
    8
      vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go
  99. 43
    13
      vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go
  100. 0
    0
      vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go

+ 2
- 3
go.mod View File

@@ -5,7 +5,6 @@ go 1.12
5 5
 require (
6 6
 	git.rootprojects.org/root/go-gitver v1.1.2
7 7
 	github.com/UnnoTed/fileb0x v1.1.3
8
-	golang.org/x/net v0.0.0-20190620200207-3b0461eec859
9
-	golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
10
-	golang.org/x/tools v0.0.0-20190702201734-44aeb8b7c377 // indirect
8
+	golang.org/x/net v0.0.0-20180921000356-2f5d2388922f
9
+	golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb
11 10
 )

+ 2
- 10
go.sum View File

@@ -42,19 +42,11 @@ github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4 h1:gKMu1Bf6QI
42 42
 github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4/go.mod h1:50wTf68f99/Zt14pr046Tgt3Lp2vLyFZKzbFXTOabXw=
43 43
 golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b h1:2b9XGzhjiYsYPnKXoEfL7klWZQIt8IfyRCz62gCqqlQ=
44 44
 golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
45
-golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
46 45
 golang.org/x/net v0.0.0-20180921000356-2f5d2388922f h1:QM2QVxvDoW9PFSPp/zy9FgxJLfaWTZlS61KEPtBwacM=
47 46
 golang.org/x/net v0.0.0-20180921000356-2f5d2388922f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
48
-golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
49
-golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
50
-golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
51
-golang.org/x/sys v0.0.0-20181019160139-8e24a49d80f8 h1:R91KX5nmbbvEd7w370cbVzKC+EzCTGqZq63Zad5IcLM=
52 47
 golang.org/x/sys v0.0.0-20181019160139-8e24a49d80f8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
53
-golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
54
-golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
55
-golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
56
-golang.org/x/tools v0.0.0-20190702201734-44aeb8b7c377 h1:P/0pu7r+pn3Fkv7pyRpb7tBawImpURm2mTIbR6MadCc=
57
-golang.org/x/tools v0.0.0-20190702201734-44aeb8b7c377/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
48
+golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb h1:fgwFCsaw9buMuxNd6+DQfAuSFqbNiQZpcgJQAgJsK6k=
49
+golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
58 50
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
59 51
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
60 52
 gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=

+ 8
- 8
installer/install_windows.go View File

@@ -111,17 +111,17 @@ func installServiceman(c *service.Service) ([]string, error) {
111 111
 	smbin := filepath.Join(smdir, `bin\serviceman.%s`, c.Name)
112 112
 
113 113
 	if smbin != self {
114
-		err := os.MkdirAll(filepath.Dir(smbin))
114
+		err := os.MkdirAll(filepath.Dir(smbin), 0755)
115 115
 		if nil != err {
116
-			return "", err
116
+			return nil, err
117 117
 		}
118 118
 		bin, err := ioutil.ReadFile(self)
119 119
 		if nil != err {
120
-			return "", err
120
+			return nil, err
121 121
 		}
122
-		err := ioutil.WriteFile(smbin, bin, 0755)
122
+		err = ioutil.WriteFile(smbin, bin, 0755)
123 123
 		if nil != err {
124
-			return "", err
124
+			return nil, err
125 125
 		}
126 126
 	}
127 127
 
@@ -130,10 +130,10 @@ func installServiceman(c *service.Service) ([]string, error) {
130 130
 		// this should be impossible, so we'll just panic
131 131
 		panic(err)
132 132
 	}
133
-	confpath := filepath.Join(smpath, `etc`, conf.Name+`.json`)
134
-	err := ioutil.WriteFile(confpath, b, 0640)
133
+	confpath := filepath.Join(smdir, `etc`, c.Name+`.json`)
134
+	err = ioutil.WriteFile(confpath, b, 0640)
135 135
 	if nil != err {
136
-		return err
136
+		return nil, err
137 137
 	}
138 138
 
139 139
 	return []string{

+ 10
- 10
vendor/golang.org/x/sys/unix/README.md View File

@@ -14,7 +14,7 @@ migrating the build system to use containers so the builds are reproducible.
14 14
 This is being done on an OS-by-OS basis. Please update this documentation as
15 15
 components of the build system change.
16 16
 
17
-### Old Build System (currently for `GOOS != "Linux" || GOARCH == "sparc64"`)
17
+### Old Build System (currently for `GOOS != "linux"`)
18 18
 
19 19
 The old build system generates the Go files based on the C header files
20 20
 present on your system. This means that files
@@ -32,9 +32,9 @@ To build the files for your current OS and architecture, make sure GOOS and
32 32
 GOARCH are set correctly and run `mkall.sh`. This will generate the files for
33 33
 your specific system. Running `mkall.sh -n` shows the commands that will be run.
34 34
 
35
-Requirements: bash, perl, go
35
+Requirements: bash, go
36 36
 
37
-### New Build System (currently for `GOOS == "Linux" && GOARCH != "sparc64"`)
37
+### New Build System (currently for `GOOS == "linux"`)
38 38
 
39 39
 The new build system uses a Docker container to generate the go files directly
40 40
 from source checkouts of the kernel and various system libraries. This means
@@ -52,14 +52,14 @@ system and have your GOOS and GOARCH set accordingly. Running `mkall.sh` will
52 52
 then generate all of the files for all of the GOOS/GOARCH pairs in the new build
53 53
 system. Running `mkall.sh -n` shows the commands that will be run.
54 54
 
55
-Requirements: bash, perl, go, docker
55
+Requirements: bash, go, docker
56 56
 
57 57
 ## Component files
58 58
 
59 59
 This section describes the various files used in the code generation process.
60 60
 It also contains instructions on how to modify these files to add a new
61 61
 architecture/OS or to add additional syscalls, types, or constants. Note that
62
-if you are using the new build system, the scripts cannot be called normally.
62
+if you are using the new build system, the scripts/programs cannot be called normally.
63 63
 They must be called from within the docker container.
64 64
 
65 65
 ### asm files
@@ -81,8 +81,8 @@ each GOOS/GOARCH pair.
81 81
 
82 82
 ### mksysnum
83 83
 
84
-Mksysnum is a script located at `${GOOS}/mksysnum.pl` (or `mksysnum_${GOOS}.pl`
85
-for the old system). This script takes in a list of header files containing the
84
+Mksysnum is a Go program located at `${GOOS}/mksysnum.go` (or `mksysnum_${GOOS}.go`
85
+for the old system). This program takes in a list of header files containing the
86 86
 syscall number declarations and parses them to produce the corresponding list of
87 87
 Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated
88 88
 constants.
@@ -92,14 +92,14 @@ new installation of the target OS (or updating the source checkouts for the
92 92
 new build system). However, depending on the OS, you make need to update the
93 93
 parsing in mksysnum.
94 94
 
95
-### mksyscall.pl
95
+### mksyscall.go
96 96
 
97 97
 The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are
98 98
 hand-written Go files which implement system calls (for unix, the specific OS,
99 99
 or the specific OS/Architecture pair respectively) that need special handling
100 100
 and list `//sys` comments giving prototypes for ones that can be generated.
101 101
 
102
-The mksyscall.pl script takes the `//sys` and `//sysnb` comments and converts
102
+The mksyscall.go program takes the `//sys` and `//sysnb` comments and converts
103 103
 them into syscalls. This requires the name of the prototype in the comment to
104 104
 match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function
105 105
 prototype can be exported (capitalized) or not.
@@ -160,7 +160,7 @@ signal numbers, and constants. Generated by `mkerrors.sh` (see above).
160 160
 ### `zsyscall_${GOOS}_${GOARCH}.go`
161 161
 
162 162
 A file containing all the generated syscalls for a specific GOOS and GOARCH.
163
-Generated by `mksyscall.pl` (see above).
163
+Generated by `mksyscall.go` (see above).
164 164
 
165 165
 ### `zsysnum_${GOOS}_${GOARCH}.go`
166 166
 

+ 29
- 0
vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s View File

@@ -0,0 +1,29 @@
1
+// Copyright 2018 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for ARM64, FreeBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-56
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-80
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-104
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
29
+	JMP	syscall·RawSyscall6(SB)

+ 0
- 12
vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s View File

@@ -15,12 +15,6 @@
15 15
 // Just jump to package syscall's implementation for all these functions.
16 16
 // The runtime may know about them.
17 17
 
18
-TEXT ·Syscall(SB),NOSPLIT,$0-56
19
-	BR	syscall·Syscall(SB)
20
-
21
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
22
-	BR	syscall·Syscall6(SB)
23
-
24 18
 TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
25 19
 	BL	runtime·entersyscall(SB)
26 20
 	MOVD	a1+8(FP), R3
@@ -36,12 +30,6 @@ TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
36 30
 	BL	runtime·exitsyscall(SB)
37 31
 	RET
38 32
 
39
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
40
-	BR	syscall·RawSyscall(SB)
41
-
42
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
43
-	BR	syscall·RawSyscall6(SB)
44
-
45 33
 TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
46 34
 	MOVD	a1+8(FP), R3
47 35
 	MOVD	a2+16(FP), R4

+ 54
- 0
vendor/golang.org/x/sys/unix/asm_linux_riscv64.s View File

@@ -0,0 +1,54 @@
1
+// Copyright 2019 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build riscv64,!gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System calls for linux/riscv64.
11
+//
12
+// Where available, just jump to package syscall's implementation of
13
+// these functions.
14
+
15
+TEXT ·Syscall(SB),NOSPLIT,$0-56
16
+	JMP	syscall·Syscall(SB)
17
+
18
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
19
+	JMP	syscall·Syscall6(SB)
20
+
21
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
22
+	CALL	runtime·entersyscall(SB)
23
+	MOV	a1+8(FP), A0
24
+	MOV	a2+16(FP), A1
25
+	MOV	a3+24(FP), A2
26
+	MOV	$0, A3
27
+	MOV	$0, A4
28
+	MOV	$0, A5
29
+	MOV	$0, A6
30
+	MOV	trap+0(FP), A7	// syscall entry
31
+	ECALL
32
+	MOV	A0, r1+32(FP)	// r1
33
+	MOV	A1, r2+40(FP)	// r2
34
+	CALL	runtime·exitsyscall(SB)
35
+	RET
36
+
37
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
38
+	JMP	syscall·RawSyscall(SB)
39
+
40
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
41
+	JMP	syscall·RawSyscall6(SB)
42
+
43
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
44
+	MOV	a1+8(FP), A0
45
+	MOV	a2+16(FP), A1
46
+	MOV	a3+24(FP), A2
47
+	MOV	ZERO, A3
48
+	MOV	ZERO, A4
49
+	MOV	ZERO, A5
50
+	MOV	trap+0(FP), A7	// syscall entry
51
+	ECALL
52
+	MOV	A0, r1+32(FP)
53
+	MOV	A1, r2+40(FP)
54
+	RET

+ 29
- 0
vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s View File

@@ -0,0 +1,29 @@
1
+// Copyright 2019 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for ARM64, NetBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-56
17
+	B	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-80
20
+	B	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-104
23
+	B	syscall·Syscall9(SB)
24
+
25
+TEXT	·RawSyscall(SB),NOSPLIT,$0-56
26
+	B	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
29
+	B	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/golang.org/x/sys/unix/asm_openbsd_arm64.s View File

@@ -0,0 +1,29 @@
1
+// Copyright 2019 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for arm64, OpenBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-56
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-80
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-104
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT	·RawSyscall(SB),NOSPLIT,$0-56
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
29
+	JMP	syscall·RawSyscall6(SB)

+ 87
- 2
vendor/golang.org/x/sys/unix/dirent.go View File

@@ -6,12 +6,97 @@
6 6
 
7 7
 package unix
8 8
 
9
-import "syscall"
9
+import "unsafe"
10
+
11
+// readInt returns the size-bytes unsigned integer in native byte order at offset off.
12
+func readInt(b []byte, off, size uintptr) (u uint64, ok bool) {
13
+	if len(b) < int(off+size) {
14
+		return 0, false
15
+	}
16
+	if isBigEndian {
17
+		return readIntBE(b[off:], size), true
18
+	}
19
+	return readIntLE(b[off:], size), true
20
+}
21
+
22
+func readIntBE(b []byte, size uintptr) uint64 {
23
+	switch size {
24
+	case 1:
25
+		return uint64(b[0])
26
+	case 2:
27
+		_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
28
+		return uint64(b[1]) | uint64(b[0])<<8
29
+	case 4:
30
+		_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
31
+		return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24
32
+	case 8:
33
+		_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
34
+		return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
35
+			uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
36
+	default:
37
+		panic("syscall: readInt with unsupported size")
38
+	}
39
+}
40
+
41
+func readIntLE(b []byte, size uintptr) uint64 {
42
+	switch size {
43
+	case 1:
44
+		return uint64(b[0])
45
+	case 2:
46
+		_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
47
+		return uint64(b[0]) | uint64(b[1])<<8
48
+	case 4:
49
+		_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
50
+		return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24
51
+	case 8:
52
+		_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
53
+		return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
54
+			uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
55
+	default:
56
+		panic("syscall: readInt with unsupported size")
57
+	}
58
+}
10 59
 
11 60
 // ParseDirent parses up to max directory entries in buf,
12 61
 // appending the names to names. It returns the number of
13 62
 // bytes consumed from buf, the number of entries added
14 63
 // to names, and the new names slice.
15 64
 func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
16
-	return syscall.ParseDirent(buf, max, names)
65
+	origlen := len(buf)
66
+	count = 0
67
+	for max != 0 && len(buf) > 0 {
68
+		reclen, ok := direntReclen(buf)
69
+		if !ok || reclen > uint64(len(buf)) {
70
+			return origlen, count, names
71
+		}
72
+		rec := buf[:reclen]
73
+		buf = buf[reclen:]
74
+		ino, ok := direntIno(rec)
75
+		if !ok {
76
+			break
77
+		}
78
+		if ino == 0 { // File absent in directory.
79
+			continue
80
+		}
81
+		const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))
82
+		namlen, ok := direntNamlen(rec)
83
+		if !ok || namoff+namlen > uint64(len(rec)) {
84
+			break
85
+		}
86
+		name := rec[namoff : namoff+namlen]
87
+		for i, c := range name {
88
+			if c == 0 {
89
+				name = name[:i]
90
+				break
91
+			}
92
+		}
93
+		// Check for useless names before allocating a string.
94
+		if string(name) == "." || string(name) == ".." {
95
+			continue
96
+		}
97
+		max--
98
+		count++
99
+		names = append(names, string(name))
100
+	}
101
+	return origlen - len(buf), count, names
17 102
 }

+ 1
- 1
vendor/golang.org/x/sys/unix/fcntl.go View File

@@ -2,7 +2,7 @@
2 2
 // Use of this source code is governed by a BSD-style
3 3
 // license that can be found in the LICENSE file.
4 4
 
5
-// +build darwin dragonfly freebsd linux netbsd openbsd
5
+// +build dragonfly freebsd linux netbsd openbsd
6 6
 
7 7
 package unix
8 8
 

+ 18
- 0
vendor/golang.org/x/sys/unix/fcntl_darwin.go View File

@@ -0,0 +1,18 @@
1
+// Copyright 2019 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+package unix
6
+
7
+import "unsafe"
8
+
9
+// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
10
+func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
11
+	return fcntl(int(fd), cmd, arg)
12
+}
13
+
14
+// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
15
+func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
16
+	_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk))))
17
+	return err
18
+}

+ 63
- 40
vendor/golang.org/x/sys/unix/mkall.sh View File

@@ -10,13 +10,14 @@
10 10
 GOOSARCH="${GOOS}_${GOARCH}"
11 11
 
12 12
 # defaults
13
-mksyscall="./mksyscall.pl"
13
+mksyscall="go run mksyscall.go"
14 14
 mkerrors="./mkerrors.sh"
15 15
 zerrors="zerrors_$GOOSARCH.go"
16 16
 mksysctl=""
17 17
 zsysctl="zsysctl_$GOOSARCH.go"
18 18
 mksysnum=
19 19
 mktypes=
20
+mkasm=
20 21
 run="sh"
21 22
 cmd=""
22 23
 
@@ -45,8 +46,8 @@ case "$#" in
45 46
 	exit 2
46 47
 esac
47 48
 
48
-if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
49
-	# Use then new build system
49
+if [[ "$GOOS" = "linux" ]]; then
50
+	# Use the Docker-based build system
50 51
 	# Files generated through docker (use $cmd so you can Ctl-C the build or run)
51 52
 	$cmd docker build --tag generate:$GOOS $GOOS
52 53
 	$cmd docker run --interactive --tty --volume $(dirname "$(readlink -f "$0")"):/build generate:$GOOS
@@ -61,112 +62,130 @@ _* | *_ | _)
61 62
 	;;
62 63
 aix_ppc)
63 64
 	mkerrors="$mkerrors -maix32"
64
-	mksyscall="./mksyscall_aix_ppc.pl -aix"
65
+	mksyscall="go run mksyscall_aix_ppc.go -aix"
65 66
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
66 67
 	;;
67 68
 aix_ppc64)
68 69
 	mkerrors="$mkerrors -maix64"
69
-	mksyscall="./mksyscall_aix_ppc64.pl -aix"
70
+	mksyscall="go run mksyscall_aix_ppc64.go -aix"
70 71
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
71 72
 	;;
72 73
 darwin_386)
73 74
 	mkerrors="$mkerrors -m32"
74
-	mksyscall="./mksyscall.pl -l32"
75
-	mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
75
+	mksyscall="go run mksyscall.go -l32"
76
+	mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
76 77
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
78
+	mkasm="go run mkasm_darwin.go"
77 79
 	;;
78 80
 darwin_amd64)
79 81
 	mkerrors="$mkerrors -m64"
80
-	mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
82
+	mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
81 83
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
84
+	mkasm="go run mkasm_darwin.go"
82 85
 	;;
83 86
 darwin_arm)
84 87
 	mkerrors="$mkerrors"
85
-	mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
88
+	mksyscall="go run mksyscall.go -l32"
89
+	mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
86 90
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
91
+	mkasm="go run mkasm_darwin.go"
87 92
 	;;
88 93
 darwin_arm64)
89 94
 	mkerrors="$mkerrors -m64"
90
-	mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
95
+	mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
91 96
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
97
+	mkasm="go run mkasm_darwin.go"
92 98
 	;;
93 99
 dragonfly_amd64)
94 100
 	mkerrors="$mkerrors -m64"
95
-	mksyscall="./mksyscall.pl -dragonfly"
96
-	mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
101
+	mksyscall="go run mksyscall.go -dragonfly"
102
+	mksysnum="go run mksysnum.go 'https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master'"
97 103
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
98 104
 	;;
99 105
 freebsd_386)
100 106
 	mkerrors="$mkerrors -m32"
101
-	mksyscall="./mksyscall.pl -l32"
102
-	mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
107
+	mksyscall="go run mksyscall.go -l32"
108
+	mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
103 109
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
104 110
 	;;
105 111
 freebsd_amd64)
106 112
 	mkerrors="$mkerrors -m64"
107
-	mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
113
+	mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
108 114
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
109 115
 	;;
110 116
 freebsd_arm)
111 117
 	mkerrors="$mkerrors"
112
-	mksyscall="./mksyscall.pl -l32 -arm"
113
-	mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
118
+	mksyscall="go run mksyscall.go -l32 -arm"
119
+	mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
114 120
 	# Let the type of C char be signed for making the bare syscall
115 121
 	# API consistent across platforms.
116 122
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
117 123
 	;;
118
-linux_sparc64)
119
-	GOOSARCH_in=syscall_linux_sparc64.go
120
-	unistd_h=/usr/include/sparc64-linux-gnu/asm/unistd.h
124
+freebsd_arm64)
121 125
 	mkerrors="$mkerrors -m64"
122
-	mksysnum="./mksysnum_linux.pl $unistd_h"
126
+	mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
123 127
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
124 128
 	;;
125 129
 netbsd_386)
126 130
 	mkerrors="$mkerrors -m32"
127
-	mksyscall="./mksyscall.pl -l32 -netbsd"
128
-	mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
131
+	mksyscall="go run mksyscall.go -l32 -netbsd"
132
+	mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
129 133
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
130 134
 	;;
131 135
 netbsd_amd64)
132 136
 	mkerrors="$mkerrors -m64"
133
-	mksyscall="./mksyscall.pl -netbsd"
134
-	mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
137
+	mksyscall="go run mksyscall.go -netbsd"
138
+	mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
135 139
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
136 140
 	;;
137 141
 netbsd_arm)
138 142
 	mkerrors="$mkerrors"
139
-	mksyscall="./mksyscall.pl -l32 -netbsd -arm"
140
-	mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
143
+	mksyscall="go run mksyscall.go -l32 -netbsd -arm"
144
+	mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
141 145
 	# Let the type of C char be signed for making the bare syscall
142 146
 	# API consistent across platforms.
143 147
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
144 148
 	;;
149
+netbsd_arm64)
150
+	mkerrors="$mkerrors -m64"
151
+	mksyscall="go run mksyscall.go -netbsd"
152
+	mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
153
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
154
+	;;
145 155
 openbsd_386)
146 156
 	mkerrors="$mkerrors -m32"
147
-	mksyscall="./mksyscall.pl -l32 -openbsd"
148
-	mksysctl="./mksysctl_openbsd.pl"
149
-	mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
157
+	mksyscall="go run mksyscall.go -l32 -openbsd"
158
+	mksysctl="go run mksysctl_openbsd.go"
159
+	mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
150 160
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
151 161
 	;;
152 162
 openbsd_amd64)
153 163
 	mkerrors="$mkerrors -m64"
154
-	mksyscall="./mksyscall.pl -openbsd"
155
-	mksysctl="./mksysctl_openbsd.pl"
156
-	mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
164
+	mksyscall="go run mksyscall.go -openbsd"
165
+	mksysctl="go run mksysctl_openbsd.go"
166
+	mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
157 167
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
158 168
 	;;
159 169
 openbsd_arm)
160 170
 	mkerrors="$mkerrors"
161
-	mksyscall="./mksyscall.pl -l32 -openbsd -arm"
162
-	mksysctl="./mksysctl_openbsd.pl"
163
-	mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
171
+	mksyscall="go run mksyscall.go -l32 -openbsd -arm"
172
+	mksysctl="go run mksysctl_openbsd.go"
173
+	mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
174
+	# Let the type of C char be signed for making the bare syscall
175
+	# API consistent across platforms.
176
+	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
177
+	;;
178
+openbsd_arm64)
179
+	mkerrors="$mkerrors -m64"
180
+	mksyscall="go run mksyscall.go -openbsd"
181
+	mksysctl="go run mksysctl_openbsd.go"
182
+	mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
164 183
 	# Let the type of C char be signed for making the bare syscall
165 184
 	# API consistent across platforms.
166 185
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
167 186
 	;;
168 187
 solaris_amd64)
169
-	mksyscall="./mksyscall_solaris.pl"
188
+	mksyscall="go run mksyscall_solaris.go"
170 189
 	mkerrors="$mkerrors -m64"
171 190
 	mksysnum=
172 191
 	mktypes="GOARCH=$GOARCH go tool cgo -godefs"
@@ -191,6 +210,11 @@ esac
191 210
 			if [ "$GOOSARCH" == "aix_ppc64" ]; then
192 211
 				# aix/ppc64 script generates files instead of writing to stdin.
193 212
 				echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in && gofmt -w zsyscall_$GOOSARCH.go && gofmt -w zsyscall_"$GOOSARCH"_gccgo.go && gofmt -w zsyscall_"$GOOSARCH"_gc.go " ;
213
+			elif [ "$GOOS" == "darwin" ]; then
214
+			        # pre-1.12, direct syscalls
215
+			        echo "$mksyscall -tags $GOOS,$GOARCH,!go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.1_11.go";
216
+			        # 1.12 and later, syscalls via libSystem
217
+				echo "$mksyscall -tags $GOOS,$GOARCH,go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
194 218
 			else
195 219
 				echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
196 220
 			fi
@@ -198,7 +222,6 @@ esac
198 222
 	esac
199 223
 	if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
200 224
 	if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
201
-	if [ -n "$mktypes" ]; then
202
-		echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go";
203
-	fi
225
+	if [ -n "$mktypes" ]; then echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go"; fi
226
+	if [ -n "$mkasm" ]; then echo "$mkasm $GOARCH"; fi
204 227
 ) | $run

+ 61
- 0
vendor/golang.org/x/sys/unix/mkasm_darwin.go View File

@@ -0,0 +1,61 @@
1
+// Copyright 2018 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build ignore
6
+
7
+// mkasm_darwin.go generates assembly trampolines to call libSystem routines from Go.
8
+//This program must be run after mksyscall.go.
9
+package main
10
+
11
+import (
12
+	"bytes"
13
+	"fmt"
14
+	"io/ioutil"
15
+	"log"
16
+	"os"
17
+	"strings"
18
+)
19
+
20
+func main() {
21
+	in1, err := ioutil.ReadFile("syscall_darwin.go")
22
+	if err != nil {
23
+		log.Fatalf("can't open syscall_darwin.go: %s", err)
24
+	}
25
+	arch := os.Args[1]
26
+	in2, err := ioutil.ReadFile(fmt.Sprintf("syscall_darwin_%s.go", arch))
27
+	if err != nil {
28
+		log.Fatalf("can't open syscall_darwin_%s.go: %s", arch, err)
29
+	}
30
+	in3, err := ioutil.ReadFile(fmt.Sprintf("zsyscall_darwin_%s.go", arch))
31
+	if err != nil {
32
+		log.Fatalf("can't open zsyscall_darwin_%s.go: %s", arch, err)
33
+	}
34
+	in := string(in1) + string(in2) + string(in3)
35
+
36
+	trampolines := map[string]bool{}
37
+
38
+	var out bytes.Buffer
39
+
40
+	fmt.Fprintf(&out, "// go run mkasm_darwin.go %s\n", strings.Join(os.Args[1:], " "))
41
+	fmt.Fprintf(&out, "// Code generated by the command above; DO NOT EDIT.\n")
42
+	fmt.Fprintf(&out, "\n")
43
+	fmt.Fprintf(&out, "// +build go1.12\n")
44
+	fmt.Fprintf(&out, "\n")
45
+	fmt.Fprintf(&out, "#include \"textflag.h\"\n")
46
+	for _, line := range strings.Split(in, "\n") {
47
+		if !strings.HasPrefix(line, "func ") || !strings.HasSuffix(line, "_trampoline()") {
48
+			continue
49
+		}
50
+		fn := line[5 : len(line)-13]
51
+		if !trampolines[fn] {
52
+			trampolines[fn] = true
53
+			fmt.Fprintf(&out, "TEXT ·%s_trampoline(SB),NOSPLIT,$0-0\n", fn)
54
+			fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn)
55
+		}
56
+	}
57
+	err = ioutil.WriteFile(fmt.Sprintf("zsyscall_darwin_%s.s", arch), out.Bytes(), 0644)
58
+	if err != nil {
59
+		log.Fatalf("can't write zsyscall_darwin_%s.s: %s", arch, err)
60
+	}
61
+}

+ 30
- 21
vendor/golang.org/x/sys/unix/mkerrors.sh View File

@@ -17,12 +17,10 @@ if test -z "$GOARCH" -o -z "$GOOS"; then
17 17
 fi
18 18
 
19 19
 # Check that we are using the new build system if we should
20
-if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
21
-	if [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then
22
-		echo 1>&2 "In the new build system, mkerrors should not be called directly."
23
-		echo 1>&2 "See README.md"
24
-		exit 1
25
-	fi
20
+if [[ "$GOOS" = "linux" ]] && [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then
21
+	echo 1>&2 "In the Docker based build system, mkerrors should not be called directly."
22
+	echo 1>&2 "See README.md"
23
+	exit 1
26 24
 fi
27 25
 
28 26
 if [[ "$GOOS" = "aix" ]]; then
@@ -101,7 +99,7 @@ includes_DragonFly='
101 99
 '
102 100
 
103 101
 includes_FreeBSD='
104
-#include <sys/capability.h>
102
+#include <sys/capsicum.h>
105 103
 #include <sys/param.h>
106 104
 #include <sys/types.h>
107 105
 #include <sys/event.h>
@@ -181,22 +179,29 @@ struct ltchars {
181 179
 #include <sys/stat.h>
182 180
 #include <sys/types.h>
183 181
 #include <sys/time.h>
182
+#include <sys/signalfd.h>
184 183
 #include <sys/socket.h>
185 184
 #include <sys/xattr.h>
185
+#include <linux/bpf.h>
186
+#include <linux/capability.h>
187
+#include <linux/errqueue.h>
186 188
 #include <linux/if.h>
187 189
 #include <linux/if_alg.h>
188 190
 #include <linux/if_arp.h>
189 191
 #include <linux/if_ether.h>
192
+#include <linux/if_ppp.h>
190 193
 #include <linux/if_tun.h>
191 194
 #include <linux/if_packet.h>
192 195
 #include <linux/if_addr.h>
193 196
 #include <linux/falloc.h>
197
+#include <linux/fanotify.h>
194 198
 #include <linux/filter.h>
195 199
 #include <linux/fs.h>
196 200
 #include <linux/kexec.h>
197 201
 #include <linux/keyctl.h>
198 202
 #include <linux/magic.h>
199 203
 #include <linux/memfd.h>
204
+#include <linux/module.h>
200 205
 #include <linux/netfilter/nfnetlink.h>
201 206
 #include <linux/netlink.h>
202 207
 #include <linux/net_namespace.h>
@@ -219,9 +224,18 @@ struct ltchars {
219 224
 #include <linux/hdreg.h>
220 225
 #include <linux/rtc.h>
221 226
 #include <linux/if_xdp.h>
227
+#include <linux/cryptouser.h>
222 228
 #include <mtd/ubi-user.h>
223 229
 #include <net/route.h>
230
+
231
+#if defined(__sparc__)
232
+// On sparc{,64}, the kernel defines struct termios2 itself which clashes with the
233
+// definition in glibc. As only the error constants are needed here, include the
234
+// generic termibits.h (which is included by termbits.h on sparc).
235
+#include <asm-generic/termbits.h>
236
+#else
224 237
 #include <asm/termbits.h>
238
+#endif
225 239
 
226 240
 #ifndef MSG_FASTOPEN
227 241
 #define MSG_FASTOPEN    0x20000000
@@ -249,16 +263,6 @@ struct ltchars {
249 263
 #define FS_KEY_DESC_PREFIX              "fscrypt:"
250 264
 #define FS_KEY_DESC_PREFIX_SIZE         8
251 265
 #define FS_MAX_KEY_SIZE                 64
252
-
253
-// XDP socket constants do not appear to be picked up otherwise.
254
-// Copied from samples/bpf/xdpsock_user.c.
255
-#ifndef SOL_XDP
256
-#define SOL_XDP 283
257
-#endif
258
-
259
-#ifndef AF_XDP
260
-#define AF_XDP 44
261
-#endif
262 266
 '
263 267
 
264 268
 includes_NetBSD='
@@ -431,7 +435,7 @@ ccflags="$@"
431 435
 		$2 ~ /^TC[IO](ON|OFF)$/ ||
432 436
 		$2 ~ /^IN_/ ||
433 437
 		$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
434
-		$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
438
+		$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|MCAST|EVFILT|NOTE|EV|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
435 439
 		$2 ~ /^TP_STATUS_/ ||
436 440
 		$2 ~ /^FALLOC_/ ||
437 441
 		$2 == "ICMPV6_FILTER" ||
@@ -445,10 +449,11 @@ ccflags="$@"
445 449
 		$2 !~ "MNT_BITS" &&
446 450
 		$2 ~ /^(MS|MNT|UMOUNT)_/ ||
447 451
 		$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
448
-		$2 ~ /^(O|F|E?FD|NAME|S|PTRACE|PT)_/ ||
452
+		$2 ~ /^(O|F|[ES]?FD|NAME|S|PTRACE|PT)_/ ||
449 453
 		$2 ~ /^KEXEC_/ ||
450 454
 		$2 ~ /^LINUX_REBOOT_CMD_/ ||
451 455
 		$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
456
+		$2 ~ /^MODULE_INIT_/ ||
452 457
 		$2 !~ "NLA_TYPE_MASK" &&
453 458
 		$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ ||
454 459
 		$2 ~ /^SIOC/ ||
@@ -463,14 +468,15 @@ ccflags="$@"
463 468
 		$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|LOCKS|MEMLOCK|MSGQUEUE|NICE|NOFILE|NPROC|RSS|RTPRIO|RTTIME|SIGPENDING|STACK)|RLIM_INFINITY/ ||
464 469
 		$2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
465 470
 		$2 ~ /^CLONE_[A-Z_]+/ ||
466
-		$2 !~ /^(BPF_TIMEVAL)$/ &&
471
+		$2 !~ /^(BPF_TIMEVAL|BPF_FIB_LOOKUP_[A-Z]+)$/ &&
467 472
 		$2 ~ /^(BPF|DLT)_/ ||
468
-		$2 ~ /^CLOCK_/ ||
473
+		$2 ~ /^(CLOCK|TIMER)_/ ||
469 474
 		$2 ~ /^CAN_/ ||
470 475
 		$2 ~ /^CAP_/ ||
471 476
 		$2 ~ /^ALG_/ ||
472 477
 		$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE|IOC_(GET|SET)_ENCRYPTION)/ ||
473 478
 		$2 ~ /^GRND_/ ||
479
+		$2 ~ /^RND/ ||
474 480
 		$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
475 481
 		$2 ~ /^KEYCTL_/ ||
476 482
 		$2 ~ /^PERF_EVENT_IOC_/ ||
@@ -496,8 +502,11 @@ ccflags="$@"
496 502
 		$2 ~ /^NFN/ ||
497 503
 		$2 ~ /^XDP_/ ||
498 504
 		$2 ~ /^(HDIO|WIN|SMART)_/ ||
505
+		$2 ~ /^CRYPTO_/ ||
499 506
 		$2 !~ "WMESGLEN" &&
500 507
 		$2 ~ /^W[A-Z0-9]+$/ ||
508
+		$2 ~/^PPPIOC/ ||
509
+		$2 ~ /^FAN_|FANOTIFY_/ ||
501 510
 		$2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)}
502 511
 		$2 ~ /^__WCOREFLAG$/ {next}
503 512
 		$2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}

+ 29
- 5
vendor/golang.org/x/sys/unix/mkpost.go View File

@@ -28,10 +28,10 @@ func main() {
28 28
 	if goarch == "" {
29 29
 		goarch = os.Getenv("GOARCH")
30 30
 	}
31
-	// Check that we are using the new build system if we should be.
32
-	if goos == "linux" && goarch != "sparc64" {
31
+	// Check that we are using the Docker-based build system if we should be.
32
+	if goos == "linux" {
33 33
 		if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
34
-			os.Stderr.WriteString("In the new build system, mkpost should not be called directly.\n")
34
+			os.Stderr.WriteString("In the Docker-based build system, mkpost should not be called directly.\n")
35 35
 			os.Stderr.WriteString("See README.md\n")
36 36
 			os.Exit(1)
37 37
 		}
@@ -42,9 +42,20 @@ func main() {
42 42
 		log.Fatal(err)
43 43
 	}
44 44
 
45
+	if goos == "aix" {
46
+		// Replace type of Atim, Mtim and Ctim by Timespec in Stat_t
47
+		// to avoid having both StTimespec and Timespec.
48
+		sttimespec := regexp.MustCompile(`_Ctype_struct_st_timespec`)
49
+		b = sttimespec.ReplaceAll(b, []byte("Timespec"))
50
+	}
51
+
45 52
 	// Intentionally export __val fields in Fsid and Sigset_t
46
-	valRegex := regexp.MustCompile(`type (Fsid|Sigset_t) struct {(\s+)X__val(\s+\S+\s+)}`)
47
-	b = valRegex.ReplaceAll(b, []byte("type $1 struct {${2}Val$3}"))
53
+	valRegex := regexp.MustCompile(`type (Fsid|Sigset_t) struct {(\s+)X__(bits|val)(\s+\S+\s+)}`)
54
+	b = valRegex.ReplaceAll(b, []byte("type $1 struct {${2}Val$4}"))
55
+
56
+	// Intentionally export __fds_bits field in FdSet
57
+	fdSetRegex := regexp.MustCompile(`type (FdSet) struct {(\s+)X__fds_bits(\s+\S+\s+)}`)
58
+	b = fdSetRegex.ReplaceAll(b, []byte("type $1 struct {${2}Bits$3}"))
48 59
 
49 60
 	// If we have empty Ptrace structs, we should delete them. Only s390x emits
50 61
 	// nonempty Ptrace structs.
@@ -65,6 +76,10 @@ func main() {
65 76
 	convertUtsnameRegex := regexp.MustCompile(`((Sys|Node|Domain)name|Release|Version|Machine)(\s+)\[(\d+)\]u?int8`)
66 77
 	b = convertUtsnameRegex.ReplaceAll(b, []byte("$1$3[$4]byte"))
67 78
 
79
+	// Convert [1024]int8 to [1024]byte in Ptmget members
80
+	convertPtmget := regexp.MustCompile(`([SC]n)(\s+)\[(\d+)\]u?int8`)
81
+	b = convertPtmget.ReplaceAll(b, []byte("$1[$3]byte"))
82
+
68 83
 	// Remove spare fields (e.g. in Statx_t)
69 84
 	spareFieldsRegex := regexp.MustCompile(`X__spare\S*`)
70 85
 	b = spareFieldsRegex.ReplaceAll(b, []byte("_"))
@@ -88,6 +103,15 @@ func main() {
88 103
 	cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`)
89 104
 	b = cgoCommandRegex.ReplaceAll(b, []byte(replacement))
90 105
 
106
+	// Rename Stat_t time fields
107
+	if goos == "freebsd" && goarch == "386" {
108
+		// Hide Stat_t.[AMCB]tim_ext fields
109
+		renameStatTimeExtFieldsRegex := regexp.MustCompile(`[AMCB]tim_ext`)
110
+		b = renameStatTimeExtFieldsRegex.ReplaceAll(b, []byte("_"))
111
+	}
112
+	renameStatTimeFieldsRegex := regexp.MustCompile(`([AMCB])(?:irth)?time?(?:spec)?\s+(Timespec|StTimespec)`)
113
+	b = renameStatTimeFieldsRegex.ReplaceAll(b, []byte("${1}tim ${2}"))
114
+
91 115
 	// gofmt
92 116
 	b, err = format.Source(b)
93 117
 	if err != nil {

+ 407
- 0
vendor/golang.org/x/sys/unix/mksyscall.go View File

@@ -0,0 +1,407 @@
1
+// Copyright 2018 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build ignore
6
+
7
+/*
8
+This program reads a file containing function prototypes
9
+(like syscall_darwin.go) and generates system call bodies.
10
+The prototypes are marked by lines beginning with "//sys"
11
+and read like func declarations if //sys is replaced by func, but:
12
+	* The parameter lists must give a name for each argument.
13
+	  This includes return parameters.
14
+	* The parameter lists must give a type for each argument:
15
+	  the (x, y, z int) shorthand is not allowed.
16
+	* If the return parameter is an error number, it must be named errno.
17
+
18
+A line beginning with //sysnb is like //sys, except that the
19
+goroutine will not be suspended during the execution of the system
20
+call.  This must only be used for system calls which can never
21
+block, as otherwise the system call could cause all goroutines to
22
+hang.
23
+*/
24
+package main
25
+
26
+import (
27
+	"bufio"
28
+	"flag"
29
+	"fmt"
30
+	"os"
31
+	"regexp"
32
+	"strings"
33
+)
34
+
35
+var (
36
+	b32       = flag.Bool("b32", false, "32bit big-endian")
37
+	l32       = flag.Bool("l32", false, "32bit little-endian")
38
+	plan9     = flag.Bool("plan9", false, "plan9")
39
+	openbsd   = flag.Bool("openbsd", false, "openbsd")
40
+	netbsd    = flag.Bool("netbsd", false, "netbsd")
41
+	dragonfly = flag.Bool("dragonfly", false, "dragonfly")
42
+	arm       = flag.Bool("arm", false, "arm") // 64-bit value should use (even, odd)-pair
43
+	tags      = flag.String("tags", "", "build tags")
44
+	filename  = flag.String("output", "", "output file name (standard output if omitted)")
45
+)
46
+
47
+// cmdLine returns this programs's commandline arguments
48
+func cmdLine() string {
49
+	return "go run mksyscall.go " + strings.Join(os.Args[1:], " ")
50
+}
51
+
52
+// buildTags returns build tags
53
+func buildTags() string {
54
+	return *tags
55
+}
56
+
57
+// Param is function parameter
58
+type Param struct {
59
+	Name string
60
+	Type string
61
+}
62
+
63
+// usage prints the program usage
64
+func usage() {
65
+	fmt.Fprintf(os.Stderr, "usage: go run mksyscall.go [-b32 | -l32] [-tags x,y] [file ...]\n")
66
+	os.Exit(1)
67
+}
68
+
69
+// parseParamList parses parameter list and returns a slice of parameters
70
+func parseParamList(list string) []string {
71
+	list = strings.TrimSpace(list)
72
+	if list == "" {
73
+		return []string{}
74
+	}
75
+	return regexp.MustCompile(`\s*,\s*`).Split(list, -1)
76
+}
77
+
78
+// parseParam splits a parameter into name and type
79
+func parseParam(p string) Param {
80
+	ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p)
81
+	if ps == nil {
82
+		fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p)
83
+		os.Exit(1)
84
+	}
85
+	return Param{ps[1], ps[2]}
86
+}
87
+
88
+func main() {
89
+	// Get the OS and architecture (using GOARCH_TARGET if it exists)
90
+	goos := os.Getenv("GOOS")
91
+	if goos == "" {
92
+		fmt.Fprintln(os.Stderr, "GOOS not defined in environment")
93
+		os.Exit(1)
94
+	}
95
+	goarch := os.Getenv("GOARCH_TARGET")
96
+	if goarch == "" {
97
+		goarch = os.Getenv("GOARCH")
98
+	}
99
+
100
+	// Check that we are using the Docker-based build system if we should
101
+	if goos == "linux" {
102
+		if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
103
+			fmt.Fprintf(os.Stderr, "In the Docker-based build system, mksyscall should not be called directly.\n")
104
+			fmt.Fprintf(os.Stderr, "See README.md\n")
105
+			os.Exit(1)
106
+		}
107
+	}
108
+
109
+	flag.Usage = usage
110
+	flag.Parse()
111
+	if len(flag.Args()) <= 0 {
112
+		fmt.Fprintf(os.Stderr, "no files to parse provided\n")
113
+		usage()
114
+	}
115
+
116
+	endianness := ""
117
+	if *b32 {
118
+		endianness = "big-endian"
119
+	} else if *l32 {
120
+		endianness = "little-endian"
121
+	}
122
+
123
+	libc := false
124
+	if goos == "darwin" && strings.Contains(buildTags(), ",go1.12") {
125
+		libc = true
126
+	}
127
+	trampolines := map[string]bool{}
128
+
129
+	text := ""
130
+	for _, path := range flag.Args() {
131
+		file, err := os.Open(path)
132
+		if err != nil {
133
+			fmt.Fprintf(os.Stderr, err.Error())
134
+			os.Exit(1)
135
+		}
136
+		s := bufio.NewScanner(file)
137
+		for s.Scan() {
138
+			t := s.Text()
139
+			t = strings.TrimSpace(t)
140
+			t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `)
141
+			nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t)
142
+			if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil {
143
+				continue
144
+			}
145
+
146
+			// Line must be of the form
147
+			//	func Open(path string, mode int, perm int) (fd int, errno error)
148
+			// Split into name, in params, out params.
149
+			f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$`).FindStringSubmatch(t)
150
+			if f == nil {
151
+				fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t)
152
+				os.Exit(1)
153
+			}
154
+			funct, inps, outps, sysname := f[2], f[3], f[4], f[5]
155
+
156
+			// ClockGettime doesn't have a syscall number on Darwin, only generate libc wrappers.
157
+			if goos == "darwin" && !libc && funct == "ClockGettime" {
158
+				continue
159
+			}
160
+
161
+			// Split argument lists on comma.
162
+			in := parseParamList(inps)
163
+			out := parseParamList(outps)
164
+
165
+			// Try in vain to keep people from editing this file.
166
+			// The theory is that they jump into the middle of the file
167
+			// without reading the header.
168
+			text += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"
169
+
170
+			// Go function header.
171
+			outDecl := ""
172
+			if len(out) > 0 {
173
+				outDecl = fmt.Sprintf(" (%s)", strings.Join(out, ", "))
174
+			}
175
+			text += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outDecl)
176
+
177
+			// Check if err return available
178
+			errvar := ""
179
+			for _, param := range out {
180
+				p := parseParam(param)
181
+				if p.Type == "error" {
182
+					errvar = p.Name
183
+					break
184
+				}
185
+			}
186
+
187
+			// Prepare arguments to Syscall.
188
+			var args []string
189
+			n := 0
190
+			for _, param := range in {
191
+				p := parseParam(param)
192
+				if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil {
193
+					args = append(args, "uintptr(unsafe.Pointer("+p.Name+"))")
194
+				} else if p.Type == "string" && errvar != "" {
195
+					text += fmt.Sprintf("\tvar _p%d *byte\n", n)
196
+					text += fmt.Sprintf("\t_p%d, %s = BytePtrFromString(%s)\n", n, errvar, p.Name)
197
+					text += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar)
198
+					args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n))
199
+					n++
200
+				} else if p.Type == "string" {
201
+					fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n")
202
+					text += fmt.Sprintf("\tvar _p%d *byte\n", n)
203
+					text += fmt.Sprintf("\t_p%d, _ = BytePtrFromString(%s)\n", n, p.Name)
204
+					args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n))
205
+					n++
206
+				} else if regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type) != nil {
207
+					// Convert slice into pointer, length.
208
+					// Have to be careful not to take address of &a[0] if len == 0:
209
+					// pass dummy pointer in that case.
210
+					// Used to pass nil, but some OSes or simulators reject write(fd, nil, 0).
211
+					text += fmt.Sprintf("\tvar _p%d unsafe.Pointer\n", n)
212
+					text += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = unsafe.Pointer(&%s[0])\n\t}", p.Name, n, p.Name)
213
+					text += fmt.Sprintf(" else {\n\t\t_p%d = unsafe.Pointer(&_zero)\n\t}\n", n)
214
+					args = append(args, fmt.Sprintf("uintptr(_p%d)", n), fmt.Sprintf("uintptr(len(%s))", p.Name))
215
+					n++
216
+				} else if p.Type == "int64" && (*openbsd || *netbsd) {
217
+					args = append(args, "0")
218
+					if endianness == "big-endian" {
219
+						args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
220
+					} else if endianness == "little-endian" {
221
+						args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
222
+					} else {
223
+						args = append(args, fmt.Sprintf("uintptr(%s)", p.Name))
224
+					}
225
+				} else if p.Type == "int64" && *dragonfly {
226
+					if regexp.MustCompile(`^(?i)extp(read|write)`).FindStringSubmatch(funct) == nil {
227
+						args = append(args, "0")
228
+					}
229
+					if endianness == "big-endian" {
230
+						args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
231
+					} else if endianness == "little-endian" {
232
+						args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
233
+					} else {
234
+						args = append(args, fmt.Sprintf("uintptr(%s)", p.Name))
235
+					}
236
+				} else if (p.Type == "int64" || p.Type == "uint64") && endianness != "" {
237
+					if len(args)%2 == 1 && *arm {
238
+						// arm abi specifies 64-bit argument uses
239
+						// (even, odd) pair
240
+						args = append(args, "0")
241
+					}
242
+					if endianness == "big-endian" {
243
+						args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
244
+					} else {
245
+						args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
246
+					}
247
+				} else {
248
+					args = append(args, fmt.Sprintf("uintptr(%s)", p.Name))
249
+				}
250
+			}
251
+
252
+			// Determine which form to use; pad args with zeros.
253
+			asm := "Syscall"
254
+			if nonblock != nil {
255
+				if errvar == "" && goos == "linux" {
256
+					asm = "RawSyscallNoError"
257
+				} else {
258
+					asm = "RawSyscall"
259
+				}
260
+			} else {
261
+				if errvar == "" && goos == "linux" {
262
+					asm = "SyscallNoError"
263
+				}
264
+			}
265
+			if len(args) <= 3 {
266
+				for len(args) < 3 {
267
+					args = append(args, "0")
268
+				}
269
+			} else if len(args) <= 6 {
270
+				asm += "6"
271
+				for len(args) < 6 {
272
+					args = append(args, "0")
273
+				}
274
+			} else if len(args) <= 9 {
275
+				asm += "9"
276
+				for len(args) < 9 {
277
+					args = append(args, "0")
278
+				}
279
+			} else {
280
+				fmt.Fprintf(os.Stderr, "%s:%s too many arguments to system call\n", path, funct)
281
+			}
282
+
283
+			// System call number.
284
+			if sysname == "" {
285
+				sysname = "SYS_" + funct
286
+				sysname = regexp.MustCompile(`([a-z])([A-Z])`).ReplaceAllString(sysname, `${1}_$2`)
287
+				sysname = strings.ToUpper(sysname)
288
+			}
289
+
290
+			var libcFn string
291
+			if libc {
292
+				asm = "syscall_" + strings.ToLower(asm[:1]) + asm[1:] // internal syscall call
293
+				sysname = strings.TrimPrefix(sysname, "SYS_")         // remove SYS_
294
+				sysname = strings.ToLower(sysname)                    // lowercase
295
+				if sysname == "getdirentries64" {
296
+					// Special case - libSystem name and
297
+					// raw syscall name don't match.
298
+					sysname = "__getdirentries64"
299
+				}
300
+				libcFn = sysname
301
+				sysname = "funcPC(libc_" + sysname + "_trampoline)"
302
+			}
303
+
304
+			// Actual call.
305
+			arglist := strings.Join(args, ", ")
306
+			call := fmt.Sprintf("%s(%s, %s)", asm, sysname, arglist)
307
+
308
+			// Assign return values.
309
+			body := ""
310
+			ret := []string{"_", "_", "_"}
311
+			doErrno := false
312
+			for i := 0; i < len(out); i++ {
313
+				p := parseParam(out[i])
314
+				reg := ""
315
+				if p.Name == "err" && !*plan9 {
316
+					reg = "e1"
317
+					ret[2] = reg
318
+					doErrno = true
319
+				} else if p.Name == "err" && *plan9 {
320
+					ret[0] = "r0"
321
+					ret[2] = "e1"
322
+					break
323
+				} else {
324
+					reg = fmt.Sprintf("r%d", i)
325
+					ret[i] = reg
326
+				}
327
+				if p.Type == "bool" {
328
+					reg = fmt.Sprintf("%s != 0", reg)
329
+				}
330
+				if p.Type == "int64" && endianness != "" {
331
+					// 64-bit number in r1:r0 or r0:r1.
332
+					if i+2 > len(out) {
333
+						fmt.Fprintf(os.Stderr, "%s:%s not enough registers for int64 return\n", path, funct)
334
+					}
335
+					if endianness == "big-endian" {
336
+						reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i, i+1)
337
+					} else {
338
+						reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i+1, i)
339
+					}
340
+					ret[i] = fmt.Sprintf("r%d", i)
341
+					ret[i+1] = fmt.Sprintf("r%d", i+1)
342
+				}
343
+				if reg != "e1" || *plan9 {
344
+					body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg)
345
+				}
346
+			}
347
+			if ret[0] == "_" && ret[1] == "_" && ret[2] == "_" {
348
+				text += fmt.Sprintf("\t%s\n", call)
349
+			} else {
350
+				if errvar == "" && goos == "linux" {
351
+					// raw syscall without error on Linux, see golang.org/issue/22924
352
+					text += fmt.Sprintf("\t%s, %s := %s\n", ret[0], ret[1], call)
353
+				} else {
354
+					text += fmt.Sprintf("\t%s, %s, %s := %s\n", ret[0], ret[1], ret[2], call)
355
+				}
356
+			}
357
+			text += body
358
+
359
+			if *plan9 && ret[2] == "e1" {
360
+				text += "\tif int32(r0) == -1 {\n"
361
+				text += "\t\terr = e1\n"
362
+				text += "\t}\n"
363
+			} else if doErrno {
364
+				text += "\tif e1 != 0 {\n"
365
+				text += "\t\terr = errnoErr(e1)\n"
366
+				text += "\t}\n"
367
+			}
368
+			text += "\treturn\n"
369
+			text += "}\n\n"
370
+
371
+			if libc && !trampolines[libcFn] {
372
+				// some system calls share a trampoline, like read and readlen.
373
+				trampolines[libcFn] = true
374
+				// Declare assembly trampoline.
375
+				text += fmt.Sprintf("func libc_%s_trampoline()\n", libcFn)
376
+				// Assembly trampoline calls the libc_* function, which this magic
377
+				// redirects to use the function from libSystem.
378
+				text += fmt.Sprintf("//go:linkname libc_%s libc_%s\n", libcFn, libcFn)
379
+				text += fmt.Sprintf("//go:cgo_import_dynamic libc_%s %s \"/usr/lib/libSystem.B.dylib\"\n", libcFn, libcFn)
380
+				text += "\n"
381
+			}
382
+		}
383
+		if err := s.Err(); err != nil {
384
+			fmt.Fprintf(os.Stderr, err.Error())
385
+			os.Exit(1)
386
+		}
387
+		file.Close()
388
+	}
389
+	fmt.Printf(srcTemplate, cmdLine(), buildTags(), text)
390
+}
391
+
392
+const srcTemplate = `// %s
393
+// Code generated by the command above; see README.md. DO NOT EDIT.
394
+
395
+// +build %s
396
+
397
+package unix
398
+
399
+import (
400
+	"syscall"
401
+	"unsafe"
402
+)
403
+
404
+var _ syscall.Errno
405
+
406
+%s
407
+`

+ 0
- 341
vendor/golang.org/x/sys/unix/mksyscall.pl View File

@@ -1,341 +0,0 @@
1
-#!/usr/bin/env perl
2
-# Copyright 2009 The Go Authors. All rights reserved.
3
-# Use of this source code is governed by a BSD-style
4
-# license that can be found in the LICENSE file.
5
-
6
-# This program reads a file containing function prototypes
7
-# (like syscall_darwin.go) and generates system call bodies.
8
-# The prototypes are marked by lines beginning with "//sys"
9
-# and read like func declarations if //sys is replaced by func, but:
10
-#	* The parameter lists must give a name for each argument.
11
-#	  This includes return parameters.
12
-#	* The parameter lists must give a type for each argument:
13
-#	  the (x, y, z int) shorthand is not allowed.
14
-#	* If the return parameter is an error number, it must be named errno.
15
-
16
-# A line beginning with //sysnb is like //sys, except that the
17
-# goroutine will not be suspended during the execution of the system
18
-# call.  This must only be used for system calls which can never
19
-# block, as otherwise the system call could cause all goroutines to
20
-# hang.
21
-
22
-use strict;
23
-
24
-my $cmdline = "mksyscall.pl " . join(' ', @ARGV);
25
-my $errors = 0;
26
-my $_32bit = "";
27
-my $plan9 = 0;
28
-my $openbsd = 0;
29
-my $netbsd = 0;
30
-my $dragonfly = 0;
31
-my $arm = 0; # 64-bit value should use (even, odd)-pair
32
-my $tags = "";  # build tags
33
-
34
-if($ARGV[0] eq "-b32") {
35
-	$_32bit = "big-endian";
36
-	shift;
37
-} elsif($ARGV[0] eq "-l32") {
38
-	$_32bit = "little-endian";
39
-	shift;
40
-}
41
-if($ARGV[0] eq "-plan9") {
42
-	$plan9 = 1;
43
-	shift;
44
-}
45
-if($ARGV[0] eq "-openbsd") {
46
-	$openbsd = 1;
47
-	shift;
48
-}
49
-if($ARGV[0] eq "-netbsd") {
50
-	$netbsd = 1;
51
-	shift;
52
-}
53
-if($ARGV[0] eq "-dragonfly") {
54
-	$dragonfly = 1;
55
-	shift;
56
-}
57
-if($ARGV[0] eq "-arm") {
58
-	$arm = 1;
59
-	shift;
60
-}
61
-if($ARGV[0] eq "-tags") {
62
-	shift;
63
-	$tags = $ARGV[0];
64
-	shift;
65
-}
66
-
67
-if($ARGV[0] =~ /^-/) {
68
-	print STDERR "usage: mksyscall.pl [-b32 | -l32] [-tags x,y] [file ...]\n";
69
-	exit 1;
70
-}
71
-
72
-# Check that we are using the new build system if we should
73
-if($ENV{'GOOS'} eq "linux" && $ENV{'GOARCH'} ne "sparc64") {
74
-	if($ENV{'GOLANG_SYS_BUILD'} ne "docker") {
75
-		print STDERR "In the new build system, mksyscall should not be called directly.\n";
76
-		print STDERR "See README.md\n";
77
-		exit 1;
78
-	}
79
-}
80
-
81
-
82
-sub parseparamlist($) {
83
-	my ($list) = @_;
84
-	$list =~ s/^\s*//;
85
-	$list =~ s/\s*$//;
86
-	if($list eq "") {
87
-		return ();
88
-	}
89
-	return split(/\s*,\s*/, $list);
90
-}
91
-
92
-sub parseparam($) {
93
-	my ($p) = @_;
94
-	if($p !~ /^(\S*) (\S*)$/) {
95
-		print STDERR "$ARGV:$.: malformed parameter: $p\n";
96
-		$errors = 1;
97
-		return ("xx", "int");
98
-	}
99
-	return ($1, $2);
100
-}
101
-
102
-my $text = "";
103
-while(<>) {
104
-	chomp;
105
-	s/\s+/ /g;
106
-	s/^\s+//;
107
-	s/\s+$//;
108
-	my $nonblock = /^\/\/sysnb /;
109
-	next if !/^\/\/sys / && !$nonblock;
110
-
111
-	# Line must be of the form
112
-	#	func Open(path string, mode int, perm int) (fd int, errno error)
113
-	# Split into name, in params, out params.
114
-	if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$/) {
115
-		print STDERR "$ARGV:$.: malformed //sys declaration\n";
116
-		$errors = 1;
117
-		next;
118
-	}
119
-	my ($func, $in, $out, $sysname) = ($2, $3, $4, $5);
120
-
121
-	# Split argument lists on comma.
122
-	my @in = parseparamlist($in);
123
-	my @out = parseparamlist($out);
124
-
125
-	# Try in vain to keep people from editing this file.
126
-	# The theory is that they jump into the middle of the file
127
-	# without reading the header.
128
-	$text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n";
129
-
130
-	# Go function header.
131
-	my $out_decl = @out ? sprintf(" (%s)", join(', ', @out)) : "";
132
-	$text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out_decl;
133
-
134
-	# Check if err return available
135
-	my $errvar = "";
136
-	foreach my $p (@out) {
137
-		my ($name, $type) = parseparam($p);
138
-		if($type eq "error") {
139
-			$errvar = $name;
140
-			last;
141
-		}
142
-	}
143
-
144
-	# Prepare arguments to Syscall.
145
-	my @args = ();
146
-	my $n = 0;
147
-	foreach my $p (@in) {
148
-		my ($name, $type) = parseparam($p);
149
-		if($type =~ /^\*/) {
150
-			push @args, "uintptr(unsafe.Pointer($name))";
151
-		} elsif($type eq "string" && $errvar ne "") {
152
-			$text .= "\tvar _p$n *byte\n";
153
-			$text .= "\t_p$n, $errvar = BytePtrFromString($name)\n";
154
-			$text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
155
-			push @args, "uintptr(unsafe.Pointer(_p$n))";
156
-			$n++;
157
-		} elsif($type eq "string") {
158
-			print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
159
-			$text .= "\tvar _p$n *byte\n";
160
-			$text .= "\t_p$n, _ = BytePtrFromString($name)\n";
161
-			push @args, "uintptr(unsafe.Pointer(_p$n))";
162
-			$n++;
163
-		} elsif($type =~ /^\[\](.*)/) {
164
-			# Convert slice into pointer, length.
165
-			# Have to be careful not to take address of &a[0] if len == 0:
166
-			# pass dummy pointer in that case.
167
-			# Used to pass nil, but some OSes or simulators reject write(fd, nil, 0).
168
-			$text .= "\tvar _p$n unsafe.Pointer\n";
169
-			$text .= "\tif len($name) > 0 {\n\t\t_p$n = unsafe.Pointer(\&${name}[0])\n\t}";
170
-			$text .= " else {\n\t\t_p$n = unsafe.Pointer(&_zero)\n\t}";
171
-			$text .= "\n";
172
-			push @args, "uintptr(_p$n)", "uintptr(len($name))";
173
-			$n++;
174
-		} elsif($type eq "int64" && ($openbsd || $netbsd)) {
175
-			push @args, "0";
176
-			if($_32bit eq "big-endian") {
177
-				push @args, "uintptr($name>>32)", "uintptr($name)";
178
-			} elsif($_32bit eq "little-endian") {
179
-				push @args, "uintptr($name)", "uintptr($name>>32)";
180
-			} else {
181
-				push @args, "uintptr($name)";
182
-			}
183
-		} elsif($type eq "int64" && $dragonfly) {
184
-			if ($func !~ /^extp(read|write)/i) {
185
-				push @args, "0";
186
-			}
187
-			if($_32bit eq "big-endian") {
188
-				push @args, "uintptr($name>>32)", "uintptr($name)";
189
-			} elsif($_32bit eq "little-endian") {
190
-				push @args, "uintptr($name)", "uintptr($name>>32)";
191
-			} else {
192
-				push @args, "uintptr($name)";
193
-			}
194
-		} elsif($type eq "int64" && $_32bit ne "") {
195
-			if(@args % 2 && $arm) {
196
-				# arm abi specifies 64-bit argument uses
197
-				# (even, odd) pair
198
-				push @args, "0"
199
-			}
200
-			if($_32bit eq "big-endian") {
201
-				push @args, "uintptr($name>>32)", "uintptr($name)";
202
-			} else {
203
-				push @args, "uintptr($name)", "uintptr($name>>32)";
204
-			}
205
-		} else {
206
-			push @args, "uintptr($name)";
207
-		}
208
-	}
209
-
210
-	# Determine which form to use; pad args with zeros.
211
-	my $asm = "Syscall";
212
-	if ($nonblock) {
213
-		if ($errvar eq "" && $ENV{'GOOS'} eq "linux") {
214
-			$asm = "RawSyscallNoError";
215
-		} else {
216
-			$asm = "RawSyscall";
217
-		}
218
-	} else {
219
-		if ($errvar eq "" && $ENV{'GOOS'} eq "linux") {
220
-			$asm = "SyscallNoError";
221
-		}
222
-	}
223
-	if(@args <= 3) {
224
-		while(@args < 3) {
225
-			push @args, "0";
226
-		}
227
-	} elsif(@args <= 6) {
228
-		$asm .= "6";
229
-		while(@args < 6) {
230
-			push @args, "0";
231
-		}
232
-	} elsif(@args <= 9) {
233
-		$asm .= "9";
234
-		while(@args < 9) {
235
-			push @args, "0";
236
-		}
237
-	} else {
238
-		print STDERR "$ARGV:$.: too many arguments to system call\n";
239
-	}
240
-
241
-	# System call number.
242
-	if($sysname eq "") {
243
-		$sysname = "SYS_$func";
244
-		$sysname =~ s/([a-z])([A-Z])/${1}_$2/g;	# turn FooBar into Foo_Bar
245
-		$sysname =~ y/a-z/A-Z/;
246
-	}
247
-
248
-	# Actual call.
249
-	my $args = join(', ', @args);
250
-	my $call = "$asm($sysname, $args)";
251
-
252
-	# Assign return values.
253
-	my $body = "";
254
-	my @ret = ("_", "_", "_");
255
-	my $do_errno = 0;
256
-	for(my $i=0; $i<@out; $i++) {
257
-		my $p = $out[$i];
258
-		my ($name, $type) = parseparam($p);
259
-		my $reg = "";
260
-		if($name eq "err" && !$plan9) {
261
-			$reg = "e1";
262
-			$ret[2] = $reg;
263
-			$do_errno = 1;
264
-		} elsif($name eq "err" && $plan9) {
265
-			$ret[0] = "r0";
266
-			$ret[2] = "e1";
267
-			next;
268
-		} else {
269
-			$reg = sprintf("r%d", $i);
270
-			$ret[$i] = $reg;
271
-		}
272
-		if($type eq "bool") {
273
-			$reg = "$reg != 0";
274
-		}
275
-		if($type eq "int64" && $_32bit ne "") {
276
-			# 64-bit number in r1:r0 or r0:r1.
277
-			if($i+2 > @out) {
278
-				print STDERR "$ARGV:$.: not enough registers for int64 return\n";
279
-			}
280
-			if($_32bit eq "big-endian") {
281
-				$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1);
282
-			} else {
283
-				$reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i);
284
-			}
285
-			$ret[$i] = sprintf("r%d", $i);
286
-			$ret[$i+1] = sprintf("r%d", $i+1);
287
-		}
288
-		if($reg ne "e1" || $plan9) {
289
-			$body .= "\t$name = $type($reg)\n";
290
-		}
291
-	}
292
-	if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
293
-		$text .= "\t$call\n";
294
-	} else {
295
-		if ($errvar eq "" && $ENV{'GOOS'} eq "linux") {
296
-			# raw syscall without error on Linux, see golang.org/issue/22924
297
-			$text .= "\t$ret[0], $ret[1] := $call\n";
298
-		} else {
299
-			$text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
300
-		}
301
-	}
302
-	$text .= $body;
303
-
304
-	if ($plan9 && $ret[2] eq "e1") {
305
-		$text .= "\tif int32(r0) == -1 {\n";
306
-		$text .= "\t\terr = e1\n";
307
-		$text .= "\t}\n";
308
-	} elsif ($do_errno) {
309
-		$text .= "\tif e1 != 0 {\n";
310
-		$text .= "\t\terr = errnoErr(e1)\n";
311
-		$text .= "\t}\n";
312
-	}
313
-	$text .= "\treturn\n";
314
-	$text .= "}\n\n";
315
-}
316
-
317
-chomp $text;
318
-chomp $text;
319
-
320
-if($errors) {
321
-	exit 1;
322
-}
323
-
324
-print <<EOF;
325
-// $cmdline
326
-// Code generated by the command above; see README.md. DO NOT EDIT.
327
-
328
-// +build $tags
329
-
330
-package unix
331
-
332
-import (
333
-	"syscall"
334
-	"unsafe"
335
-)
336
-
337
-var _ syscall.Errno
338
-
339
-$text
340
-EOF
341
-exit 0;

+ 415
- 0
vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go View File

@@ -0,0 +1,415 @@
1
+// Copyright 2019 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build ignore
6
+
7
+/*
8
+This program reads a file containing function prototypes
9
+(like syscall_aix.go) and generates system call bodies.
10
+The prototypes are marked by lines beginning with "//sys"
11
+and read like func declarations if //sys is replaced by func, but:
12
+	* The parameter lists must give a name for each argument.
13
+	  This includes return parameters.
14
+	* The parameter lists must give a type for each argument:
15
+	  the (x, y, z int) shorthand is not allowed.
16
+	* If the return parameter is an error number, it must be named err.
17
+	* If go func name needs to be different than its libc name,
18
+	* or the function is not in libc, name could be specified
19
+	* at the end, after "=" sign, like
20
+	  //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
21
+*/
22
+package main
23
+
24
+import (
25
+	"bufio"
26
+	"flag"
27
+	"fmt"
28
+	"os"
29
+	"regexp"
30
+	"strings"
31
+)
32
+
33
+var (
34
+	b32  = flag.Bool("b32", false, "32bit big-endian")
35
+	l32  = flag.Bool("l32", false, "32bit little-endian")
36
+	aix  = flag.Bool("aix", false, "aix")
37
+	tags = flag.String("tags", "", "build tags")
38
+)
39
+
40
+// cmdLine returns this programs's commandline arguments
41
+func cmdLine() string {
42
+	return "go run mksyscall_aix_ppc.go " + strings.Join(os.Args[1:], " ")
43
+}
44
+
45
+// buildTags returns build tags
46
+func buildTags() string {
47
+	return *tags
48
+}
49
+
50
+// Param is function parameter
51
+type Param struct {
52
+	Name string
53
+	Type string
54
+}
55
+
56
+// usage prints the program usage
57
+func usage() {
58
+	fmt.Fprintf(os.Stderr, "usage: go run mksyscall_aix_ppc.go [-b32 | -l32] [-tags x,y] [file ...]\n")
59
+	os.Exit(1)
60
+}
61
+
62
+// parseParamList parses parameter list and returns a slice of parameters
63
+func parseParamList(list string) []string {
64
+	list = strings.TrimSpace(list)
65
+	if list == "" {
66
+		return []string{}
67
+	}
68
+	return regexp.MustCompile(`\s*,\s*`).Split(list, -1)
69
+}
70
+
71
+// parseParam splits a parameter into name and type
72
+func parseParam(p string) Param {
73
+	ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p)
74
+	if ps == nil {
75
+		fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p)
76
+		os.Exit(1)
77
+	}
78
+	return Param{ps[1], ps[2]}
79
+}
80
+
81
+func main() {
82
+	flag.Usage = usage
83
+	flag.Parse()
84
+	if len(flag.Args()) <= 0 {
85
+		fmt.Fprintf(os.Stderr, "no files to parse provided\n")
86
+		usage()
87
+	}
88
+
89
+	endianness := ""
90
+	if *b32 {
91
+		endianness = "big-endian"
92
+	} else if *l32 {
93
+		endianness = "little-endian"
94
+	}
95
+
96
+	pack := ""
97
+	text := ""
98
+	cExtern := "/*\n#include <stdint.h>\n#include <stddef.h>\n"
99
+	for _, path := range flag.Args() {
100
+		file, err := os.Open(path)
101
+		if err != nil {
102
+			fmt.Fprintf(os.Stderr, err.Error())
103
+			os.Exit(1)
104
+		}
105
+		s := bufio.NewScanner(file)
106
+		for s.Scan() {
107
+			t := s.Text()
108
+			t = strings.TrimSpace(t)
109
+			t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `)
110
+			if p := regexp.MustCompile(`^package (\S+)$`).FindStringSubmatch(t); p != nil && pack == "" {
111
+				pack = p[1]
112
+			}
113
+			nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t)
114
+			if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil {
115
+				continue
116
+			}
117
+
118
+			// Line must be of the form
119
+			//	func Open(path string, mode int, perm int) (fd int, err error)
120
+			// Split into name, in params, out params.
121
+			f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$`).FindStringSubmatch(t)
122
+			if f == nil {
123
+				fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t)
124
+				os.Exit(1)
125
+			}
126
+			funct, inps, outps, modname, sysname := f[2], f[3], f[4], f[5], f[6]
127
+
128
+			// Split argument lists on comma.
129
+			in := parseParamList(inps)
130
+			out := parseParamList(outps)
131
+
132
+			inps = strings.Join(in, ", ")
133
+			outps = strings.Join(out, ", ")
134
+
135
+			// Try in vain to keep people from editing this file.
136
+			// The theory is that they jump into the middle of the file
137
+			// without reading the header.
138
+			text += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"
139
+
140
+			// Check if value return, err return available
141
+			errvar := ""
142
+			retvar := ""
143
+			rettype := ""
144
+			for _, param := range out {
145
+				p := parseParam(param)
146
+				if p.Type == "error" {
147
+					errvar = p.Name
148
+				} else {
149
+					retvar = p.Name
150
+					rettype = p.Type
151
+				}
152
+			}
153
+
154
+			// System call name.
155
+			if sysname == "" {
156
+				sysname = funct
157
+			}
158
+			sysname = regexp.MustCompile(`([a-z])([A-Z])`).ReplaceAllString(sysname, `${1}_$2`)
159
+			sysname = strings.ToLower(sysname) // All libc functions are lowercase.
160
+
161
+			cRettype := ""
162
+			if rettype == "unsafe.Pointer" {
163
+				cRettype = "uintptr_t"
164
+			} else if rettype == "uintptr" {
165
+				cRettype = "uintptr_t"
166
+			} else if regexp.MustCompile(`^_`).FindStringSubmatch(rettype) != nil {
167
+				cRettype = "uintptr_t"
168
+			} else if rettype == "int" {
169
+				cRettype = "int"
170
+			} else if rettype == "int32" {
171
+				cRettype = "int"
172
+			} else if rettype == "int64" {
173
+				cRettype = "long long"
174
+			} else if rettype == "uint32" {
175
+				cRettype = "unsigned int"
176
+			} else if rettype == "uint64" {
177
+				cRettype = "unsigned long long"
178
+			} else {
179
+				cRettype = "int"
180
+			}
181
+			if sysname == "exit" {
182
+				cRettype = "void"
183
+			}
184
+
185
+			// Change p.Types to c
186
+			var cIn []string
187
+			for _, param := range in {
188
+				p := parseParam(param)
189
+				if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil {
190
+					cIn = append(cIn, "uintptr_t")
191
+				} else if p.Type == "string" {
192
+					cIn = append(cIn, "uintptr_t")
193
+				} else if regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type) != nil {
194
+					cIn = append(cIn, "uintptr_t", "size_t")
195
+				} else if p.Type == "unsafe.Pointer" {
196
+					cIn = append(cIn, "uintptr_t")
197
+				} else if p.Type == "uintptr" {
198
+					cIn = append(cIn, "uintptr_t")
199
+				} else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil {
200
+					cIn = append(cIn, "uintptr_t")
201
+				} else if p.Type == "int" {
202
+					cIn = append(cIn, "int")
203
+				} else if p.Type == "int32" {
204
+					cIn = append(cIn, "int")
205
+				} else if p.Type == "int64" {
206
+					cIn = append(cIn, "long long")
207
+				} else if p.Type == "uint32" {
208
+					cIn = append(cIn, "unsigned int")
209
+				} else if p.Type == "uint64" {
210
+					cIn = append(cIn, "unsigned long long")
211
+				} else {
212
+					cIn = append(cIn, "int")
213
+				}
214
+			}
215
+
216
+			if funct != "fcntl" && funct != "FcntlInt" && funct != "readlen" && funct != "writelen" {
217
+				if sysname == "select" {
218
+					// select is a keyword of Go. Its name is
219
+					// changed to c_select.
220
+					cExtern += "#define c_select select\n"
221
+				}
222
+				// Imports of system calls from libc
223
+				cExtern += fmt.Sprintf("%s %s", cRettype, sysname)
224
+				cIn := strings.Join(cIn, ", ")
225
+				cExtern += fmt.Sprintf("(%s);\n", cIn)
226
+			}
227
+
228
+			// So file name.
229
+			if *aix {
230
+				if modname == "" {
231
+					modname = "libc.a/shr_64.o"
232
+				} else {
233
+					fmt.Fprintf(os.Stderr, "%s: only syscall using libc are available\n", funct)
234
+					os.Exit(1)
235
+				}
236
+			}
237
+
238
+			strconvfunc := "C.CString"
239
+
240
+			// Go function header.
241
+			if outps != "" {
242
+				outps = fmt.Sprintf(" (%s)", outps)
243
+			}
244
+			if text != "" {
245
+				text += "\n"
246
+			}
247
+
248
+			text += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outps)
249
+
250
+			// Prepare arguments to Syscall.
251
+			var args []string
252
+			n := 0
253
+			argN := 0
254
+			for _, param := range in {
255
+				p := parseParam(param)
256
+				if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil {
257
+					args = append(args, "C.uintptr_t(uintptr(unsafe.Pointer("+p.Name+")))")
258
+				} else if p.Type == "string" && errvar != "" {
259
+					text += fmt.Sprintf("\t_p%d := uintptr(unsafe.Pointer(%s(%s)))\n", n, strconvfunc, p.Name)
260
+					args = append(args, fmt.Sprintf("C.uintptr_t(_p%d)", n))
261
+					n++
262
+				} else if p.Type == "string" {
263
+					fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n")
264
+					text += fmt.Sprintf("\t_p%d := uintptr(unsafe.Pointer(%s(%s)))\n", n, strconvfunc, p.Name)
265
+					args = append(args, fmt.Sprintf("C.uintptr_t(_p%d)", n))
266
+					n++
267
+				} else if m := regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type); m != nil {
268
+					// Convert slice into pointer, length.
269
+					// Have to be careful not to take address of &a[0] if len == 0:
270
+					// pass nil in that case.
271
+					text += fmt.Sprintf("\tvar _p%d *%s\n", n, m[1])
272
+					text += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = &%s[0]\n\t}\n", p.Name, n, p.Name)
273
+					args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(unsafe.Pointer(_p%d)))", n))
274
+					n++
275
+					text += fmt.Sprintf("\tvar _p%d int\n", n)
276
+					text += fmt.Sprintf("\t_p%d = len(%s)\n", n, p.Name)
277
+					args = append(args, fmt.Sprintf("C.size_t(_p%d)", n))
278
+					n++
279
+				} else if p.Type == "int64" && endianness != "" {
280
+					if endianness == "big-endian" {
281
+						args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
282
+					} else {
283
+						args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
284
+					}
285
+					n++
286
+				} else if p.Type == "bool" {
287
+					text += fmt.Sprintf("\tvar _p%d uint32\n", n)
288
+					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)
289
+					args = append(args, fmt.Sprintf("_p%d", n))
290
+				} else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil {
291
+					args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(%s))", p.Name))
292
+				} else if p.Type == "unsafe.Pointer" {
293
+					args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(%s))", p.Name))
294
+				} else if p.Type == "int" {
295
+					if (argN == 2) && ((funct == "readlen") || (funct == "writelen")) {
296
+						args = append(args, fmt.Sprintf("C.size_t(%s)", p.Name))
297
+					} else if argN == 0 && funct == "fcntl" {
298
+						args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name))
299
+					} else if (argN == 2) && ((funct == "fcntl") || (funct == "FcntlInt")) {
300
+						args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name))
301
+					} else {
302
+						args = append(args, fmt.Sprintf("C.int(%s)", p.Name))
303
+					}
304
+				} else if p.Type == "int32" {
305
+					args = append(args, fmt.Sprintf("C.int(%s)", p.Name))
306
+				} else if p.Type == "int64" {
307
+					args = append(args, fmt.Sprintf("C.longlong(%s)", p.Name))
308
+				} else if p.Type == "uint32" {
309
+					args = append(args, fmt.Sprintf("C.uint(%s)", p.Name))
310
+				} else if p.Type == "uint64" {
311
+					args = append(args, fmt.Sprintf("C.ulonglong(%s)", p.Name))
312
+				} else if p.Type == "uintptr" {
313
+					args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name))
314
+				} else {
315
+					args = append(args, fmt.Sprintf("C.int(%s)", p.Name))
316
+				}
317
+				argN++
318
+			}
319
+
320
+			// Actual call.
321
+			arglist := strings.Join(args, ", ")
322
+			call := ""
323
+			if sysname == "exit" {
324
+				if errvar != "" {
325
+					call += "er :="
326
+				} else {
327
+					call += ""
328
+				}
329
+			} else if errvar != "" {
330
+				call += "r0,er :="
331
+			} else if retvar != "" {
332
+				call += "r0,_ :="
333
+			} else {
334
+				call += ""
335
+			}
336
+			if sysname == "select" {
337
+				// select is a keyword of Go. Its name is
338
+				// changed to c_select.
339
+				call += fmt.Sprintf("C.c_%s(%s)", sysname, arglist)
340
+			} else {
341
+				call += fmt.Sprintf("C.%s(%s)", sysname, arglist)
342
+			}
343
+
344
+			// Assign return values.
345
+			body := ""
346
+			for i := 0; i < len(out); i++ {
347
+				p := parseParam(out[i])
348
+				reg := ""
349
+				if p.Name == "err" {
350
+					reg = "e1"
351
+				} else {
352
+					reg = "r0"
353
+				}
354
+				if reg != "e1" {
355
+					body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg)
356
+				}
357
+			}
358
+
359
+			// verify return
360
+			if sysname != "exit" && errvar != "" {
361
+				if regexp.MustCompile(`^uintptr`).FindStringSubmatch(cRettype) != nil {
362
+					body += "\tif (uintptr(r0) ==^uintptr(0) && er != nil) {\n"
363
+					body += fmt.Sprintf("\t\t%s = er\n", errvar)
364
+					body += "\t}\n"
365
+				} else {
366
+					body += "\tif (r0 ==-1 && er != nil) {\n"
367
+					body += fmt.Sprintf("\t\t%s = er\n", errvar)
368
+					body += "\t}\n"
369
+				}
370
+			} else if errvar != "" {
371
+				body += "\tif (er != nil) {\n"
372
+				body += fmt.Sprintf("\t\t%s = er\n", errvar)
373
+				body += "\t}\n"
374
+			}
375
+
376
+			text += fmt.Sprintf("\t%s\n", call)
377
+			text += body
378
+
379
+			text += "\treturn\n"
380
+			text += "}\n"
381
+		}
382
+		if err := s.Err(); err != nil {
383
+			fmt.Fprintf(os.Stderr, err.Error())
384
+			os.Exit(1)
385
+		}
386
+		file.Close()
387
+	}
388
+	imp := ""
389
+	if pack != "unix" {
390
+		imp = "import \"golang.org/x/sys/unix\"\n"
391
+
392
+	}
393
+	fmt.Printf(srcTemplate, cmdLine(), buildTags(), pack, cExtern, imp, text)
394
+}
395
+
396
+const srcTemplate = `// %s
397
+// Code generated by the command above; see README.md. DO NOT EDIT.
398
+
399
+// +build %s
400
+
401
+package %s
402
+
403
+
404
+%s
405
+*/
406
+import "C"
407
+import (
408
+	"unsafe"
409
+)
410
+
411
+
412
+%s
413
+
414
+%s
415
+`

+ 0
- 384
vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.pl View File

@@ -1,384 +0,0 @@
1
-#!/usr/bin/env perl
2
-# Copyright 2018 The Go Authors. All rights reserved.
3
-# Use of this source code is governed by a BSD-style
4
-# license that can be found in the LICENSE file.
5
-
6
-# This program reads a file containing function prototypes
7
-# (like syscall_aix.go) and generates system call bodies.
8
-# The prototypes are marked by lines beginning with "//sys"
9
-# and read like func declarations if //sys is replaced by func, but:
10
-#	* The parameter lists must give a name for each argument.
11
-#	  This includes return parameters.
12
-#	* The parameter lists must give a type for each argument:
13
-#	  the (x, y, z int) shorthand is not allowed.
14
-#	* If the return parameter is an error number, it must be named err.
15
-#	* If go func name needs to be different than its libc name,
16
-#	* or the function is not in libc, name could be specified
17
-#	* at the end, after "=" sign, like
18
-#	  //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt
19
-
20
-use strict;
21
-
22
-my $cmdline = "mksyscall_aix_ppc.pl " . join(' ', @ARGV);
23
-my $errors = 0;
24
-my $_32bit = "";
25
-my $tags = "";  # build tags
26
-my $aix = 0;
27
-my $solaris = 0;
28
-
29
-binmode STDOUT;
30
-
31
-if($ARGV[0] eq "-b32") {
32
-	$_32bit = "big-endian";
33
-	shift;
34
-} elsif($ARGV[0] eq "-l32") {
35
-	$_32bit = "little-endian";
36
-	shift;
37
-}
38
-if($ARGV[0] eq "-aix") {
39
-	$aix = 1;
40
-	shift;
41
-}
42
-if($ARGV[0] eq "-tags") {
43
-	shift;
44
-	$tags = $ARGV[0];
45
-	shift;
46
-}
47
-
48
-if($ARGV[0] =~ /^-/) {
49
-	print STDERR "usage: mksyscall_aix.pl [-b32 | -l32] [-tags x,y] [file ...]\n";
50
-	exit 1;
51
-}
52
-
53
-sub parseparamlist($) {
54
-	my ($list) = @_;
55
-	$list =~ s/^\s*//;
56
-	$list =~ s/\s*$//;
57
-	if($list eq "") {
58
-		return ();
59
-	}
60
-	return split(/\s*,\s*/, $list);
61
-}
62
-
63
-sub parseparam($) {
64
-	my ($p) = @_;
65
-	if($p !~ /^(\S*) (\S*)$/) {
66
-		print STDERR "$ARGV:$.: malformed parameter: $p\n";
67
-		$errors = 1;
68
-		return ("xx", "int");
69
-	}
70
-	return ($1, $2);
71
-}
72
-
73
-my $package = "";
74
-my $text = "";
75
-my $c_extern = "/*\n#include <stdint.h>\n#include <stddef.h>\n";
76
-my @vars = ();
77
-while(<>) {
78
-	chomp;
79
-	s/\s+/ /g;
80
-	s/^\s+//;
81
-	s/\s+$//;
82
-	$package = $1 if !$package && /^package (\S+)$/;
83
-	my $nonblock = /^\/\/sysnb /;
84
-	next if !/^\/\/sys / && !$nonblock;
85
-
86
-	# Line must be of the form
87
-	# func Open(path string, mode int, perm int) (fd int, err error)
88
-	# Split into name, in params, out params.
89
-	if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$/) {
90
-		print STDERR "$ARGV:$.: malformed //sys declaration\n";
91
-		$errors = 1;
92
-		next;
93
-	}
94
-	my ($nb, $func, $in, $out, $modname, $sysname) = ($1, $2, $3, $4, $5, $6);
95
-
96
-	# Split argument lists on comma.
97
-	my @in = parseparamlist($in);
98
-	my @out = parseparamlist($out);
99
-
100
-	$in = join(', ', @in);
101
-	$out = join(', ', @out);
102
-
103
-	# Try in vain to keep people from editing this file.
104
-	# The theory is that they jump into the middle of the file
105
-	# without reading the header.
106
-	$text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n";
107
-
108
-	# Check if value return, err return available
109
-	my $errvar = "";
110
-	my $retvar = "";
111
-	my $rettype = "";
112
-	foreach my $p (@out) {
113
-		my ($name, $type) = parseparam($p);
114
-		if($type eq "error") {
115
-			$errvar = $name;
116
-		} else {
117
-			$retvar = $name;
118
-			$rettype = $type;
119
-		}
120
-	}
121
-
122
-	# System call name.
123
-	#if($func ne "fcntl") {
124
-
125
-	if($sysname eq "") {
126
-		$sysname = "$func";
127
-	}
128
-
129
-	$sysname =~ s/([a-z])([A-Z])/${1}_$2/g;
130
-	$sysname =~ y/A-Z/a-z/; # All libc functions are lowercase.
131
-
132
-	my $C_rettype = "";
133
-	if($rettype eq "unsafe.Pointer") {
134
-		$C_rettype = "uintptr_t";
135
-	} elsif($rettype eq "uintptr") {
136
-		$C_rettype = "uintptr_t";
137
-	} elsif($rettype =~ /^_/) {
138
-		$C_rettype = "uintptr_t";
139
-	} elsif($rettype eq "int") {
140
-		$C_rettype = "int";
141
-	} elsif($rettype eq "int32") {
142
-		$C_rettype = "int";
143
-	} elsif($rettype eq "int64") {
144
-		$C_rettype = "long long";
145
-	} elsif($rettype eq "uint32") {
146
-		$C_rettype = "unsigned int";
147
-	} elsif($rettype eq "uint64") {
148
-		$C_rettype = "unsigned long long";
149
-	} else {
150
-		$C_rettype = "int";
151
-	}
152
-	if($sysname eq "exit") {
153
-		$C_rettype = "void";
154
-	}
155
-
156
-	# Change types to c
157
-	my @c_in = ();
158
-	foreach my $p (@in) {
159
-		my ($name, $type) = parseparam($p);
160
-		if($type =~ /^\*/) {
161
-			push @c_in, "uintptr_t";
162
-			} elsif($type eq "string") {
163
-			push @c_in, "uintptr_t";
164
-		} elsif($type =~ /^\[\](.*)/) {
165
-			push @c_in, "uintptr_t", "size_t";
166
-		} elsif($type eq "unsafe.Pointer") {
167
-			push @c_in, "uintptr_t";
168
-		} elsif($type eq "uintptr") {
169
-			push @c_in, "uintptr_t";
170
-		} elsif($type =~ /^_/) {
171
-			push @c_in, "uintptr_t";
172
-		} elsif($type eq "int") {
173
-			push @c_in, "int";
174
-		} elsif($type eq "int32") {
175
-			push @c_in, "int";
176
-		} elsif($type eq "int64") {
177
-			push @c_in, "long long";
178
-		} elsif($type eq "uint32") {
179
-			push @c_in, "unsigned int";
180
-		} elsif($type eq "uint64") {
181
-			push @c_in, "unsigned long long";
182
-		} else {
183
-			push @c_in, "int";
184
-		}
185
-	}
186
-
187
-	if ($func ne "fcntl" && $func ne "FcntlInt" && $func ne "readlen" && $func ne "writelen") {
188
-		# Imports of system calls from libc
189
-		$c_extern .= "$C_rettype $sysname";
190
-		my $c_in = join(', ', @c_in);
191
-		$c_extern .= "($c_in);\n";
192
-	}
193
-
194
-	# So file name.
195
-	if($aix) {
196
-		if($modname eq "") {
197
-			$modname = "libc.a/shr_64.o";
198
-		} else {
199
-			print STDERR "$func: only syscall using libc are available\n";
200
-			$errors = 1;
201
-			next;
202
-		}
203
-	}
204
-
205
-	my $strconvfunc = "C.CString";
206
-	my $strconvtype = "*byte";
207
-
208
-	# Go function header.
209
-	if($out ne "") {
210
-		$out = " ($out)";
211
-	}
212
-	if($text ne "") {
213
-		$text .= "\n"
214
-	}
215
-
216
-	$text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out ;
217
-
218
-	# Prepare arguments to call.
219
-	my @args = ();
220
-	my $n = 0;
221
-	my $arg_n = 0;
222
-	foreach my $p (@in) {
223
-		my ($name, $type) = parseparam($p);
224
-		if($type =~ /^\*/) {
225
-			push @args, "C.uintptr_t(uintptr(unsafe.Pointer($name)))";
226
-		} elsif($type eq "string" && $errvar ne "") {
227
-			$text .= "\t_p$n := uintptr(unsafe.Pointer($strconvfunc($name)))\n";
228
-			push @args, "C.uintptr_t(_p$n)";
229
-			$n++;
230
-		} elsif($type eq "string") {
231
-			print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
232
-			$text .= "\t_p$n := uintptr(unsafe.Pointer($strconvfunc($name)))\n";
233
-			push @args, "C.uintptr_t(_p$n)";
234
-			$n++;
235
-		} elsif($type =~ /^\[\](.*)/) {
236
-			# Convert slice into pointer, length.
237
-			# Have to be careful not to take address of &a[0] if len == 0:
238
-			# pass nil in that case.
239
-			$text .= "\tvar _p$n *$1\n";
240
-			$text .= "\tif len($name) > 0 {\n\t\t_p$n = \&$name\[0]\n\t}\n";
241
-			push @args, "C.uintptr_t(uintptr(unsafe.Pointer(_p$n)))";
242
-			$n++;
243
-			$text .= "\tvar _p$n int\n";
244
-			$text .= "\t_p$n = len($name)\n";
245
-			push @args, "C.size_t(_p$n)";
246
-			$n++;
247
-		} elsif($type eq "int64" && $_32bit ne "") {
248
-			if($_32bit eq "big-endian") {
249
-				push @args, "uintptr($name >> 32)", "uintptr($name)";
250
-			} else {
251
-				push @args, "uintptr($name)", "uintptr($name >> 32)";
252
-			}
253
-			$n++;
254
-		} elsif($type eq "bool") {
255
-			$text .= "\tvar _p$n uint32\n";
256
-			$text .= "\tif $name {\n\t\t_p$n = 1\n\t} else {\n\t\t_p$n = 0\n\t}\n";
257
-			push @args, "_p$n";
258
-			$n++;
259
-		} elsif($type =~ /^_/) {
260
-			push @args, "C.uintptr_t(uintptr($name))";
261
-		} elsif($type eq "unsafe.Pointer") {
262
-			push @args, "C.uintptr_t(uintptr($name))";
263
-		} elsif($type eq "int") {
264
-			if (($arg_n == 2) && (($func eq "readlen") || ($func eq "writelen"))) {
265
-				push @args, "C.size_t($name)";
266
-			} elsif ($arg_n == 0 && $func eq "fcntl") {
267
-				push @args, "C.uintptr_t($name)";
268
-			} elsif (($arg_n == 2) && (($func eq "fcntl") || ($func eq "FcntlInt"))) {
269
-				push @args, "C.uintptr_t($name)";
270
-			} else {
271
-				push @args, "C.int($name)";
272
-			}
273
-		} elsif($type eq "int32") {
274
-			push @args, "C.int($name)";
275
-		} elsif($type eq "int64") {
276
-			push @args, "C.longlong($name)";
277
-		} elsif($type eq "uint32") {
278
-			push @args, "C.uint($name)";
279
-		} elsif($type eq "uint64") {
280
-			push @args, "C.ulonglong($name)";
281
-		} elsif($type eq "uintptr") {
282
-			push @args, "C.uintptr_t($name)";
283
-		} else {
284
-			push @args, "C.int($name)";
285
-		}
286
-		$arg_n++;
287
-	}
288
-	my $nargs = @args;
289
-
290
-
291
-	# Determine which form to use; pad args with zeros.
292
-	if ($nonblock) {
293
-	}
294
-
295
-	my $args = join(', ', @args);
296
-	my $call = "";
297
-	if ($sysname eq "exit") {
298
-		if ($errvar ne "") {
299
-			$call .= "er :=";
300
-		} else {
301
-			$call .= "";
302
-		}
303
-	}  elsif ($errvar ne "") {
304
-		$call .= "r0,er :=";
305
-	}  elsif ($retvar ne "") {
306
-		$call .= "r0,_ :=";
307
-	}  else {
308
-		$call .= ""
309
-	}
310
-	$call .= "C.$sysname($args)";
311
-
312
-	# Assign return values.
313
-	my $body = "";
314
-	my $failexpr = "";
315
-
316
-	for(my $i=0; $i<@out; $i++) {
317
-		my $p = $out[$i];
318
-		my ($name, $type) = parseparam($p);
319
-		my $reg = "";
320
-		if($name eq "err") {
321
-			$reg = "e1";
322
-		} else {
323