aboutsummaryrefslogtreecommitdiff
path: root/src/syscall
diff options
context:
space:
mode:
Diffstat (limited to 'src/syscall')
-rw-r--r--src/syscall/asm_darwin_386.s5
-rw-r--r--src/syscall/asm_darwin_amd64.s4
-rw-r--r--src/syscall/asm_dragonfly_386.s5
-rw-r--r--src/syscall/asm_dragonfly_amd64.s5
-rw-r--r--src/syscall/asm_freebsd_386.s5
-rw-r--r--src/syscall/asm_freebsd_amd64.s5
-rw-r--r--src/syscall/asm_freebsd_arm.s5
-rw-r--r--src/syscall/asm_linux_386.s7
-rw-r--r--src/syscall/asm_linux_amd64.s5
-rw-r--r--src/syscall/asm_linux_arm.s5
-rw-r--r--src/syscall/asm_nacl_386.s1
-rw-r--r--src/syscall/asm_nacl_amd64p32.s1
-rw-r--r--src/syscall/asm_nacl_arm.s1
-rw-r--r--src/syscall/asm_netbsd_386.s5
-rw-r--r--src/syscall/asm_netbsd_amd64.s5
-rw-r--r--src/syscall/asm_netbsd_arm.s5
-rw-r--r--src/syscall/asm_openbsd_386.s5
-rw-r--r--src/syscall/asm_openbsd_amd64.s5
-rw-r--r--src/syscall/asm_plan9_386.s6
-rw-r--r--src/syscall/asm_plan9_amd64.s6
-rw-r--r--src/syscall/env_plan9.go39
-rw-r--r--src/syscall/env_unix.go48
-rw-r--r--src/syscall/env_windows.go8
-rw-r--r--src/syscall/exec_linux.go123
-rw-r--r--src/syscall/export_test.go7
-rw-r--r--src/syscall/mksyscall_windows.go24
-rw-r--r--src/syscall/str.go6
-rw-r--r--src/syscall/syscall_test.go17
-rw-r--r--src/syscall/syscall_unix.go2
-rw-r--r--src/syscall/zsyscall_windows.go15
30 files changed, 230 insertions, 150 deletions
diff --git a/src/syscall/asm_darwin_386.s b/src/syscall/asm_darwin_386.s
index 7d8ddf4378..7205deb12d 100644
--- a/src/syscall/asm_darwin_386.s
+++ b/src/syscall/asm_darwin_386.s
@@ -17,7 +17,6 @@
// Trap # in AX, args on stack above caller pc.
TEXT ·Syscall(SB),NOSPLIT,$0-28
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -42,7 +41,6 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-40
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -70,7 +68,6 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-52
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -101,7 +98,6 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
@@ -123,7 +119,6 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
diff --git a/src/syscall/asm_darwin_amd64.s b/src/syscall/asm_darwin_amd64.s
index a3b1bd5346..e57199d2b6 100644
--- a/src/syscall/asm_darwin_amd64.s
+++ b/src/syscall/asm_darwin_amd64.s
@@ -17,7 +17,6 @@
// Trap # in AX, args in DI SI DX, return in AX DX
TEXT ·Syscall(SB),NOSPLIT,$0-56
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@@ -42,7 +41,6 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-80
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@@ -67,7 +65,6 @@ ok6:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
@@ -89,7 +86,6 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
diff --git a/src/syscall/asm_dragonfly_386.s b/src/syscall/asm_dragonfly_386.s
index 0d7d6ba1e7..7012d23c21 100644
--- a/src/syscall/asm_dragonfly_386.s
+++ b/src/syscall/asm_dragonfly_386.s
@@ -14,7 +14,6 @@
// Trap # in AX, args on stack above caller pc.
TEXT ·Syscall(SB),NOSPLIT,$0-32
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -39,7 +38,6 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-44
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -67,7 +65,6 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-56
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -98,7 +95,6 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-32
- GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
@@ -120,7 +116,6 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-44
- GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
diff --git a/src/syscall/asm_dragonfly_amd64.s b/src/syscall/asm_dragonfly_amd64.s
index b81cf8dda9..004d36089a 100644
--- a/src/syscall/asm_dragonfly_amd64.s
+++ b/src/syscall/asm_dragonfly_amd64.s
@@ -15,7 +15,6 @@
// Trap # in AX, args in DI SI DX, return in AX DX
TEXT ·Syscall(SB),NOSPLIT,$0-64
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@@ -39,7 +38,6 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-88
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@@ -63,7 +61,6 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-112
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX
MOVQ 16(SP), DI
@@ -97,7 +94,6 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-64
- GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
@@ -118,7 +114,6 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-88
- GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
diff --git a/src/syscall/asm_freebsd_386.s b/src/syscall/asm_freebsd_386.s
index ff5f9f4a2a..1400d5fea7 100644
--- a/src/syscall/asm_freebsd_386.s
+++ b/src/syscall/asm_freebsd_386.s
@@ -17,7 +17,6 @@
// Trap # in AX, args on stack above caller pc.
TEXT ·Syscall(SB),NOSPLIT,$0-28
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -42,7 +41,6 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-40
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -70,7 +68,6 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-52
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -101,7 +98,6 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
@@ -123,7 +119,6 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
diff --git a/src/syscall/asm_freebsd_amd64.s b/src/syscall/asm_freebsd_amd64.s
index 47ceb9287b..c52519098e 100644
--- a/src/syscall/asm_freebsd_amd64.s
+++ b/src/syscall/asm_freebsd_amd64.s
@@ -23,7 +23,6 @@
// Trap # in AX, args in DI SI DX, return in AX DX
TEXT ·Syscall(SB),NOSPLIT,$0-56
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@@ -47,7 +46,6 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-80
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@@ -71,7 +69,6 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-104
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX
MOVQ 16(SP), DI
@@ -105,7 +102,6 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
@@ -126,7 +122,6 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
diff --git a/src/syscall/asm_freebsd_arm.s b/src/syscall/asm_freebsd_arm.s
index ed369ce73e..6b0c182a76 100644
--- a/src/syscall/asm_freebsd_arm.s
+++ b/src/syscall/asm_freebsd_arm.s
@@ -14,7 +14,6 @@
// func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2, errno uintptr)
TEXT ·Syscall(SB),NOSPLIT,$0-28
- GO_ARGS
BL runtime·entersyscall(SB)
MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1
@@ -37,7 +36,6 @@ error:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-40
- GO_ARGS
BL runtime·entersyscall(SB)
MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1
@@ -64,7 +62,6 @@ error6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-52
- GO_ARGS
BL runtime·entersyscall(SB)
MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1
@@ -91,7 +88,6 @@ error9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- GO_ARGS
MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1
MOVW 8(FP), R1 // a2
@@ -111,7 +107,6 @@ errorr:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- GO_ARGS
MOVW 0(FP), R7 // syscall number
MOVW 4(FP), R0 // a1
MOVW 8(FP), R1 // a2
diff --git a/src/syscall/asm_linux_386.s b/src/syscall/asm_linux_386.s
index 2ce51822da..fa1b371206 100644
--- a/src/syscall/asm_linux_386.s
+++ b/src/syscall/asm_linux_386.s
@@ -16,7 +16,6 @@
// Trap # in AX, args in BX CX DX SI DI, return in AX
TEXT ·Syscall(SB),NOSPLIT,$0-28
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
MOVL 8(SP), BX
@@ -42,7 +41,6 @@ ok:
// func Syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
TEXT ·Syscall6(SB),NOSPLIT,$0-40
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
MOVL 8(SP), BX
@@ -69,7 +67,6 @@ ok6:
// func RawSyscall(trap uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr);
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- GO_ARGS
MOVL 4(SP), AX // syscall entry
MOVL 8(SP), BX
MOVL 12(SP), CX
@@ -92,7 +89,6 @@ ok1:
// func RawSyscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- GO_ARGS
MOVL 4(SP), AX // syscall entry
MOVL 8(SP), BX
MOVL 12(SP), CX
@@ -119,7 +115,6 @@ ok2:
// func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, errno int)
// Kernel interface gets call sub-number and pointer to a0.
TEXT ·socketcall(SB),NOSPLIT,$0-36
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL $SYS_SOCKETCALL, AX // syscall entry
MOVL 4(SP), BX // socket call number
@@ -144,7 +139,6 @@ oksock:
// func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, errno int)
// Kernel interface gets call sub-number and pointer to a0.
TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
- GO_ARGS
MOVL $SYS_SOCKETCALL, AX // syscall entry
MOVL 4(SP), BX // socket call number
LEAL 8(SP), CX // pointer to call arguments
@@ -170,7 +164,6 @@ oksock1:
// Underlying system call is
// llseek(int fd, int offhi, int offlo, int64 *result, int whence)
TEXT ·seek(SB),NOSPLIT,$0-28
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL $SYS__LLSEEK, AX // syscall entry
MOVL 4(SP), BX // fd
diff --git a/src/syscall/asm_linux_amd64.s b/src/syscall/asm_linux_amd64.s
index 0277c506c0..b3ce2165d6 100644
--- a/src/syscall/asm_linux_amd64.s
+++ b/src/syscall/asm_linux_amd64.s
@@ -18,7 +18,6 @@
// would pass 4th arg in CX, not R10.
TEXT ·Syscall(SB),NOSPLIT,$0-56
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@@ -44,7 +43,6 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-80
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 16(SP), DI
MOVQ 24(SP), SI
@@ -70,7 +68,6 @@ ok6:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
@@ -93,7 +90,6 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
@@ -116,7 +112,6 @@ ok2:
RET
TEXT ·gettimeofday(SB),NOSPLIT,$0-16
- GO_ARGS
MOVQ 8(SP), DI
MOVQ $0, SI
MOVQ runtime·__vdso_gettimeofday_sym(SB), AX
diff --git a/src/syscall/asm_linux_arm.s b/src/syscall/asm_linux_arm.s
index 9451013813..3526533019 100644
--- a/src/syscall/asm_linux_arm.s
+++ b/src/syscall/asm_linux_arm.s
@@ -14,7 +14,6 @@
// func Syscall(syscall uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr);
TEXT ·Syscall(SB),NOSPLIT,$0-28
- GO_ARGS
BL runtime·entersyscall(SB)
MOVW 4(SP), R7
MOVW 8(SP), R0
@@ -46,7 +45,6 @@ ok:
// func Syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
// Actually Syscall5 but the rest of the code expects it to be named Syscall6.
TEXT ·Syscall6(SB),NOSPLIT,$0-40
- GO_ARGS
BL runtime·entersyscall(SB)
MOVW 4(SP), R7 // syscall entry
MOVW 8(SP), R0
@@ -78,7 +76,6 @@ ok6:
// func RawSyscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
// Actually RawSyscall5 but the rest of the code expects it to be named RawSyscall6.
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- GO_ARGS
MOVW 4(SP), R7 // syscall entry
MOVW 8(SP), R0
MOVW 12(SP), R1
@@ -111,7 +108,6 @@ ok2:
// Underlying system call is
// llseek(int fd, int offhi, int offlo, int64 *result, int whence)
TEXT ·seek(SB),NOSPLIT,$0-32
- GO_ARGS
BL runtime·entersyscall(SB)
MOVW $SYS__LLSEEK, R7 // syscall entry
MOVW 4(SP), R0 // fd
@@ -139,7 +135,6 @@ okseek:
// func RawSyscall(trap uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr);
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- GO_ARGS
MOVW 4(SP), R7 // syscall entry
MOVW 8(SP), R0
MOVW 12(SP), R1
diff --git a/src/syscall/asm_nacl_386.s b/src/syscall/asm_nacl_386.s
index 5352b7697c..cb6fb44166 100644
--- a/src/syscall/asm_nacl_386.s
+++ b/src/syscall/asm_nacl_386.s
@@ -17,7 +17,6 @@
MOVL $(0x10000 + ((code)<<5)), AX; JMP AX
TEXT syscall·Syscall(SB),NOSPLIT,$12-28
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL trap+0(FP), AX
MOVL a1+4(FP), BX
diff --git a/src/syscall/asm_nacl_amd64p32.s b/src/syscall/asm_nacl_amd64p32.s
index 637fafab45..72391c431a 100644
--- a/src/syscall/asm_nacl_amd64p32.s
+++ b/src/syscall/asm_nacl_amd64p32.s
@@ -17,7 +17,6 @@
MOVL $(0x10000 + ((code)<<5)), AX; JMP AX
TEXT syscall·Syscall(SB),NOSPLIT,$0-28
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL trap+0(FP), AX
MOVL a1+4(FP), DI
diff --git a/src/syscall/asm_nacl_arm.s b/src/syscall/asm_nacl_arm.s
index 3e4479432b..78e10bf7a2 100644
--- a/src/syscall/asm_nacl_arm.s
+++ b/src/syscall/asm_nacl_arm.s
@@ -17,7 +17,6 @@
MOVW $(0x10000 + ((code)<<5)), R8; B (R8)
TEXT syscall·Syscall(SB),NOSPLIT,$0-28
- GO_ARGS
BL runtime·entersyscall(SB)
MOVW trap+0(FP), R8
MOVW a1+4(FP), R0
diff --git a/src/syscall/asm_netbsd_386.s b/src/syscall/asm_netbsd_386.s
index 29442ca9dd..a8c4849f23 100644
--- a/src/syscall/asm_netbsd_386.s
+++ b/src/syscall/asm_netbsd_386.s
@@ -17,7 +17,6 @@
// Trap # in AX, args on stack above caller pc.
TEXT ·Syscall(SB),NOSPLIT,$0-28
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -42,7 +41,6 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-40
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -70,7 +68,6 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-52
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -101,7 +98,6 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
@@ -123,7 +119,6 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
diff --git a/src/syscall/asm_netbsd_amd64.s b/src/syscall/asm_netbsd_amd64.s
index 6d0f311f41..b300148f43 100644
--- a/src/syscall/asm_netbsd_amd64.s
+++ b/src/syscall/asm_netbsd_amd64.s
@@ -18,7 +18,6 @@
// Trap # in AX, args in DI SI DX, return in AX DX
TEXT ·Syscall(SB),NOSPLIT,$0-56
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX // syscall entry
MOVQ 16(SP), DI
@@ -42,7 +41,6 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-80
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX // syscall entry
MOVQ 16(SP), DI
@@ -66,7 +64,6 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-104
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX // syscall entry
MOVQ 16(SP), DI
@@ -99,7 +96,6 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
@@ -120,7 +116,6 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
diff --git a/src/syscall/asm_netbsd_arm.s b/src/syscall/asm_netbsd_arm.s
index c4190ea332..290bb58061 100644
--- a/src/syscall/asm_netbsd_arm.s
+++ b/src/syscall/asm_netbsd_arm.s
@@ -14,7 +14,6 @@
// func Syscall9(trap int32, a1, a2, a3, a4, a5, a6, a7, a8, a9 int64) (r1, r2, err int32)
TEXT ·Syscall(SB),NOSPLIT,$0-28
- GO_ARGS
BL runtime·entersyscall(SB)
MOVW 0(FP), R0 // sigcall num
MOVW 4(FP), R1 // a1
@@ -37,7 +36,6 @@ error:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-40
- GO_ARGS
BL runtime·entersyscall(SB)
MOVW 0(FP), R0 // sigcall num
MOVW 4(FP), R1 // a1
@@ -63,7 +61,6 @@ error6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-52
- GO_ARGS
BL runtime·entersyscall(SB)
MOVW 0(FP), R0 // sigcall num
MOVW 4(FP), R1 // a1
@@ -89,7 +86,6 @@ error9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- GO_ARGS
MOVW 0(FP), R0 // sigcall num
MOVW 4(FP), R1 // a1
MOVW 8(FP), R2 // a2
@@ -109,7 +105,6 @@ errorr:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- GO_ARGS
MOVW 0(FP), R0 // sigcall num
MOVW 4(FP), R1 // a1
MOVW 8(FP), R2 // a2
diff --git a/src/syscall/asm_openbsd_386.s b/src/syscall/asm_openbsd_386.s
index e448a70ca1..6458bdf020 100644
--- a/src/syscall/asm_openbsd_386.s
+++ b/src/syscall/asm_openbsd_386.s
@@ -17,7 +17,6 @@
// Trap # in AX, args on stack above caller pc.
TEXT ·Syscall(SB),NOSPLIT,$0-28
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -42,7 +41,6 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-40
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -70,7 +68,6 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-52
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -101,7 +98,6 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
@@ -123,7 +119,6 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
diff --git a/src/syscall/asm_openbsd_amd64.s b/src/syscall/asm_openbsd_amd64.s
index 654e3df742..1e981fc01d 100644
--- a/src/syscall/asm_openbsd_amd64.s
+++ b/src/syscall/asm_openbsd_amd64.s
@@ -18,7 +18,6 @@
// Trap # in AX, args in DI SI DX, return in AX DX
TEXT ·Syscall(SB),NOSPLIT,$0-56
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX // syscall entry
MOVQ 16(SP), DI
@@ -42,7 +41,6 @@ ok:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-80
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX // syscall entry
MOVQ 16(SP), DI
@@ -66,7 +64,6 @@ ok6:
RET
TEXT ·Syscall9(SB),NOSPLIT,$0-104
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), AX // syscall entry
MOVQ 16(SP), DI
@@ -99,7 +96,6 @@ ok9:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
@@ -120,7 +116,6 @@ ok1:
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- GO_ARGS
MOVQ 16(SP), DI
MOVQ 24(SP), SI
MOVQ 32(SP), DX
diff --git a/src/syscall/asm_plan9_386.s b/src/syscall/asm_plan9_386.s
index 46562de845..fc13640b93 100644
--- a/src/syscall/asm_plan9_386.s
+++ b/src/syscall/asm_plan9_386.s
@@ -19,7 +19,6 @@
// Trap # in AX, args on stack above caller pc.
TEXT ·Syscall(SB),NOSPLIT,$0-32
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -55,7 +54,6 @@ copyresult3:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-44
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
@@ -94,7 +92,6 @@ copyresult4:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
@@ -110,7 +107,6 @@ TEXT ·RawSyscall(SB),NOSPLIT,$0-28
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- GO_ARGS
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
@@ -132,7 +128,6 @@ TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
//func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string)
TEXT ·seek(SB),NOSPLIT,$0-36
- GO_ARGS
LEAL newoffset+24(SP), AX
MOVL AX, placeholder+4(SP)
@@ -164,7 +159,6 @@ copyresult6:
//func exit(code int)
// Import runtime·exit for cleanly exiting.
TEXT ·exit(SB),NOSPLIT,$4-4
- GO_ARGS
NO_LOCAL_POINTERS
MOVL code+0(FP), AX
MOVL AX, 0(SP)
diff --git a/src/syscall/asm_plan9_amd64.s b/src/syscall/asm_plan9_amd64.s
index 283e28999a..92419b7172 100644
--- a/src/syscall/asm_plan9_amd64.s
+++ b/src/syscall/asm_plan9_amd64.s
@@ -18,7 +18,6 @@
//func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
TEXT ·Syscall(SB),NOSPLIT,$0-64
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), BP // syscall entry
// slide args down on top of system call number
@@ -54,7 +53,6 @@ copyresult3:
RET
TEXT ·Syscall6(SB),NOSPLIT,$0-88
- GO_ARGS
CALL runtime·entersyscall(SB)
MOVQ 8(SP), BP // syscall entry
// slide args down on top of system call number
@@ -93,7 +91,6 @@ copyresult4:
RET
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- GO_ARGS
MOVQ 8(SP), BP // syscall entry
// slide args down on top of system call number
LEAQ 16(SP), SI
@@ -109,7 +106,6 @@ TEXT ·RawSyscall(SB),NOSPLIT,$0-56
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- GO_ARGS
MOVQ 8(SP), BP // syscall entry
// slide args down on top of system call number
LEAQ 16(SP), SI
@@ -131,7 +127,6 @@ TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
//func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string)
TEXT ·seek(SB),NOSPLIT,$0-56
- GO_ARGS
LEAQ newoffset+40(SP), AX
MOVQ AX, placeholder+8(SP)
@@ -162,7 +157,6 @@ copyresult6:
//func exit(code int)
// Import runtime·exit for cleanly exiting.
TEXT ·exit(SB),NOSPLIT,$8-8
- GO_ARGS
NO_LOCAL_POINTERS
MOVQ code+0(FP), AX
MOVQ AX, 0(SP)
diff --git a/src/syscall/env_plan9.go b/src/syscall/env_plan9.go
index 9587ab5af9..9345079052 100644
--- a/src/syscall/env_plan9.go
+++ b/src/syscall/env_plan9.go
@@ -12,16 +12,22 @@ import (
)
var (
- // envOnce guards copyenv, which populates env.
+ // envOnce guards copyenv, which populates env, envi and envs.
envOnce sync.Once
- // envLock guards env and envs.
+ // envLock guards env, envi and envs.
envLock sync.RWMutex
// env maps from an environment variable to its value.
+ // TODO: remove this? golang.org/issue/8849
env = make(map[string]string)
+ // envi maps from an environment variable to its index in envs.
+ // TODO: remove this? golang.org/issue/8849
+ envi = make(map[string]int)
+
// envs contains elements of env in the form "key=value".
+ // empty strings mean deleted.
envs []string
errZeroLengthKey = errors.New("zero length key")
@@ -83,6 +89,7 @@ func copyenv() {
}
env[key] = v
envs[i] = key + "=" + v
+ envi[key] = i
i++
}
}
@@ -121,6 +128,7 @@ func Setenv(key, value string) error {
}
env[key] = value
envs = append(envs, key+"="+value)
+ envi[key] = len(envs) - 1
return nil
}
@@ -129,14 +137,39 @@ func Clearenv() {
defer envLock.Unlock()
env = make(map[string]string)
+ envi = make(map[string]int)
envs = []string{}
RawSyscall(SYS_RFORK, RFCENVG, 0, 0)
}
+func Unsetenv(key string) error {
+ if len(key) == 0 {
+ return errZeroLengthKey
+ }
+
+ envLock.Lock()
+ defer envLock.Unlock()
+
+ Remove("/env/" + key)
+
+ if i, ok := envi[key]; ok {
+ delete(env, key)
+ delete(envi, key)
+ envs[i] = ""
+ }
+ return nil
+}
+
func Environ() []string {
envLock.RLock()
defer envLock.RUnlock()
envOnce.Do(copyenv)
- return append([]string(nil), envs...)
+ ret := make([]string, 0, len(envs))
+ for _, pair := range envs {
+ if pair != "" {
+ ret = append(ret, pair)
+ }
+ }
+ return ret
}
diff --git a/src/syscall/env_unix.go b/src/syscall/env_unix.go
index ad354ed057..b5ded9c763 100644
--- a/src/syscall/env_unix.go
+++ b/src/syscall/env_unix.go
@@ -20,14 +20,18 @@ var (
// env maps from an environment variable to its first occurrence in envs.
env map[string]int
- // envs is provided by the runtime. elements are expected to be
- // of the form "key=value".
- envs []string
+ // envs is provided by the runtime. elements are expected to
+ // be of the form "key=value". An empty string means deleted
+ // (or a duplicate to be ignored).
+ envs []string = runtime_envs()
)
-// setenv_c is provided by the runtime, but is a no-op if cgo isn't
-// loaded.
+func runtime_envs() []string // in package runtime
+
+// setenv_c and unsetenv_c are provided by the runtime but are no-ops
+// if cgo isn't loaded.
func setenv_c(k, v string)
+func unsetenv_c(k string)
func copyenv() {
env = make(map[string]int)
@@ -36,7 +40,13 @@ func copyenv() {
if s[j] == '=' {
key := s[:j]
if _, ok := env[key]; !ok {
- env[key] = i
+ env[key] = i // first mention of key
+ } else {
+ // Clear duplicate keys. This permits Unsetenv to
+ // safely delete only the first item without
+ // worrying about unshadowing a later one,
+ // which might be a security problem.
+ envs[i] = ""
}
break
}
@@ -44,6 +54,20 @@ func copyenv() {
}
}
+func Unsetenv(key string) error {
+ envOnce.Do(copyenv)
+
+ envLock.Lock()
+ defer envLock.Unlock()
+
+ if i, ok := env[key]; ok {
+ envs[i] = ""
+ delete(env, key)
+ }
+ unsetenv_c(key)
+ return nil
+}
+
func Getenv(key string) (value string, found bool) {
envOnce.Do(copyenv)
if len(key) == 0 {
@@ -104,16 +128,22 @@ func Clearenv() {
envLock.Lock()
defer envLock.Unlock()
+ for k := range env {
+ unsetenv_c(k)
+ }
env = make(map[string]int)
envs = []string{}
- // TODO(bradfitz): pass through to C
}
func Environ() []string {
envOnce.Do(copyenv)
envLock.RLock()
defer envLock.RUnlock()
- a := make([]string, len(envs))
- copy(a, envs)
+ a := make([]string, 0, len(envs))
+ for _, env := range envs {
+ if env != "" {
+ a = append(a, env)
+ }
+ }
return a
}
diff --git a/src/syscall/env_windows.go b/src/syscall/env_windows.go
index 420b387246..bc21690d9f 100644
--- a/src/syscall/env_windows.go
+++ b/src/syscall/env_windows.go
@@ -47,6 +47,14 @@ func Setenv(key, value string) error {
return nil
}
+func Unsetenv(key string) error {
+ keyp, err := UTF16PtrFromString(key)
+ if err != nil {
+ return err
+ }
+ return SetEnvironmentVariable(keyp, nil)
+}
+
func Clearenv() {
for _, s := range Environ() {
// Environment variables can begin with =
diff --git a/src/syscall/exec_linux.go b/src/syscall/exec_linux.go
index f61dfc424a..72e2f0b69c 100644
--- a/src/syscall/exec_linux.go
+++ b/src/syscall/exec_linux.go
@@ -10,19 +10,29 @@ import (
"unsafe"
)
+// SysProcIDMap holds Container ID to Host ID mappings used for User Namespaces in Linux.
+// See user_namespaces(7).
+type SysProcIDMap struct {
+ ContainerID int // Container ID.
+ HostID int // Host ID.
+ Size int // Size.
+}
+
type SysProcAttr struct {
- Chroot string // Chroot.
- Credential *Credential // Credential.
- Ptrace bool // Enable tracing.
- Setsid bool // Create session.
- Setpgid bool // Set process group ID to new pid (SYSV setpgrp)
- Setctty bool // Set controlling terminal to fd Ctty (only meaningful if Setsid is set)
- Noctty bool // Detach fd 0 from controlling terminal
- Ctty int // Controlling TTY fd (Linux only)
- Pdeathsig Signal // Signal that the process will get when its parent dies (Linux only)
- Cloneflags uintptr // Flags for clone calls (Linux only)
- Foreground bool // Set foreground process group to child's pid. (Implies Setpgid. Stdin should be a TTY)
- Joinpgrp int // If != 0, child's process group ID. (Setpgid must not be set)
+ Chroot string // Chroot.
+ Credential *Credential // Credential.
+ Ptrace bool // Enable tracing.
+ Setsid bool // Create session.
+ Setpgid bool // Set process group ID to new pid (SYSV setpgrp)
+ Setctty bool // Set controlling terminal to fd Ctty (only meaningful if Setsid is set)
+ Noctty bool // Detach fd 0 from controlling terminal
+ Ctty int // Controlling TTY fd (Linux only)
+ Pdeathsig Signal // Signal that the process will get when its parent dies (Linux only)
+ Cloneflags uintptr // Flags for clone calls (Linux only)
+ Foreground bool // Set foreground process group to child's pid. (Implies Setpgid. Stdin should be a TTY)
+ Joinpgrp int // If != 0, child's process group ID. (Setpgid must not be set)
+ UidMappings []SysProcIDMap // User ID mappings for user namespaces.
+ GidMappings []SysProcIDMap // Group ID mappings for user namespaces.
}
// Implemented in runtime package.
@@ -44,8 +54,10 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
var (
r1 uintptr
err1 Errno
+ err2 Errno
nextfd int
i int
+ p [2]int
)
// Guard against side effects of shuffling fds below.
@@ -61,6 +73,14 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
}
nextfd++
+ // Allocate another pipe for parent to child communication for
+ // synchronizing writing of User ID/Group ID mappings.
+ if sys.UidMappings != nil || sys.GidMappings != nil {
+ if err := forkExecPipe(p[:]); err != nil {
+ return 0, err.(Errno)
+ }
+ }
+
// About to call fork.
// No more allocation or calls of non-assembly functions.
runtime_BeforeFork()
@@ -75,6 +95,16 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
runtime_AfterFork()
pid = int(r1)
+ if sys.UidMappings != nil || sys.GidMappings != nil {
+ Close(p[0])
+ err := writeUidGidMappings(pid, sys)
+ if err != nil {
+ err2 = err.(Errno)
+ }
+ RawSyscall(SYS_WRITE, uintptr(p[1]), uintptr(unsafe.Pointer(&err2)), unsafe.Sizeof(err2))
+ Close(p[1])
+ }
+
if sys.Joinpgrp != 0 {
// Place the child in the specified process group.
RawSyscall(SYS_SETPGID, r1, uintptr(sys.Joinpgrp), 0)
@@ -93,6 +123,25 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
// Fork succeeded, now in child.
+ // Wait for User ID/Group ID mappings to be written.
+ if sys.UidMappings != nil || sys.GidMappings != nil {
+ if _, _, err1 = RawSyscall(SYS_CLOSE, uintptr(p[1]), 0, 0); err1 != 0 {
+ goto childerror
+ }
+ r1, _, err1 = RawSyscall(SYS_READ, uintptr(p[0]), uintptr(unsafe.Pointer(&err2)), unsafe.Sizeof(err2))
+ if err1 != 0 {
+ goto childerror
+ }
+ if r1 != unsafe.Sizeof(err2) {
+ err1 = EINVAL
+ goto childerror
+ }
+ if err2 != 0 {
+ err1 = err2
+ goto childerror
+ }
+ }
+
// Parent death signal
if sys.Pdeathsig != 0 {
_, _, err1 = RawSyscall6(SYS_PRCTL, PR_SET_PDEATHSIG, uintptr(sys.Pdeathsig), 0, 0, 0, 0)
@@ -296,3 +345,53 @@ func forkExecPipe(p []int) (err error) {
}
return
}
+
+// writeIDMappings writes the user namespace User ID or Group ID mappings to the specified path.
+func writeIDMappings(path string, idMap []SysProcIDMap) error {
+ fd, err := Open(path, O_RDWR, 0)
+ if err != nil {
+ return err
+ }
+
+ data := ""
+ for _, im := range idMap {
+ data = data + itoa(im.ContainerID) + " " + itoa(im.HostID) + " " + itoa(im.Size) + "\n"
+ }
+
+ bytes, err := ByteSliceFromString(data)
+ if err != nil {
+ Close(fd)
+ return err
+ }
+
+ if _, err := Write(fd, bytes); err != nil {
+ Close(fd)
+ return err
+ }
+
+ if err := Close(fd); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+// writeUidGidMappings writes User ID and Group ID mappings for user namespaces
+// for a process and it is called from the parent process.
+func writeUidGidMappings(pid int, sys *SysProcAttr) error {
+ if sys.UidMappings != nil {
+ uidf := "/proc/" + itoa(pid) + "/uid_map"
+ if err := writeIDMappings(uidf, sys.UidMappings); err != nil {
+ return err
+ }
+ }
+
+ if sys.GidMappings != nil {
+ gidf := "/proc/" + itoa(pid) + "/gid_map"
+ if err := writeIDMappings(gidf, sys.GidMappings); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
diff --git a/src/syscall/export_test.go b/src/syscall/export_test.go
new file mode 100644
index 0000000000..c9774622c8
--- /dev/null
+++ b/src/syscall/export_test.go
@@ -0,0 +1,7 @@
+// 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
+
+var Itoa = itoa
diff --git a/src/syscall/mksyscall_windows.go b/src/syscall/mksyscall_windows.go
index ea9ee45511..1cdd6b4d22 100644
--- a/src/syscall/mksyscall_windows.go
+++ b/src/syscall/mksyscall_windows.go
@@ -158,7 +158,6 @@ func (p *Param) SyscallArgList() []string {
case p.Type[0] == '*':
s = fmt.Sprintf("unsafe.Pointer(%s)", p.Name)
case p.Type == "string":
- p.fn.use(p.tmpVar())
s = fmt.Sprintf("unsafe.Pointer(%s)", p.tmpVar())
case p.Type == "bool":
s = p.tmpVar()
@@ -304,7 +303,6 @@ type Fn struct {
Params []*Param
Rets *Rets
PrintTrace bool
- Used []string
dllname string
dllfuncname string
src string
@@ -312,15 +310,6 @@ type Fn struct {
curTmpVarIdx int // insure tmp variables have uniq names
}
-func (f *Fn) use(v string) {
- for _, e := range f.Used {
- if e == v {
- return
- }
- }
- f.Used = append(f.Used, v)
-}
-
// extractParams parses s to extract function parameters.
func extractParams(s string, f *Fn) ([]*Param, error) {
s = trim(s)
@@ -339,7 +328,7 @@ func extractParams(s string, f *Fn) ([]*Param, error) {
}
}
ps[i] = &Param{
- Name: sanitizeName(trim(b[0])),
+ Name: trim(b[0]),
Type: trim(b[1]),
fn: f,
tmpVarIdx: -1,
@@ -348,13 +337,6 @@ func extractParams(s string, f *Fn) ([]*Param, error) {
return ps, nil
}
-func sanitizeName(n string) string {
- if n == "use" {
- return "use_"
- }
- return n
-}
-
// extractSection extracts text out of string s starting after start
// and ending just before end. found return value will indicate success,
// and prefix, body and suffix will contain correspondent parts of string s.
@@ -698,7 +680,7 @@ var (
{{define "funcbody"}}
func {{.Name}}({{.ParamList}}) {{if .Rets.List}}{{.Rets.List}} {{end}}{
{{template "tmpvars" .}} {{template "syscall" .}}
-{{template "used" .}}{{template "seterror" .}}{{template "printtrace" .}} return
+{{template "seterror" .}}{{template "printtrace" .}} return
}
{{end}}
@@ -707,8 +689,6 @@ func {{.Name}}({{.ParamList}}) {{if .Rets.List}}{{.Rets.List}} {{end}}{
{{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(), {{.ParamCount}}, {{.SyscallParamList}}){{end}}
-{{define "used"}}{{range .Used}}use(unsafe.Pointer({{.}}));{{end}}{{end}}
-
{{define "seterror"}}{{if .Rets.SetErrorCode}} {{.Rets.SetErrorCode}}
{{end}}{{end}}
diff --git a/src/syscall/str.go b/src/syscall/str.go
index 0fce842e8c..2ddf04b227 100644
--- a/src/syscall/str.go
+++ b/src/syscall/str.go
@@ -6,8 +6,12 @@ package syscall
func itoa(val int) string { // do it here rather than with fmt to avoid dependency
if val < 0 {
- return "-" + itoa(-val)
+ return "-" + uitoa(uint(-val))
}
+ return uitoa(uint(val))
+}
+
+func uitoa(val uint) string {
var buf [32]byte // big enough for int64
i := len(buf) - 1
for val >= 10 {
diff --git a/src/syscall/syscall_test.go b/src/syscall/syscall_test.go
index 2a39b54f1b..846c4873d2 100644
--- a/src/syscall/syscall_test.go
+++ b/src/syscall/syscall_test.go
@@ -5,6 +5,7 @@
package syscall_test
import (
+ "fmt"
"syscall"
"testing"
)
@@ -28,3 +29,19 @@ func TestEnv(t *testing.T) {
// make sure TESTENV gets set to "", not deleted
testSetGetenv(t, "TESTENV", "")
}
+
+func TestItoa(t *testing.T) {
+ // Make most negative integer: 0x8000...
+ i := 1
+ for i<<1 != 0 {
+ i <<= 1
+ }
+ if i >= 0 {
+ t.Fatal("bad math")
+ }
+ s := syscall.Itoa(i)
+ f := fmt.Sprint(i)
+ if s != f {
+ t.Fatalf("itoa(%d) = %s, want %s", i, s, f)
+ }
+}
diff --git a/src/syscall/syscall_unix.go b/src/syscall/syscall_unix.go
index f18dfca5e6..a06bd7dd08 100644
--- a/src/syscall/syscall_unix.go
+++ b/src/syscall/syscall_unix.go
@@ -109,7 +109,7 @@ func (e Errno) Error() string {
}
func (e Errno) Temporary() bool {
- return e == EINTR || e == EMFILE || e.Timeout()
+ return e == EINTR || e == EMFILE || e == ECONNRESET || e == ECONNABORTED || e.Timeout()
}
func (e Errno) Timeout() bool {
diff --git a/src/syscall/zsyscall_windows.go b/src/syscall/zsyscall_windows.go
index 9f2c84fb1f..1f44750b7f 100644
--- a/src/syscall/zsyscall_windows.go
+++ b/src/syscall/zsyscall_windows.go
@@ -177,7 +177,6 @@ func LoadLibrary(libname string) (handle Handle, err error) {
return
}
r0, _, e1 := Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
handle = Handle(r0)
if handle == 0 {
if e1 != 0 {
@@ -208,7 +207,6 @@ func GetProcAddress(module Handle, procname string) (proc uintptr, err error) {
return
}
r0, _, e1 := Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(_p0)), 0)
- use(unsafe.Pointer(_p0))
proc = uintptr(r0)
if proc == 0 {
if e1 != 0 {
@@ -1561,7 +1559,6 @@ func GetHostByName(name string) (h *Hostent, err error) {
return
}
r0, _, e1 := Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
h = (*Hostent)(unsafe.Pointer(r0))
if h == nil {
if e1 != 0 {
@@ -1585,8 +1582,6 @@ func GetServByName(name string, proto string) (s *Servent, err error) {
return
}
r0, _, e1 := Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
- use(unsafe.Pointer(_p0))
- use(unsafe.Pointer(_p1))
s = (*Servent)(unsafe.Pointer(r0))
if s == nil {
if e1 != 0 {
@@ -1611,7 +1606,6 @@ func GetProtoByName(name string) (p *Protoent, err error) {
return
}
r0, _, e1 := Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(_p0)), 0, 0)
- use(unsafe.Pointer(_p0))
p = (*Protoent)(unsafe.Pointer(r0))
if p == nil {
if e1 != 0 {
@@ -1630,7 +1624,6 @@ func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSR
return
}
r0, _, _ := Syscall6(procDnsQuery_W.Addr(), 6, uintptr(unsafe.Pointer(_p0)), uintptr(qtype), uintptr(options), uintptr(unsafe.Pointer(extra)), uintptr(unsafe.Pointer(qrs)), uintptr(unsafe.Pointer(pr)))
- use(unsafe.Pointer(_p0))
if r0 != 0 {
status = Errno(r0)
}
@@ -1750,8 +1743,8 @@ func NetApiBufferFree(buf *byte) (neterr error) {
return
}
-func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use_ *uint32) (err error) {
- r1, _, e1 := Syscall9(procLookupAccountSidW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use_)), 0, 0)
+func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
+ r1, _, e1 := Syscall9(procLookupAccountSidW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
if r1 == 0 {
if e1 != 0 {
err = error(e1)
@@ -1762,8 +1755,8 @@ func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint3
return
}
-func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use_ *uint32) (err error) {
- r1, _, e1 := Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use_)), 0, 0)
+func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
+ r1, _, e1 := Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
if r1 == 0 {
if e1 != 0 {
err = error(e1)