From ebf82447be4b30bedc19ad868c3a0662b1ba596d Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sun, 17 Apr 2011 13:21:13 -0400 Subject: optimize cancellation enable/disable code the goal is to be able to use pthread_setcancelstate internally in the implementation, whenever a function might want to use functions which are cancellation points but avoid becoming a cancellation point itself. i could have just used a separate internal function for temporarily inhibiting cancellation, but the solution in this commit is better because (1) it's one less implementation-specific detail in functions that need to use it, and (2) application code can also get the same benefit. previously, pthread_setcancelstate dependend on pthread_self, which would pull in unwanted thread setup overhead for non-threaded programs. now, it temporarily stores the state in the global libc struct if threads have not been initialized, and later moves it if needed. this way we can instead use __pthread_self, which has no dependencies and assumes that the thread register is already valid. --- src/internal/libc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/internal') diff --git a/src/internal/libc.h b/src/internal/libc.h index 3f1e55e5..d6df93d0 100644 --- a/src/internal/libc.h +++ b/src/internal/libc.h @@ -16,6 +16,7 @@ struct __libc { volatile int threads_minus_1; int ofl_lock; FILE *ofl_head; + int canceldisable; }; -- cgit v1.2.3-70-g09d2