• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_COMPAT_SIGNAL_H
3 #define __ASM_COMPAT_SIGNAL_H
4 
5 #include <linux/bug.h>
6 #include <linux/compat.h>
7 #include <linux/compiler.h>
8 
9 #include <asm/signal.h>
10 #include <asm/siginfo.h>
11 
12 #include <linux/uaccess.h>
13 
__copy_conv_sigset_to_user(compat_sigset_t __user * d,const sigset_t * s)14 static inline int __copy_conv_sigset_to_user(compat_sigset_t __user *d,
15 	const sigset_t *s)
16 {
17 	int err;
18 
19 	BUG_ON(sizeof(*d) != sizeof(*s));
20 	BUG_ON(_NSIG_WORDS != 2);
21 
22 	err  = __put_user(s->sig[0],	   &d->sig[0]);
23 	err |= __put_user(s->sig[0] >> 32, &d->sig[1]);
24 	err |= __put_user(s->sig[1],	   &d->sig[2]);
25 	err |= __put_user(s->sig[1] >> 32, &d->sig[3]);
26 
27 	return err;
28 }
29 
__copy_conv_sigset_from_user(sigset_t * d,const compat_sigset_t __user * s)30 static inline int __copy_conv_sigset_from_user(sigset_t *d,
31 	const compat_sigset_t __user *s)
32 {
33 	int err;
34 	union sigset_u {
35 		sigset_t	s;
36 		compat_sigset_t c;
37 	} *u = (union sigset_u *) d;
38 
39 	BUG_ON(sizeof(*d) != sizeof(*s));
40 	BUG_ON(_NSIG_WORDS != 2);
41 
42 #ifdef CONFIG_CPU_BIG_ENDIAN
43 	err  = __get_user(u->c.sig[1], &s->sig[0]);
44 	err |= __get_user(u->c.sig[0], &s->sig[1]);
45 	err |= __get_user(u->c.sig[3], &s->sig[2]);
46 	err |= __get_user(u->c.sig[2], &s->sig[3]);
47 #endif
48 #ifdef CONFIG_CPU_LITTLE_ENDIAN
49 	err  = __get_user(u->c.sig[0], &s->sig[0]);
50 	err |= __get_user(u->c.sig[1], &s->sig[1]);
51 	err |= __get_user(u->c.sig[2], &s->sig[2]);
52 	err |= __get_user(u->c.sig[3], &s->sig[3]);
53 #endif
54 
55 	return err;
56 }
57 
58 #endif /* __ASM_COMPAT_SIGNAL_H */
59