diff --git a/src/pkg/syscall/syscall_mingw.go b/src/pkg/syscall/syscall_mingw.go index 067a26f2016..be09480dbdb 100644 --- a/src/pkg/syscall/syscall_mingw.go +++ b/src/pkg/syscall/syscall_mingw.go @@ -121,9 +121,18 @@ func getSysProcAddr(m uint32, pname string) uintptr { //sys GetComputerName(buf *uint16, n *uint32) (ok bool, errno int) = GetComputerNameW //sys SetEndOfFile(handle int32) (ok bool, errno int) //sys GetSystemTimeAsFileTime(time *Filetime) +//sys sleep(msec uint32) = Sleep // syscall interface implementation for other packages +func Sleep(nsec int64) (errno int) { + nsec += 999999 // round up to milliseconds + msec := uint32(nsec / 1e6) + sleep(msec) + errno = 0 + return +} + func Errstr(errno int) string { if errno == EMINGW { return "not supported by windows" diff --git a/src/pkg/syscall/zsyscall_mingw_386.go b/src/pkg/syscall/zsyscall_mingw_386.go index ccfb616ef1e..2032c14a650 100644 --- a/src/pkg/syscall/zsyscall_mingw_386.go +++ b/src/pkg/syscall/zsyscall_mingw_386.go @@ -1,4 +1,4 @@ -// mksyscall_mingw.sh -l32 syscall_mingw.go syscall_mingw_386.go +// mksyscall_mingw.sh -l32 syscall_mingw.go zsyscall_mingw_386.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT package syscall @@ -33,6 +33,7 @@ var ( procGetComputerNameW = getSysProcAddr(modKERNEL32, "GetComputerNameW") procSetEndOfFile = getSysProcAddr(modKERNEL32, "SetEndOfFile") procGetSystemTimeAsFileTime = getSysProcAddr(modKERNEL32, "GetSystemTimeAsFileTime") + procSleep = getSysProcAddr(modKERNEL32, "Sleep") ) func GetLastError() (lasterrno int) { @@ -315,3 +316,8 @@ func GetSystemTimeAsFileTime(time *Filetime) { Syscall(procGetSystemTimeAsFileTime, uintptr(unsafe.Pointer(time)), 0, 0) return } + +func sleep(msec uint32) { + Syscall(procSleep, uintptr(msec), 0, 0) + return +}