github.com/neonyo/sys@v0.0.0-20230720094341-b1ee14be3ce8/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 // +build 386 amd64 amd64p32 7 // +build gccgo 8 9 #include <cpuid.h> 10 #include <stdint.h> 11 #include <x86intrin.h> 12 13 // Need to wrap __get_cpuid_count because it's declared as static. 14 int 15 gccgoGetCpuidCount(uint32_t leaf, uint32_t subleaf, 16 uint32_t *eax, uint32_t *ebx, 17 uint32_t *ecx, uint32_t *edx) 18 { 19 return __get_cpuid_count(leaf, subleaf, eax, ebx, ecx, edx); 20 } 21 22 #pragma GCC diagnostic ignored "-Wunknown-pragmas" 23 #pragma GCC push_options 24 #pragma GCC target("xsave") 25 #pragma clang attribute push (__attribute__((target("xsave"))), apply_to=function) 26 27 // xgetbv reads the contents of an XCR (Extended Control Register) 28 // specified in the ECX register into registers EDX:EAX. 29 // Currently, the only supported value for XCR is 0. 30 void 31 gccgoXgetbv(uint32_t *eax, uint32_t *edx) 32 { 33 uint64_t v = _xgetbv(0); 34 *eax = v & 0xffffffff; 35 *edx = v >> 32; 36 } 37 38 #pragma clang attribute pop 39 #pragma GCC pop_options