mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-06 00:57:18 -04:00
windows: Implement WaitForMultipleObjects
This is a very classic and highly useful Windows API that I'm surprised it's still not here. Change-Id: If54319099cd94dd727126c579dd5a681979321cd Reviewed-on: https://go-review.googlesource.com/c/160937 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
committed by
Alex Brainman
parent
7ae0202eb7
commit
980327fe3c
@@ -112,6 +112,7 @@ var (
|
||||
procGetProcessTimes = modkernel32.NewProc("GetProcessTimes")
|
||||
procDuplicateHandle = modkernel32.NewProc("DuplicateHandle")
|
||||
procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject")
|
||||
procWaitForMultipleObjects = modkernel32.NewProc("WaitForMultipleObjects")
|
||||
procGetTempPathW = modkernel32.NewProc("GetTempPathW")
|
||||
procCreatePipe = modkernel32.NewProc("CreatePipe")
|
||||
procGetFileType = modkernel32.NewProc("GetFileType")
|
||||
@@ -1084,6 +1085,25 @@ func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32,
|
||||
return
|
||||
}
|
||||
|
||||
func waitForMultipleObjects(count uint32, handles uintptr, waitAll bool, waitMilliseconds uint32) (event uint32, err error) {
|
||||
var _p0 uint32
|
||||
if waitAll {
|
||||
_p0 = 1
|
||||
} else {
|
||||
_p0 = 0
|
||||
}
|
||||
r0, _, e1 := syscall.Syscall6(procWaitForMultipleObjects.Addr(), 4, uintptr(count), uintptr(handles), uintptr(_p0), uintptr(waitMilliseconds), 0, 0)
|
||||
event = uint32(r0)
|
||||
if event == 0xffffffff {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
|
||||
n = uint32(r0)
|
||||
|
||||
Reference in New Issue
Block a user