compat.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. #ifndef _ASM_SPARC64_COMPAT_H
  2. #define _ASM_SPARC64_COMPAT_H
  3. /*
  4. * Architecture specific compatibility types
  5. */
  6. #include <linux/types.h>
  7. #define COMPAT_USER_HZ 100
  8. typedef u32 compat_size_t;
  9. typedef s32 compat_ssize_t;
  10. typedef s32 compat_time_t;
  11. typedef s32 compat_clock_t;
  12. typedef s32 compat_pid_t;
  13. typedef u16 __compat_uid_t;
  14. typedef u16 __compat_gid_t;
  15. typedef u32 __compat_uid32_t;
  16. typedef u32 __compat_gid32_t;
  17. typedef u16 compat_mode_t;
  18. typedef u32 compat_ino_t;
  19. typedef u16 compat_dev_t;
  20. typedef s32 compat_off_t;
  21. typedef s64 compat_loff_t;
  22. typedef s16 compat_nlink_t;
  23. typedef u16 compat_ipc_pid_t;
  24. typedef s32 compat_daddr_t;
  25. typedef u32 compat_caddr_t;
  26. typedef __kernel_fsid_t compat_fsid_t;
  27. typedef s32 compat_key_t;
  28. typedef s32 compat_timer_t;
  29. typedef s32 compat_int_t;
  30. typedef s32 compat_long_t;
  31. typedef u32 compat_uint_t;
  32. typedef u32 compat_ulong_t;
  33. struct compat_timespec {
  34. compat_time_t tv_sec;
  35. s32 tv_nsec;
  36. };
  37. struct compat_timeval {
  38. compat_time_t tv_sec;
  39. s32 tv_usec;
  40. };
  41. struct compat_stat {
  42. compat_dev_t st_dev;
  43. compat_ino_t st_ino;
  44. compat_mode_t st_mode;
  45. compat_nlink_t st_nlink;
  46. __compat_uid_t st_uid;
  47. __compat_gid_t st_gid;
  48. compat_dev_t st_rdev;
  49. compat_off_t st_size;
  50. compat_time_t st_atime;
  51. compat_ulong_t st_atime_nsec;
  52. compat_time_t st_mtime;
  53. compat_ulong_t st_mtime_nsec;
  54. compat_time_t st_ctime;
  55. compat_ulong_t st_ctime_nsec;
  56. compat_off_t st_blksize;
  57. compat_off_t st_blocks;
  58. u32 __unused4[2];
  59. };
  60. struct compat_stat64 {
  61. unsigned long long st_dev;
  62. unsigned long long st_ino;
  63. unsigned int st_mode;
  64. unsigned int st_nlink;
  65. unsigned int st_uid;
  66. unsigned int st_gid;
  67. unsigned long long st_rdev;
  68. unsigned char __pad3[8];
  69. long long st_size;
  70. unsigned int st_blksize;
  71. unsigned char __pad4[8];
  72. unsigned int st_blocks;
  73. unsigned int st_atime;
  74. unsigned int st_atime_nsec;
  75. unsigned int st_mtime;
  76. unsigned int st_mtime_nsec;
  77. unsigned int st_ctime;
  78. unsigned int st_ctime_nsec;
  79. unsigned int __unused4;
  80. unsigned int __unused5;
  81. };
  82. struct compat_flock {
  83. short l_type;
  84. short l_whence;
  85. compat_off_t l_start;
  86. compat_off_t l_len;
  87. compat_pid_t l_pid;
  88. short __unused;
  89. };
  90. #define F_GETLK64 12
  91. #define F_SETLK64 13
  92. #define F_SETLKW64 14
  93. struct compat_flock64 {
  94. short l_type;
  95. short l_whence;
  96. compat_loff_t l_start;
  97. compat_loff_t l_len;
  98. compat_pid_t l_pid;
  99. short __unused;
  100. };
  101. struct compat_statfs {
  102. int f_type;
  103. int f_bsize;
  104. int f_blocks;
  105. int f_bfree;
  106. int f_bavail;
  107. int f_files;
  108. int f_ffree;
  109. compat_fsid_t f_fsid;
  110. int f_namelen; /* SunOS ignores this field. */
  111. int f_frsize;
  112. int f_spare[5];
  113. };
  114. #define COMPAT_RLIM_INFINITY 0x7fffffff
  115. typedef u32 compat_old_sigset_t;
  116. #define _COMPAT_NSIG 64
  117. #define _COMPAT_NSIG_BPW 32
  118. typedef u32 compat_sigset_word;
  119. #define COMPAT_OFF_T_MAX 0x7fffffff
  120. #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
  121. /*
  122. * A pointer passed in from user mode. This should not
  123. * be used for syscall parameters, just declare them
  124. * as pointers because the syscall entry code will have
  125. * appropriately comverted them already.
  126. */
  127. typedef u32 compat_uptr_t;
  128. static inline void __user *compat_ptr(compat_uptr_t uptr)
  129. {
  130. return (void __user *)(unsigned long)uptr;
  131. }
  132. static inline compat_uptr_t ptr_to_compat(void __user *uptr)
  133. {
  134. return (u32)(unsigned long)uptr;
  135. }
  136. static __inline__ void __user *compat_alloc_user_space(long len)
  137. {
  138. struct pt_regs *regs = current_thread_info()->kregs;
  139. unsigned long usp = regs->u_regs[UREG_I6];
  140. if (!(test_thread_flag(TIF_32BIT)))
  141. usp += STACK_BIAS;
  142. else
  143. usp &= 0xffffffffUL;
  144. return (void __user *) (usp - len);
  145. }
  146. struct compat_ipc64_perm {
  147. compat_key_t key;
  148. __compat_uid32_t uid;
  149. __compat_gid32_t gid;
  150. __compat_uid32_t cuid;
  151. __compat_gid32_t cgid;
  152. unsigned short __pad1;
  153. compat_mode_t mode;
  154. unsigned short __pad2;
  155. unsigned short seq;
  156. unsigned long __unused1; /* yes they really are 64bit pads */
  157. unsigned long __unused2;
  158. };
  159. struct compat_semid64_ds {
  160. struct compat_ipc64_perm sem_perm;
  161. unsigned int __pad1;
  162. compat_time_t sem_otime;
  163. unsigned int __pad2;
  164. compat_time_t sem_ctime;
  165. u32 sem_nsems;
  166. u32 __unused1;
  167. u32 __unused2;
  168. };
  169. struct compat_msqid64_ds {
  170. struct compat_ipc64_perm msg_perm;
  171. unsigned int __pad1;
  172. compat_time_t msg_stime;
  173. unsigned int __pad2;
  174. compat_time_t msg_rtime;
  175. unsigned int __pad3;
  176. compat_time_t msg_ctime;
  177. unsigned int msg_cbytes;
  178. unsigned int msg_qnum;
  179. unsigned int msg_qbytes;
  180. compat_pid_t msg_lspid;
  181. compat_pid_t msg_lrpid;
  182. unsigned int __unused1;
  183. unsigned int __unused2;
  184. };
  185. struct compat_shmid64_ds {
  186. struct compat_ipc64_perm shm_perm;
  187. unsigned int __pad1;
  188. compat_time_t shm_atime;
  189. unsigned int __pad2;
  190. compat_time_t shm_dtime;
  191. unsigned int __pad3;
  192. compat_time_t shm_ctime;
  193. compat_size_t shm_segsz;
  194. compat_pid_t shm_cpid;
  195. compat_pid_t shm_lpid;
  196. unsigned int shm_nattch;
  197. unsigned int __unused1;
  198. unsigned int __unused2;
  199. };
  200. #endif /* _ASM_SPARC64_COMPAT_H */