compat.h 4.7 KB

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