Skip to content

Commit 6c23c1e

Browse files
committed
Cleanup: Naming and remove out of place struct keyword
Struct for C++ instance is unusual
1 parent 9800785 commit 6c23c1e

6 files changed

Lines changed: 40 additions & 40 deletions

File tree

src/rtapi/uspace_posix.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#endif
2828

2929
namespace {
30-
struct PosixTask : rtapi_task {
31-
PosixTask() : rtapi_task{}, thr{} {
30+
struct PosixTask : RtapiTask {
31+
PosixTask() : RtapiTask{}, thr{} {
3232
}
3333

3434
pthread_t thr; /* thread's context */
@@ -42,7 +42,7 @@ struct PosixApp : RtapiApp {
4242
}
4343
}
4444

45-
struct rtapi_task *do_task_new() {
45+
RtapiTask *do_task_new() {
4646
return new PosixTask;
4747
}
4848

@@ -138,14 +138,14 @@ struct PosixApp : RtapiApp {
138138
}
139139

140140
long long task_pll_get_reference(void) {
141-
struct rtapi_task *task = reinterpret_cast<rtapi_task *>(pthread_getspecific(key));
141+
RtapiTask *task = reinterpret_cast<RtapiTask *>(pthread_getspecific(key));
142142
if (!task)
143143
return 0;
144144
return task->nextstart.tv_sec * 1000000000LL + task->nextstart.tv_nsec;
145145
}
146146

147147
int task_pll_set_correction(long value) {
148-
struct rtapi_task *task = reinterpret_cast<rtapi_task *>(pthread_getspecific(key));
148+
RtapiTask *task = reinterpret_cast<RtapiTask *>(pthread_getspecific(key));
149149
if (!task)
150150
return -EINVAL;
151151
if (value > task->pll_correction_limit)
@@ -160,7 +160,7 @@ struct PosixApp : RtapiApp {
160160
if (do_thread_lock)
161161
pthread_mutex_unlock(&thread_lock);
162162
pthread_testcancel();
163-
struct rtapi_task *task = reinterpret_cast<rtapi_task *>(pthread_getspecific(key));
163+
RtapiTask *task = reinterpret_cast<RtapiTask *>(pthread_getspecific(key));
164164
rtapi_timespec_advance(task->nextstart, task->nextstart, task->period + task->pll_correction);
165165
struct timespec now;
166166
clock_gettime(CLOCK_MONOTONIC, &now);
@@ -195,7 +195,7 @@ struct PosixApp : RtapiApp {
195195
}
196196

197197
int task_self() {
198-
struct rtapi_task *task = reinterpret_cast<rtapi_task *>(pthread_getspecific(key));
198+
RtapiTask *task = reinterpret_cast<RtapiTask *>(pthread_getspecific(key));
199199
if (!task)
200200
return -EINVAL;
201201
return task->id;

src/rtapi/uspace_rtai.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
namespace {
3030
RtapiApp *app;
3131

32-
struct RtaiTask : rtapi_task {
33-
RtaiTask() : rtapi_task{}, cancel{}, rt_task{}, thr{} {
32+
struct RtaiTask : RtapiTask {
33+
RtaiTask() : RtapiTask{}, cancel{}, rt_task{}, thr{} {
3434
}
3535
std::atomic_int cancel;
3636
RT_TASK *rt_task;
3737
pthread_t thr;
3838
};
3939

40-
template <class T = rtapi_task> T *get_task(int task_id) {
40+
template <class T = RtapiTask> T *get_task(int task_id) {
4141
return static_cast<T *>(RtapiApp::get_task(task_id));
4242
}
4343

@@ -47,7 +47,7 @@ struct RtaiApp : RtapiApp {
4747
pthread_once(&key_once, init_key);
4848
}
4949

50-
struct rtapi_task *do_task_new() {
50+
RtapiTask *do_task_new() {
5151
return new RtaiTask;
5252
}
5353

@@ -176,7 +176,7 @@ struct RtaiApp : RtapiApp {
176176
}
177177

178178
int task_self() {
179-
struct rtapi_task *task = reinterpret_cast<rtapi_task *>(pthread_getspecific(key));
179+
RtapiTask *task = reinterpret_cast<RtapiTask *>(pthread_getspecific(key));
180180
if (!task)
181181
return -EINVAL;
182182
return task->id;

src/rtapi/uspace_rtapi_app.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ void WithRoot::init(uid_t ruid_ini, uid_t euid_ini) {
4646
euid = euid_ini;
4747
}
4848

49-
rtapi_task::rtapi_task()
49+
RtapiTask::RtapiTask()
5050
: magic{}, id{}, owner{}, uses_fp{}, stacksize{}, prio{}, period{}, nextstart{}, pll_correction{},
5151
pll_correction_limit{}, arg{}, taskcode{}
5252

5353
{
5454
}
5555

56-
struct rtapi_task *RtapiApp::task_array[MAX_TASKS];
56+
RtapiTask *RtapiApp::task_array[MAX_TASKS];
5757

5858
/* Priority functions. Uspace uses POSIX task priorities. */
5959

@@ -111,8 +111,8 @@ int RtapiApp::prio_next_lower(int prio) const {
111111

112112
int RtapiApp::allocate_task_id() {
113113
for (int n = 0; n < MAX_TASKS; n++) {
114-
rtapi_task **taskptr = &(task_array[n]);
115-
if (__sync_bool_compare_and_swap(taskptr, (rtapi_task *)0, TASK_MAGIC_INIT))
114+
RtapiTask **taskptr = &(task_array[n]);
115+
if (__sync_bool_compare_and_swap(taskptr, (RtapiTask *)0, TASK_MAGIC_INIT))
116116
return n;
117117
}
118118
return -ENOSPC;
@@ -138,7 +138,7 @@ int RtapiApp::task_new(
138138
if (n < 0)
139139
return n;
140140

141-
struct rtapi_task *task = do_task_new();
141+
RtapiTask *task = do_task_new();
142142
if (stacksize < (1024 * 1024))
143143
stacksize = (1024 * 1024);
144144
task->id = n;
@@ -157,18 +157,18 @@ int RtapiApp::task_new(
157157
return n;
158158
}
159159

160-
rtapi_task *RtapiApp::get_task(int task_id) {
160+
RtapiTask *RtapiApp::get_task(int task_id) {
161161
if (task_id < 0 || task_id >= MAX_TASKS)
162162
return NULL;
163163
/* validate task handle */
164-
rtapi_task *task = task_array[task_id];
164+
RtapiTask *task = task_array[task_id];
165165
if (!task || task == TASK_MAGIC_INIT || task->magic != TASK_MAGIC)
166166
return NULL;
167167

168168
return task;
169169
}
170170

171-
void RtapiApp::unexpected_realtime_delay(rtapi_task *task, int /*nperiod*/) {
171+
void RtapiApp::unexpected_realtime_delay(RtapiTask *task, int /*nperiod*/) {
172172
static int printed = 0;
173173
if (!printed) {
174174
rtapi_print_msg(

src/rtapi/uspace_rtapi_app.hh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ struct WithRoot {
5959
static uid_t ruid, euid;
6060
};
6161

62-
struct rtapi_task {
63-
rtapi_task();
62+
struct RtapiTask {
63+
RtapiTask();
6464

6565
int magic; /* to check for valid handle */
6666
int id;
@@ -78,7 +78,7 @@ struct rtapi_task {
7878

7979
#define MAX_TASKS 64
8080
#define TASK_MAGIC 21979 /* random numbers used as signatures */
81-
#define TASK_MAGIC_INIT ((rtapi_task *)(-1))
81+
#define TASK_MAGIC_INIT ((RtapiTask *)(-1))
8282

8383
struct RtapiApp {
8484

@@ -94,10 +94,10 @@ struct RtapiApp {
9494
int prio_next_lower(int prio) const;
9595
long clock_set_period(long int period_nsec);
9696
int task_new(void (*taskcode)(void *), void *arg, int prio, int owner, unsigned long int stacksize, int uses_fp);
97-
virtual rtapi_task *do_task_new() = 0;
97+
virtual RtapiTask *do_task_new() = 0;
9898
static int allocate_task_id();
99-
static struct rtapi_task *get_task(int task_id);
100-
void unexpected_realtime_delay(rtapi_task *task, int nperiod = 1);
99+
static RtapiTask *get_task(int task_id);
100+
void unexpected_realtime_delay(RtapiTask *task, int nperiod = 1);
101101
virtual int task_delete(int id) = 0;
102102
virtual int task_start(int task_id, unsigned long period_nsec) = 0;
103103
virtual int task_pause(int task_id) = 0;
@@ -114,10 +114,10 @@ struct RtapiApp {
114114
static void set_namef(const char *fmt, ...);
115115
int policy;
116116
long period;
117-
static struct rtapi_task *task_array[MAX_TASKS];
117+
static RtapiTask *task_array[MAX_TASKS];
118118
};
119119

120-
template <class T = rtapi_task> T *rtapi_get_task(int task_id) {
120+
template <class T = RtapiTask> T *rtapi_get_task(int task_id) {
121121
return static_cast<T *>(RtapiApp::get_task(task_id));
122122
}
123123

src/rtapi/uspace_xenomai.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#endif
2828

2929
namespace {
30-
struct XenomaiTask : rtapi_task {
31-
XenomaiTask() : rtapi_task{}, cancel{}, thr{} {
30+
struct XenomaiTask : RtapiTask {
31+
XenomaiTask() : RtapiTask{}, cancel{}, thr{} {
3232
}
3333
std::atomic_int cancel;
3434
pthread_t thr;
@@ -40,7 +40,7 @@ struct XenomaiApp : RtapiApp {
4040
pthread_once(&key_once, init_key);
4141
}
4242

43-
struct rtapi_task *do_task_new() {
43+
RtapiTask *do_task_new() {
4444
return new XenomaiTask;
4545
}
4646

@@ -133,14 +133,14 @@ struct XenomaiApp : RtapiApp {
133133
}
134134

135135
long long task_pll_get_reference(void) {
136-
struct rtapi_task *task = reinterpret_cast<rtapi_task *>(pthread_getspecific(key));
136+
RtapiTask *task = reinterpret_cast<RtapiTask *>(pthread_getspecific(key));
137137
if (!task)
138138
return 0;
139139
return task->nextstart.tv_sec * 1000000000LL + task->nextstart.tv_nsec;
140140
}
141141

142142
int task_pll_set_correction(long value) {
143-
struct rtapi_task *task = reinterpret_cast<rtapi_task *>(pthread_getspecific(key));
143+
RtapiTask *task = reinterpret_cast<RtapiTask *>(pthread_getspecific(key));
144144
if (!task)
145145
return -EINVAL;
146146
if (value > task->pll_correction_limit)
@@ -189,7 +189,7 @@ struct XenomaiApp : RtapiApp {
189189
}
190190

191191
int task_self() {
192-
struct rtapi_task *task = reinterpret_cast<rtapi_task *>(pthread_getspecific(key));
192+
RtapiTask *task = reinterpret_cast<RtapiTask *>(pthread_getspecific(key));
193193
if (!task)
194194
return -EINVAL;
195195
return task->id;

src/rtapi/uspace_xenomai_evl.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
#endif
3939

4040
namespace {
41-
struct EvlTask : rtapi_task {
42-
EvlTask() : rtapi_task{}, cancel{}, thr{} {
41+
struct EvlTask : RtapiTask {
42+
EvlTask() : RtapiTask{}, cancel{}, thr{} {
4343
}
4444
std::atomic_int cancel;
4545
pthread_t thr;
@@ -51,7 +51,7 @@ struct EvlApp : RtapiApp {
5151
pthread_once(&key_once, init_key);
5252
}
5353

54-
struct rtapi_task *do_task_new() {
54+
RtapiTask *do_task_new() {
5555
return new EvlTask;
5656
}
5757

@@ -154,14 +154,14 @@ struct EvlApp : RtapiApp {
154154
}
155155

156156
long long task_pll_get_reference(void) {
157-
struct rtapi_task *task = reinterpret_cast<rtapi_task *>(pthread_getspecific(key));
157+
RtapiTask *task = reinterpret_cast<RtapiTask *>(pthread_getspecific(key));
158158
if (!task)
159159
return 0;
160160
return task->nextstart.tv_sec * 1000000000LL + task->nextstart.tv_nsec;
161161
}
162162

163163
int task_pll_set_correction(long value) {
164-
struct rtapi_task *task = reinterpret_cast<rtapi_task *>(pthread_getspecific(key));
164+
RtapiTask *task = reinterpret_cast<RtapiTask *>(pthread_getspecific(key));
165165
if (!task)
166166
return -EINVAL;
167167
if (value > task->pll_correction_limit)
@@ -210,7 +210,7 @@ struct EvlApp : RtapiApp {
210210
}
211211

212212
int task_self() {
213-
struct rtapi_task *task = reinterpret_cast<rtapi_task *>(pthread_getspecific(key));
213+
RtapiTask *task = reinterpret_cast<RtapiTask *>(pthread_getspecific(key));
214214
if (!task)
215215
return -EINVAL;
216216
return task->id;

0 commit comments

Comments
 (0)