1313#include < errno.h>
1414#include < stdio.h>
1515#include < cstring>
16+ #include < stdexcept>
1617#ifdef HAVE_SYS_IO_H
1718#include < sys/io.h>
1819#endif
1920
2021namespace
2122{
22- struct RtaiTask : rtapi_task {
23- RtaiTask () : rtapi_task{}, cancel{}, thr{} {}
23+ struct EvlTask : rtapi_task {
24+ EvlTask () : rtapi_task{}, cancel{}, thr{} {}
2425 std::atomic_int cancel;
2526 pthread_t thr;
2627};
2728
2829
29- struct XenomaiApp : RtapiApp {
30- XenomaiApp () : RtapiApp(SCHED_FIFO) {
30+ struct EvlApp : RtapiApp {
31+ EvlApp () : RtapiApp(SCHED_FIFO) {
3132 pthread_once (&key_once, init_key);
3233 }
3334
34- RtaiTask *do_task_new () {
35- return new RtaiTask ;
35+ struct rtapi_task *do_task_new () {
36+ return new EvlTask ;
3637 }
3738
3839 int task_delete (int id) {
39- auto task = ::rtapi_get_task<RtaiTask >(id);
40+ auto task = ::rtapi_get_task<EvlTask >(id);
4041 if (!task) return -EINVAL;
4142
4243 task->cancel = 1 ;
@@ -48,7 +49,7 @@ struct XenomaiApp : RtapiApp {
4849 }
4950
5051 int task_start (int task_id, unsigned long period_nsec) {
51- auto task = ::rtapi_get_task<RtaiTask >(task_id);
52+ auto task = ::rtapi_get_task<EvlTask >(task_id);
5253 if (!task) return -EINVAL;
5354
5455 task->period = period_nsec;
@@ -92,7 +93,7 @@ struct XenomaiApp : RtapiApp {
9293 }
9394
9495 static void *wrapper (void *arg) {
95- auto task = reinterpret_cast <RtaiTask *>(arg);
96+ auto task = reinterpret_cast <EvlTask *>(arg);
9697 pthread_setspecific (key, arg);
9798
9899 {
@@ -148,7 +149,7 @@ struct XenomaiApp : RtapiApp {
148149
149150 void wait () {
150151 int task_id = task_self ();
151- auto task = ::rtapi_get_task<RtaiTask >(task_id);
152+ auto task = ::rtapi_get_task<EvlTask >(task_id);
152153 if (task->cancel ) {
153154 pthread_exit (nullptr );
154155 }
@@ -216,14 +217,16 @@ struct XenomaiApp : RtapiApp {
216217 }
217218};
218219
219- pthread_once_t XenomaiApp ::key_once;
220- pthread_key_t XenomaiApp ::key;
220+ pthread_once_t EvlApp ::key_once;
221+ pthread_key_t EvlApp ::key;
221222}
222223
223224extern " C" RtapiApp *make (int policy);
224225
225226RtapiApp *make (int policy) {
226- (void ) policy;
227+ if (policy != SCHED_FIFO){
228+ throw std::invalid_argument (" Only SCHED_FIFO allowed" );
229+ }
227230 rtapi_print_msg (RTAPI_MSG_ERR, " Note: Using XENOMAI4 EVL realtime\n " );
228- return new XenomaiApp ();
231+ return new EvlApp ();
229232}
0 commit comments