compat.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_SPARC64_COMPAT_H
  3. #define _ASM_SPARC64_COMPAT_H
  4. /*
  5. * Architecture specific compatibility types
  6. */
  7. #include <linux/types.h>
  8. #define compat_mode_t compat_mode_t
  9. typedef u16 compat_mode_t;
  10. #define __compat_uid_t __compat_uid_t
  11. typedef u16 __compat_uid_t;
  12. typedef u16 __compat_gid_t;
  13. #define compat_dev_t compat_dev_t
  14. typedef u16 compat_dev_t;
  15. #define compat_ipc_pid_t compat_ipc_pid_t
  16. typedef u16 compat_ipc_pid_t;
  17. #define compat_ipc64_perm compat_ipc64_perm
  18. #define COMPAT_RLIM_INFINITY 0x7fffffff
  19. #include <asm-generic/compat.h>
  20. #define COMPAT_UTS_MACHINE "sparc\0\0"
  21. typedef s16 compat_nlink_t;
  22. struct compat_stat {
  23. compat_dev_t st_dev;
  24. compat_ino_t st_ino;
  25. compat_mode_t st_mode;
  26. compat_nlink_t st_nlink;
  27. __compat_uid_t st_uid;
  28. __compat_gid_t st_gid;
  29. compat_dev_t st_rdev;
  30. compat_off_t st_size;
  31. old_time32_t st_atime;
  32. compat_ulong_t st_atime_nsec;
  33. old_time32_t st_mtime;
  34. compat_ulong_t st_mtime_nsec;
  35. old_time32_t st_ctime;
  36. compat_ulong_t st_ctime_nsec;
  37. compat_off_t st_blksize;
  38. compat_off_t st_blocks;
  39. u32 __unused4[2];
  40. };
  41. struct compat_stat64 {
  42. unsigned long long st_dev;
  43. unsigned long long st_ino;
  44. unsigned int st_mode;
  45. unsigned int st_nlink;
  46. unsigned int st_uid;
  47. unsigned int st_gid;
  48. unsigned long long st_rdev;
  49. unsigned char __pad3[8];
  50. long long st_size;
  51. unsigned int st_blksize;
  52. unsigned char __pad4[8];
  53. unsigned int st_blocks;
  54. unsigned int st_atime;
  55. unsigned int st_atime_nsec;
  56. unsigned int st_mtime;
  57. unsigned int st_mtime_nsec;
  58. unsigned int st_ctime;
  59. unsigned int st_ctime_nsec;
  60. unsigned int __unused4;
  61. unsigned int __unused5;
  62. };
  63. #define __ARCH_COMPAT_FLOCK_PAD short __unused;
  64. struct compat_ipc64_perm {
  65. compat_key_t key;
  66. __compat_uid32_t uid;
  67. __compat_gid32_t gid;
  68. __compat_uid32_t cuid;
  69. __compat_gid32_t cgid;
  70. unsigned short __pad1;
  71. compat_mode_t mode;
  72. unsigned short __pad2;
  73. unsigned short seq;
  74. unsigned long __unused1; /* yes they really are 64bit pads */
  75. unsigned long __unused2;
  76. };
  77. struct compat_semid64_ds {
  78. struct compat_ipc64_perm sem_perm;
  79. unsigned int sem_otime_high;
  80. unsigned int sem_otime;
  81. unsigned int sem_ctime_high;
  82. unsigned int sem_ctime;
  83. u32 sem_nsems;
  84. u32 __unused1;
  85. u32 __unused2;
  86. };
  87. struct compat_msqid64_ds {
  88. struct compat_ipc64_perm msg_perm;
  89. unsigned int msg_stime_high;
  90. unsigned int msg_stime;
  91. unsigned int msg_rtime_high;
  92. unsigned int msg_rtime;
  93. unsigned int msg_ctime_high;
  94. unsigned int msg_ctime;
  95. unsigned int msg_cbytes;
  96. unsigned int msg_qnum;
  97. unsigned int msg_qbytes;
  98. compat_pid_t msg_lspid;
  99. compat_pid_t msg_lrpid;
  100. unsigned int __unused1;
  101. unsigned int __unused2;
  102. };
  103. struct compat_shmid64_ds {
  104. struct compat_ipc64_perm shm_perm;
  105. unsigned int shm_atime_high;
  106. unsigned int shm_atime;
  107. unsigned int shm_dtime_high;
  108. unsigned int shm_dtime;
  109. unsigned int shm_ctime_high;
  110. unsigned int shm_ctime;
  111. compat_size_t shm_segsz;
  112. compat_pid_t shm_cpid;
  113. compat_pid_t shm_lpid;
  114. unsigned int shm_nattch;
  115. unsigned int __unused1;
  116. unsigned int __unused2;
  117. };
  118. #ifdef CONFIG_COMPAT
  119. static inline int is_compat_task(void)
  120. {
  121. return test_thread_flag(TIF_32BIT);
  122. }
  123. static inline bool in_compat_syscall(void)
  124. {
  125. /* Vector 0x110 is LINUX_32BIT_SYSCALL_TRAP */
  126. return pt_regs_trap_type(current_pt_regs()) == 0x110;
  127. }
  128. #define in_compat_syscall in_compat_syscall
  129. #endif
  130. #endif /* _ASM_SPARC64_COMPAT_H */