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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. // +build aix
  5. // +build 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 (cmsg *Cmsghdr) SetLen(length int) {
  24. cmsg.Len = uint32(length)
  25. }
  26. // In order to only have Timespec structure, type of Stat_t's fields
  27. // Atim, Mtim and Ctim is changed from StTimespec to Timespec during
  28. // ztypes generation.
  29. // On ppc64, Timespec.Nsec is an int64 while StTimespec.Nsec is an
  30. // int32, so the fields' value must be modified.
  31. func fixStatTimFields(stat *Stat_t) {
  32. stat.Atim.Nsec >>= 32
  33. stat.Mtim.Nsec >>= 32
  34. stat.Ctim.Nsec >>= 32
  35. }
  36. func Fstat(fd int, stat *Stat_t) error {
  37. err := fstat(fd, stat)
  38. if err != nil {
  39. return err
  40. }
  41. fixStatTimFields(stat)
  42. return nil
  43. }
  44. func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error {
  45. err := fstatat(dirfd, path, stat, flags)
  46. if err != nil {
  47. return err
  48. }
  49. fixStatTimFields(stat)
  50. return nil
  51. }
  52. func Lstat(path string, stat *Stat_t) error {
  53. err := lstat(path, stat)
  54. if err != nil {
  55. return err
  56. }
  57. fixStatTimFields(stat)
  58. return nil
  59. }
  60. func Stat(path string, statptr *Stat_t) error {
  61. err := stat(path, statptr)
  62. if err != nil {
  63. return err
  64. }
  65. fixStatTimFields(statptr)
  66. return nil
  67. }