diff options
author | austriancoder <austriancoder> | 2004-10-04 21:09:34 +0000 |
---|---|---|
committer | austriancoder <austriancoder> | 2004-10-04 21:09:34 +0000 |
commit | 6e40c29e483fd3eb70d35b76ee7992397498bf9a (patch) | |
tree | 9d62123d5b0e2bee43830f270ba7e1f54ce3f3c1 /dxr3memcpy.c | |
parent | 47e5051fb4e5ea6594b00fe10af583df473493e0 (diff) | |
download | vdr-plugin-dxr3-6e40c29e483fd3eb70d35b76ee7992397498bf9a.tar.gz vdr-plugin-dxr3-6e40c29e483fd3eb70d35b76ee7992397498bf9a.tar.bz2 |
- extended cDxr3MemcpyBench::Rdtsc(uint32_t config_flags)
support for non x86 arch
support for cpu's, which dont support rdtsc timing
Diffstat (limited to 'dxr3memcpy.c')
-rw-r--r-- | dxr3memcpy.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/dxr3memcpy.c b/dxr3memcpy.c index 1b5f564..c50b350 100644 --- a/dxr3memcpy.c +++ b/dxr3memcpy.c @@ -34,7 +34,12 @@ #include "dxr3log.h" #include "dxr3cpu.h" #include "dxr3memcpy.h" +#include <sys/times.h> +#include <limits.h> + +// ================================== +//! our function pointer void *(* dxr3_memcpy)(void *to, const void *from, size_t len); #ifdef __i386__ @@ -54,7 +59,7 @@ __asm__ __volatile__(\ } */ // ================================== -// linux kernel __memcpy (from: /include/asm/string.h) +//! linux kernel __memcpy (from: /include/asm/string.h) static __inline__ void * __memcpy ( void * to, const void * from, @@ -312,7 +317,7 @@ static void *linux_kernel_memcpy(void *to, const void *from, size_t len) { // ================================== -// constr. +//! constr. cDxr3MemcpyBench::cDxr3MemcpyBench(uint32_t config_flags) { // @@ -389,13 +394,13 @@ cDxr3MemcpyBench::cDxr3MemcpyBench(uint32_t config_flags) } // count 100 runs of the memcpy function - t = Rdtsc(); + t = Rdtsc(config_flags); for (j = 0; j < 50; j++) { m_methods[i].function(buf2,buf1,BUFSIZE); m_methods[i].function(buf1,buf2,BUFSIZE); } - t = Rdtsc() - t; + t = Rdtsc(config_flags) - t; m_methods[i].time = t; @@ -417,16 +422,27 @@ cDxr3MemcpyBench::cDxr3MemcpyBench(uint32_t config_flags) } // ================================== -// neede for exact timing -unsigned long long int cDxr3MemcpyBench::Rdtsc() +//! needed for exact timing +#ifdef __i386__ +unsigned long long int cDxr3MemcpyBench::Rdtsc(uint32_t config_flags) { - #ifdef __i386__ - unsigned long long int x; - __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)); - return x; - #else - /* FIXME: implement an equivalent for using optimized memcpy on other - architectures */ - return 0; - #endif + // we need rdtsc support + if (config_flags && CC_MMX) + { + unsigned long long int x; + __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)); + return x; + } + else + { + return times(NULL); + } + +} +#else +unsigned long long int cDxr3MemcpyBench::Rdtsc(uint32_t config_flags) +{ + struct tms tp; + return times(&tp); } +#endif
\ No newline at end of file |