mirror of
https://github.com/golang/go
synced 2024-11-22 06:44:40 -07:00
syscall: mingw Sleep
R=rsc, brainman CC=golang-dev https://golang.org/cl/961047
This commit is contained in:
parent
77817e08d5
commit
4aaddf8a35
@ -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"
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user