options/posix: implement pthread_testcancel()

This commit is contained in:
Geert Custers 2021-02-04 09:17:20 +01:00
parent 292270aca3
commit ca5cb128cf

View file

@ -342,8 +342,12 @@ int pthread_setcancelstate(int state, int *oldstate) {
return 0;
}
void pthread_testcancel(void) {
__ensure(!"Not implemented");
__builtin_unreachable();
auto self = reinterpret_cast<Tcb *>(mlibc::get_current_tcb());
int value = self->cancelBits;
if (value & (tcbCancelEnableBit | tcbCancelTriggerBit)) {
__mlibc_do_cancel();
__builtin_unreachable();
}
}
int pthread_cancel(pthread_t thread) {
auto tcb = reinterpret_cast<Tcb *>(thread);