sigaction.c 969 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * sigaction() for Xtensa uClibc
  4. *
  5. * Copyright (C) 2007, 2008 Tensilica Inc.
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <errno.h>
  10. #include <signal.h>
  11. #include <sys/syscall.h>
  12. #include <string.h>
  13. #include <bits/kernel_sigaction.h>
  14. #define SA_RESTORER 0x04000000
  15. extern void __default_sa_restorer(void);
  16. int __libc_sigaction(int sig, const struct sigaction *act,
  17. struct sigaction *oact)
  18. {
  19. struct sigaction kact;
  20. if (act && !(act->sa_flags & SA_RESTORER)) {
  21. memcpy(&kact, act, sizeof(kact));
  22. kact.sa_restorer = __default_sa_restorer;
  23. kact.sa_flags |= SA_RESTORER;
  24. act = &kact;
  25. }
  26. /* NB: kernel (as of 2.6.25) will return EINVAL
  27. * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */
  28. return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
  29. }
  30. #ifndef LIBC_SIGACTION
  31. weak_alias(__libc_sigaction, sigaction)
  32. libc_hidden_weak(sigaction)
  33. #endif