github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/vendor_skip/golang.org/x/sys/cpu/cpu_gccgo_x86.c (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build (386 || amd64 || amd64p32) && gccgo 6 7 #include <cpuid.h> 8 #include <stdint.h> 9 #include <x86intrin.h> 10 11 // Need to wrap __get_cpuid_count because it's declared as static. 12 int 13 gccgoGetCpuidCount(uint32_t leaf, uint32_t subleaf, 14 uint32_t *eax, uint32_t *ebx, 15 uint32_t *ecx, uint32_t *edx) 16 { 17 return __get_cpuid_count(leaf, subleaf, eax, ebx, ecx, edx); 18 } 19 20 #pragma GCC diagnostic ignored "-Wunknown-pragmas" 21 #pragma GCC push_options 22 #pragma GCC target("xsave") 23 #pragma clang attribute push (__attribute__((target("xsave"))), apply_to=function) 24 25 // xgetbv reads the contents of an XCR (Extended Control Register) 26 // specified in the ECX register into registers EDX:EAX. 27 // Currently, the only supported value for XCR is 0. 28 void 29 gccgoXgetbv(uint32_t *eax, uint32_t *edx) 30 { 31 uint64_t v = _xgetbv(0); 32 *eax = v & 0xffffffff; 33 *edx = v >> 32; 34 } 35 36 #pragma clang attribute pop 37 #pragma GCC pop_options