« Return to Thread: [PATCH] Fix aliasing violation.

Re: [PATCH] Fix aliasing violation.

by goldsimon@gmx.de :: Rate this Message:

Reply to Author | View in Thread

David Woodhouse wrote:
>> But we should use SMEMCPY.  I use a macro that converts this to a
>> series of inline load/stores.
>>    
> Isn't that the compiler's job?
>  

In 1.3.0, we converted all calls to 'memcpy' to either 'MEMCPY' or
'SMEMCPY' (s for short). The goal is optimization: SMEMCPY is defined to
memcpy (which the compiler may inline e.g. if size is known at compile
time and small); whil MEMCPY can be overridden to provide a better copy
mechanism (on my platform, for example, copying non-aligned data can be
solved much better when loading full words and shifting in registers).

Therfore, using 'memcpy' directly should be avoided: when you know your
compiler can't optimize it, you can redefine SMEMCPY to inlining yourself.

Simon


_______________________________________________
lwip-devel mailing list
lwip-devel@...
http://lists.nongnu.org/mailman/listinfo/lwip-devel

 « Return to Thread: [PATCH] Fix aliasing violation.