lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-devel] SMEMCPY()


From: Bill Auerbach
Subject: Re: [lwip-devel] SMEMCPY()
Date: Mon, 13 Jun 2011 11:04:10 -0400

If people take "light weight" to mean small code footprint then memcpy will
take up less code than however many SMEMCPY's there are creating an inline
for loop and copy.  Some compilers that see a memcpy with a small constant
may also optimize this to an inlined byte copy and maybe more efficient by
unrolling the byte copies.

>I see your point there. In that case, letting SMEMCPY() default to a
>byte copy define might be the best idea? Something like:
>
>#define SMEMCPY(dst, src, len) do { size_t i; for(i = 0; i < len; i++) {
>((u8_t*)dst)[i] = ((u8_t*)src)[i]; } }while(0)
>
>should do it, then.
>Of course, it's always size vs. speed, I guess. On some platforms,
>calling memcpy is smaller than a local byte-copy loop, on other
>platforms it may be the other way round. However, I think the
>define-version is better than defaulting to memcpy here.
>
>Simon




reply via email to

[Prev in Thread] Current Thread [Next in Thread]