summaryrefslogtreecommitdiff
path: root/src/pkg
diff options
context:
space:
mode:
authorAram H?v?rneanu <aram@mgk.ro>2014-09-06 19:35:46 +0200
committerAram H?v?rneanu <aram@mgk.ro>2014-09-06 19:35:46 +0200
commit0216eb1a463589a6c2498c67f418f0e351fc46b8 (patch)
treec6e484679755088c76b86e0a26406ad6c67dd11c /src/pkg
parent3c63238a55767eb0329761b3538362b67f66291e (diff)
downloadgo-0216eb1a463589a6c2498c67f418f0e351fc46b8.tar.gz
runtime, syscall: rewrite syscall_solaris.goc in Go
LGTM=dave, rsc R=khr, dvyukov, dave, gobot, rsc CC=golang-codereviews, rsc https://codereview.appspot.com/133220044
Diffstat (limited to 'src/pkg')
-rw-r--r--src/pkg/runtime/syscall_solaris.c23
-rw-r--r--src/pkg/runtime/syscall_solaris.go322
-rw-r--r--src/pkg/runtime/syscall_solaris.goc374
-rw-r--r--src/pkg/runtime/thunk_solaris_amd64.s88
-rw-r--r--src/pkg/syscall/asm_solaris_amd64.s76
-rw-r--r--src/pkg/syscall/so_solaris.go2
6 files changed, 509 insertions, 376 deletions
diff --git a/src/pkg/runtime/syscall_solaris.c b/src/pkg/runtime/syscall_solaris.c
new file mode 100644
index 000000000..13ac31bde
--- /dev/null
+++ b/src/pkg/runtime/syscall_solaris.c
@@ -0,0 +1,23 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#pragma dynimport libc·chdir chdir "libc.so"
+#pragma dynimport libc·chroot chroot "libc.so"
+#pragma dynimport libc·close close "libc.so"
+#pragma dynimport libc·dlclose dlclose "libc.so"
+#pragma dynimport libc·dlopen dlopen "libc.so"
+#pragma dynimport libc·dlsym dlsym "libc.so"
+#pragma dynimport libc·execve execve "libc.so"
+#pragma dynimport libc·fcntl fcntl "libc.so"
+#pragma dynimport libc·gethostname gethostname "libc.so"
+#pragma dynimport libc·ioctl ioctl "libc.so"
+#pragma dynimport libc·pipe pipe "libc.so"
+#pragma dynimport libc·setgid setgid "libc.so"
+#pragma dynimport libc·setgroups setgroups "libc.so"
+#pragma dynimport libc·setsid setsid "libc.so"
+#pragma dynimport libc·setuid setuid "libc.so"
+#pragma dynimport libc·setpgid setsid "libc.so"
+#pragma dynimport libc·syscall syscall "libc.so"
+#pragma dynimport libc·forkx forkx "libc.so"
+#pragma dynimport libc·wait4 wait4 "libc.so"
diff --git a/src/pkg/runtime/syscall_solaris.go b/src/pkg/runtime/syscall_solaris.go
new file mode 100644
index 000000000..d0a3fc8dd
--- /dev/null
+++ b/src/pkg/runtime/syscall_solaris.go
@@ -0,0 +1,322 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package runtime
+
+import "unsafe"
+
+var (
+ libc_chdir,
+ libc_chroot,
+ libc_close,
+ libc_dlopen,
+ libc_dlclose,
+ libc_dlsym,
+ libc_execve,
+ libc_exit,
+ libc_fcntl,
+ libc_forkx,
+ libc_gethostname,
+ libc_ioctl,
+ libc_pipe,
+ libc_setgid,
+ libc_setgroups,
+ libc_setsid,
+ libc_setuid,
+ libc_setpgid,
+ libc_syscall,
+ libc_wait4,
+ libc_write,
+ pipe1 libcFunc
+)
+
+//go:nosplit
+func syscall_sysvicall6(fn, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(fn),
+ n: nargs,
+ args: unsafe.Pointer(&a1),
+ }
+ entersyscallblock()
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ exitsyscall()
+ return call.r1, call.r2, call.err
+}
+
+//go:nosplit
+func syscall_rawsysvicall6(fn, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(fn),
+ n: nargs,
+ args: unsafe.Pointer(&a1),
+ }
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ return call.r1, call.r2, call.err
+}
+
+// TODO(aram): Once we remove all instances of C calling sysvicallN, make
+// sysvicallN return errors and replace the body of the following functions
+// with calls to sysvicallN.
+
+//go:nosplit
+func syscall_chdir(path uintptr) (err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_chdir),
+ n: 1,
+ args: unsafe.Pointer(&path),
+ }
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ return call.err
+}
+
+//go:nosplit
+func syscall_chroot(path uintptr) (err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_chroot),
+ n: 1,
+ args: unsafe.Pointer(&path),
+ }
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ return call.err
+}
+
+// like close, but must not split stack, for forkx.
+//go:nosplit
+func syscall_close(fd int32) int32 {
+ return int32(sysvicall1(&libc_close, uintptr(fd)))
+}
+
+func syscall_dlopen(name *byte, mode uintptr) (handle uintptr, err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_dlopen),
+ n: 2,
+ args: unsafe.Pointer(&name),
+ }
+ entersyscallblock()
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ exitsyscall()
+ if call.r1 == 0 {
+ return call.r1, call.err
+ }
+ return call.r1, 0
+}
+
+func syscall_dlclose(handle uintptr) (err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_dlclose),
+ n: 1,
+ args: unsafe.Pointer(&handle),
+ }
+ entersyscallblock()
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ exitsyscall()
+ return call.r1
+}
+
+func syscall_dlsym(handle uintptr, name *byte) (proc uintptr, err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_dlsym),
+ n: 2,
+ args: unsafe.Pointer(&handle),
+ }
+ entersyscallblock()
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ exitsyscall()
+ if call.r1 == 0 {
+ return call.r1, call.err
+ }
+ return call.r1, 0
+}
+
+//go:nosplit
+func syscall_execve(path, argv, envp uintptr) (err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_execve),
+ n: 3,
+ args: unsafe.Pointer(&path),
+ }
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ return call.err
+}
+
+// like exit, but must not split stack, for forkx.
+//go:nosplit
+func syscall_exit(code uintptr) {
+ sysvicall1(&libc_exit, code)
+}
+
+//go:nosplit
+func syscall_fcntl(fd, cmd, arg uintptr) (val, err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_fcntl),
+ n: 3,
+ args: unsafe.Pointer(&fd),
+ }
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ return call.r1, call.err
+}
+
+//go:nosplit
+func syscall_forkx(flags uintptr) (pid uintptr, err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_forkx),
+ n: 1,
+ args: unsafe.Pointer(&flags),
+ }
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ return call.r1, call.err
+}
+
+func syscall_gethostname() (name string, err uintptr) {
+ cname := new([_MAXHOSTNAMELEN]byte)
+ var args = [2]uintptr{uintptr(unsafe.Pointer(&cname[0])), _MAXHOSTNAMELEN}
+ call := libcall{
+ fn: unsafe.Pointer(&libc_gethostname),
+ n: 2,
+ args: unsafe.Pointer(&args[0]),
+ }
+ entersyscallblock()
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ exitsyscall()
+ if call.r1 != 0 {
+ return "", call.err
+ }
+ cname[_MAXHOSTNAMELEN-1] = 0
+ return gostringnocopy(&cname[0]), 0
+}
+
+//go:nosplit
+func syscall_ioctl(fd, req, arg uintptr) (err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_ioctl),
+ n: 3,
+ args: unsafe.Pointer(&fd),
+ }
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ return call.err
+}
+
+func syscall_pipe() (r, w, err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&pipe1),
+ n: 0,
+ args: unsafe.Pointer(&pipe1), // it's unused but must be non-nil, otherwise crashes
+ }
+ entersyscallblock()
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ exitsyscall()
+ return call.r1, call.r2, call.err
+}
+
+// This is syscall.RawSyscall, it exists to satisfy some build dependency,
+// but it doesn't work correctly.
+//
+// DO NOT USE!
+//
+// TODO(aram): make this panic once we stop calling fcntl(2) in net using it.
+func syscall_rawsyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_syscall),
+ n: 4,
+ args: unsafe.Pointer(&trap),
+ }
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ return call.r1, call.r2, call.err
+}
+
+//go:nosplit
+func syscall_setgid(gid uintptr) (err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_setgid),
+ n: 1,
+ args: unsafe.Pointer(&gid),
+ }
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ return call.err
+}
+
+//go:nosplit
+func syscall_setgroups(ngid, gid uintptr) (err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_setgroups),
+ n: 2,
+ args: unsafe.Pointer(&ngid),
+ }
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ return call.err
+}
+
+//go:nosplit
+func syscall_setsid() (pid, err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_setsid),
+ n: 0,
+ args: unsafe.Pointer(&libc_setsid), // it's unused but must be non-nil, otherwise crashes
+ }
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ return call.r1, call.err
+}
+
+//go:nosplit
+func syscall_setuid(uid uintptr) (err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_setuid),
+ n: 1,
+ args: unsafe.Pointer(&uid),
+ }
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ return call.err
+}
+
+//go:nosplit
+func syscall_setpgid(pid, pgid uintptr) (err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_setpgid),
+ n: 2,
+ args: unsafe.Pointer(&pid),
+ }
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ return call.err
+}
+
+// This is syscall.Syscall, it exists to satisfy some build dependency,
+// but it doesn't work correctly.
+//
+// DO NOT USE!
+//
+// TODO(aram): make this panic once we stop calling fcntl(2) in net using it.
+func syscall_syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_syscall),
+ n: 4,
+ args: unsafe.Pointer(&trap),
+ }
+ entersyscallblock()
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ exitsyscall()
+ return call.r1, call.r2, call.err
+}
+
+func syscall_wait4(pid uintptr, wstatus *uint32, options uintptr, rusage unsafe.Pointer) (wpid int, err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_wait4),
+ n: 4,
+ args: unsafe.Pointer(&pid),
+ }
+ entersyscallblock()
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ exitsyscall()
+ return int(call.r1), call.err
+}
+
+//go:nosplit
+func syscall_write(fd, buf, nbyte uintptr) (n, err uintptr) {
+ call := libcall{
+ fn: unsafe.Pointer(&libc_write),
+ n: 3,
+ args: unsafe.Pointer(&fd),
+ }
+ asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
+ return call.r1, call.err
+}
diff --git a/src/pkg/runtime/syscall_solaris.goc b/src/pkg/runtime/syscall_solaris.goc
deleted file mode 100644
index 935a2f6cf..000000000
--- a/src/pkg/runtime/syscall_solaris.goc
+++ /dev/null
@@ -1,374 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package syscall
-#include "runtime.h"
-#include "defs_GOOS_GOARCH.h"
-#include "os_GOOS.h"
-#include "cgocall.h"
-#include "textflag.h"
-
-#pragma dynimport libc·chdir chdir "libc.so"
-#pragma dynimport libc·chroot chroot "libc.so"
-#pragma dynimport libc·close close "libc.so"
-#pragma dynimport libc·dlclose dlclose "libc.so"
-#pragma dynimport libc·dlopen dlopen "libc.so"
-#pragma dynimport libc·dlsym dlsym "libc.so"
-#pragma dynimport libc·execve execve "libc.so"
-#pragma dynimport libc·fcntl fcntl "libc.so"
-#pragma dynimport libc·gethostname gethostname "libc.so"
-#pragma dynimport libc·ioctl ioctl "libc.so"
-#pragma dynimport libc·pipe pipe "libc.so"
-#pragma dynimport libc·setgid setgid "libc.so"
-#pragma dynimport libc·setgroups setgroups "libc.so"
-#pragma dynimport libc·setsid setsid "libc.so"
-#pragma dynimport libc·setuid setuid "libc.so"
-#pragma dynimport libc·setpgid setsid "libc.so"
-#pragma dynimport libc·syscall syscall "libc.so"
-#pragma dynimport libc·forkx forkx "libc.so"
-#pragma dynimport libc·wait4 wait4 "libc.so"
-extern uintptr libc·chdir;
-extern uintptr libc·chroot;
-extern uintptr libc·close;
-extern uintptr libc·dlclose;
-extern uintptr libc·dlopen;
-extern uintptr libc·dlsym;
-extern uintptr libc·execve;
-extern uintptr libc·exit;
-extern uintptr libc·fcntl;
-extern uintptr libc·gethostname;
-extern uintptr libc·ioctl;
-extern uintptr libc·pipe;
-extern uintptr libc·setgid;
-extern uintptr libc·setgroups;
-extern uintptr libc·setsid;
-extern uintptr libc·setuid;
-extern uintptr libc·setpgid;
-extern uintptr libc·syscall;
-extern uintptr libc·forkx;
-extern uintptr libc·wait4;
-extern uintptr libc·write;
-
-func sysvicall6(func uintptr, nargs uintptr, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr, a5 uintptr, a6 uintptr) (r1 uintptr, r2 uintptr, err uintptr)
-{
- LibCall c;
-
- USED(a2);
- USED(a3);
- USED(a4);
- USED(a5);
- USED(a6);
- c.fn = (void*)func;
- c.n = nargs;
- c.args = (void*)&a1;
- runtime·cgocall(runtime·asmsysvicall6, &c);
- err = c.err;
- r1 = c.r1;
- r2 = c.r2;
-}
-
-#pragma textflag NOSPLIT
-func rawSysvicall6(func uintptr, nargs uintptr, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr, a5 uintptr, a6 uintptr) (r1 uintptr, r2 uintptr, err uintptr)
-{
- LibCall c;
-
- USED(a2);
- USED(a3);
- USED(a4);
- USED(a5);
- USED(a6);
- c.fn = (void*)func;
- c.n = nargs;
- c.args = (void*)&a1;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
- r1 = c.r1;
- r2 = c.r2;
-}
-
-#pragma textflag NOSPLIT
-func chdir(path uintptr) (err uintptr) {
- LibCall c;
-
- c.fn = (void*)libc·chdir;
- c.n = 1;
- c.args = (void*)&path;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
-}
-
-#pragma textflag NOSPLIT
-func chroot1(path uintptr) (err uintptr) {
- LibCall c;
-
- c.fn = (void*)libc·chroot;
- c.n = 1;
- c.args = (void*)&path;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
-}
-
-#pragma textflag NOSPLIT
-func close(fd uintptr) (err uintptr) {
- LibCall c;
-
- c.fn = (void*)libc·close;
- c.n = 1;
- c.args = (void*)&fd;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
-}
-
-func dlclose(handle uintptr) (err uintptr) {
- LibCall c;
-
- USED(handle);
- c.fn = (void*)libc·dlclose;
- c.n = 1;
- c.args = (void*)&handle;
- runtime·cgocall(runtime·asmsysvicall6, &c);
- err = c.r1;
-}
-
-func dlopen(name *uint8, mode uintptr) (handle uintptr, err uintptr) {
- LibCall c;
-
- USED(mode);
- c.fn = (void*)libc·dlopen;
- c.n = 2;
- c.args = (void*)&name;
- runtime·cgocall(runtime·asmsysvicall6, &c);
- handle = c.r1;
- if(handle == 0)
- err = c.err;
- else
- err = 0;
-}
-
-func dlsym(handle uintptr, name *uint8) (proc uintptr, err uintptr) {
- LibCall c;
-
- USED(name);
- c.fn = (void*)libc·dlsym;
- c.n = 2;
- c.args = &handle;
- runtime·cgocall(runtime·asmsysvicall6, &c);
- proc = c.r1;
- if(proc == 0)
- err = c.err;
- else
- err = 0;
-}
-
-#pragma textflag NOSPLIT
-func execve(path uintptr, argv uintptr, envp uintptr) (err uintptr) {
- LibCall c;
-
- USED(argv);
- USED(envp);
- c.fn = (void*)libc·execve;
- c.n = 3;
- c.args = (void*)&path;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
-}
-
-#pragma textflag NOSPLIT
-func exit(code uintptr) {
- LibCall c;
-
- c.fn = (void*)libc·exit;
- c.n = 1;
- c.args = (void*)&code;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
-}
-
-#pragma textflag NOSPLIT
-func fcntl1(fd uintptr, cmd uintptr, arg uintptr) (val uintptr, err uintptr) {
- LibCall c;
-
- USED(cmd);
- USED(arg);
- c.fn = (void*)libc·fcntl;
- c.n = 3;
- c.args = (void*)&fd;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
- val = c.r1;
-}
-
-func gethostname() (name String, err uintptr) {
- struct { uintptr v[2]; } args;
- uint8 cname[MAXHOSTNAMELEN];
- LibCall c;
-
- c.fn = (void*)libc·gethostname;
- c.n = 2;
- args.v[0] = (uintptr)&cname[0];
- args.v[1] = MAXHOSTNAMELEN;
- c.args = (void*)&args;
- runtime·cgocall(runtime·asmsysvicall6, &c);
- err = c.err;
- if(c.r1) {
- name = runtime·emptystring;
- return;
- }
- cname[MAXHOSTNAMELEN - 1] = 0;
- name = runtime·gostring(cname);
-}
-
-#pragma textflag NOSPLIT
-func ioctl(fd uintptr, req uintptr, arg uintptr) (err uintptr) {
- LibCall c;
-
- USED(req);
- USED(arg);
- c.fn = (void*)libc·ioctl;
- c.n = 3;
- c.args = (void*)&fd;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
-}
-
-func wait4(pid uintptr, wstatus *uint32, options uintptr, rusage *void) (wpid int, err uintptr) {
- LibCall c;
-
- USED(wstatus);
- USED(options);
- USED(rusage);
- c.fn = (void*)libc·wait4;
- c.n = 4;
- c.args = (void*)&pid;
- runtime·cgocall(runtime·asmsysvicall6, &c);
- err = c.err;
- wpid = c.r1;
-}
-
-#pragma textflag NOSPLIT
-func setgid(gid uintptr) (err uintptr) {
- LibCall c;
-
- c.fn = (void*)libc·setgid;
- c.n = 1;
- c.args = (void*)&gid;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
-}
-
-#pragma textflag NOSPLIT
-func setgroups1(ngid uintptr, gid uintptr) (err uintptr) {
- LibCall c;
-
- USED(gid);
- c.fn = (void*)libc·setgroups;
- c.n = 2;
- c.args = (void*)&ngid;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
-}
-
-#pragma textflag NOSPLIT
-func setsid() (pid uintptr, err uintptr) {
- LibCall c;
-
- c.fn = (void*)libc·setsid;
- c.n = 0;
- c.args = (void*)0;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
- pid = c.r1;
-}
-
-#pragma textflag NOSPLIT
-func setuid(uid uintptr) (err uintptr) {
- LibCall c;
-
- c.fn = (void*)libc·setuid;
- c.n = 1;
- c.args = (void*)&uid;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
-}
-
-#pragma textflag NOSPLIT
-func setpgid(pid uintptr, pgid uintptr) (err uintptr) {
- LibCall c;
-
- USED(pgid);
- c.fn = (void*)libc·setpgid;
- c.n = 2;
- c.args = (void*)&pid;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
-}
-
-#pragma textflag NOSPLIT
-func forkx(flags uintptr) (pid uintptr, err uintptr) {
- LibCall c;
-
- c.fn = (void*)libc·forkx;
- c.n = 1;
- c.args = (void*)&flags;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
- pid = c.r1;
-}
-
-void runtime·pipe1(void);
-
-func pipe() (r uintptr, w uintptr, err uintptr) {
- LibCall c;
-
- c.fn = (void*)runtime·pipe1;
- c.n = 0;
- c.args = (void*)0;
- runtime·cgocall(runtime·asmsysvicall6, &c);
- err = c.err;
- r = c.r1;
- w = c.r2;
-}
-
-#pragma textflag NOSPLIT
-func write1(fd uintptr, buf uintptr, nbyte uintptr) (n uintptr, err uintptr) {
- LibCall c;
-
- USED(buf);
- USED(nbyte);
- c.fn = (void*)libc·write;
- c.n = 3;
- c.args = (void*)fd;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
- n = c.r1;
-}
-
-func Syscall(trap uintptr, a1 uintptr, a2 uintptr, a3 uintptr) (r1 uintptr, r2 uintptr, err uintptr) {
- LibCall c;
-
- USED(a1);
- USED(a2);
- USED(a3);
- c.fn = (void*)libc·syscall;
- c.n = 4;
- c.args = &trap;
- runtime·cgocall(runtime·asmsysvicall6, &c);
- err = c.err;
- r1 = c.r1;
- r2 = c.r2;
-}
-
-func RawSyscall(trap uintptr, a1 uintptr, a2 uintptr, a3 uintptr) (r1 uintptr, r2 uintptr, err uintptr) {
- LibCall c;
-
- USED(a1);
- USED(a2);
- USED(a3);
- c.fn = (void*)libc·syscall;
- c.n = 4;
- c.args = &trap;
- runtime·asmcgocall(runtime·asmsysvicall6, &c);
- err = c.err;
- r1 = c.r1;
- r2 = c.r2;
-}
diff --git a/src/pkg/runtime/thunk_solaris_amd64.s b/src/pkg/runtime/thunk_solaris_amd64.s
new file mode 100644
index 000000000..352011e04
--- /dev/null
+++ b/src/pkg/runtime/thunk_solaris_amd64.s
@@ -0,0 +1,88 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// This file exposes various external library functions to Go code in the runtime.
+
+#include "zasm_GOOS_GOARCH.h"
+#include "../../cmd/ld/textflag.h"
+
+TEXT runtime·libc_chdir(SB),NOSPLIT,$0
+ MOVQ libc·chdir(SB), AX
+ JMP AX
+
+TEXT runtime·libc_chroot(SB),NOSPLIT,$0
+ MOVQ libc·chroot(SB), AX
+ JMP AX
+
+TEXT runtime·libc_close(SB),NOSPLIT,$0
+ MOVQ libc·close(SB), AX
+ JMP AX
+
+TEXT runtime·libc_dlopen(SB),NOSPLIT,$0
+ MOVQ libc·dlopen(SB), AX
+ JMP AX
+
+TEXT runtime·libc_dlclose(SB),NOSPLIT,$0
+ MOVQ libc·dlclose(SB), AX
+ JMP AX
+
+TEXT runtime·libc_dlsym(SB),NOSPLIT,$0
+ MOVQ libc·dlsym(SB), AX
+ JMP AX
+
+TEXT runtime·libc_execve(SB),NOSPLIT,$0
+ MOVQ libc·execve(SB), AX
+ JMP AX
+
+TEXT runtime·libc_exit(SB),NOSPLIT,$0
+ MOVQ libc·exit(SB), AX
+ JMP AX
+
+TEXT runtime·libc_fcntl(SB),NOSPLIT,$0
+ MOVQ libc·fcntl(SB), AX
+ JMP AX
+
+TEXT runtime·libc_forkx(SB),NOSPLIT,$0
+ MOVQ libc·forkx(SB), AX
+ JMP AX
+
+TEXT runtime·libc_gethostname(SB),NOSPLIT,$0
+ MOVQ libc·gethostname(SB), AX
+ JMP AX
+
+TEXT runtime·libc_ioctl(SB),NOSPLIT,$0
+ MOVQ libc·ioctl(SB), AX
+ JMP AX
+
+TEXT runtime·libc_setgid(SB),NOSPLIT,$0
+ MOVQ libc·setgid(SB), AX
+ JMP AX
+
+TEXT runtime·libc_setgroups(SB),NOSPLIT,$0
+ MOVQ libc·setgroups(SB), AX
+ JMP AX
+
+TEXT runtime·libc_setsid(SB),NOSPLIT,$0
+ MOVQ libc·setsid(SB), AX
+ JMP AX
+
+TEXT runtime·libc_setuid(SB),NOSPLIT,$0
+ MOVQ libc·setuid(SB), AX
+ JMP AX
+
+TEXT runtime·libc_setpgid(SB),NOSPLIT,$0
+ MOVQ libc·setpgid(SB), AX
+ JMP AX
+
+TEXT runtime·libc_syscall(SB),NOSPLIT,$0
+ MOVQ libc·syscall(SB), AX
+ JMP AX
+
+TEXT runtime·libc_wait4(SB),NOSPLIT,$0
+ MOVQ libc·wait4(SB), AX
+ JMP AX
+
+TEXT runtime·libc_write(SB),NOSPLIT,$0
+ MOVQ libc·write(SB), AX
+ JMP AX
diff --git a/src/pkg/syscall/asm_solaris_amd64.s b/src/pkg/syscall/asm_solaris_amd64.s
index 3735890fa..d0d271c76 100644
--- a/src/pkg/syscall/asm_solaris_amd64.s
+++ b/src/pkg/syscall/asm_solaris_amd64.s
@@ -2,6 +2,80 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "textflag.h"
+
//
-// System calls for amd64, Solaris are implemented in ../runtime/syscall_solaris.goc
+// System calls for solaris/amd64 are implemented in ../runtime/syscall_solaris.go
//
+
+TEXT ·sysvicall6(SB),NOSPLIT,$0
+ JMP runtime·syscall_sysvicall6(SB)
+
+TEXT ·rawSysvicall6(SB),NOSPLIT,$0
+ JMP runtime·syscall_rawsysvicall6(SB)
+
+TEXT ·chdir(SB),NOSPLIT,$0
+ JMP runtime·syscall_chdir(SB)
+
+TEXT ·chroot1(SB),NOSPLIT,$0
+ JMP runtime·syscall_chroot(SB)
+
+TEXT ·close(SB),NOSPLIT,$0
+ JMP runtime·syscall_close(SB)
+
+TEXT ·dlopen(SB),NOSPLIT,$0
+ JMP runtime·syscall_dlopen(SB)
+
+TEXT ·dlclose(SB),NOSPLIT,$0
+ JMP runtime·syscall_dlclose(SB)
+
+TEXT ·dlsym(SB),NOSPLIT,$0
+ JMP runtime·syscall_dlsym(SB)
+
+TEXT ·execve(SB),NOSPLIT,$0
+ JMP runtime·syscall_execve(SB)
+
+TEXT ·exit(SB),NOSPLIT,$0
+ JMP runtime·syscall_exit(SB)
+
+TEXT ·fcntl1(SB),NOSPLIT,$0
+ JMP runtime·syscall_fcntl(SB)
+
+TEXT ·forkx(SB),NOSPLIT,$0
+ JMP runtime·syscall_forkx(SB)
+
+TEXT ·gethostname(SB),NOSPLIT,$0
+ JMP runtime·syscall_gethostname(SB)
+
+TEXT ·ioctl(SB),NOSPLIT,$0
+ JMP runtime·syscall_ioctl(SB)
+
+TEXT ·pipe(SB),NOSPLIT,$0
+ JMP runtime·syscall_pipe(SB)
+
+TEXT ·RawSyscall(SB),NOSPLIT,$0
+ JMP runtime·syscall_rawsyscall(SB)
+
+TEXT ·setgid(SB),NOSPLIT,$0
+ JMP runtime·syscall_setgid(SB)
+
+TEXT ·setgroups1(SB),NOSPLIT,$0
+ JMP runtime·syscall_setgroups(SB)
+
+TEXT ·setsid(SB),NOSPLIT,$0
+ JMP runtime·syscall_setsid(SB)
+
+TEXT ·setuid(SB),NOSPLIT,$0
+ JMP runtime·syscall_setuid(SB)
+
+TEXT ·setpgid(SB),NOSPLIT,$0
+ JMP runtime·syscall_setpgid(SB)
+
+TEXT ·Syscall(SB),NOSPLIT,$0
+ JMP runtime·syscall_syscall(SB)
+
+TEXT ·wait4(SB),NOSPLIT,$0
+ JMP runtime·syscall_wait4(SB)
+
+TEXT ·write1(SB),NOSPLIT,$0
+ JMP runtime·syscall_write(SB)
diff --git a/src/pkg/syscall/so_solaris.go b/src/pkg/syscall/so_solaris.go
index 659cd67c1..bf1b75604 100644
--- a/src/pkg/syscall/so_solaris.go
+++ b/src/pkg/syscall/so_solaris.go
@@ -19,7 +19,7 @@ type soError struct {
func (e *soError) Error() string { return e.Msg }
-// Implemented in ../runtime/syscall_solaris.goc.
+// Implemented in asm_solaris_amd64.s.
func rawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
func dlclose(handle uintptr) (err Errno)