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 static inline int __copy_conv_sigset_to_user(compat_sigset_t __user *d,
14 	const sigset_t *s)
15 {
16 	int err;
17 
18 	BUG_ON(sizeof(*d) != sizeof(*s));
19 	BUG_ON(_NSIG_WORDS != 2);
20 
21 	err  = __put_user(s->sig[0],	   &d->sig[0]);
22 	err |= __put_user(s->sig[0] >> 32, &d->sig[1]);
23 	err |= __put_user(s->sig[1],	   &d->sig[2]);
24 	err |= __put_user(s->sig[1] >> 32, &d->sig[3]);
25 
26 	return err;
27 }
28 
29 static inline int __copy_conv_sigset_from_user(sigset_t *d,
30 	const compat_sigset_t __user *s)
31 {
32 	int err;
33 	union sigset_u {
34 		sigset_t	s;
35 		compat_sigset_t c;
36 	} *u = (union sigset_u *) d;
37 
38 	BUG_ON(sizeof(*d) != sizeof(*s));
39 	BUG_ON(_NSIG_WORDS != 2);
40 
41 #ifdef CONFIG_CPU_BIG_ENDIAN
42 	err  = __get_user(u->c.sig[1], &s->sig[0]);
43 	err |= __get_user(u->c.sig[0], &s->sig[1]);
44 	err |= __get_user(u->c.sig[3], &s->sig[2]);
45 	err |= __get_user(u->c.sig[2], &s->sig[3]);
46 #endif
47 #ifdef CONFIG_CPU_LITTLE_ENDIAN
48 	err  = __get_user(u->c.sig[0], &s->sig[0]);
49 	err |= __get_user(u->c.sig[1], &s->sig[1]);
50 	err |= __get_user(u->c.sig[2], &s->sig[2]);
51 	err |= __get_user(u->c.sig[3], &s->sig[3]);
52 #endif
53 
54 	return err;
55 }
56 
57 #endif /* __ASM_COMPAT_SIGNAL_H */
58