Re: use of cast expressions as lvalues is deprecated

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

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux