blob: 64e0b9343b8c395537604f68a7be06aaea5d757a [file] [log] [blame]
Ralf Baechle431dc802007-02-13 00:05:11 +00001#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
Ralf Baechle151fd6a2007-02-15 11:40:37 +00008#include <asm/signal.h>
9#include <asm/siginfo.h>
10
Ralf Baechle4c156992007-02-14 10:40:05 +000011#include <asm/uaccess.h>
12
Ralf Baechle431dc802007-02-13 00:05:11 +000013static 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
Ralf Baechle70342282013-01-22 12:59:30 +010021 err = __put_user(s->sig[0], &d->sig[0]);
Ralf Baechle431dc802007-02-13 00:05:11 +000022 err |= __put_user(s->sig[0] >> 32, &d->sig[1]);
Ralf Baechle70342282013-01-22 12:59:30 +010023 err |= __put_user(s->sig[1], &d->sig[2]);
Ralf Baechle431dc802007-02-13 00:05:11 +000024 err |= __put_user(s->sig[1] >> 32, &d->sig[3]);
25
26 return err;
27}
28
29static 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
Ralf Baechle431dc802007-02-13 00:05:11 +000041#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 */