Files
RetroArch/input/common
libretroadmin fb993da590 linux_common: route thread cancellation through rthreads
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.
2026-07-16 00:46:51 +02:00
..
2023-02-19 19:32:05 +01:00
2023-06-01 22:52:05 +02:00