Skip to content

Commit 1c3a33c

Browse files
committed
Cleanup: Rename, remove define
1 parent 808db77 commit 1c3a33c

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

src/rtapi/uspace_posix.cc

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ struct PosixTask : rtapi_task
1919
pthread_t thr; /* thread's context */
2020
};
2121

22-
struct Posix : RtapiApp
22+
struct PosixApp : RtapiApp
2323
{
24-
#define RTAPI_CLOCK (CLOCK_MONOTONIC)
25-
26-
Posix(int policy = SCHED_FIFO) : RtapiApp(policy), do_thread_lock(policy != SCHED_FIFO) {
24+
PosixApp(int policy = SCHED_FIFO) : RtapiApp(policy), do_thread_lock(policy != SCHED_FIFO) {
2725
if(instance != nullptr){
2826
throw std::invalid_argument("Only one instance allowed!");
2927
}
@@ -108,7 +106,7 @@ struct Posix : RtapiApp
108106
pthread_mutex_lock(&instance->thread_lock);
109107

110108
struct timespec now;
111-
clock_gettime(RTAPI_CLOCK, &now);
109+
clock_gettime(CLOCK_MONOTONIC, &now);
112110
rtapi_timespec_advance(task->nextstart, now, task->period + task->pll_correction);
113111

114112
/* call the task function with the task argument */
@@ -150,7 +148,7 @@ struct Posix : RtapiApp
150148
struct rtapi_task *task = reinterpret_cast<rtapi_task*>(pthread_getspecific(key));
151149
rtapi_timespec_advance(task->nextstart, task->nextstart, task->period + task->pll_correction);
152150
struct timespec now;
153-
clock_gettime(RTAPI_CLOCK, &now);
151+
clock_gettime(CLOCK_MONOTONIC, &now);
154152
if(rtapi_timespec_less(task->nextstart, now))
155153
{
156154
if(policy == SCHED_FIFO)
@@ -219,15 +217,15 @@ struct Posix : RtapiApp
219217
clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, nullptr);
220218
}
221219

222-
static Posix* instance;
220+
static PosixApp* instance;
223221
};
224222

225-
Posix* Posix::instance=nullptr;
223+
PosixApp* PosixApp::instance=nullptr;
226224

227-
pthread_once_t Posix::key_once = PTHREAD_ONCE_INIT;
228-
pthread_once_t Posix::lock_once = PTHREAD_ONCE_INIT;
229-
pthread_key_t Posix::key;
230-
pthread_mutex_t Posix::thread_lock;
225+
pthread_once_t PosixApp::key_once = PTHREAD_ONCE_INIT;
226+
pthread_once_t PosixApp::lock_once = PTHREAD_ONCE_INIT;
227+
pthread_key_t PosixApp::key;
228+
pthread_mutex_t PosixApp::thread_lock;
231229

232230
}
233231

@@ -239,5 +237,5 @@ RtapiApp *make(int policy) {
239237
}else{
240238
rtapi_print_msg(RTAPI_MSG_ERR, "Note: Using POSIX realtime\n");
241239
}
242-
return new Posix(policy);
240+
return new PosixApp(policy);
243241
}

0 commit comments

Comments
 (0)