[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [lwip-devel] SMEMCPY
From: |
Goldschmidt Simon |
Subject: |
RE: [lwip-devel] SMEMCPY |
Date: |
Tue, 22 Jan 2008 13:35:47 +0100 |
> SMEMCPY description is :
>
> "SMEMCPY: override this with care! Some compilers (e.g. gcc) can
inline a
> * call to memcpy() if the length is known at compile time and is
small."
>
> But I see some use in sockets.c like SMEMCPY(addr, &sin, *addrlen); In
this case, the size is not known at compile > time. What is the correct
use (or description) for this macro ?
Those macros are defined because memcpy can be sped up on many platforms
(using loop unrolling / large register file etc.). But most of the time,
this involves a lengthy initialization (finding out whether src and dst
are aligned etc.).
So while in this situation, the compiler can't inline the memcpy, we
still know *addrlen is so small that it perhaps isn't worth the lengthy
initialization of the overridden MEMCPY and thus use the (perhaps)
smaller implementation of memcpy() (which SMEMCPY points to).
Simon