sigaction.c 1.0 KB

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