Re: use of cast expressions as lvalues is deprecated

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

 



Massimiliano,

  Just as a follow-on, a typical enhancement to the memcpy routine is
to write an MMX based prelacement which can do up to 64-byte moves
using 8 mmx megisters (mm0 - mm7).

corey


On Mon, 14 Feb 2005 10:01:30 -0600, Eljay Love-Jensen <eljay@xxxxxxxxx> wrote:
> 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