Converting memset to safememset Topic is solved

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
alwalker
Member++
Posts: 27
Joined: Sun Apr 08, 2018 11:19 pm

Converting memset to safememset

Postby alwalker » Sat Jan 04, 2020 5:31 pm

Hi,

I'm integrating a third party C code library into the XMOS environment and have encountered an issue with the string functions as specified in string.h.

I've followed the examples as best i can for using the safestring.h equivalents, but I'm still getting the below errors.

Can anyone advise on the correct syntax please?

The attachment shows the associated code fragments from a number of separate files for reference.

Kind regards,

Al


Combination 1

#define bzero(a, b) safememset(a, 0, b)
bzero((uint8_t *)message_info->payload.value8, message_info->payload_length_bytes);


Errors & Warnings
  • cannot pass unsafe pointer as safe pointer without explicit cast
  • incompatible type for argument 1 of `safememset'



Combination 2

#define bzero(a, b) _safe_memset((char * alias) a, 0, b)
bzero((uint8_t *)message_info->payload.value8, message_info->payload_length_bytes);


Errors & Warnings
  • expected ')'
  • implicit declaration of function '_safe_memset' is invalid in C99 [-Wimplicit-function-declaration]



Combination 3

No #define
safememset((uint8_t *)message_info->payload.value8, 0, message_info->payload_length_bytes);


Errors & Warnings
  • cannot pass unsafe pointer as safe pointer without explicit cast
  • incompatible type for argument 1 of `safememset'

Combination 4

No #define
_safe_memset((char * alias) message_info->payload.value8, 0, message_info->payload_length_bytes);


Errors & Warnings
  • expected ')'
  • implicit declaration of function '_safe_memset' is invalid in C99 [-Wimplicit-function-declaration]
200105 safememset error.png
You do not have the required permissions to view the files attached to this post.
View Solution
alwalker
Member++
Posts: 27
Joined: Sun Apr 08, 2018 11:19 pm

Postby alwalker » Thu Jan 09, 2020 5:40 pm

I solved the problem by creating my own (renamed) version of string.h using standard ANSI/C99 code and compiling as C rather than xC. The xTIMEcomposer version of string.h implements its ‘safe’ versions for use across taks, which I don’t need as all the C code is running in the same task.

Who is online

Users browsing this forum: No registered users and 1 guest