From: <jmk...@us...> - 2004-03-14 19:43:01
|
Update of /cvsroot/emc/emc2/src/hal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1386/src/hal Modified Files: hal_lib.c Log Message: all public hal functions now check to see if hal_init has been called before accessing shared memory (hal_init maps the memory, access without mapping = segfault or oops) Index: hal_lib.c =================================================================== RCS file: /cvsroot/emc/emc2/src/hal/hal_lib.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** hal_lib.c 3 Mar 2004 04:55:04 -0000 1.11 --- hal_lib.c 14 Mar 2004 19:34:01 -0000 1.12 *************** *** 321,324 **** --- 321,329 ---- void *retval; + if (hal_data == 0) { + rtapi_print_msg(RTAPI_MSG_ERR, + "HAL: ERROR: hal_malloc called before init\n"); + return 0; + } /* get the mutex */ rtapi_mutex_get(&(hal_data->mutex)); *************** *** 399,402 **** --- 404,412 ---- hal_comp_t *comp; + if (hal_data == 0) { + rtapi_print_msg(RTAPI_MSG_ERR, + "HAL: ERROR: pin_new called before init\n"); + return HAL_INVAL; + } rtapi_print_msg(RTAPI_MSG_DBG, "HAL: creating pin '%s'\n", name); /* get mutex before accessing shared data */ *************** *** 475,478 **** --- 485,493 ---- void *data_addr; + if (hal_data == 0) { + rtapi_print_msg(RTAPI_MSG_ERR, + "HAL: ERROR: signal_new called before init\n"); + return HAL_INVAL; + } rtapi_print_msg(RTAPI_MSG_DBG, "HAL: creating signal '%s'\n", name); /* get mutex before accessing shared data */ *************** *** 574,577 **** --- 589,597 ---- int *prev, next; + if (hal_data == 0) { + rtapi_print_msg(RTAPI_MSG_ERR, + "HAL: ERROR: signal_delete called before init\n"); + return HAL_INVAL; + } rtapi_print_msg(RTAPI_MSG_DBG, "HAL: deleting signal '%s'\n", name); /* get mutex before accessing shared data */ *************** *** 609,612 **** --- 629,637 ---- void **data_ptr_addr, *data_addr; + if (hal_data == 0) { + rtapi_print_msg(RTAPI_MSG_ERR, + "HAL: ERROR: link called before init\n"); + return HAL_INVAL; + } rtapi_print_msg(RTAPI_MSG_DBG, "HAL: linking pin '%s' to '%s'\n", pin_name, sig_name); *************** *** 736,739 **** --- 761,769 ---- hal_comp_t *comp; + if (hal_data == 0) { + rtapi_print_msg(RTAPI_MSG_ERR, + "HAL: ERROR: param_new called before init\n"); + return HAL_INVAL; + } rtapi_print_msg(RTAPI_MSG_DBG, "HAL: creating parameter '%s'\n", name); /* get mutex before accessing shared data */ *************** *** 845,848 **** --- 875,883 ---- void *d_ptr; + if (hal_data == 0) { + rtapi_print_msg(RTAPI_MSG_ERR, + "HAL: ERROR: param_set called before init\n"); + return HAL_INVAL; + } rtapi_print_msg(RTAPI_MSG_DBG, "HAL: setting parameter '%s'\n", name); /* get mutex before accessing shared data */ *************** *** 920,923 **** --- 955,963 ---- hal_comp_t *comp; + if (hal_data == 0) { + rtapi_print_msg(RTAPI_MSG_ERR, + "HAL: ERROR: export_funct called before init\n"); + return HAL_INVAL; + } /* get mutex before accessing shared data */ rtapi_mutex_get(&(hal_data->mutex)); *************** *** 993,996 **** --- 1033,1041 ---- char buf[HAL_NAME_LEN + 1]; + if (hal_data == 0) { + rtapi_print_msg(RTAPI_MSG_ERR, + "HAL: ERROR: create_thread called before init\n"); + return HAL_INVAL; + } /* get mutex before accessing shared data */ rtapi_mutex_get(&(hal_data->mutex)); *************** *** 1111,1114 **** --- 1156,1164 ---- hal_funct_entry_t *funct_entry; + if (hal_data == 0) { + rtapi_print_msg(RTAPI_MSG_ERR, + "HAL: ERROR: add_funct called before init\n"); + return HAL_INVAL; + } rtapi_print_msg(RTAPI_MSG_DBG, "HAL: adding function '%s' to thread '%s'\n", *************** *** 1195,1198 **** --- 1245,1253 ---- hal_funct_entry_t *funct_entry; + if (hal_data == 0) { + rtapi_print_msg(RTAPI_MSG_ERR, + "HAL: ERROR: del_funct called before init\n"); + return HAL_INVAL; + } rtapi_print_msg(RTAPI_MSG_DBG, "HAL: removing function '%s' from thread '%s'\n", *************** *** 1270,1273 **** --- 1325,1333 ---- { /* a trivial function for a change! */ + if (hal_data == 0) { + rtapi_print_msg(RTAPI_MSG_ERR, + "HAL: ERROR: start_threads called before init\n"); + return HAL_INVAL; + } hal_data->threads_running = 1; return HAL_SUCCESS; *************** *** 1277,1280 **** --- 1337,1345 ---- { /* wow, two in a row! */ + if (hal_data == 0) { + rtapi_print_msg(RTAPI_MSG_ERR, + "HAL: ERROR: stop_threads called before init\n"); + return HAL_INVAL; + } hal_data->threads_running = 0; return HAL_SUCCESS; |