MM> Section 3.6 Mention use of the deref() macro in embedded C for
MM> safety. Give an example.
I could use a little help with this. Would anyone be able to provide a
good working example?
There are examples in the tapset. Josh switched us over to the
"kread" function:
function _struct_timeval:string(addr:long)
%{ /* pure */
struct timeval *tv = (struct timeval *)(unsigned long)THIS->addr;
if (tv == NULL)
strlcpy (THIS->__retvalue, "NULL", MAXSTRINGLEN);
else
snprintf(THIS->__retvalue, MAXSTRINGLEN, "[%ld.%06ld]",
kread(&(tv->tv_sec)), kread(&(tv->tv_usec)));
%}
(However, it is not clear that the NULL-handling case is relevant or
appropriate. If the timeval* coming in from the application is
permitted to be NULL, fine, but if it's meant as a crash-prevention
mechanism in this embedded-C routine, then it's not right.)