iPXE
Functions
x86_string.c File Reference

Optimised string operations. More...

#include <string.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
void * __attribute__ ((noinline))
 Copy memory area.
void * __memmove (void *dest, const void *src, size_t len)
 Copy (possibly overlapping) memory area.

Detailed Description

Optimised string operations.

Definition in file x86_string.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
void* __attribute__ ( (noinline)  )

Copy memory area.

Copy memory area backwards.

Parameters:
destDestination address
srcSource address
lenLength
Return values:
destDestination address

Definition at line 42 of file x86_string.c.

References __asm__(), dest, edi, esi, and src.

                                                            {
        void *edi = dest;
        const void *esi = src;
        int discard_ecx;

        /* We often do large dword-aligned and dword-length block
         * moves.  Using movsl rather than movsb speeds these up by
         * around 32%.
         */
        __asm__ __volatile__ ( "rep movsl"
                               : "=&D" ( edi ), "=&S" ( esi ),
                                 "=&c" ( discard_ecx )
                               : "0" ( edi ), "1" ( esi ), "2" ( len >> 2 )
                               : "memory" );
        __asm__ __volatile__ ( "rep movsb"
                               : "=&D" ( edi ), "=&S" ( esi ),
                                 "=&c" ( discard_ecx )
                               : "0" ( edi ), "1" ( esi ), "2" ( len & 3 )
                               : "memory" );
        return dest;
}
void* __memmove ( void *  dest,
const void *  src,
size_t  len 
)

Copy (possibly overlapping) memory area.

Parameters:
destDestination address
srcSource address
lenLength
Return values:
destDestination address

Definition at line 103 of file x86_string.c.

References __memcpy(), and __memcpy_reverse().

                                                             {

        if ( dest <= src ) {
                return __memcpy ( dest, src, len );
        } else {
                return __memcpy_reverse ( dest, src, len );
        }
}