From a2a95425350da93551388acdca8a00818a34c317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Thu, 3 Jan 2008 01:38:06 +0100 Subject: 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. --- src/xine-utils/memcpy.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/xine-utils/memcpy.c b/src/xine-utils/memcpy.c index fc42f3399..45009d23c 100644 --- a/src/xine-utils/memcpy.c +++ b/src/xine-utils/memcpy.c @@ -382,30 +382,29 @@ static void *linux_kernel_memcpy(void *to, const void *from, size_t len) { #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 *user_data, xine_cfg_entry_t *entry) { 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; + memcpy_timing[i] = t; - xprintf(xine, XINE_VERBOSITY_LOG, "\t%s : %" PRIu64 "\n", memcpy_method[i].name, t); + xprintf(xine, XINE_VERBOSITY_LOG, "\t%s memcpy() : %" PRIu64 "\n", memcpy_method[i].name, t); - if( best == 0 || t < memcpy_method[best].time ) + if( best == 0 || t < memcpy_timing[best] ) best = i; } -- cgit v1.2.3