From: <fla...@gm...> - 2008-01-03 00:38:11
|
# HG changeset patch # User Diego 'Flameeyes' Pettenò <fla...@gm...> # Date 1199320686 -3600 # Node ID e19ff9a0ec5577f5acd748d10fa8fdf953c4a4c3 # Parent f4249853e7b62f082c635238a1c0445215f9fc61 Make memcpy_method a static constant structure, and replace the name string with an array of characters. Move timing results to a different static array, to reduce the amount of data that would go to .data section. diff -r e19ff9a0ec5577f5acd748d10fa8fdf953c4a4c3 -r f4249853e7b62f082c635238a1c0445215f9fc61 src/xine-utils/memcpy.c --- a/src/xine-utils/memcpy.c Thu Jan 03 01:38:06 2008 +0100 +++ b/src/xine-utils/memcpy.c Thu Jan 03 01:25:57 2008 +0100 @@ -382,29 +382,28 @@ static void *linux_kernel_memcpy(void *t #endif /* _MSC_VER */ #endif /* ARCH_X86 */ -static struct { - const char *const name; +static const struct { + const char name[16]; void *(*const function)(void *to, const void *from, size_t len); - - uint64_t time; /* This type could be used for non-MSC build too! */ uint32_t cpu_require; } memcpy_method[] = { - { NULL, NULL, 0, 0 }, - { "libc memcpy()", memcpy, 0, 0 }, + { "", NULL, 0 }, + { "libc", memcpy, 0 }, #if (defined(ARCH_X86) || defined(ARCH_X86_64)) && !defined(_MSC_VER) - { "linux kernel memcpy()", linux_kernel_memcpy, 0, 0 }, - { "MMX optimized memcpy()", mmx_memcpy, 0, MM_MMX }, - { "MMXEXT optimized memcpy()", mmx2_memcpy, 0, MM_MMXEXT }, - { "SSE optimized memcpy()", sse_memcpy, 0, MM_MMXEXT|MM_SSE }, + { "linux kernel", linux_kernel_memcpy, 0 }, + { "MMX ", mmx_memcpy, MM_MMX }, + { "MMXEXT", mmx2_memcpy, MM_MMXEXT }, + { "SSE", sse_memcpy, MM_MMXEXT|MM_SSE }, #endif /* ARCH_X86 */ #if defined (ARCH_PPC) && !defined (HOST_OS_DARWIN) - { "ppcasm_memcpy()", ppcasm_memcpy, 0, 0 }, - { "ppcasm_cacheable_memcpy()", ppcasm_cacheable_memcpy, 0, MM_ACCEL_PPC_CACHE32 }, + { "ppcasm", ppcasm_memcpy, 0 }, + { "ppcasm_cached", ppcasm_cacheable_memcpy, MM_ACCEL_PPC_CACHE32 }, #endif /* ARCH_PPC && !HOST_OS_DARWIN */ - { NULL, NULL, 0, 0 } }; + +static uint64_t memcpy_timing[sizeof(memcpy_method)/sizeof(memcpy_method[0])] = { 0, }; #if (defined(ARCH_X86) || defined(ARCH_X86_64)) && defined(HAVE_SYS_TIMES_H) static int64_t rdtsc(int config_flags) @@ -446,7 +445,7 @@ static void update_fast_memcpy(void *use if (method != 0 && (config_flags & memcpy_method[method].cpu_require) == memcpy_method[method].cpu_require ) { - lprintf("using %s\n", memcpy_method[method].name ); + lprintf("using %s memcpy()\n", memcpy_method[method].name ); xine_fast_memcpy = memcpy_method[method].function; return; } else { @@ -487,7 +486,7 @@ void xine_probe_fast_memcpy(xine_t *xine if( best != 0 && (config_flags & memcpy_method[best].cpu_require) == memcpy_method[best].cpu_require ) { - lprintf("using %s\n", memcpy_method[best].name ); + lprintf("using %s memcpy()\n", memcpy_method[best].name ); xine_fast_memcpy = memcpy_method[best].function; return; } @@ -509,7 +508,7 @@ void xine_probe_fast_memcpy(xine_t *xine memset(buf1,0,BUFSIZE); memset(buf2,0,BUFSIZE); - for(i=1; memcpy_method[i].name; i++) + for(i = 1; i < sizeof(memcpy_method)/sizeof(memcpy_method[0]); i++) { if( (config_flags & memcpy_method[i].cpu_require) != memcpy_method[i].cpu_require ) @@ -522,11 +521,11 @@ void xine_probe_fast_memcpy(xine_t *xine } t = rdtsc(config_flags) - t; - memcpy_method[i].time = t; - - xprintf(xine, XINE_VERBOSITY_LOG, "\t%s : %" PRIu64 "\n", memcpy_method[i].name, t); - - if( best == 0 || t < memcpy_method[best].time ) + memcpy_timing[i] = t; + + xprintf(xine, XINE_VERBOSITY_LOG, "\t%s memcpy() : %" PRIu64 "\n", memcpy_method[i].name, t); + + if( best == 0 || t < memcpy_timing[best] ) best = i; } |