Ralf Baechle | 431dc80 | 2007-02-13 00:05:11 +0000 | [diff] [blame] | 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 | |
Ralf Baechle | 151fd6a | 2007-02-15 11:40:37 +0000 | [diff] [blame] | 8 | #include <asm/signal.h> |
| 9 | #include <asm/siginfo.h> |
| 10 | |
Ralf Baechle | 4c15699 | 2007-02-14 10:40:05 +0000 | [diff] [blame] | 11 | #include <asm/uaccess.h> |
| 12 | |
Ralf Baechle | 431dc80 | 2007-02-13 00:05:11 +0000 | [diff] [blame] | 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 | |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 21 | err = __put_user(s->sig[0], &d->sig[0]); |
Ralf Baechle | 431dc80 | 2007-02-13 00:05:11 +0000 | [diff] [blame] | 22 | err |= __put_user(s->sig[0] >> 32, &d->sig[1]); |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 23 | err |= __put_user(s->sig[1], &d->sig[2]); |
Ralf Baechle | 431dc80 | 2007-02-13 00:05:11 +0000 | [diff] [blame] | 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 | |
Ralf Baechle | 431dc80 | 2007-02-13 00:05:11 +0000 | [diff] [blame] | 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 */ |