// See https://msdn.microsoft.com/en-us/library/windows/desktop/aa365542(v=vs.85).aspx
func setFilePointerEx(handle Handle, distToMove int64, newFilePointer *int64, whence uint32) error {
var e1 Errno
- switch runtime.GOARCH {
- default:
- panic("unsupported architecture")
- case "amd64":
+ if unsafe.Sizeof(uintptr(0)) == 8 {
_, _, e1 = Syscall6(procSetFilePointerEx.Addr(), 4, uintptr(handle), uintptr(distToMove), uintptr(unsafe.Pointer(newFilePointer)), uintptr(whence), 0, 0)
- case "386":
- // distToMove is a LARGE_INTEGER:
- // https://msdn.microsoft.com/en-us/library/windows/desktop/aa383713(v=vs.85).aspx
- _, _, e1 = Syscall6(procSetFilePointerEx.Addr(), 5, uintptr(handle), uintptr(distToMove), uintptr(distToMove>>32), uintptr(unsafe.Pointer(newFilePointer)), uintptr(whence), 0)
- case "arm":
- // distToMove must be 8-byte aligned per ARM calling convention
- // https://msdn.microsoft.com/en-us/library/dn736986.aspx#Anchor_7
- _, _, e1 = Syscall6(procSetFilePointerEx.Addr(), 6, uintptr(handle), 0, uintptr(distToMove), uintptr(distToMove>>32), uintptr(unsafe.Pointer(newFilePointer)), uintptr(whence))
+ } else {
+ // Different 32-bit systems disgaree about whether distToMove starts 8-byte aligned.
+ switch runtime.GOARCH {
+ default:
+ panic("unsupported 32-bit architecture")
+ case "386":
+ // distToMove is a LARGE_INTEGER:
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/aa383713(v=vs.85).aspx
+ _, _, e1 = Syscall6(procSetFilePointerEx.Addr(), 5, uintptr(handle), uintptr(distToMove), uintptr(distToMove>>32), uintptr(unsafe.Pointer(newFilePointer)), uintptr(whence), 0)
+ case "arm":
+ // distToMove must be 8-byte aligned per ARM calling convention
+ // https://msdn.microsoft.com/en-us/library/dn736986.aspx#Anchor_7
+ _, _, e1 = Syscall6(procSetFilePointerEx.Addr(), 6, uintptr(handle), 0, uintptr(distToMove), uintptr(distToMove>>32), uintptr(unsafe.Pointer(newFilePointer)), uintptr(whence))
+ }
}
if e1 != 0 {
return errnoErr(e1)