ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-ppc64 / compat.h
1 #ifndef _ASM_PPC64_COMPAT_H
2 #define _ASM_PPC64_COMPAT_H
3 /*
4  * Architecture specific compatibility types
5  */
6 #include <linux/types.h>
7 #include <linux/sched.h>
8
9 #define COMPAT_USER_HZ  100
10
11 typedef u32             compat_size_t;
12 typedef s32             compat_ssize_t;
13 typedef s32             compat_time_t;
14 typedef s32             compat_clock_t;
15 typedef s32             compat_pid_t;
16 typedef u32             compat_uid_t;
17 typedef u32             compat_gid_t;
18 typedef u32             compat_mode_t;
19 typedef u32             compat_ino_t;
20 typedef u32             compat_dev_t;
21 typedef s32             compat_off_t;
22 typedef s64             compat_loff_t;
23 typedef s16             compat_nlink_t;
24 typedef u16             compat_ipc_pid_t;
25 typedef s32             compat_daddr_t;
26 typedef u32             compat_caddr_t;
27 typedef __kernel_fsid_t compat_fsid_t;
28
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
34 struct compat_timespec {
35         compat_time_t   tv_sec;
36         s32             tv_nsec;
37 };
38
39 struct compat_timeval {
40         compat_time_t   tv_sec;
41         s32             tv_usec;
42 };
43
44 struct compat_stat {
45         compat_dev_t    st_dev;
46         compat_ino_t    st_ino;
47         compat_mode_t   st_mode;
48         compat_nlink_t  st_nlink;       
49         compat_uid_t    st_uid;
50         compat_gid_t    st_gid;
51         compat_dev_t    st_rdev;
52         compat_off_t    st_size;
53         compat_off_t    st_blksize;
54         compat_off_t    st_blocks;
55         compat_time_t   st_atime;
56         u32             st_atime_nsec;
57         compat_time_t   st_mtime;
58         u32             st_mtime_nsec;
59         compat_time_t   st_ctime;
60         u32             st_ctime_nsec;
61         u32             __unused4[2];
62 };
63
64 struct compat_flock {
65         short           l_type;
66         short           l_whence;
67         compat_off_t    l_start;
68         compat_off_t    l_len;
69         compat_pid_t    l_pid;
70 };
71
72 #define F_GETLK64       12      /*  using 'struct flock64' */
73 #define F_SETLK64       13
74 #define F_SETLKW64      14
75
76 struct compat_flock64 {
77         short           l_type;
78         short           l_whence;
79         compat_loff_t   l_start;
80         compat_loff_t   l_len;
81         compat_pid_t    l_pid;
82 };
83
84 struct compat_statfs {
85         int             f_type;
86         int             f_bsize;
87         int             f_blocks;
88         int             f_bfree;
89         int             f_bavail;
90         int             f_files;
91         int             f_ffree;
92         compat_fsid_t   f_fsid;
93         int             f_namelen;      /* SunOS ignores this field. */
94         int             f_frsize;
95         int             f_spare[5];
96 };
97
98 #define COMPAT_RLIM_OLD_INFINITY        0x7fffffff
99 #define COMPAT_RLIM_INFINITY            0xffffffff
100
101 typedef u32             compat_old_sigset_t;
102
103 #define _COMPAT_NSIG            64
104 #define _COMPAT_NSIG_BPW        32
105
106 typedef u32             compat_sigset_word;
107
108 #define COMPAT_OFF_T_MAX        0x7fffffff
109 #define COMPAT_LOFF_T_MAX       0x7fffffffffffffffL
110
111 /*
112  * A pointer passed in from user mode. This should not
113  * be used for syscall parameters, just declare them
114  * as pointers because the syscall entry code will have
115  * appropriately comverted them already.
116  */
117 typedef u32             compat_uptr_t;
118
119 static inline void *compat_ptr(compat_uptr_t uptr)
120 {
121         return (void *)(unsigned long)uptr;
122 }
123
124 static inline void *compat_alloc_user_space(long len)
125 {
126         struct pt_regs *regs = current->thread.regs;
127         unsigned long usp = regs->gpr[1];
128
129         /*
130          * We cant access below the stack pointer in the 32bit ABI and
131          * can access 288 bytes in the 64bit ABI
132          */
133         if (!(test_thread_flag(TIF_32BIT)))
134                 usp -= 288;
135
136         return (void *) (usp - len);
137 }
138
139 #endif /* _ASM_PPC64_COMPAT_H */