syscall_aix_ppc64.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. //go:build aix && ppc64
  5. // +build aix,ppc64
  6. package unix
  7. //sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
  8. //sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
  9. //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek
  10. //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64
  11. func setTimespec(sec, nsec int64) Timespec {
  12. return Timespec{Sec: sec, Nsec: nsec}
  13. }
  14. func setTimeval(sec, usec int64) Timeval {
  15. return Timeval{Sec: int64(sec), Usec: int32(usec)}
  16. }
  17. func (iov *Iovec) SetLen(length int) {
  18. iov.Len = uint64(length)
  19. }
  20. func (msghdr *Msghdr) SetControllen(length int) {
  21. msghdr.Controllen = uint32(length)
  22. }
  23. func (msghdr *Msghdr) SetIovlen(length int) {
  24. msghdr.Iovlen = int32(length)
  25. }
  26. func (cmsg *Cmsghdr) SetLen(length int) {
  27. cmsg.Len = uint32(length)
  28. }
  29. // In order to only have Timespec structure, type of Stat_t's fields
  30. // Atim, Mtim and Ctim is changed from StTimespec to Timespec during
  31. // ztypes generation.
  32. // On ppc64, Timespec.Nsec is an int64 while StTimespec.Nsec is an
  33. // int32, so the fields' value must be modified.
  34. func fixStatTimFields(stat *Stat_t) {
  35. stat.Atim.Nsec >>= 32
  36. stat.Mtim.Nsec >>= 32
  37. stat.Ctim.Nsec >>= 32
  38. }
  39. func Fstat(fd int, stat *Stat_t) error {
  40. err := fstat(fd, stat)
  41. if err != nil {
  42. return err
  43. }
  44. fixStatTimFields(stat)
  45. return nil
  46. }
  47. func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error {
  48. err := fstatat(dirfd, path, stat, flags)
  49. if err != nil {
  50. return err
  51. }
  52. fixStatTimFields(stat)
  53. return nil
  54. }
  55. func Lstat(path string, stat *Stat_t) error {
  56. err := lstat(path, stat)
  57. if err != nil {
  58. return err
  59. }
  60. fixStatTimFields(stat)
  61. return nil
  62. }
  63. func Stat(path string, statptr *Stat_t) error {
  64. err := stat(path, statptr)
  65. if err != nil {
  66. return err
  67. }
  68. fixStatTimFields(statptr)
  69. return nil
  70. }