Skip to content

Commit 45d02f9

Browse files
author
Araragi Hokuto
committed
unix: update code generation for illumos
Since illumos now has a separate syscall_illumos.go along with syscall_solaris{_amd64}.go, code generation process requires some update. This commit adds a --illumos for mksyscall_solaris.go, and adds handling for $GOOS=illumos.
1 parent a55eb83 commit 45d02f9

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

unix/mkall.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ solaris_amd64)
190190
mksysnum=
191191
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
192192
;;
193+
illumos_amd64)
194+
mksyscall="go run mksyscall_solaris.go"
195+
mkerrors=
196+
mksysnum=
197+
mktypes=
198+
;;
193199
*)
194200
echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
195201
exit 1
@@ -217,6 +223,11 @@ esac
217223
echo "$mksyscall -tags $GOOS,$GOARCH,go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
218224
# 1.13 and later, syscalls via libSystem (including syscallPtr)
219225
echo "$mksyscall -tags $GOOS,$GOARCH,go1.13 syscall_darwin.1_13.go |gofmt >zsyscall_$GOOSARCH.1_13.go";
226+
elif [ "$GOOS" == "illumos" ]; then
227+
# illumos code generation requires a --illumos switch
228+
echo "$mksyscall -illumos -tags illumos,$GOARCH syscall_illumos.go |gofmt > zsyscall_illumos_$GOARCH.go";
229+
# illumos implies solaris, so solaris code generation is also required
230+
echo "$mksyscall -tags solaris,$GOARCH syscall_solaris.go syscall_solaris_$GOARCH.go |gofmt >zsyscall_solaris_$GOARCH.go";
220231
else
221232
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
222233
fi

unix/mksyscall_solaris.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var (
3535
b32 = flag.Bool("b32", false, "32bit big-endian")
3636
l32 = flag.Bool("l32", false, "32bit little-endian")
3737
tags = flag.String("tags", "", "build tags")
38+
illumos = flag.Bool("illumos", false, "illumos specific code generation")
3839
)
3940

4041
// cmdLine returns this programs's commandline arguments
@@ -306,8 +307,12 @@ func main() {
306307
imp := ""
307308
if pack != "unix" {
308309
imp = "import \"golang.org/x/sys/unix\"\n"
310+
}
309311

312+
if !*illumos {
313+
imp += "import \"syscall\"\n"
310314
}
315+
311316
vardecls := "\t" + strings.Join(vars, ",\n\t")
312317
vardecls += " syscallFunc"
313318
fmt.Printf(srcTemplate, cmdLine(), buildTags(), pack, imp, dynimports, linknames, vardecls, text)
@@ -320,10 +325,7 @@ const srcTemplate = `// %s
320325
321326
package %s
322327
323-
import (
324-
"syscall"
325-
"unsafe"
326-
)
328+
import "unsafe"
327329
%s
328330
%s
329331
%s

unix/zsyscall_illumos_amd64.go

Lines changed: 5 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)