Install SIGCANCEL handler for all threads. Remove unneeded atomic stores and loads. States are only changed within the thread itself. Define pthread_testcancel as a macro so it gets inlined inside cancellation points