Skip to content

Commit 632fcbd

Browse files
jeplerpetterreinholdtsen
authored andcommitted
halcmd: convert halcmd_commands to C++
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
1 parent 0702e66 commit 632fcbd

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/hal/utils/Submakefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
HALCMDSRCS := hal/utils/halcmd.c hal/utils/halcmd_commands.c hal/utils/halcmd_main.c
2-
HALSHSRCS := hal/utils/halcmd.c hal/utils/halcmd_commands.c hal/utils/halsh.c
1+
HALCMDSRCS := hal/utils/halcmd.c hal/utils/halcmd_commands.cc hal/utils/halcmd_main.c
2+
HALSHSRCS := hal/utils/halcmd.c hal/utils/halcmd_commands.cc hal/utils/halsh.c
33

44
ifneq ($(READLINE_LIBS),)
55
HALCMDSRCS += hal/utils/halcmd_completion.c
@@ -10,12 +10,12 @@ $(call TOOBJSDEPS, $(HALSHSRCS)) : EXTRAFLAGS = -fPIC
1010
$(call TOOBJSDEPS, hal/utils/halsh.c) : EXTRAFLAGS += $(TCL_CFLAGS)
1111
../tcl/hal.so: $(call TOOBJS, $(HALSHSRCS)) ../lib/liblinuxcncini.so.0 ../lib/liblinuxcnchal.so.0
1212
$(ECHO) Linking $(notdir $@)
13-
$(Q)$(CC) $(LDFLAGS) -shared $^ $(TCL_LIBS) -o $@
13+
$(Q)$(CXX) $(LDFLAGS) -shared $^ $(TCL_LIBS) -o $@
1414
TARGETS += ../tcl/hal.so
1515

1616
../bin/halcmd: $(call TOOBJS, $(HALCMDSRCS)) ../lib/liblinuxcncini.so.0 ../lib/liblinuxcnchal.so.0
1717
$(ECHO) Linking $(notdir $@)
18-
$(Q)$(CC) $(LDFLAGS) -o $@ $^ $(READLINE_LIBS)
18+
$(Q)$(CXX) $(LDFLAGS) -o $@ $^ $(READLINE_LIBS)
1919
TARGETS += ../bin/halcmd
2020

2121
HALRMTSRCS := hal/utils/halrmt.c
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ static void print_param_names(char **patterns);
7575
static void print_funct_names(char **patterns);
7676
static void print_thread_names(char **patterns);
7777
static void print_lock_status();
78-
static int count_list(int list_root);
7978
static void print_mem_status();
8079
static const char *data_type(int type);
8180
static const char *data_type2(int type);
@@ -1173,7 +1172,7 @@ int do_loadrt_cmd(char *mod_name, char *args[])
11731172
strncat(arg_string, " ", MAX_CMD_LEN);
11741173
}
11751174
/* allocate HAL shmem for the string */
1176-
cp1 = hal_malloc(strlen(arg_string)+1);
1175+
cp1 = (char*)hal_malloc(strlen(arg_string)+1);
11771176
if ( cp1 == NULL ) {
11781177
halcmd_error("failed to allocate memory for module args\n");
11791178
return -1;
@@ -2136,16 +2135,18 @@ static void print_lock_status()
21362135
halcmd_output(" HAL_LOCK_RUN - running/stopping HAL is locked\n");
21372136
}
21382137

2139-
static int count_list(int list_root)
2138+
template<class T>
2139+
int count_list(SHMFIELD(T) list_root)
21402140
{
2141-
int n, next;
2141+
int n;
2142+
SHMFIELD(T) next;
21422143

21432144
rtapi_mutex_get(&(hal_data->mutex));
21442145
next = list_root;
21452146
n = 0;
21462147
while (next != 0) {
21472148
n++;
2148-
next = *((int *) SHMPTR(next));
2149+
next = SHMPTR(next)->next_ptr;
21492150
}
21502151
rtapi_mutex_give(&(hal_data->mutex));
21512152
return n;

0 commit comments

Comments
 (0)