Not beautiful, but required. For a bean-counting approach, we could also make xeno_resource_holder elements conditional. Index: xenomai/ksrc/skins/native/syscall.c =================================================================== --- xenomai.orig/ksrc/skins/native/syscall.c +++ xenomai/ksrc/skins/native/syscall.c @@ -3818,15 +3818,33 @@ static void *__shadow_eventcb(int event, case XNSHADOW_CLIENT_DETACH: rh = ppd2rholder((xnshadow_ppd_t *) data); +#ifdef CONFIG_XENO_OPT_NATIVE_ALARM __native_alarm_flush_rq(&rh->alarmq); +#endif +#ifdef CONFIG_XENO_OPT_NATIVE_COND __native_cond_flush_rq(&rh->condq); +#endif +#ifdef CONFIG_XENO_OPT_NATIVE_EVENT __native_event_flush_rq(&rh->eventq); +#endif +#ifdef CONFIG_XENO_OPT_NATIVE_HEAP __native_heap_flush_rq(&rh->heapq); +#endif +#ifdef CONFIG_XENO_OPT_NATIVE_INTR __native_intr_flush_rq(&rh->intrq); +#endif +#ifdef CONFIG_XENO_OPT_NATIVE_MUTEX __native_mutex_flush_rq(&rh->mutexq); +#endif +#ifdef CONFIG_XENO_OPT_NATIVE_PIPE __native_pipe_flush_rq(&rh->pipeq); +#endif +#ifdef CONFIG_XENO_OPT_NATIVE_QUEUE __native_queue_flush_rq(&rh->queueq); +#endif +#ifdef CONFIG_XENO_OPT_NATIVE_SEM __native_sem_flush_rq(&rh->semq); +#endif xnarch_sysfree(rh, sizeof(*rh));