use of cast expressions as lvalues is deprecated
Eljay Love-Jensen
eljay@adobe.com
Tue Feb 15 06:16:00 GMT 2005
Hi Massimiliano,
Your neglecting constness.
Try this...
void* qmemcpy(void* dst, void const* src, register long len)
{
// assert(dst != NULL);
// assert(src != NULL);
// assert(len > 0);
register char* d = dst;
register char const* s = src;
for(; --len >= 0; *d++ = *s++)
/*no body*/;
return dst;
}
...and remember: the optimizer is amazing, and works hard to eliminate
inefficiencies and improve performance.
Also, there are some tricks you could do that would improve the performance
of the above as much as an order of magnitude by "tricky use of switch
statement loop unrolling" and moving larger items at a time (with alignment
constraints on certain platforms). Assuming that performance is important.
Don't undervalue the standard memcpy routine. Some compilers have a nicely
optimized memcpy.
HTH,
--Eljay
More information about the Gcc-help
mailing list