mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-10 03:21:30 -10:00
The illuminance-sensor code in input/common/linux_common.c used raw pthreads: pthread_setcancelstate() around the file-reading critical section, and pthread_cancel() on close via a pthread_t reconstructed by casting sthread_get_thread_id() -- a fragile round-trip through the opaque id. Add cancellation primitives to rthreads and route the driver through them: void sthread_set_cancel_enable(bool enable); bool sthread_cancel(sthread_t *thread); sthread_cancel() takes the sthread_t directly and uses its backing handle, dropping the pthread_t cast. Both are implemented with pthread_setcancelstate()/pthread_cancel() on pthread backends that provide them, gated by RTHREADS_HAVE_CANCEL which excludes Win32, GEKKO, 3DS and Android/Bionic (Bionic has no pthread_cancel; rthreads.c is compiled there even though linux_common.c is not). Where unsupported they are a no-op / return false, and the existing cooperative sensor->done flag still stops the thread. linux_common.c no longer includes <pthread.h> or references pthread directly. No functional change on Linux.