我想使用cpuid指令来识别Intel CPU的功能。我在Kernel.framework中找到了cpuid.h头文件,所以我将Kernel.framework添加到了我的项目中,并在我的源文件中包含了<Kernel/i386/cpuid.h>
。那生产如何在Mac框架中调用cpuid指令?
kern/kern_types.h: No such file or directory
我不明白。但是我认为我想使用的功能do_cpuid
是内联定义的,所以我尝试将其复制到我的源代码中。
static inline void
do_cpuid(uint32_t selector, uint32_t *data)
{
asm("cpuid"
: "=a" (data[0]),
"=b" (data[1]),
"=c" (data[2]),
"=d" (data[3])
: "a"(selector));
}
这给了我的错误:
error: can't find a register in class 'BREG' while reloading 'asm'
error: 'asm' operand has impossible constraints
谷歌搜索的错误导致我这样一个问题:Problem on Mac : "Can't find a register in class BREG while reloading asm"
但是解决这个问题是使用动态无pic选项(编译设置),Xcode对编译设置的帮助表示“不适合共享库(它们需要与位置无关)”。我正在构建一个框架,我认为这是一个共享库。那我该如何做这项工作?