lkml.org 
[lkml]   [2006]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: memcpy_toio on i386 using byte writes even when n%2==0
    linux-os (Dick Johnson) wrote:
    > If byte writes are used, they should always be last for any
    > odd byte. I think you found a bug in spite of the fact that
    > whoever made the revision to memcpy probably thinks they
    > did something 'cool'. This is an example of cute code causing
    > problems. The classic example of a proper memcpy() that uses
    > the ix86 built-in macros runs like this:
    >
    > pushl %esi # Save precious registers
    > pushl %edi
    > movl COUNT(%esp),%ecx
    > movl SOURCE(%esp),%esi
    > movl DEST(%esp),%edi
    > cld
    > shrl $1,%ecx # Make WORDS, possibly set carry
    > rep movsw # Copy the words
    > adcl %ecx,%ecx # Any spare byte
    > rep movsb # Copy any spare byte
    > popl %edi # Restore precious registers
    > popl %esi
    >
    > Note that there isn't any code for moving dwords because the
    > chances of gaining anything are slim (alignment may hurt).

    I'd say the chances of gaining something from executing half as many
    instructions on copying a large block of memory are very good indeed..

    --
    Robert Hancock Saskatoon, SK, Canada
    To email, remove "nospam" from hancockr@nospamshaw.ca
    Home Page: http://www.roberthancock.com/

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2006-05-31 02:58    [W:0.022 / U:30.376 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site