- 论坛徽章:
- 4
|
如题, 如何在mips16上实现__x86_64__定义下的rdtsc:
static inline uint64_t
rdtsc(void)
{
#if defined(BENCHMARK_OS_MACOSX) || defined(__x86_64__) || defined(__amd64__)
union {
uint64_t tsc_64;
struct {
uint32_t lo_32;
uint32_t hi_32;
};
} tsc;
asm volatile("rdtsc" :
"=a" (tsc.lo_32),
"=d" (tsc.hi_32));
return tsc.tsc_64;
#elif defined(__mips__)
uint64_t dest;
//__asm__ __volatile__("mfc0 %0,$9;nop":"=r"(dest));
return dest;
#else
#error "11111111111"
return 0;
#endif
}
在google上搜索了半天只发现如下实现,
__asm__ __volatile__("mfc0 %0,$9;nop":"=r"(dest));
同时需要在Makfile中指定 "PKG_USE_MIPS16:=0" 编译, 否则会找不到指令"mfc0",
但是发生令人意外的结果(在AR9531上运行出现内部错误)
在此寻求各位大神,如何实现上述功能代码, 先感谢下
|
|