Permalink
Browse files

csp: do not use require signed chars for csp_thread_create arg

FreeRTOS release 8.0+ no longer requires task names to be signed chars.
Fix the csp_thread_create function to just use a char* for the name.
  • Loading branch information...
jledet committed Nov 25, 2015
1 parent 3ffa889 commit 3d60a80c82d0589601a62a2cc62e9d69a1191be6
View
@@ -137,9 +137,9 @@ int main(int argc, char **argv) {
csp_route_print_interfaces();
csp_thread_handle_t handle_server;
- csp_thread_create(task_server, (signed char *) "SERVER", 1000, NULL, 0, &handle_server);
+ csp_thread_create(task_server, "SERVER", 1000, NULL, 0, &handle_server);
csp_thread_handle_t handle_client;
- csp_thread_create(task_client, (signed char *) "CLIENT", 1000, NULL, 0, &handle_client);
+ csp_thread_create(task_client, "CLIENT", 1000, NULL, 0, &handle_client);
/* Wait for program to terminate (ctrl + c) */
while(1) {
View
@@ -183,12 +183,12 @@ int main(int argc, char * argv[]) {
/* Server */
printf("Starting Server task\r\n");
csp_thread_handle_t handle_server;
- csp_thread_create(task_server, (signed char *) "SERVER", 1000, NULL, 0, &handle_server);
+ csp_thread_create(task_server, "SERVER", 1000, NULL, 0, &handle_server);
/* Client */
printf("Starting Client task\r\n");
csp_thread_handle_t handle_client;
- csp_thread_create(task_client, (signed char *) "SERVER", 1000, NULL, 0, &handle_client);
+ csp_thread_create(task_client, "SERVER", 1000, NULL, 0, &handle_client);
/* Wait for execution to end (ctrl+c) */
while(1) {
@@ -88,9 +88,9 @@ typedef void csp_thread_return_t;
#endif // CSP_FREERTOS
#ifndef CSP_WINDOWS
-int csp_thread_create(csp_thread_return_t (* routine)(void *), const signed char * const thread_name, unsigned short stack_depth, void * parameters, unsigned int priority, csp_thread_handle_t * handle);
+int csp_thread_create(csp_thread_return_t (* routine)(void *), const char * const thread_name, unsigned short stack_depth, void * parameters, unsigned int priority, csp_thread_handle_t * handle);
#else
-int csp_thread_create(csp_thread_return_t (* routine)(void *)__attribute__((stdcall)), const signed char * const thread_name, unsigned short stack_depth, void * parameters, unsigned int priority, csp_thread_handle_t * handle);
+int csp_thread_create(csp_thread_return_t (* routine)(void *)__attribute__((stdcall)), const char * const thread_name, unsigned short stack_depth, void * parameters, unsigned int priority, csp_thread_handle_t * handle);
#endif
#ifdef __cplusplus
@@ -26,11 +26,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <csp/arch/csp_thread.h>
-int csp_thread_create(csp_thread_return_t (* routine)(void *), const signed char * const thread_name, unsigned short stack_depth, void * parameters, unsigned int priority, csp_thread_handle_t * handle) {
+int csp_thread_create(csp_thread_return_t (* routine)(void *), const char * const thread_name, unsigned short stack_depth, void * parameters, unsigned int priority, csp_thread_handle_t * handle) {
#if (FREERTOS_VERSION >= 8)
- portBASE_TYPE ret = xTaskCreate(routine, (char *) thread_name, stack_depth, parameters, priority, handle);
-#else
portBASE_TYPE ret = xTaskCreate(routine, thread_name, stack_depth, parameters, priority, handle);
+#else
+ portBASE_TYPE ret = xTaskCreate(routine, (signed char *) thread_name, stack_depth, parameters, priority, handle);
#endif
if (ret != pdTRUE)
return CSP_ERR_NOMEM;
@@ -26,6 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <csp/arch/csp_thread.h>
-int csp_thread_create(csp_thread_return_t (* routine)(void *), const signed char * const thread_name, unsigned short stack_depth, void * parameters, unsigned int priority, csp_thread_handle_t * handle) {
+int csp_thread_create(csp_thread_return_t (* routine)(void *), const char * const thread_name, unsigned short stack_depth, void * parameters, unsigned int priority, csp_thread_handle_t * handle) {
return pthread_create(handle, NULL, routine, parameters);
}
@@ -26,6 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <csp/arch/csp_thread.h>
-int csp_thread_create(csp_thread_return_t (* routine)(void *), const signed char * const thread_name, unsigned short stack_depth, void * parameters, unsigned int priority, csp_thread_handle_t * handle) {
+int csp_thread_create(csp_thread_return_t (* routine)(void *), const char * const thread_name, unsigned short stack_depth, void * parameters, unsigned int priority, csp_thread_handle_t * handle) {
return pthread_create(handle, NULL, routine, parameters);
}
@@ -2,7 +2,7 @@
#include <process.h>
#include <csp/arch/csp_thread.h>
-int csp_thread_create(csp_thread_return_t (* routine)(void *)__attribute__((stdcall)), const signed char * const thread_name, unsigned short stack_depth, void * parameters, unsigned int priority, csp_thread_handle_t * handle) {
+int csp_thread_create(csp_thread_return_t (* routine)(void *)__attribute__((stdcall)), const char * const thread_name, unsigned short stack_depth, void * parameters, unsigned int priority, csp_thread_handle_t * handle) {
HANDLE taskHandle = (HANDLE) _beginthreadex(NULL, stack_depth, routine, parameters, 0, 0);
if( taskHandle == 0 )
return CSP_ERR_NOMEM; // Failure
View
@@ -80,7 +80,7 @@ int csp_bridge_start(unsigned int task_stack_size, unsigned int task_priority, c
if_b = _if_b;
static csp_thread_handle_t handle;
- int ret = csp_thread_create(csp_bridge, (signed char *) "BRIDGE", task_stack_size, NULL, task_priority, &handle);
+ int ret = csp_thread_create(csp_bridge, "BRIDGE", task_stack_size, NULL, task_priority, &handle);
if (ret != 0) {
csp_log_error("Failed to start task");
View
@@ -286,7 +286,7 @@ CSP_DEFINE_TASK(csp_task_router) {
int csp_route_start_task(unsigned int task_stack_size, unsigned int priority) {
static csp_thread_handle_t handle_router;
- int ret = csp_thread_create(csp_task_router, (signed char *) "RTE", task_stack_size, NULL, priority, &handle_router);
+ int ret = csp_thread_create(csp_task_router, "RTE", task_stack_size, NULL, priority, &handle_router);
if (ret != 0) {
csp_log_error("Failed to start router task");
@@ -740,7 +740,7 @@ int csp_can_init(uint8_t mode, struct csp_can_config *conf) {
return CSP_ERR_NOMEM;
}
- ret = csp_thread_create(csp_can_rx_task, (signed char *) "CAN", 6000/sizeof(int), NULL, 3, &can_rx_task);
+ ret = csp_thread_create(csp_can_rx_task, "CAN", 6000/sizeof(int), NULL, 3, &can_rx_task);
if (ret != 0) {
csp_log_error("Failed to init CAN RX task");
return CSP_ERR_NOMEM;
@@ -142,7 +142,7 @@ int csp_zmqhub_init_w_endpoints(char _addr, char * publisher_endpoint,
/* Start RX thread */
static csp_thread_handle_t handle_subscriber;
- int ret = csp_thread_create(csp_zmqhub_task, (signed char *) "ZMQ", 10000, NULL, 0, &handle_subscriber);
+ int ret = csp_thread_create(csp_zmqhub_task, "ZMQ", 10000, NULL, 0, &handle_subscriber);
csp_log_info("Task start %d\r\n", ret);
/* Regsiter interface */

0 comments on commit 3d60a80

Please sign in to comment.