xref: /openbmc/linux/arch/powerpc/include/asm/compat.h (revision f21e49be)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_COMPAT_H
3 #define _ASM_POWERPC_COMPAT_H
4 #ifdef __KERNEL__
5 /*
6  * Architecture specific compatibility types
7  */
8 #include <linux/types.h>
9 #include <linux/sched.h>
10 
11 #include <asm-generic/compat.h>
12 
13 #define COMPAT_USER_HZ		100
14 #ifdef __BIG_ENDIAN__
15 #define COMPAT_UTS_MACHINE	"ppc\0\0"
16 #else
17 #define COMPAT_UTS_MACHINE	"ppcle\0\0"
18 #endif
19 
20 typedef u32		__compat_uid_t;
21 typedef u32		__compat_gid_t;
22 typedef u32		compat_dev_t;
23 typedef s16		compat_nlink_t;
24 typedef u16		compat_ipc_pid_t;
25 typedef __kernel_fsid_t	compat_fsid_t;
26 
27 struct compat_stat {
28 	compat_dev_t	st_dev;
29 	compat_ino_t	st_ino;
30 	compat_mode_t	st_mode;
31 	compat_nlink_t	st_nlink;
32 	__compat_uid32_t	st_uid;
33 	__compat_gid32_t	st_gid;
34 	compat_dev_t	st_rdev;
35 	compat_off_t	st_size;
36 	compat_off_t	st_blksize;
37 	compat_off_t	st_blocks;
38 	old_time32_t	st_atime;
39 	u32		st_atime_nsec;
40 	old_time32_t	st_mtime;
41 	u32		st_mtime_nsec;
42 	old_time32_t	st_ctime;
43 	u32		st_ctime_nsec;
44 	u32		__unused4[2];
45 };
46 
47 struct compat_flock {
48 	short		l_type;
49 	short		l_whence;
50 	compat_off_t	l_start;
51 	compat_off_t	l_len;
52 	compat_pid_t	l_pid;
53 };
54 
55 #define F_GETLK64	12	/*  using 'struct flock64' */
56 #define F_SETLK64	13
57 #define F_SETLKW64	14
58 
59 struct compat_flock64 {
60 	short		l_type;
61 	short		l_whence;
62 	compat_loff_t	l_start;
63 	compat_loff_t	l_len;
64 	compat_pid_t	l_pid;
65 };
66 
67 struct compat_statfs {
68 	int		f_type;
69 	int		f_bsize;
70 	int		f_blocks;
71 	int		f_bfree;
72 	int		f_bavail;
73 	int		f_files;
74 	int		f_ffree;
75 	compat_fsid_t	f_fsid;
76 	int		f_namelen;	/* SunOS ignores this field. */
77 	int		f_frsize;
78 	int		f_flags;
79 	int		f_spare[4];
80 };
81 
82 #define COMPAT_RLIM_INFINITY		0xffffffff
83 
84 #define COMPAT_OFF_T_MAX	0x7fffffff
85 
86 /*
87  * ipc64_perm is actually 32/64bit clean but since the compat layer refers to
88  * it we may as well define it.
89  */
90 struct compat_ipc64_perm {
91 	compat_key_t key;
92 	__compat_uid_t uid;
93 	__compat_gid_t gid;
94 	__compat_uid_t cuid;
95 	__compat_gid_t cgid;
96 	compat_mode_t mode;
97 	unsigned int seq;
98 	unsigned int __pad2;
99 	unsigned long __unused1;	/* yes they really are 64bit pads */
100 	unsigned long __unused2;
101 };
102 
103 struct compat_semid64_ds {
104 	struct compat_ipc64_perm sem_perm;
105 	unsigned int sem_otime_high;
106 	unsigned int sem_otime;
107 	unsigned int sem_ctime_high;
108 	unsigned int sem_ctime;
109 	compat_ulong_t sem_nsems;
110 	compat_ulong_t __unused3;
111 	compat_ulong_t __unused4;
112 };
113 
114 struct compat_msqid64_ds {
115 	struct compat_ipc64_perm msg_perm;
116 	unsigned int msg_stime_high;
117 	unsigned int msg_stime;
118 	unsigned int msg_rtime_high;
119 	unsigned int msg_rtime;
120 	unsigned int msg_ctime_high;
121 	unsigned int msg_ctime;
122 	compat_ulong_t msg_cbytes;
123 	compat_ulong_t msg_qnum;
124 	compat_ulong_t msg_qbytes;
125 	compat_pid_t msg_lspid;
126 	compat_pid_t msg_lrpid;
127 	compat_ulong_t __unused4;
128 	compat_ulong_t __unused5;
129 };
130 
131 struct compat_shmid64_ds {
132 	struct compat_ipc64_perm shm_perm;
133 	unsigned int shm_atime_high;
134 	unsigned int shm_atime;
135 	unsigned int shm_dtime_high;
136 	unsigned int shm_dtime;
137 	unsigned int shm_ctime_high;
138 	unsigned int shm_ctime;
139 	unsigned int __unused4;
140 	compat_size_t shm_segsz;
141 	compat_pid_t shm_cpid;
142 	compat_pid_t shm_lpid;
143 	compat_ulong_t shm_nattch;
144 	compat_ulong_t __unused5;
145 	compat_ulong_t __unused6;
146 };
147 
148 static inline int is_compat_task(void)
149 {
150 	return is_32bit_task();
151 }
152 
153 #endif /* __KERNEL__ */
154 #endif /* _ASM_POWERPC_COMPAT_H */
155