Merge branch 'linus' into core/futexes
[pandora-kernel.git] / arch / mips / include / asm / compat-signal.h
1 #ifndef __ASM_COMPAT_SIGNAL_H
2 #define __ASM_COMPAT_SIGNAL_H
3
4 #include <linux/bug.h>
5 #include <linux/compat.h>
6 #include <linux/compiler.h>
7
8 #include <asm/signal.h>
9 #include <asm/siginfo.h>
10
11 #include <asm/uaccess.h>
12
13 #define SI_PAD_SIZE32   ((SI_MAX_SIZE/sizeof(int)) - 3)
14
15 typedef struct compat_siginfo {
16         int si_signo;
17         int si_code;
18         int si_errno;
19
20         union {
21                 int _pad[SI_PAD_SIZE32];
22
23                 /* kill() */
24                 struct {
25                         compat_pid_t _pid;      /* sender's pid */
26                         compat_uid_t _uid;      /* sender's uid */
27                 } _kill;
28
29                 /* SIGCHLD */
30                 struct {
31                         compat_pid_t _pid;      /* which child */
32                         compat_uid_t _uid;      /* sender's uid */
33                         int _status;            /* exit code */
34                         compat_clock_t _utime;
35                         compat_clock_t _stime;
36                 } _sigchld;
37
38                 /* IRIX SIGCHLD */
39                 struct {
40                         compat_pid_t _pid;      /* which child */
41                         compat_clock_t _utime;
42                         int _status;            /* exit code */
43                         compat_clock_t _stime;
44                 } _irix_sigchld;
45
46                 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
47                 struct {
48                         s32 _addr; /* faulting insn/memory ref. */
49                 } _sigfault;
50
51                 /* SIGPOLL, SIGXFSZ (To do ...)  */
52                 struct {
53                         int _band;      /* POLL_IN, POLL_OUT, POLL_MSG */
54                         int _fd;
55                 } _sigpoll;
56
57                 /* POSIX.1b timers */
58                 struct {
59                         timer_t _tid;           /* timer id */
60                         int _overrun;           /* overrun count */
61                         compat_sigval_t _sigval;/* same as below */
62                         int _sys_private;       /* not to be passed to user */
63                 } _timer;
64
65                 /* POSIX.1b signals */
66                 struct {
67                         compat_pid_t _pid;      /* sender's pid */
68                         compat_uid_t _uid;      /* sender's uid */
69                         compat_sigval_t _sigval;
70                 } _rt;
71
72         } _sifields;
73 } compat_siginfo_t;
74
75 static inline int __copy_conv_sigset_to_user(compat_sigset_t __user *d,
76         const sigset_t *s)
77 {
78         int err;
79
80         BUG_ON(sizeof(*d) != sizeof(*s));
81         BUG_ON(_NSIG_WORDS != 2);
82
83         err  = __put_user(s->sig[0],       &d->sig[0]);
84         err |= __put_user(s->sig[0] >> 32, &d->sig[1]);
85         err |= __put_user(s->sig[1],       &d->sig[2]);
86         err |= __put_user(s->sig[1] >> 32, &d->sig[3]);
87
88         return err;
89 }
90
91 static inline int __copy_conv_sigset_from_user(sigset_t *d,
92         const compat_sigset_t __user *s)
93 {
94         int err;
95         union sigset_u {
96                 sigset_t        s;
97                 compat_sigset_t c;
98         } *u = (union sigset_u *) d;
99
100         BUG_ON(sizeof(*d) != sizeof(*s));
101         BUG_ON(_NSIG_WORDS != 2);
102
103 #ifdef CONFIG_CPU_BIG_ENDIAN
104         err  = __get_user(u->c.sig[1], &s->sig[0]);
105         err |= __get_user(u->c.sig[0], &s->sig[1]);
106         err |= __get_user(u->c.sig[3], &s->sig[2]);
107         err |= __get_user(u->c.sig[2], &s->sig[3]);
108 #endif
109 #ifdef CONFIG_CPU_LITTLE_ENDIAN
110         err  = __get_user(u->c.sig[0], &s->sig[0]);
111         err |= __get_user(u->c.sig[1], &s->sig[1]);
112         err |= __get_user(u->c.sig[2], &s->sig[2]);
113         err |= __get_user(u->c.sig[3], &s->sig[3]);
114 #endif
115
116         return err;
117 }
118
119 #endif /* __ASM_COMPAT_SIGNAL_H */