cpuid.h revision 243830
1241600Sgonzo/*===---- cpuid.h - X86 cpu model detection --------------------------------=== 2241600Sgonzo * 3241600Sgonzo * Permission is hereby granted, free of charge, to any person obtaining a copy 4241600Sgonzo * of this software and associated documentation files (the "Software"), to deal 5241600Sgonzo * in the Software without restriction, including without limitation the rights 6241600Sgonzo * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7241600Sgonzo * copies of the Software, and to permit persons to whom the Software is 8241600Sgonzo * furnished to do so, subject to the following conditions: 9241600Sgonzo * 10241600Sgonzo * The above copyright notice and this permission notice shall be included in 11241600Sgonzo * all copies or substantial portions of the Software. 12241600Sgonzo * 13241600Sgonzo * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14241600Sgonzo * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15241600Sgonzo * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16241600Sgonzo * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17241600Sgonzo * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18241600Sgonzo * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19241600Sgonzo * THE SOFTWARE. 20241600Sgonzo * 21241600Sgonzo *===-----------------------------------------------------------------------=== 22241600Sgonzo */ 23241600Sgonzo 24241600Sgonzo#if !(__x86_64__ || __i386__) 25241600Sgonzo#error this header is for x86 only 26241600Sgonzo#endif 27241600Sgonzo 28241600Sgonzostatic inline int __get_cpuid (unsigned int level, unsigned int *eax, 29241600Sgonzo unsigned int *ebx, unsigned int *ecx, 30241600Sgonzo unsigned int *edx) { 31241600Sgonzo __asm("cpuid" : "=a"(*eax), "=b" (*ebx), "=c"(*ecx), "=d"(*edx) : "0"(level)); 32241600Sgonzo return 1; 33241600Sgonzo} 34241600Sgonzo