detect_x86.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file.
  2. //go:build (386 && !gccgo && !noasm && !appengine) || (amd64 && !gccgo && !noasm && !appengine)
  3. // +build 386,!gccgo,!noasm,!appengine amd64,!gccgo,!noasm,!appengine
  4. package cpuid
  5. func asmCpuid(op uint32) (eax, ebx, ecx, edx uint32)
  6. func asmCpuidex(op, op2 uint32) (eax, ebx, ecx, edx uint32)
  7. func asmXgetbv(index uint32) (eax, edx uint32)
  8. func asmRdtscpAsm() (eax, ebx, ecx, edx uint32)
  9. func asmDarwinHasAVX512() bool
  10. func initCPU() {
  11. cpuid = asmCpuid
  12. cpuidex = asmCpuidex
  13. xgetbv = asmXgetbv
  14. rdtscpAsm = asmRdtscpAsm
  15. darwinHasAVX512 = asmDarwinHasAVX512
  16. }
  17. func addInfo(c *CPUInfo, safe bool) {
  18. c.maxFunc = maxFunctionID()
  19. c.maxExFunc = maxExtendedFunction()
  20. c.BrandName = brandName()
  21. c.CacheLine = cacheLine()
  22. c.Family, c.Model, c.Stepping = familyModel()
  23. c.featureSet = support()
  24. c.SGX = hasSGX(c.featureSet.inSet(SGX), c.featureSet.inSet(SGXLC))
  25. c.ThreadsPerCore = threadsPerCore()
  26. c.LogicalCores = logicalCores()
  27. c.PhysicalCores = physicalCores()
  28. c.VendorID, c.VendorString = vendorID()
  29. c.cacheSize()
  30. c.frequencies()
  31. }