Rework the condition variables support for VxWorks
authorAlexandre Oliva <oliva@dacore.com>
Tue, 7 Jul 2020 05:47:53 +0000 (02:47 -0300)
committerOlivier Hainque <hainque@adacore.com>
Wed, 14 Oct 2020 19:24:45 +0000 (19:24 +0000)
commit8f8cba46b89ad16bac2ce58d554c25b54b0e7c7f
tree22bfa60b5c9cd8ccd75d45a53d2c14caffe1f037
parent93103603fd66a9fcf3ea2d8b52657e4b2496f544
Rework the condition variables support for VxWorks

This change reworks the condition variables support for VxWorks
to address the very legit points raised by Rasmus in

 https://gcc.gnu.org/pipermail/gcc/2020-May/232524.html

While some of the issues were taken care of by the use of semFlush,
a few others were indeed calling for adjustments.

We first considered resorting to the condvarLib library available
in VxWorks7. Unfortunately, it is vx7 only and we wanted something working
for at least vx 6.9 as well. It also turned out requiring the use of
recursive mutexes for condVarWait, which seemed unnecessarily constraining.

Instead, this change corrects the sequencing logic in a few places and
leverages the semExchange API to ensure the key atomicity requirement on
cond_wait operations.

2020-10-14  Alexandre Oliva  <oliva@adacore.com>

libgcc/
* config/gthr-vxworks-thread.c: Include stdlib.h.
(tls_delete_hook): Prototype it.
(__gthread_cond_signal): Return early if no waiters.  Consume
signal in case the semaphore got full.  Use semInfoGet instead
of kernel-mode-only semInfo.
(__gthread_cond_timedwait): Use semExchange.  Always take the
mutex again before returning.
* config/gthr-vxworks-cond.c (__ghtread_cond_wait): Likewise.
libgcc/config/gthr-vxworks-cond.c
libgcc/config/gthr-vxworks-thread.c