diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2011-11-18 18:22:07 +0000 |
---|---|---|
committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2011-11-18 18:22:07 +0000 |
commit | 2a0fe10e3e5dd6da617d9f7f675e0778be957314 (patch) | |
tree | 5a1b4631f335fecb4c1bb6d24ec45ff4d8c3e413 | |
parent | 817593b5183d6bd79c62dbc31de2f24d74a288b3 (diff) | |
download | xine-lib-2a0fe10e3e5dd6da617d9f7f675e0778be957314.tar.gz xine-lib-2a0fe10e3e5dd6da617d9f7f675e0778be957314.tar.bz2 |
Use POSIX timers where available for determining which memcpy method to use.
-rw-r--r-- | src/xine-utils/memcpy.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/xine-utils/memcpy.c b/src/xine-utils/memcpy.c index 9056749e2..fa568c485 100644 --- a/src/xine-utils/memcpy.c +++ b/src/xine-utils/memcpy.c @@ -408,7 +408,18 @@ static struct { { NULL, NULL, 0, 0 } }; -#if (defined(ARCH_X86) || defined(ARCH_X86_64)) && defined(HAVE_SYS_TIMES_H) +#ifdef HAVE_POSIX_TIMERS +/* Prefer clock_gettime() where available. */ +static int64_t _x_gettime(void) +{ + struct timespec tm; + return (clock_gettime (CLOCK_THREAD_CPUTIME_ID, &tm) == -1) + ? times (NULL) + : (int64_t)tm.tv_sec * 1e9 + tm.tv_nsec; +} +# define rdtsc(x) _x_gettime() + +#elif (defined(ARCH_X86) || defined(ARCH_X86_64)) && defined(HAVE_SYS_TIMES_H) static int64_t rdtsc(int config_flags) { int64_t x; @@ -511,6 +522,12 @@ void xine_probe_fast_memcpy(xine_t *xine) memset(buf1,0,BUFSIZE); memset(buf2,0,BUFSIZE); + /* some initial activity to ensure that we're not running slowly :-) */ + for(j=0;j<50;j++) { + memcpy_method[i].function(buf2,buf1,BUFSIZE); + memcpy_method[i].function(buf1,buf2,BUFSIZE); + } + for(i=1; memcpy_method[i].name; i++) { if( (config_flags & memcpy_method[i].cpu_require) != |