impossible constraint in 'asm' error

你说的曾经没有我的故事 提交于 2020-01-06 06:53:44

问题


I'm trying to cross-compile a c++ file with arm-linux-gnueabi-g++.:

make CROSS_COMPILE=arm-linux-gnueabi- all

But an error occurs:

arm-linux-gnueabi-g++ -O2 -c -oa32.o PMCTestA.cpp
In file included from PMCTest.h:54:0,
                 from PMCTestA.cpp:24:
PMCTestLinux.h: In member function ‘void CCounters::GetProcessorVendor()’:
PMCTestLinux.h:63:73: error: impossible constraint in ‘asm’
make: *** [a32.o] Error 1

And here is part of the code in PMCTestLinux.h from row 61:

static void Cpuid (int Output[4], int aa) { 
    int a, b, c, d;
    __asm("cpuid" : "=a"(a),"=b"(b),"=c"(c),"=d"(d) : "a"(aa),"c"(0) : );
    Output[0] = a;
    Output[1] = b;
    Output[2] = c;
    Output[3] = d;
}

static inline void Serialize () {
    // serialize CPU
    __asm__ __volatile__ ( "xorl %%eax, %%eax \n cpuid " : : : "%eax","%ebx","%ecx","%edx" );
}

static inline int Readtsc() {
    // read time stamp counter
    int r;
    __asm__ __volatile__ ( "rdtsc" : "=a"(r) : : "%edx");    
    return r;
}

static inline int Readpmc(int nPerfCtr) {
    // read performance monitor counter number nPerfCtr
    int r;
    __asm__ __volatile__ ( "rdpmc" : "=a"(r) : "c"(nPerfCtr) : "%edx");    
    return r;
}

Does anyone know something about this error? I'm not sure if the problem is about the compiler. My system is Ubuntu 10.04 and the version of arm-linux-gnueabi-g++ is 4.7.3

来源:https://stackoverflow.com/questions/30918170/impossible-constraint-in-asm-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!