diff options
| author | Rutger Broekhoff | 2023-12-29 21:31:53 +0100 |
|---|---|---|
| committer | Rutger Broekhoff | 2023-12-29 21:31:53 +0100 |
| commit | 404aeae4545d2426c089a5f8d5e82dae56f5212b (patch) | |
| tree | 2d84e00af272b39fc04f3795ae06bc48970e57b5 /vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c | |
| parent | 209d8b0187ed025dec9ac149ebcced3462877bff (diff) | |
| download | gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.tar.gz gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.zip | |
Make Nix builds work
Diffstat (limited to 'vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c')
| -rw-r--r-- | vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c b/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c new file mode 100644 index 0000000..3f73a05 --- /dev/null +++ b/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c | |||
| @@ -0,0 +1,37 @@ | |||
| 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 | ||