restart.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Linuxthreads - a simple clone()-based implementation of Posix */
  2. /* threads for Linux. */
  3. /* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */
  4. /* */
  5. /* This program is free software; you can redistribute it and/or */
  6. /* modify it under the terms of the GNU Library General Public License */
  7. /* as published by the Free Software Foundation; either version 2 */
  8. /* of the License, or (at your option) any later version. */
  9. /* */
  10. /* This program is distributed in the hope that it will be useful, */
  11. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  12. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  13. /* GNU Library General Public License for more details. */
  14. #include <signal.h>
  15. #include <sys/syscall.h>
  16. #define __ASSUME_REALTIME_SIGNALS defined(__NR_rt_sigaction)
  17. /* Primitives for controlling thread execution */
  18. static __inline__ void restart(pthread_descr th)
  19. {
  20. /* See pthread.c */
  21. #if __ASSUME_REALTIME_SIGNALS
  22. __pthread_restart_new(th);
  23. #else
  24. __pthread_restart(th);
  25. #endif
  26. }
  27. static __inline__ void suspend(pthread_descr self)
  28. {
  29. /* See pthread.c */
  30. #if __ASSUME_REALTIME_SIGNALS
  31. __pthread_wait_for_restart_signal(self);
  32. #else
  33. __pthread_suspend(self);
  34. #endif
  35. }
  36. static __inline__ int timedsuspend(pthread_descr self,
  37. const struct timespec *abstime)
  38. {
  39. /* See pthread.c */
  40. #if __ASSUME_REALTIME_SIGNALS
  41. return __pthread_timedsuspend_new(self, abstime);
  42. #else
  43. return __pthread_timedsuspend(self, abstime);
  44. #endif
  45. }