Skip to content

Commit 62a53b8

Browse files
committed
Naming: type instead of status
1 parent 1d22326 commit 62a53b8

7 files changed

Lines changed: 47 additions & 46 deletions

File tree

src/hal/hal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ extern int hal_unready(int comp_id);
237237
*/
238238
extern char* hal_comp_name(int comp_id);
239239

240-
extern rtapi_realtime_status_t hal_realtime_status(void);
240+
/** hal_get_realtime_type() returns the type of the running real time
241+
*/
242+
extern rtapi_realtime_type_t hal_get_realtime_type(void);
241243

242244
/** The HAL maintains lists of variables, functions, and so on in
243245
a central database, located in shared memory so all components

src/hal/hal_lib.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -537,13 +537,13 @@ char *hal_comp_name(int comp_id)
537537
return result;
538538
}
539539

540-
int hal_realtime_status() {
540+
int hal_get_realtime_type() {
541541
if (hal_data == 0) {
542542
rtapi_print_msg(RTAPI_MSG_ERR,
543-
"HAL: ERROR: hal_realtime_status called before init\n");
543+
"HAL: ERROR: hal_get_realtime_type called before init\n");
544544
return -EINVAL;
545545
}
546-
return hal_data->realtime_status;
546+
return hal_data->realtime_type;
547547
}
548548

549549
/***********************************************************************
@@ -3121,7 +3121,7 @@ int rtapi_app_main(void)
31213121
rtapi_print_msg(RTAPI_MSG_DBG,
31223122
"HAL_LIB: kernel lib installed successfully\n");
31233123

3124-
hal_data->realtime_status = rtapi_realtime_status();
3124+
hal_data->realtime_type = rtapi_realtime_type();
31253125

31263126
return 0;
31273127
}
@@ -3130,7 +3130,7 @@ void rtapi_app_exit(void)
31303130
{
31313131
hal_thread_t *thread;
31323132

3133-
hal_data->realtime_status = -1;
3133+
hal_data->realtime_type = REALTIME_TYPE_UNINITIALIZED;
31343134

31353135
rtapi_print_msg(RTAPI_MSG_DBG, "HAL_LIB: removing kernel lib\n");
31363136
hal_proc_clean();
@@ -3289,7 +3289,7 @@ static int init_hal_data(void)
32893289
list_init_entry(&(hal_data->funct_entry_free));
32903290
hal_data->thread_free_ptr = 0;
32913291
hal_data->exact_base_period = 0;
3292-
hal_data->realtime_status = -1;
3292+
hal_data->realtime_type = REALTIME_TYPE_UNINITIALIZED;
32933293
/* set up for shmalloc_xx() */
32943294
hal_data->shmem_bot = sizeof(hal_data_t);
32953295
hal_data->shmem_top = HAL_SIZE;

src/hal/hal_priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ typedef struct hal_data_t {
275275
SHMFIELD(hal_thread_t) thread_free_ptr; /* list of free thread structs */
276276
int exact_base_period; /* if set, pretend that rtapi satisfied our
277277
period request exactly */
278-
int realtime_status; /* reflects the realtime status */
278+
rtapi_realtime_type_t realtime_type; /* reflects the realtime type */
279279
unsigned char lock; /* hal locking, can be one of the HAL_LOCK_* types */
280280
} hal_data_t;
281281

src/hal/halmodule.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,10 +1829,9 @@ PyObject *get_info_params(PyObject * /*self*/, PyObject * /*args*/) {
18291829
return python_list;
18301830
}
18311831

1832-
static PyObject *pyhal_realtime_status(PyObject * /*self*/, PyObject * /*o*/) {
1833-
// hal_ready did not exist in EMC 2.0.x, make it a no-op
1832+
static PyObject *pyhal_get_realtime_type(PyObject * /*self*/, PyObject * /*o*/) {
18341833
TEST_HAL_SHMEM_BASE(__FUNCTION__);
1835-
int res = hal_realtime_status();
1834+
int res = hal_get_realtime_type();
18361835
return PyLong_FromLong(res);
18371836
}
18381837

@@ -2306,8 +2305,8 @@ static PyMethodDef module_methods[] = {
23062305
".get_info_signals(): Get a list of dicts for all the signals; {NAME:, VALUE:}"},
23072306
{"get_info_params", get_info_params, METH_VARARGS,
23082307
".get_info_params(): Get a list of dicts for all the parameters; {NAME:, VALUE:}"},
2309-
{"realtime_status", pyhal_realtime_status, METH_NOARGS,
2310-
"Call realtime_status"},
2308+
{"get_realtime_type", pyhal_get_realtime_type, METH_NOARGS,
2309+
"Call get_realtime_type"},
23112310
{},
23122311
};
23132312

