compat-signal.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef __ASM_COMPAT_SIGNAL_H
  2. #define __ASM_COMPAT_SIGNAL_H
  3. #include <linux/bug.h>
  4. #include <linux/compat.h>
  5. #include <linux/compiler.h>
  6. #include <asm/signal.h>
  7. #include <asm/siginfo.h>
  8. #include <asm/uaccess.h>
  9. static inline int __copy_conv_sigset_to_user(compat_sigset_t __user *d,
  10. const sigset_t *s)
  11. {
  12. int err;
  13. BUG_ON(sizeof(*d) != sizeof(*s));
  14. BUG_ON(_NSIG_WORDS != 2);
  15. err = __put_user(s->sig[0], &d->sig[0]);
  16. err |= __put_user(s->sig[0] >> 32, &d->sig[1]);
  17. err |= __put_user(s->sig[1], &d->sig[2]);
  18. err |= __put_user(s->sig[1] >> 32, &d->sig[3]);
  19. return err;
  20. }
  21. static inline int __copy_conv_sigset_from_user(sigset_t *d,
  22. const compat_sigset_t __user *s)
  23. {
  24. int err;
  25. union sigset_u {
  26. sigset_t s;
  27. compat_sigset_t c;
  28. } *u = (union sigset_u *) d;
  29. BUG_ON(sizeof(*d) != sizeof(*s));
  30. BUG_ON(_NSIG_WORDS != 2);
  31. #ifdef CONFIG_CPU_BIG_ENDIAN
  32. err = __get_user(u->c.sig[1], &s->sig[0]);
  33. err |= __get_user(u->c.sig[0], &s->sig[1]);
  34. err |= __get_user(u->c.sig[3], &s->sig[2]);
  35. err |= __get_user(u->c.sig[2], &s->sig[3]);
  36. #endif
  37. #ifdef CONFIG_CPU_LITTLE_ENDIAN
  38. err = __get_user(u->c.sig[0], &s->sig[0]);
  39. err |= __get_user(u->c.sig[1], &s->sig[1]);
  40. err |= __get_user(u->c.sig[2], &s->sig[2]);
  41. err |= __get_user(u->c.sig[3], &s->sig[3]);
  42. #endif
  43. return err;
  44. }
  45. #endif /* __ASM_COMPAT_SIGNAL_H */