sigaction.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. # ifndef __UCLIBC_HAS_THREADS__
  32. strong_alias(__libc_sigaction,sigaction)
  33. libc_hidden_def(sigaction)
  34. # else
  35. weak_alias(__libc_sigaction,sigaction)
  36. libc_hidden_weak(sigaction)
  37. # endif
  38. #endif