pthread_cleanup_push.c 384 B

1234567891011121314151617181920
  1. #include "pthread_impl.h"
  2. static void dummy(struct __ptcb *cb)
  3. {
  4. }
  5. weak_alias(dummy, __do_cleanup_push);
  6. weak_alias(dummy, __do_cleanup_pop);
  7. void _pthread_cleanup_push(struct __ptcb *cb, void (*f)(void *), void *x)
  8. {
  9. cb->__f = f;
  10. cb->__x = x;
  11. __do_cleanup_push(cb);
  12. }
  13. void _pthread_cleanup_pop(struct __ptcb *cb, int run)
  14. {
  15. __do_cleanup_pop(cb);
  16. if (run) cb->__f(cb->__x);
  17. }