iPXE
Macros | Functions | Variables
memcpy_test.c File Reference

memcpy() self-tests More...

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <ipxe/test.h>
#include <ipxe/profile.h>

Go to the source code of this file.

Macros

#define PROFILE_COUNT   16
 Number of sample iterations for profiling. More...
 
#define MEMCPY_TEST_CONSTANT(...)
 Perform a constant-length memcpy() test. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void memcpy_0 (void *dest, void *src)
 
void memcpy_1 (void *dest, void *src)
 
void memcpy_2 (void *dest, void *src)
 
void memcpy_3 (void *dest, void *src)
 
void memcpy_4 (void *dest, void *src)
 
void memcpy_5 (void *dest, void *src)
 
void memcpy_6 (void *dest, void *src)
 
void memcpy_7 (void *dest, void *src)
 
void memcpy_8 (void *dest, void *src)
 
void memcpy_9 (void *dest, void *src)
 
void memcpy_10 (void *dest, void *src)
 
void memcpy_11 (void *dest, void *src)
 
void memcpy_12 (void *dest, void *src)
 
void memcpy_13 (void *dest, void *src)
 
void memcpy_14 (void *dest, void *src)
 
void memcpy_15 (void *dest, void *src)
 
void memcpy_16 (void *dest, void *src)
 
void memcpy_17 (void *dest, void *src)
 
void memcpy_18 (void *dest, void *src)
 
void memcpy_19 (void *dest, void *src)
 
void memcpy_20 (void *dest, void *src)
 
void memcpy_21 (void *dest, void *src)
 
void memcpy_22 (void *dest, void *src)
 
void memcpy_23 (void *dest, void *src)
 
void memcpy_24 (void *dest, void *src)
 
void memcpy_25 (void *dest, void *src)
 
void memcpy_26 (void *dest, void *src)
 
void memcpy_27 (void *dest, void *src)
 
void memcpy_28 (void *dest, void *src)
 
void memcpy_29 (void *dest, void *src)
 
void memcpy_30 (void *dest, void *src)
 
void memcpy_31 (void *dest, void *src)
 
void * memcpy_var (void *dest, const void *src, size_t len)
 Force a call to the variable-length implementation of memcpy() More...
 
static void memcpy_test_speed (unsigned int dest_offset, unsigned int src_offset, size_t len)
 Test memcpy() speed. More...
 
static void memcpy_test_exec (void)
 Perform memcpy() self-tests. More...
 

Variables

struct self_test memcpy_test __self_test
 memcpy() self-test More...
 

Detailed Description

memcpy() self-tests

Definition in file memcpy_test.c.

Macro Definition Documentation

◆ PROFILE_COUNT

#define PROFILE_COUNT   16

Number of sample iterations for profiling.

Definition at line 42 of file memcpy_test.c.

◆ MEMCPY_TEST_CONSTANT

#define MEMCPY_TEST_CONSTANT (   ...)
Value:
do { \
static const uint8_t src[] = { __VA_ARGS__ }; \
uint8_t dest_const[ 1 + sizeof ( src ) + 1 ]; \
uint8_t dest_var[ 1 + sizeof ( src ) + 1 ]; \
\
dest_const[0] = 0x33; \
dest_const[ sizeof ( dest_const ) - 1 ] = 0x44; \
memcpy ( ( dest_const + 1 ), src, \
( sizeof ( dest_const ) - 2 ) ); \
ok ( dest_const[0] == 0x33 ); \
ok ( dest_const[ sizeof ( dest_const ) - 1 ] == 0x44 ); \
ok ( memcmp ( ( dest_const + 1 ), src, \
( sizeof ( dest_const ) - 2 ) ) == 0 ); \
\
dest_var[0] = 0x55; \
dest_var[ sizeof ( dest_var ) - 1 ] = 0x66; \
memcpy_var ( ( dest_var + 1 ), src, \
( sizeof ( dest_var ) - 2 ) ); \
ok ( dest_var[0] == 0x55 ); \
ok ( dest_var[ sizeof ( dest_var ) - 1 ] == 0x66 ); \
ok ( memcmp ( ( dest_var + 1 ), src, \
( sizeof ( dest_var ) - 2 ) ) == 0 ); \
} while ( 0 )
static const void * src
Definition: string.h:47
unsigned char uint8_t
Definition: stdint.h:10
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114

