Skip to content

Commit ef9b8fa

Browse files
committed
Cleanup: Naming
1 parent 027aa3a commit ef9b8fa

4 files changed

Lines changed: 38 additions & 28 deletions

File tree

src/rtapi/uspace_posix.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ struct Posix : RtapiApp
3434
instance = this;
3535
}
3636

37+
struct rtapi_task *do_task_new() {
38+
return new PosixTask;
39+
}
40+
3741
int task_delete(int id) {
3842
auto task = ::rtapi_get_task<PosixTask>(id);
3943
if(!task) return -EINVAL;
@@ -174,9 +178,6 @@ struct Posix : RtapiApp
174178
pthread_mutex_lock(&thread_lock);
175179
}
176180

177-
struct rtapi_task *do_task_new() {
178-
return new PosixTask;
179-
}
180181
unsigned char do_inb(unsigned int port) {
181182
#ifdef HAVE_SYS_IO_H
182183
return inb(port);

src/rtapi/uspace_rtai.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#pragma GCC diagnostic ignored "-Wnarrowing"
66
#include <rtai_lxrt.h>
77
#pragma GCC diagnostic pop
8+
#include <stdexcept>
89
#ifdef HAVE_SYS_IO_H
910
#include <sys/io.h>
1011
#endif
@@ -31,7 +32,7 @@ struct RtaiApp : RtapiApp {
3132
pthread_once(&key_once, init_key);
3233
}
3334

34-
RtaiTask *do_task_new() {
35+
struct rtapi_task *do_task_new() {
3536
return new RtaiTask;
3637
}
3738

@@ -195,7 +196,9 @@ pthread_key_t RtaiApp::key;
195196
extern "C" RtapiApp *make(int policy);
196197

197198
RtapiApp *make(int policy) {
198-
(void) policy;
199+
if(policy != SCHED_FIFO){
200+
throw std::invalid_argument("Only SCHED_FIFO allowed");
201+
}
199202
rtapi_print_msg(RTAPI_MSG_ERR, "Note: Using LXRT realtime\n");
200203
return app = new RtaiApp();
201204
}

src/rtapi/uspace_xenomai.cc

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
#include <errno.h>
66
#include <stdio.h>
77
#include <cstring>
8+
#include <stdexcept>
89
#ifdef HAVE_SYS_IO_H
910
#include <sys/io.h>
1011
#endif
1112

1213
namespace
1314
{
14-
struct RtaiTask : rtapi_task {
15-
RtaiTask() : rtapi_task{}, cancel{}, thr{} {}
15+
struct XenomaiTask : rtapi_task {
16+
XenomaiTask() : rtapi_task{}, cancel{}, thr{} {}
1617
std::atomic_int cancel;
1718
pthread_t thr;
1819
};
@@ -23,12 +24,12 @@ struct XenomaiApp : RtapiApp {
2324
pthread_once(&key_once, init_key);
2425
}
2526

26-
RtaiTask *do_task_new() {
27-
return new RtaiTask;
27+
struct rtapi_task *do_task_new() {
28+
return new XenomaiTask;
2829
}
2930

3031
int task_delete(int id) {
31-
auto task = ::rtapi_get_task<RtaiTask>(id);
32+
auto task = ::rtapi_get_task<XenomaiTask>(id);
3233
if(!task) return -EINVAL;
3334

3435
task->cancel = 1;
@@ -40,7 +41,7 @@ struct XenomaiApp : RtapiApp {
4041
}
4142

4243
int task_start(int task_id, unsigned long period_nsec) {
43-
auto task = ::rtapi_get_task<RtaiTask>(task_id);
44+
auto task = ::rtapi_get_task<XenomaiTask>(task_id);
4445
if(!task) return -EINVAL;
4546

4647
task->period = period_nsec;
@@ -84,7 +85,7 @@ struct XenomaiApp : RtapiApp {
8485
}
8586

8687
static void *wrapper(void *arg) {
87-
auto task = reinterpret_cast<RtaiTask*>(arg);
88+
auto task = reinterpret_cast<XenomaiTask*>(arg);
8889
pthread_setspecific(key, arg);
8990

9091
struct timespec now;
@@ -130,7 +131,7 @@ struct XenomaiApp : RtapiApp {
130131

131132
void wait() {
132133
int task_id = task_self();
133-
auto task = ::rtapi_get_task<RtaiTask>(task_id);
134+
auto task = ::rtapi_get_task<XenomaiTask>(task_id);
134135
if(task->cancel) {
135136
pthread_exit(nullptr);
136137
}
@@ -203,7 +204,9 @@ pthread_key_t XenomaiApp::key;
203204
extern "C" RtapiApp *make(int policy);
204205

205206
RtapiApp *make(int policy) {
206-
(void) policy;
207+
if(policy != SCHED_FIFO){
208+
throw std::invalid_argument("Only SCHED_FIFO allowed");
209+
}
207210
rtapi_print_msg(RTAPI_MSG_ERR, "Note: Using XENOMAI (posix-skin) realtime\n");
208211
return new XenomaiApp();
209212
}

src/rtapi/uspace_xenomai_evl.cc

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,31 @@
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

2021
namespace
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

223224
extern "C" RtapiApp *make(int policy);
224225

225226
RtapiApp *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

Comments
 (0)