iPXE
Functions | Variables
string.h File Reference

Optimised string operations. More...

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void * __memcpy (void *dest, const void *src, size_t len)
 
void * __memcpy_reverse (void *dest, const void *src, size_t len)
 
static __attribute__ ((always_inline)) void *__constant_memcpy(void *dest
 Copy memory area (where length is a compile-time constant) More...
 
union {
   uint32_t   u32 [2]
 
   uint16_t   u16 [4]
 
   uint8_t   u8 [8]
 
__attribute__ ((__may_alias__)) *src_u
 
 switch (len)
 
 if (len >=26) return __memcpy(dest
 
 if (__builtin_constant_p(offset))
 
__asm__ __volatile__ ("rep stosb" :"=&D"(discard_D), "=&c"(discard_c) :"0"(dest), "1"(len), "a"(fill) :"memory")
 

Variables

static const void * src
 
static const void size_t len
 
const void * esi = src
 
void * edi = dest
 
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
 
 else
 
static int fill
 
size_t discard_c
 
uint32_t eax = 0
 

Detailed Description

Optimised string operations.

Definition in file string.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ __memcpy()

void* __memcpy ( void *  dest,
const void *  src,
size_t  len 
)

Referenced by __memmove().

◆ __memcpy_reverse()

void* __memcpy_reverse ( void *  dest,
const void *  src,
size_t  len 
)

Referenced by __memmove(), and if().

◆ __attribute__() [1/2]

static __attribute__ ( (always_inline)  )
inlinestatic

Copy memory area (where length is a compile-time constant)

Fill memory region with zero (where length is a compile-time constant)

Fill memory region.

Copy (possibly overlapping) memory area.

Copy memory area.

Parameters
destDestination address
srcSource address
lenLength
Return values
destDestination address
Parameters
destDestination address
fillFill pattern
lenLength
Return values
destDestination address
Parameters
destDestination address
lenLength
Return values
destDestination address

◆ __attribute__() [2/2]

const union @590 __attribute__ ( (__may_alias__)  )

◆ switch()

switch ( len  )

Definition at line 61 of file string.h.

61  {
62  case 0 : /* 0 bytes */
63  return dest;
64  /*
65  * Single-register moves; these are always better than a
66  * string operation. We can clobber an arbitrary two
67  * registers (data, source, dest can re-use source register)
68  * instead of being restricted to esi and edi. There's also a
69  * much greater potential for optimising with nearby code.
70  *
71  */
72  case 1 : /* 4 bytes */
73  dest_u->u8[0] = src_u->u8[0];
74  return dest;
75  case 2 : /* 6 bytes */
76  dest_u->u16[0] = src_u->u16[0];
77  return dest;
78  case 4 : /* 4 bytes */
79  dest_u->u32[0] = src_u->u32[0];
80  return dest;
81  /*
82  * Double-register moves; these are probably still a win.
83  *
84  */
85  case 3 : /* 12 bytes */
86  dest_u->u16[0] = src_u->u16[0];
87  dest_u->u8[2] = src_u->u8[2];
88  return dest;
89  case 5 : /* 10 bytes */
90  dest_u->u32[0] = src_u->u32[0];
91  dest_u->u8[4] = src_u->u8[4];
92  return dest;
93  case 6 : /* 12 bytes */
94  dest_u->u32[0] = src_u->u32[0];
95  dest_u->u16[2] = src_u->u16[2];
96  return dest;
97  case 8 : /* 10 bytes */
98  dest_u->u32[0] = src_u->u32[0];
99  dest_u->u32[1] = src_u->u32[1];
100  return dest;
101  }
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
Definition: string.h:150

References dest.

◆ if() [1/2]

if ( len >=  26)

◆ if() [2/2]

if ( __builtin_constant_p(offset )

Definition at line 188 of file string.h.

188  {
189  if ( offset <= 0 ) {
190  return memcpy ( dest, src, len );
191  } else {
192  return __memcpy_reverse ( dest, src, len );
193  }
194  } else {
static const void size_t len
Definition: string.h:47
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
Definition: string.h:150
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
void * __memcpy_reverse(void *dest, const void *src, size_t len)

References __memcpy_reverse(), dest, len, memcpy(), offset, and src.

◆ __volatile__()

__asm__ __volatile__ ( )

Variable Documentation

◆ src

const void* src

Definition at line 47 of file string.h.

Referenced by if().

◆ len

len
Initial value:
{
union {
uint8_t u8[8];
} __attribute__ (( __may_alias__ )) *dest_u = dest
uint16_t u16
Definition: stdint.h:21
unsigned short uint16_t
Definition: stdint.h:11
static __attribute__((always_inline)) void *__constant_memcpy(void *dest
Copy memory area (where length is a compile-time constant)
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
Definition: string.h:150
unsigned char uint8_t
Definition: stdint.h:10
unsigned int uint32_t
Definition: stdint.h:12
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23

Definition at line 47 of file string.h.

Referenced by if().

◆ u32

Definition at line 54 of file string.h.

◆ u16

Definition at line 55 of file string.h.

◆ u8

uint8_t u8[8]

Definition at line 56 of file string.h.

◆ esi

esi = src

Definition at line 58 of file string.h.

Referenced by __attribute__().

◆ edi

void * edi = dest

Definition at line 59 of file string.h.

Referenced by __attribute__().

◆ dest

if ( len >= 6*4 ) __asm__ __volatile__ ( "stosl" if ( len >= 5*4 ) __asm__ __volatile__ ( "stosl" if ( len >= 4*4 ) __asm__ __volatile__ ( "stosl" if ( len >= 3*4 ) __asm__ __volatile__ ( "stosl" if ( len >= 2*4 ) __asm__ __volatile__ ( "stosl" if ( len >= 1*4 ) __asm__ __volatile__ ( "stosl" if ( ( len % 4 ) >= 2 ) __asm__ __volatile__ ( "stosw" if ( ( len % 2 ) >= 1 ) __asm__ __volatile__ ( "stosb" return dest

Definition at line 150 of file string.h.

Referenced by if(), and switch().

◆ else

else
Initial value:
{
return __memmove ( dest, src, len )
static const void size_t len
Definition: string.h:47
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
Definition: string.h:150
void * __memmove(void *dest, const void *src, size_t len)
Copy (possibly overlapping) memory area.
Definition: x86_string.c:103
static const void * src
Definition: string.h:47

Definition at line 194 of file string.h.

◆ fill

int fill

Definition at line 208 of file string.h.

◆ discard_c

size_t discard_c

Definition at line 210 of file string.h.

◆ eax

eax = 0

Definition at line 234 of file string.h.

Referenced by com32_cfarcall().