Intrinsics for CPUID like informations?

后端 未结 5 1712
夕颜
夕颜 2020-11-29 10:12

Considering that I\'m coding in C++, if possible, I would like to use an Intrinsics-like solution to read useful informations about the hardware, my concerns/considerations

5条回答
  •  难免孤独
    2020-11-29 10:39

    After some digging I have found a useful built-in functions that is gcc specific.

    The only problem is that this kind of functions are really limited ( basically you have only 2 functions, 1 for the CPU "name" and 1 for the set of registers )

    an example is

    #include 
    
    int main()
    {
        if (__builtin_cpu_supports("mmx")) {
            printf("\nI got MMX !\n");
        } else
            printf("\nWhat ? MMX ? What is that ?\n");
        return (0);
    }
    

    and apparently this built-in functions work under mingw-w64 too.

提交回复
热议问题