Perform a constant-length memcpy() test.

... Data to copy

Definition at line 97 of file memcpy_test.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ memcpy_0()

void memcpy_0 ( void *  dest,
void *  src 
)

Definition at line 46 of file memcpy_test.c.

46 { memcpy ( dest, src, 0 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_1()

void memcpy_1 ( void *  dest,
void *  src 
)

Definition at line 47 of file memcpy_test.c.

47 { memcpy ( dest, src, 1 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_2()

void memcpy_2 ( void *  dest,
void *  src 
)

Definition at line 48 of file memcpy_test.c.

48 { memcpy ( dest, src, 2 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_3()

void memcpy_3 ( void *  dest,
void *  src 
)

Definition at line 49 of file memcpy_test.c.

49 { memcpy ( dest, src, 3 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_4()

void memcpy_4 ( void *  dest,
void *  src 
)

Definition at line 50 of file memcpy_test.c.

50 { memcpy ( dest, src, 4 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_5()

void memcpy_5 ( void *  dest,
void *  src 
)

Definition at line 51 of file memcpy_test.c.

51 { memcpy ( dest, src, 5 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_6()

void memcpy_6 ( void *  dest,
void *  src 
)

Definition at line 52 of file memcpy_test.c.

52 { memcpy ( dest, src, 6 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_7()

void memcpy_7 ( void *  dest,
void *  src 
)

Definition at line 53 of file memcpy_test.c.

53 { memcpy ( dest, src, 7 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_8()

void memcpy_8 ( void *  dest,
void *  src 
)

Definition at line 54 of file memcpy_test.c.

54 { memcpy ( dest, src, 8 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_9()

void memcpy_9 ( void *  dest,
void *  src 
)

Definition at line 55 of file memcpy_test.c.

55 { memcpy ( dest, src, 9 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_10()

void memcpy_10 ( void *  dest,
void *  src 
)

Definition at line 56 of file memcpy_test.c.

56 { memcpy ( dest, src, 10 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_11()

void memcpy_11 ( void *  dest,
void *  src 
)

Definition at line 57 of file memcpy_test.c.

57 { memcpy ( dest, src, 11 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_12()

void memcpy_12 ( void *  dest,
void *  src 
)

Definition at line 58 of file memcpy_test.c.

58 { memcpy ( dest, src, 12 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_13()

void memcpy_13 ( void *  dest,
void *  src 
)

Definition at line 59 of file memcpy_test.c.

59 { memcpy ( dest, src, 13 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_14()

void memcpy_14 ( void *  dest,
void *  src 
)

Definition at line 60 of file memcpy_test.c.

60 { memcpy ( dest, src, 14 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_15()

void memcpy_15 ( void *  dest,
void *  src 
)

Definition at line 61 of file memcpy_test.c.

61 { memcpy ( dest, src, 15 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_16()

void memcpy_16 ( void *  dest,
void *  src 
)

Definition at line 62 of file memcpy_test.c.

62 { memcpy ( dest, src, 16 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_17()

void memcpy_17 ( void *  dest,
void *  src 
)

Definition at line 63 of file memcpy_test.c.

63 { memcpy ( dest, src, 17 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_18()

void memcpy_18 ( void *  dest,
void *  src 
)

Definition at line 64 of file memcpy_test.c.

64 { memcpy ( dest, src, 18 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_19()

void memcpy_19 ( void *  dest,
void *  src 
)

Definition at line 65 of file memcpy_test.c.

65 { memcpy ( dest, src, 19 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_20()

void memcpy_20 ( void *  dest,
void *  src 
)

Definition at line 66 of file memcpy_test.c.

66 { memcpy ( dest, src, 20 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_21()

void memcpy_21 ( void *  dest,
void *  src 
)

Definition at line 67 of file memcpy_test.c.

67 { memcpy ( dest, src, 21 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_22()

void memcpy_22 ( void *  dest,
void *  src 
)

Definition at line 68 of file memcpy_test.c.

68 { memcpy ( dest, src, 22 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_23()

void memcpy_23 ( void *  dest,
void *  src 
)

Definition at line 69 of file memcpy_test.c.

69 { memcpy ( dest, src, 23 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_24()

void memcpy_24 ( void *  dest,
void *  src 
)

Definition at line 70 of file memcpy_test.c.

70 { memcpy ( dest, src, 24 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_25()

void memcpy_25 ( void *  dest,
void *  src 
)

Definition at line 71 of file memcpy_test.c.

71 { memcpy ( dest, src, 25 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_26()

void memcpy_26 ( void *  dest,
void *  src 
)

Definition at line 72 of file memcpy_test.c.

72 { memcpy ( dest, src, 26 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_27()

void memcpy_27 ( void *  dest,
void *  src 
)

Definition at line 73 of file memcpy_test.c.

73 { memcpy ( dest, src, 27 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_28()

void memcpy_28 ( void *  dest,
void *  src 
)

Definition at line 74 of file memcpy_test.c.

74 { memcpy ( dest, src, 28 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_29()

void memcpy_29 ( void *  dest,
void *  src 
)

Definition at line 75 of file memcpy_test.c.

75 { memcpy ( dest, src, 29 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_30()

void memcpy_30 ( void *  dest,
void *  src 
)

Definition at line 76 of file memcpy_test.c.

76 { memcpy ( dest, src, 30 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_31()

void memcpy_31 ( void *  dest,
void *  src 
)

Definition at line 77 of file memcpy_test.c.

77 { memcpy ( dest, src, 31 ); }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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, memcpy(), and src.

◆ memcpy_var()

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

Force a call to the variable-length implementation of memcpy()

Parameters
destDestination address
srcSource address
lenLength of data
Return values
destDestination address

Definition at line 87 of file memcpy_test.c.

88  {
89  return memcpy ( dest, src, len );
90 }
static const void * src
Definition: string.h:47
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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
uint32_t len
Length.
Definition: ena.h:14

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

◆ memcpy_test_speed()

static void memcpy_test_speed ( unsigned int  dest_offset,
unsigned int  src_offset,
size_t  len 
)
static

Test memcpy() speed.

Parameters
dest_offsetDestination alignment offset
src_offsetSource alignment offset
lenLength of data to copy

Definition at line 128 of file memcpy_test.c.

129  {
130  struct profiler profiler;
131  uint8_t *dest;
132  uint8_t *src;
133  unsigned int i;
134 
135  /* Allocate blocks */
136  dest = malloc ( len + dest_offset );
137  assert ( dest != NULL );
138  src = malloc ( len + src_offset );
139  assert ( src != NULL );
140 
141  /* Generate random source data */
142  for ( i = 0 ; i < len ; i++ )
143  src[ src_offset + i ] = random();
144 
145  /* Check correctness of copied data */
146  memcpy ( ( dest + dest_offset ), ( src + src_offset ), len );
147  ok ( memcmp ( ( dest + dest_offset ), ( src + src_offset ),
148  len ) == 0 );
149 
150  /* Profile memcpy() */
151  memset ( &profiler, 0, sizeof ( profiler ) );
152  for ( i = 0 ; i < PROFILE_COUNT ; i++ ) {
153  profile_start ( &profiler );
154  memcpy ( ( dest + dest_offset ), ( src + src_offset ), len );
155  profile_stop ( &profiler );
156  }
157 
158  /* Free blocks */
159  free ( dest );
160  free ( src );
161 
162  DBG ( "MEMCPY copied %zd bytes (+%d => +%d) in %ld +/- %ld ticks\n",
163  len, src_offset, dest_offset, profile_mean ( &profiler ),
164  profile_stddev ( &profiler ) );
165 }
unsigned long profile_mean(struct profiler *profiler)
Get mean sample value.
Definition: profile.c:241
static const void * src
Definition: string.h:47
A data structure for storing profiling information.
Definition: profile.h:26
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:173
unsigned long profile_stddev(struct profiler *profiler)
Get sample standard deviation.
Definition: profile.c:275
void * memcpy(void *dest, const void *src, size_t len) __nonnull
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:160
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
long int random(void)
Generate a pseudo-random number between 0 and 2147483647L or 2147483562?
Definition: random.c:31
unsigned char uint8_t
Definition: stdint.h:10
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:583
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
#define PROFILE_COUNT
Number of sample iterations for profiling.
Definition: memcpy_test.c:42
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define ok(success)
Definition: test.h:46
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
uint32_t len
Length.
Definition: ena.h:14
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
void * memset(void *dest, int character, size_t len) __nonnull

References assert(), DBG, dest, free, len, malloc(), memcmp(), memcpy(), memset(), NULL, ok, PROFILE_COUNT, profile_mean(), profile_start(), profile_stddev(), profile_stop(), random(), and src.

Referenced by memcpy_test_exec().

◆ memcpy_test_exec()

static void memcpy_test_exec ( void  )
static

Perform memcpy() self-tests.

Definition at line 171 of file memcpy_test.c.

171  {
172  unsigned int dest_offset;
173  unsigned int src_offset;
174 
175  /* Constant-length tests */
177  MEMCPY_TEST_CONSTANT ( 0x86 );
178  MEMCPY_TEST_CONSTANT ( 0x8c, 0xd3 );
179  MEMCPY_TEST_CONSTANT ( 0x4e, 0x08, 0xed );
180  MEMCPY_TEST_CONSTANT ( 0xcc, 0x61, 0x8f, 0x70 );
181  MEMCPY_TEST_CONSTANT ( 0x6d, 0x28, 0xe0, 0x9e, 0x6d );
182  MEMCPY_TEST_CONSTANT ( 0x7d, 0x13, 0x4f, 0xef, 0x17, 0xb3 );
183  MEMCPY_TEST_CONSTANT ( 0x38, 0xa7, 0xd4, 0x8d, 0x44, 0x01, 0xfd );
184  MEMCPY_TEST_CONSTANT ( 0x45, 0x9f, 0xf4, 0xf9, 0xf3, 0x0f, 0x99, 0x43 );
185  MEMCPY_TEST_CONSTANT ( 0x69, 0x8c, 0xf6, 0x12, 0x79, 0x70, 0xd8, 0x1e,
186  0x9d );
187  MEMCPY_TEST_CONSTANT ( 0xbe, 0x53, 0xb4, 0xb7, 0xdd, 0xe6, 0x35, 0x10,
188  0x3c, 0xe7 );
189  MEMCPY_TEST_CONSTANT ( 0xaf, 0x41, 0x8a, 0x88, 0xb1, 0x4e, 0x52, 0xd4,
190  0xe6, 0xc3, 0x76 );
191  MEMCPY_TEST_CONSTANT ( 0xdf, 0x43, 0xe4, 0x5d, 0xad, 0x17, 0x35, 0x38,
192  0x1a, 0x1d, 0x57, 0x58 );
193  MEMCPY_TEST_CONSTANT ( 0x20, 0x52, 0x83, 0x92, 0xb9, 0x85, 0xa4, 0x06,
194  0x94, 0xe0, 0x3d, 0x57, 0xd4 );
195  MEMCPY_TEST_CONSTANT ( 0xf1, 0x67, 0x31, 0x9e, 0x32, 0x98, 0x27, 0xe9,
196  0x8e, 0x62, 0xb4, 0x82, 0x7e, 0x02 );
197  MEMCPY_TEST_CONSTANT ( 0x93, 0xc1, 0x55, 0xe3, 0x60, 0xce, 0xac, 0x1e,
198  0xae, 0x9d, 0xca, 0xec, 0x92, 0xb3, 0x38 );
199  MEMCPY_TEST_CONSTANT ( 0xb3, 0xc1, 0xfa, 0xe7, 0x8a, 0x1c, 0xe4, 0xce,
200  0x85, 0xe6, 0x3c, 0xab, 0x1c, 0xa2, 0xaf, 0x7a );
201  MEMCPY_TEST_CONSTANT ( 0x9b, 0x6e, 0x1c, 0x48, 0x82, 0xd3, 0x6e, 0x58,
202  0xa7, 0xb0, 0xe6, 0xea, 0x6d, 0xee, 0xc8, 0xf8,
203  0xaf );
204  MEMCPY_TEST_CONSTANT ( 0x86, 0x6d, 0xb0, 0xf5, 0xf2, 0xc9, 0xcd, 0xfe,
205  0xfb, 0x38, 0x67, 0xbc, 0x51, 0x9d, 0x25, 0xbc,
206  0x09, 0x88 );
207  MEMCPY_TEST_CONSTANT ( 0x58, 0xa4, 0x96, 0x9e, 0x98, 0x36, 0xdb, 0xae,
208  0x8a, 0x08, 0x7c, 0x64, 0xf9, 0xfb, 0x25, 0xb4,
209  0x8e, 0xf3, 0xed );
210  MEMCPY_TEST_CONSTANT ( 0xc6, 0x3b, 0x84, 0x3c, 0x76, 0x24, 0x8e, 0x42,
211  0x11, 0x1f, 0x09, 0x2e, 0x24, 0xbb, 0x67, 0x71,
212  0x3a, 0xca, 0x60, 0xdd );
213  MEMCPY_TEST_CONSTANT ( 0x8e, 0x2d, 0xa9, 0x58, 0x87, 0xe2, 0xac, 0x4b,
214  0xc8, 0xbf, 0xa2, 0x4e, 0xee, 0x3a, 0xa6, 0x71,
215  0x76, 0xee, 0x42, 0x05, 0x6e );
216  MEMCPY_TEST_CONSTANT ( 0x8a, 0xda, 0xdf, 0x7b, 0x55, 0x41, 0x8c, 0xcd,
217  0x42, 0x40, 0x18, 0xe2, 0x60, 0xc4, 0x7d, 0x64,
218  0x00, 0xd5, 0xef, 0xa1, 0x7b, 0x31 );
219  MEMCPY_TEST_CONSTANT ( 0xd9, 0x25, 0xcb, 0xbb, 0x9c, 0x1d, 0xdd, 0xcd,
220  0xde, 0x96, 0xd9, 0x74, 0x13, 0x95, 0xfe, 0x68,
221  0x0b, 0x3d, 0x30, 0x8d, 0x0c, 0x1e, 0x6d );
222  MEMCPY_TEST_CONSTANT ( 0x2d, 0x0d, 0x02, 0x33, 0xd6, 0xbe, 0x6c, 0xa6,
223  0x0a, 0xab, 0xe5, 0xda, 0xe2, 0xab, 0x78, 0x3c,
224  0xd3, 0xdd, 0xea, 0xfa, 0x1a, 0xe4, 0xf4, 0xb3 );
225  MEMCPY_TEST_CONSTANT ( 0x6a, 0x34, 0x39, 0xea, 0x29, 0x5f, 0xa6, 0x18,
226  0xc1, 0x53, 0x39, 0x78, 0xdb, 0x40, 0xf2, 0x98,
227  0x78, 0xcf, 0xee, 0xfd, 0xcd, 0xf8, 0x56, 0xf8,
228  0x30 );
229  MEMCPY_TEST_CONSTANT ( 0xe4, 0xe5, 0x5a, 0x8d, 0xcf, 0x04, 0x29, 0x7c,
230  0xa7, 0xd8, 0x43, 0xbf, 0x0b, 0xbf, 0xe7, 0x68,
231  0xf7, 0x8c, 0x81, 0xf9, 0x3f, 0xad, 0xa4, 0x40,
232  0x38, 0x82 );
233  MEMCPY_TEST_CONSTANT ( 0x71, 0xcd, 0x3d, 0x26, 0xde, 0x11, 0x23, 0xd5,
234  0x42, 0x6e, 0x63, 0x72, 0x53, 0xfc, 0x28, 0x06,
235  0x4b, 0xe0, 0x2c, 0x07, 0x6b, 0xe8, 0xd9, 0x5f,
236  0xf8, 0x74, 0xed );
237  MEMCPY_TEST_CONSTANT ( 0x05, 0xb2, 0xae, 0x81, 0x91, 0xc9, 0xa2, 0x5f,
238  0xa9, 0x1b, 0x25, 0x7f, 0x32, 0x0c, 0x04, 0x00,
239  0xf1, 0x46, 0xab, 0x77, 0x1e, 0x12, 0x27, 0xe7,
240  0xf6, 0x1e, 0x0c, 0x29 );
241  MEMCPY_TEST_CONSTANT ( 0x0e, 0xca, 0xa5, 0x56, 0x3d, 0x99, 0x99, 0xf9,
242  0x6e, 0xdd, 0x93, 0x98, 0xec, 0x8b, 0x5c, 0x71,
243  0x0c, 0xb0, 0xe6, 0x12, 0xf2, 0x10, 0x1a, 0xbe,
244  0x4a, 0xe0, 0xe3, 0x00, 0xf8 );
245  MEMCPY_TEST_CONSTANT ( 0x40, 0xa8, 0x28, 0x5b, 0x12, 0x0d, 0x80, 0x8e,
246  0x8a, 0xd9, 0x92, 0x7a, 0x6e, 0x48, 0x8d, 0x14,
247  0x4b, 0xc6, 0xce, 0x21, 0x2f, 0x0e, 0x47, 0xbd,
248  0xf1, 0xca, 0x0e, 0x1f, 0x65, 0xc4 );
249  MEMCPY_TEST_CONSTANT ( 0x84, 0x83, 0x44, 0xe8, 0x1c, 0xbf, 0x23, 0x05,
250  0xdf, 0xed, 0x3b, 0xb7, 0x0b, 0x4a, 0x05, 0xec,
251  0xb7, 0x6f, 0x1c, 0xfe, 0x05, 0x05, 0x4e, 0xd1,
252  0x50, 0x88, 0x81, 0x87, 0x68, 0xf6, 0x66 );
253  MEMCPY_TEST_CONSTANT ( 0x0d, 0x1d, 0xcf, 0x3e, 0x7c, 0xf8, 0x12, 0x1b,
254  0x96, 0x7f, 0xff, 0x27, 0xca, 0xfe, 0xd3, 0x8b,
255  0x10, 0xb9, 0x5d, 0x05, 0xad, 0x50, 0xed, 0x35,
256  0x32, 0x9c, 0xe6, 0x3b, 0x73, 0xe0, 0x7d );
257 
258  /* Speed tests */
259  memcpy_test_speed ( 0, 0, 64 );
260  memcpy_test_speed ( 0, 0, 128 );
261  memcpy_test_speed ( 0, 0, 256 );
262  for ( dest_offset = 0 ; dest_offset < 4 ; dest_offset++ ) {
263  for ( src_offset = 0 ; src_offset < 4 ; src_offset++ ) {
264  memcpy_test_speed ( dest_offset, src_offset, 4096 );
265  }
266  }
267 }
static void memcpy_test_speed(unsigned int dest_offset, unsigned int src_offset, size_t len)
Test memcpy() speed.
Definition: memcpy_test.c:128
#define MEMCPY_TEST_CONSTANT(...)
Perform a constant-length memcpy() test.
Definition: memcpy_test.c:97

References MEMCPY_TEST_CONSTANT, and memcpy_test_speed().

Variable Documentation

◆ __self_test

struct self_test memcpy_test __self_test
Initial value:
= {
.name = "memcpy",
}
static void memcpy_test_exec(void)
Perform memcpy() self-tests.
Definition: memcpy_test.c:171

memcpy() self-test

Definition at line 270 of file memcpy_test.c.