You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

85 lines
1.9 KiB

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