1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_COMPAT_H
3 #define _ASM_COMPAT_H
4 /*
5  * Architecture specific compatibility types
6  */
7 #include <linux/thread_info.h>
8 #include <linux/types.h>
9 #include <asm/page.h>
10 #include <asm/ptrace.h>
11 
12 typedef s32		__compat_uid_t;
13 typedef s32		__compat_gid_t;
14 typedef __compat_uid_t	__compat_uid32_t;
15 typedef __compat_gid_t	__compat_gid32_t;
16 #define __compat_uid32_t __compat_uid32_t
17 #define __compat_gid32_t __compat_gid32_t
18 
19 #define _COMPAT_NSIG		128		/* Don't ask !$@#% ...	*/
20 #define _COMPAT_NSIG_BPW	32
21 typedef u32		compat_sigset_word;
22 
23 #include <asm-generic/compat.h>
24 
25 #define COMPAT_USER_HZ		100
26 #define COMPAT_UTS_MACHINE	"mips\0\0\0"
27 
28 typedef u32		compat_dev_t;
29 typedef u32		compat_nlink_t;
30 typedef s32		compat_ipc_pid_t;
31 typedef struct {
32 	s32	val[2];
33 } compat_fsid_t;
34 
35 struct compat_stat {
36 	compat_dev_t	st_dev;
37 	s32		st_pad1[3];
38 	compat_ino_t	st_ino;
39 	compat_mode_t	st_mode;
40 	compat_nlink_t	st_nlink;
41 	__compat_uid_t	st_uid;
42 	__compat_gid_t	st_gid;
43 	compat_dev_t	st_rdev;
44 	s32		st_pad2[2];
45 	compat_off_t	st_size;
46 	s32		st_pad3;
47 	old_time32_t	st_atime;
48 	s32		st_atime_nsec;
49 	old_time32_t	st_mtime;
50 	s32		st_mtime_nsec;
51 	old_time32_t	st_ctime;
52 	s32		st_ctime_nsec;
53 	s32		st_blksize;
54 	s32		st_blocks;
55 	s32		st_pad4[14];
56 };
57 
58 struct compat_flock {
59 	short		l_type;
60 	short		l_whence;
61 	compat_off_t	l_start;
62 	compat_off_t	l_len;
63 	s32		l_sysid;
64 	compat_pid_t	l_pid;
65 	s32		pad[4];
66 };
67 
68 #define F_GETLK64	33
69 #define F_SETLK64	34
70 #define F_SETLKW64	35
71 
72 struct compat_flock64 {
73 	short		l_type;
74 	short		l_whence;
75 	compat_loff_t	l_start;
76 	compat_loff_t	l_len;
77 	compat_pid_t	l_pid;
78 };
79 
80 struct compat_statfs {
81 	int		f_type;
82 	int		f_bsize;
83 	int		f_frsize;
84 	int		f_blocks;
85 	int		f_bfree;
86 	int		f_files;
87 	int		f_ffree;
88 	int		f_bavail;
89 	compat_fsid_t	f_fsid;
90 	int		f_namelen;
91 	int		f_flags;
92 	int		f_spare[5];
93 };
94 
95 #define COMPAT_RLIM_INFINITY	0x7fffffffUL
96 
97 #define COMPAT_OFF_T_MAX	0x7fffffff
98 
99 struct compat_ipc64_perm {
100 	compat_key_t key;
101 	__compat_uid32_t uid;
102 	__compat_gid32_t gid;
103 	__compat_uid32_t cuid;
104 	__compat_gid32_t cgid;
105 	compat_mode_t mode;
106 	unsigned short seq;
107 	unsigned short __pad2;
108 	compat_ulong_t __unused1;
109 	compat_ulong_t __unused2;
110 };
111 
112 struct compat_semid64_ds {
113 	struct compat_ipc64_perm sem_perm;
114 	compat_ulong_t	sem_otime;
115 	compat_ulong_t	sem_ctime;
116 	compat_ulong_t	sem_nsems;
117 	compat_ulong_t	sem_otime_high;
118 	compat_ulong_t	sem_ctime_high;
119 };
120 
121 struct compat_msqid64_ds {
122 	struct compat_ipc64_perm msg_perm;
123 #ifndef CONFIG_CPU_LITTLE_ENDIAN
124 	compat_ulong_t	msg_stime_high;
125 #endif
126 	compat_ulong_t	msg_stime;
127 #ifdef CONFIG_CPU_LITTLE_ENDIAN
128 	compat_ulong_t	msg_stime_high;
129 #endif
130 #ifndef CONFIG_CPU_LITTLE_ENDIAN
131 	compat_ulong_t	msg_rtime_high;
132 #endif
133 	compat_ulong_t	msg_rtime;
134 #ifdef CONFIG_CPU_LITTLE_ENDIAN
135 	compat_ulong_t	msg_rtime_high;
136 #endif
137 #ifndef CONFIG_CPU_LITTLE_ENDIAN
138 	compat_ulong_t	msg_ctime_high;
139 #endif
140 	compat_ulong_t	msg_ctime;
141 #ifdef CONFIG_CPU_LITTLE_ENDIAN
142 	compat_ulong_t	msg_ctime_high;
143 #endif
144 	compat_ulong_t	msg_cbytes;
145 	compat_ulong_t	msg_qnum;
146 	compat_ulong_t	msg_qbytes;
147 	compat_pid_t	msg_lspid;
148 	compat_pid_t	msg_lrpid;
149 	compat_ulong_t	__unused4;
150 	compat_ulong_t	__unused5;
151 };
152 
153 struct compat_shmid64_ds {
154 	struct compat_ipc64_perm shm_perm;
155 	compat_size_t	shm_segsz;
156 	compat_ulong_t	shm_atime;
157 	compat_ulong_t	shm_dtime;
158 	compat_ulong_t	shm_ctime;
159 	compat_pid_t	shm_cpid;
160 	compat_pid_t	shm_lpid;
161 	compat_ulong_t	shm_nattch;
162 	compat_ushort_t	shm_atime_high;
163 	compat_ushort_t	shm_dtime_high;
164 	compat_ushort_t	shm_ctime_high;
165 	compat_ushort_t	__unused2;
166 };
167 
168 /* MIPS has unusual order of fields in stack_t */
169 typedef struct compat_sigaltstack {
170 	compat_uptr_t			ss_sp;
171 	compat_size_t			ss_size;
172 	int				ss_flags;
173 } compat_stack_t;
174 #define compat_sigaltstack compat_sigaltstack
175 
is_compat_task(void)176 static inline int is_compat_task(void)
177 {
178 	return test_thread_flag(TIF_32BIT_ADDR);
179 }
180 
181 #endif /* _ASM_COMPAT_H */
182