src/rtapi/rtai_rtapi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ unsigned char rtapi_inb(unsigned int port)
16891689
}
16901690

16911691
int rtapi_is_realtime(void) { return 1; }
1692-
rtapi_realtime_status_t rtapi_realtime_status(void){ return REALTIME_STATUS_RTAI; }
1692+
rtapi_realtime_type_t rtapi_realtime_type(void){ return REALTIME_TYPE_RTAI; }
16931693
int rtapi_is_kernelspace(void) { return 1; }
16941694

16951695
/* starting with kernel 2.6, symbols that are used by other modules
@@ -1747,5 +1747,5 @@ EXPORT_SYMBOL(rtapi_disable_interrupt);
17471747
EXPORT_SYMBOL(rtapi_outb);
17481748
EXPORT_SYMBOL(rtapi_inb);
17491749
EXPORT_SYMBOL(rtapi_is_realtime);
1750-
EXPORT_SYMBOL(rtapi_realtime_status);
1750+
EXPORT_SYMBOL(rtapi_realtime_type);
17511751
EXPORT_SYMBOL(rtapi_is_kernelspace);

src/rtapi/rtapi.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -987,21 +987,21 @@ int rtapi_spawnp_as_root(pid_t *pid, const char *path,
987987
extern int rtapi_is_kernelspace(void);
988988

989989
typedef enum{
990-
REALTIME_STATUS_UNINITIALIZED = -1,
991-
REALTIME_STATUS_NONE = 0,
992-
REALTIME_STATUS_RTAI = 1,
993-
REALTIME_STATUS_PREEMPT_DYNAMIC = 2,
994-
REALTIME_STATUS_PREEMPT_RT = 3,
995-
REALTIME_STATUS_LXRT = 4,
996-
REALTIME_STATUS_XENOMAI = 5,
997-
REALTIME_STATUS_XENOMAI_EVL = 6,
998-
} rtapi_realtime_status_t;
990+
REALTIME_TYPE_UNINITIALIZED = -1, //Realtime not running, type unknown
991+
REALTIME_TYPE_NONE = 0, //No realtime available
992+
REALTIME_TYPE_RTAI = 1,
993+
REALTIME_TYPE_PREEMPT_DYNAMIC = 2,
994+
REALTIME_TYPE_PREEMPT_RT = 3,
995+
REALTIME_TYPE_LXRT = 4,
996+
REALTIME_TYPE_XENOMAI = 5,
997+
REALTIME_TYPE_XENOMAI_EVL = 6,
998+
} rtapi_realtime_type_t;
999999

10001000
#ifdef RTAPI
10011001
//Only available in real time context
1002-
//In userspace context, use hal_realtime_status()
1002+
//In userspace context, use hal_realtime_type()
10031003
extern int rtapi_is_realtime(void);
1004-
extern rtapi_realtime_status_t rtapi_realtime_status(void);
1004+
extern rtapi_realtime_type_t rtapi_realtime_type(void);
10051005
#endif
10061006

10071007
int rtapi_open_as_root(const char *filename, int mode);

src/rtapi/uspace_rtapi_main.cc

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -221,40 +221,40 @@ static int can_set_sched_fifo(void) {
221221
return 1;
222222
}
223223

224-
rtapi_realtime_status_t rtapi_realtime_status(void){
225-
static rtapi_realtime_status_t cached = REALTIME_STATUS_UNINITIALIZED;
226-
if(cached != REALTIME_STATUS_UNINITIALIZED){
224+
rtapi_realtime_type_t rtapi_realtime_type(void){
225+
static rtapi_realtime_type_t cached = REALTIME_TYPE_UNINITIALIZED;
226+
if(cached != REALTIME_TYPE_UNINITIALIZED){
227227
return cached;
228228
}
229229

230230
if(!detect_force() && !can_set_sched_fifo()){
231-
cached = REALTIME_STATUS_NONE;
231+
cached = REALTIME_TYPE_NONE;
232232
return cached;
233233
}
234234

235235
if(detect_rtai_lxrt()){
236-
cached = REALTIME_STATUS_LXRT;
236+
cached = REALTIME_TYPE_LXRT;
237237
return cached;
238238
}
239239
if(detect_xenomai()){
240-
cached = REALTIME_STATUS_XENOMAI;
240+
cached = REALTIME_TYPE_XENOMAI;
241241
return cached;
242242
}
243243
if(detect_xenomai_evl()){
244-
cached = REALTIME_STATUS_XENOMAI_EVL;
244+
cached = REALTIME_TYPE_XENOMAI_EVL;
245245
return cached;
246246
}
247247
if(detect_preempt_rt()){
248-
cached = REALTIME_STATUS_PREEMPT_RT;
248+
cached = REALTIME_TYPE_PREEMPT_RT;
249249
return cached;
250250
}
251251
if(detect_preempt_dynamic()){
252-
cached = REALTIME_STATUS_PREEMPT_DYNAMIC;
252+
cached = REALTIME_TYPE_PREEMPT_DYNAMIC;
253253
return cached;
254254
}
255255

256-
rtapi_print_msg(RTAPI_MSG_ERR, "rtapi_realtime_status(): Bug, something unknown is running\n");
257-
cached = REALTIME_STATUS_PREEMPT_DYNAMIC;
256+
rtapi_print_msg(RTAPI_MSG_ERR, "rtapi_realtime_type(): Bug, something unknown is running\n");
257+
cached = REALTIME_TYPE_PREEMPT_DYNAMIC;
258258
return cached;
259259
}
260260

@@ -266,7 +266,7 @@ rtapi_realtime_status_t rtapi_realtime_status(void){
266266
// wrapper-based installs like NixOS /run/wrappers) and silently masked
267267
// LINUXCNC_FORCE_REALTIME (see issue #3928).
268268
int rtapi_is_realtime() {
269-
return rtapi_realtime_status() > 0;
269+
return rtapi_realtime_type() > 0;
270270
}
271271

272272
struct message_t {
@@ -1263,25 +1263,25 @@ static void raise_net_admin_ambient(void) {
12631263

12641264
static RtapiApp *makeApp() {
12651265
RtapiApp *app;
1266-
rtapi_realtime_status_t rt_status = rtapi_realtime_status();
1267-
if (rt_status == REALTIME_STATUS_NONE) {
1266+
rtapi_realtime_type_t rt_type = rtapi_realtime_type();
1267+
if (rt_type == REALTIME_TYPE_NONE) {
12681268
app = makeDllApp("liblinuxcnc-uspace-posix.so.0", SCHED_OTHER);
12691269
} else {
12701270
WithRoot r;
12711271
harden_rt();
1272-
if (rt_status == REALTIME_STATUS_XENOMAI_EVL) {
1272+
if (rt_type == REALTIME_TYPE_XENOMAI_EVL) {
12731273
app = makeDllApp("liblinuxcnc-uspace-xenomai-evl.so.0", SCHED_FIFO);
1274-
} else if (rt_status == REALTIME_STATUS_XENOMAI) {
1274+
} else if (rt_type == REALTIME_TYPE_XENOMAI) {
12751275
app = makeDllApp("liblinuxcnc-uspace-xenomai.so.0", SCHED_FIFO);
1276-
} else if (rt_status == REALTIME_STATUS_LXRT) {
1276+
} else if (rt_type == REALTIME_TYPE_LXRT) {
12771277
app = makeDllApp("liblinuxcnc-uspace-rtai.so.0", SCHED_FIFO);
1278-
} else if (rt_status == REALTIME_STATUS_PREEMPT_RT || rt_status == REALTIME_STATUS_PREEMPT_DYNAMIC) {
1278+
} else if (rt_type == REALTIME_TYPE_PREEMPT_RT || rt_type == REALTIME_TYPE_PREEMPT_DYNAMIC) {
12791279
// SCHED_FIFO available but no Xenomai/RTAI backend. Warn if the
12801280
// kernel is not PREEMPT_RT: SCHED_FIFO still beats SCHED_OTHER,
12811281
// but latency on a PREEMPT_DYNAMIC stock kernel can be tens of
12821282
// milliseconds, which will surprise users who expect the same
12831283
// bounds as a PREEMPT_RT or Xenomai setup.
1284-
if (rt_status == REALTIME_STATUS_PREEMPT_DYNAMIC) {
1284+
if (rt_type == REALTIME_TYPE_PREEMPT_DYNAMIC) {
12851285
rtapi_print_msg(RTAPI_MSG_ERR,
12861286
"Note: SCHED_FIFO available but kernel is not PREEMPT_RT. "
12871287
"Latency may be unbounded; install a PREEMPT_RT kernel "
@@ -1290,7 +1290,7 @@ static RtapiApp *makeApp() {
12901290
app = makeDllApp("liblinuxcnc-uspace-posix.so.0", SCHED_FIFO);
12911291
} else {
12921292
app = nullptr;
1293-
rtapi_print_msg(RTAPI_MSG_ERR, "Bug: rt_status = %i in not handled\n", rt_status);
1293+
rtapi_print_msg(RTAPI_MSG_ERR, "Bug: rt_type = %i in not handled\n", rt_type);
12941294
}
12951295
}
12961296

0 commit comments

Comments
 (0)