sigaction.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* POSIX.1 sigaction call for Linux/SPARC64.
  2. Copyright (C) 1997-2017 Free Software Foundation, Inc.
  3. Contributed by Miguel de Icaza <miguel@nuclecu.unam.mx> and
  4. Jakub Jelinek <jj@ultra.linux.cz>.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #include <string.h>
  17. #include <syscall.h>
  18. #include <sysdep.h>
  19. #include <sys/signal.h>
  20. #include <errno.h>
  21. #include <bits/kernel_sigaction.h>
  22. /* SPARC 64bit userland requires a kernel that has rt signals anyway. */
  23. void __rt_sigreturn_stub (void);
  24. int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
  25. {
  26. int ret;
  27. struct kernel_sigaction kact, koact;
  28. unsigned long stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
  29. if (act) {
  30. kact.k_sa_handler = act->sa_handler;
  31. memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t));
  32. kact.sa_flags = act->sa_flags;
  33. kact.sa_restorer = NULL;
  34. }
  35. /* XXX The size argument hopefully will have to be changed to the
  36. real size of the user-level sigset_t. */
  37. ret = INLINE_SYSCALL (rt_sigaction, 5, sig,
  38. act ? &kact : 0,
  39. oact ? &koact : 0, stub, _NSIG / 8);
  40. if (oact && ret >= 0) {
  41. oact->sa_handler = koact.k_sa_handler;
  42. memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t));
  43. oact->sa_flags = koact.sa_flags;
  44. oact->sa_restorer = koact.sa_restorer;
  45. }
  46. return ret;
  47. }
  48. #ifndef LIBC_SIGACTION
  49. # ifndef __UCLIBC_HAS_THREADS__
  50. strong_alias(__libc_sigaction,sigaction)
  51. libc_hidden_def(sigaction)
  52. # else
  53. weak_alias(__libc_sigaction,sigaction)
  54. libc_hidden_weak(sigaction)
  55. # endif
  56. #endif