Check Registered base class provides virtual destructor

The base class of Registered must provide a virtual destructor to enable
safe deletion with just a base class pointer. This requirement can be
lifted by using Registered_no_delete in places where the deletion
property is not needed.

Fixes #2331
This commit is contained in:
Christian Helmuth
2017-03-14 11:51:15 +01:00
parent 139525b6c9
commit b35df4578b
6 changed files with 32 additions and 6 deletions

View File

@ -17,7 +17,7 @@
#include <cpu/atomic.h>
static Genode::Registry<Genode::Registered<Genode::Semaphore> > blocked;
static Genode::Registry<Genode::Registered_no_delete<Genode::Semaphore> > blocked;
namespace __cxxabiv1
@ -54,7 +54,7 @@ namespace __cxxabiv1
if (!Genode::cmpxchg(in_init, INIT_NONE, IN_INIT)) {
/* register current thread for blocking */
Genode::Registered<Genode::Semaphore> block(blocked);
Genode::Registered_no_delete<Genode::Semaphore> block(blocked);
/* tell guard thread that current thread needs a wakeup */
while (!Genode::cmpxchg(in_init, *in_init, *in_init | WAITERS)) ;
@ -88,7 +88,7 @@ namespace __cxxabiv1
return;
/* we had contention - wake all up */
blocked.for_each([](Genode::Registered<Genode::Semaphore> &wake) {
blocked.for_each([](Genode::Registered_no_delete<Genode::Semaphore> &wake) {
wake.up();
});
}