First, refactor sleepq_catch_signals() with the following goals:
- extract suspension check into sig_ast_checksusp() helper.
- extract signal check and calculation of the interruption errno into sig_ast_needsigchk() helper.
- improve control flow, to handle ret == 0 (can sleep) and ret != 0 (interrupted) only once, by separating checking code into sleepq_check_ast_sq_locked(), which return value is interpreted only once.
Second, add sig_intr() generic-purpose function, which gives the answer would the thread sleep according to current state of signals and suspensions. Of course the answer is racy and allows for false-negatives (no sleep when signal is delivered after process lock is dropped). Also the answer might change due to signal rescheduling among threads in multi-threaded process. Still it is the best approximation I can provide, to answering the question was the thread interrupted.