pthread_setcancelstate.c 333 B

123456789101112131415
  1. #include "pthread_impl.h"
  2. int pthread_setcancelstate(int new, int *old)
  3. {
  4. if (new > 1U) return EINVAL;
  5. if (libc.main_thread) {
  6. struct pthread *self = __pthread_self();
  7. if (old) *old = self->canceldisable;
  8. self->canceldisable = new;
  9. } else {
  10. if (old) *old = libc.canceldisable;
  11. libc.canceldisable = new;
  12. }
  13. return 0;
  14. }