summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-12-13 19:41:04 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-12-13 19:41:04 +0000
commit799e4dc9f2da787e3fe7703afc471dd7e912f5da (patch)
tree6dcb080e2af3bba6231b64c25ce917339940cc76
parent1dc71f66ca23249a4b2be870db09586367feaace (diff)
downloadxine-lib-799e4dc9f2da787e3fe7703afc471dd7e912f5da.tar.gz
xine-lib-799e4dc9f2da787e3fe7703afc471dd7e912f5da.tar.bz2
avoid rdtsc with old cpus
make sure pages are mapped CVS patchset: 3512 CVS date: 2002/12/13 19:41:04
-rw-r--r--src/xine-utils/memcpy.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/xine-utils/memcpy.c b/src/xine-utils/memcpy.c
index db47e95c4..e10cd43ee 100644
--- a/src/xine-utils/memcpy.c
+++ b/src/xine-utils/memcpy.c
@@ -384,14 +384,20 @@ static struct {
};
#ifdef ARCH_X86
-static unsigned long long int rdtsc()
+static unsigned long long int rdtsc(int config_flags)
{
unsigned long long int x;
- __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
- return x;
+
+ /* that should prevent us from trying cpuid with old cpus */
+ if( config_flags & MM_MMX ) {
+ __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
+ return x;
+ } else {
+ return times(NULL);
+ }
}
#else
-static unsigned long long int rdtsc()
+static unsigned long long int rdtsc(int config_flags)
{
/* FIXME: implement an equivalent for using optimized memcpy on other
architectures */
@@ -472,7 +478,8 @@ void xine_probe_fast_memcpy(config_values_t *config)
printf("Benchmarking memcpy methods (smaller is better):\n");
/* make sure buffers are present on physical memory */
- memcpy(buf1,buf2,BUFSIZE);
+ memset(buf1,0,BUFSIZE);
+ memset(buf2,0,BUFSIZE);
for(i=1; memcpy_method[i].name; i++)
{
@@ -480,13 +487,13 @@ void xine_probe_fast_memcpy(config_values_t *config)
memcpy_method[i].cpu_require )
continue;
- t = rdtsc();
+ t = rdtsc(config_flags);
for(j=0;j<50;j++) {
memcpy_method[i].function(buf2,buf1,BUFSIZE);
memcpy_method[i].function(buf1,buf2,BUFSIZE);
}
- t = rdtsc() - t;
+ t = rdtsc(config_flags) - t;
memcpy_method[i].time = t;
printf("\t%s : %lld\n",memcpy_method[i].name, t);