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.

syscall_aix_ppc64.go 1.9KB

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