42 #define PROFILE_COUNT 16 97 #define MEMCPY_TEST_CONSTANT( ... ) do { \ 98 static const uint8_t src[] = { __VA_ARGS__ }; \ 99 uint8_t dest_const[ 1 + sizeof ( src ) + 1 ]; \ 100 uint8_t dest_var[ 1 + sizeof ( src ) + 1 ]; \ 102 dest_const[0] = 0x33; \ 103 dest_const[ sizeof ( dest_const ) - 1 ] = 0x44; \ 104 memcpy ( ( dest_const + 1 ), src, \ 105 ( sizeof ( dest_const ) - 2 ) ); \ 106 ok ( dest_const[0] == 0x33 ); \ 107 ok ( dest_const[ sizeof ( dest_const ) - 1 ] == 0x44 ); \ 108 ok ( memcmp ( ( dest_const + 1 ), src, \ 109 ( sizeof ( dest_const ) - 2 ) ) == 0 ); \ 111 dest_var[0] = 0x55; \ 112 dest_var[ sizeof ( dest_var ) - 1 ] = 0x66; \ 113 memcpy_var ( ( dest_var + 1 ), src, \ 114 ( sizeof ( dest_var ) - 2 ) ); \ 115 ok ( dest_var[0] == 0x55 ); \ 116 ok ( dest_var[ sizeof ( dest_var ) - 1 ] == 0x66 ); \ 117 ok ( memcmp ( ( dest_var + 1 ), src, \ 118 ( sizeof ( dest_var ) - 2 ) ) == 0 ); \ 129 unsigned int src_offset,
size_t len ) {
142 for ( i = 0 ; i <
len ; i++ )
162 DBG (
"MEMCPY copied %zd bytes (+%d => +%d) in %ld +/- %ld ticks\n",
172 unsigned int dest_offset;
173 unsigned int src_offset;
192 0x1a, 0x1d, 0x57, 0x58 );
194 0x94, 0xe0, 0x3d, 0x57, 0xd4 );
196 0x8e, 0x62, 0xb4, 0x82, 0x7e, 0x02 );
198 0xae, 0x9d, 0xca, 0xec, 0x92, 0xb3, 0x38 );
200 0x85, 0xe6, 0x3c, 0xab, 0x1c, 0xa2, 0xaf, 0x7a );
202 0xa7, 0xb0, 0xe6, 0xea, 0x6d, 0xee, 0xc8, 0xf8,
205 0xfb, 0x38, 0x67, 0xbc, 0x51, 0x9d, 0x25, 0xbc,
208 0x8a, 0x08, 0x7c, 0x64, 0xf9, 0xfb, 0x25, 0xb4,
211 0x11, 0x1f, 0x09, 0x2e, 0x24, 0xbb, 0x67, 0x71,
212 0x3a, 0xca, 0x60, 0xdd );
214 0xc8, 0xbf, 0xa2, 0x4e, 0xee, 0x3a, 0xa6, 0x71,
215 0x76, 0xee, 0x42, 0x05, 0x6e );
217 0x42, 0x40, 0x18, 0xe2, 0x60, 0xc4, 0x7d, 0x64,
218 0x00, 0xd5, 0xef, 0xa1, 0x7b, 0x31 );
220 0xde, 0x96, 0xd9, 0x74, 0x13, 0x95, 0xfe, 0x68,
221 0x0b, 0x3d, 0x30, 0x8d, 0x0c, 0x1e, 0x6d );
223 0x0a, 0xab, 0xe5, 0xda, 0xe2, 0xab, 0x78, 0x3c,
224 0xd3, 0xdd, 0xea, 0xfa, 0x1a, 0xe4, 0xf4, 0xb3 );
226 0xc1, 0x53, 0x39, 0x78, 0xdb, 0x40, 0xf2, 0x98,
227 0x78, 0xcf, 0xee, 0xfd, 0xcd, 0xf8, 0x56, 0xf8,
230 0xa7, 0xd8, 0x43, 0xbf, 0x0b, 0xbf, 0xe7, 0x68,
231 0xf7, 0x8c, 0x81, 0xf9, 0x3f, 0xad, 0xa4, 0x40,
234 0x42, 0x6e, 0x63, 0x72, 0x53, 0xfc, 0x28, 0x06,
235 0x4b, 0xe0, 0x2c, 0x07, 0x6b, 0xe8, 0xd9, 0x5f,
238 0xa9, 0x1b, 0x25, 0x7f, 0x32, 0x0c, 0x04, 0x00,
239 0xf1, 0x46, 0xab, 0x77, 0x1e, 0x12, 0x27, 0xe7,
240 0xf6, 0x1e, 0x0c, 0x29 );
242 0x6e, 0xdd, 0x93, 0x98, 0xec, 0x8b, 0x5c, 0x71,
243 0x0c, 0xb0, 0xe6, 0x12, 0xf2, 0x10, 0x1a, 0xbe,
244 0x4a, 0xe0, 0xe3, 0x00, 0xf8 );
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 );
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 );
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 );
262 for ( dest_offset = 0 ; dest_offset < 4 ; dest_offset++ ) {
263 for ( src_offset = 0 ; src_offset < 4 ; src_offset++ ) {
void memcpy_12(void *dest, void *src)
unsigned long profile_mean(struct profiler *profiler)
Get mean sample value.
void memcpy_7(void *dest, void *src)
void memcpy_17(void *dest, void *src)
void memcpy_29(void *dest, void *src)
void memcpy_0(void *dest, void *src)
void memcpy_15(void *dest, void *src)
void memcpy_21(void *dest, void *src)
Self-test infrastructure.
const char * name
Test set name.
void memcpy_20(void *dest, void *src)
A data structure for storing profiling information.
void memcpy_6(void *dest, void *src)
void memcpy_19(void *dest, void *src)
static void profile_stop(struct profiler *profiler)
Stop profiling.
void memcpy_9(void *dest, void *src)
void memcpy_16(void *dest, void *src)
unsigned long profile_stddev(struct profiler *profiler)
Get sample standard deviation.
void * memcpy_var(void *dest, const void *src, size_t len)
Force a call to the variable-length implementation of memcpy()
void memcpy_4(void *dest, void *src)
void memcpy_2(void *dest, void *src)
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void memcpy_30(void *dest, void *src)
void memcpy_27(void *dest, void *src)
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
void memcpy_5(void *dest, void *src)
void memcpy_23(void *dest, void *src)
void memcpy_11(void *dest, void *src)
static void profile_start(struct profiler *profiler)
Start profiling.
static void(* free)(struct refcnt *refcnt))
void memcpy_18(void *dest, void *src)
void memcpy_28(void *dest, void *src)
void memcpy_3(void *dest, void *src)
long int random(void)
Generate a pseudo-random number between 0 and 2147483647L or 2147483562?
static void memcpy_test_exec(void)
Perform memcpy() self-tests.
void memcpy_25(void *dest, void *src)
static void memcpy_test_speed(unsigned int dest_offset, unsigned int src_offset, size_t len)
Test memcpy() speed.
void memcpy_26(void *dest, void *src)
void * malloc(size_t size)
Allocate memory.
void memcpy_14(void *dest, void *src)
struct self_test memcpy_test __self_test
memcpy() self-test
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void memcpy_10(void *dest, void *src)
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
#define PROFILE_COUNT
Number of sample iterations for profiling.
void memcpy_31(void *dest, void *src)
#define DBG(...)
Print a debugging message.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
#define NULL
NULL pointer (VOID *)
void memcpy_22(void *dest, void *src)
void memcpy_1(void *dest, void *src)
void memcpy_8(void *dest, void *src)
void memcpy_24(void *dest, void *src)
#define MEMCPY_TEST_CONSTANT(...)
Perform a constant-length memcpy() test.
void memcpy_13(void *dest, void *src)
void * memset(void *dest, int character, size_t len) __nonnull