compat.h 4.7 KB

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