【发布时间】:2015-04-26 17:05:54
【问题描述】:
我尝试在我的“SunOS sun4v 5.10”系统上编译 Csmith,但出现如下错误:
platform.cpp: In function 'long unsigned int platform_gen_seed()':
platform.cpp:78: error: impossible constraint in 'asm'
谁能告诉错误在哪里?
#if (TARGET_CPU_powerpc == 1 || TARGET_CPU_powerpc64 == 1)
/*For PPC, got from:
http://lists.ozlabs.org/pipermail/linuxppc-dev/1999-October/003889.html
*/
static unsigned long long read_time(void) {
unsigned long long retval;
unsigned long junk;
__asm__ __volatile__ ("\n\
1: mftbu %1\n\
mftb %L0\n\
mftbu %0\n\
cmpw %0,%1\n\
bne 1b"
: "=r" (retval), "=r" (junk));
return retval;
}
#else
#ifdef WIN32
static unsigned __int64 read_time(void) {
unsigned l, h;
_asm {rdtsc
mov l, eax
mov h, edx
}
return (h << 32) + l ;
}
#else
static long long read_time(void) {
long long l;
asm volatile( "rdtsc\n\t"
: "=A" (l)
);
return l;
}
#endif
#endif
unsigned long platform_gen_seed()
{
return (long) read_time();
}
【问题讨论】:
-
有助于了解第 78 行,或者至少知道您使用的是什么架构,这样我们就可以决定正在编译哪个 asm 块。
-
几乎可以肯定是最后一个
asm块;第一个用于 PowerPC,这似乎不太可能,第二个用于 MSVC,不会生成该错误消息。 -
@Jester line 78 is
asm volatile( "rdtsc\n\t" : "=A" (l) );我尝试在我的系统中编译一个名为 csmith 的测试工具。谢谢。 -
什么架构?我想原作者应该更小心使用
#else... -
@Jester SunOS sun4v 5.10
标签: gcc assembly solaris inline-assembly