github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/vendor_skip/golang.org/x/sys/unix/syscall_aix_ppc64.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build aix && ppc64 6 7 package unix 8 9 //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 10 //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek 11 12 //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64 13 14 func setTimespec(sec, nsec int64) Timespec { 15 return Timespec{Sec: sec, Nsec: nsec} 16 } 17 18 func setTimeval(sec, usec int64) Timeval { 19 return Timeval{Sec: int64(sec), Usec: int32(usec)} 20 } 21 22 func (iov *Iovec) SetLen(length int) { 23 iov.Len = uint64(length) 24 } 25 26 func (msghdr *Msghdr) SetControllen(length int) { 27 msghdr.Controllen = uint32(length) 28 } 29 30 func (msghdr *Msghdr) SetIovlen(length int) { 31 msghdr.Iovlen = int32(length) 32 } 33 34 func (cmsg *Cmsghdr) SetLen(length int) { 35 cmsg.Len = uint32(length) 36 } 37 38 // In order to only have Timespec structure, type of Stat_t's fields 39 // Atim, Mtim and Ctim is changed from StTimespec to Timespec during 40 // ztypes generation. 41 // On ppc64, Timespec.Nsec is an int64 while StTimespec.Nsec is an 42 // int32, so the fields' value must be modified. 43 func fixStatTimFields(stat *Stat_t) { 44 stat.Atim.Nsec >>= 32 45 stat.Mtim.Nsec >>= 32 46 stat.Ctim.Nsec >>= 32 47 } 48 49 func Fstat(fd int, stat *Stat_t) error { 50 err := fstat(fd, stat) 51 if err != nil { 52 return err 53 } 54 fixStatTimFields(stat) 55 return nil 56 } 57 58 func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error { 59 err := fstatat(dirfd, path, stat, flags) 60 if err != nil { 61 return err 62 } 63 fixStatTimFields(stat) 64 return nil 65 } 66 67 func Lstat(path string, stat *Stat_t) error { 68 err := lstat(path, stat) 69 if err != nil { 70 return err 71 } 72 fixStatTimFields(stat) 73 return nil 74 } 75 76 func Stat(path string, statptr *Stat_t) error { 77 err := stat(path, statptr) 78 if err != nil { 79 return err 80 } 81 fixStatTimFields(statptr) 82 return nil 83 }