Hi,

On Sun, Mar 16, 2014 at 5:06 PM, John Kasunich <[email protected]>wrote:

>
>
> On Sun, Mar 16, 2014, at 07:59 PM, John Kasunich wrote:
>
> > new          memcpy(data_addr, &pin->dummysig, sizeof(hal_data_u));
>
> I'm not sure if memcpy is neccessary here, the only
> requirement is to copy the value from one place to
> the other.  hal_data_u is a union that can contain any
> HAL data type.
>
>  122 typedef union {
>  123     hal_bit_t b;
>  124     hal_s32_t s;
>  125     hal_s32_t u;
>  126     hal_float_t f;
>  127 } hal_data_u;
>
> If you can be sure that hal_float_t is the largest member on
> all platforms, then it could just be:
>
>    *((hal_float_t)(data_addr)) = pin->dummysig.f;
>

I'm jumping in late here, but why not just do:

*(hal_data_u *)data_addr = pin->dummysig;

which is a structure copy, and the compiler will optimize it to use the
best way of copying based on the size?

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to