aboutsummaryrefslogtreecommitdiff
path: root/src/internal/cpu/cpu.go
diff options
context:
space:
mode:
authorMartin Möhrmann <moehrmann@google.com>2018-10-23 23:39:29 +0200
committerMartin Möhrmann <martisch@uos.de>2018-10-24 06:27:53 +0000
commit980340ade7acb057c2e0e244a4002c96274f8a77 (patch)
tree64c97e360eba8dc5a92231c558a780bbeaed1ba4 /src/internal/cpu/cpu.go
parent1e38ecdbbee983a049500102af9e50ee33b446a8 (diff)
downloadgo-980340ade7acb057c2e0e244a4002c96274f8a77.tar.xz
internal/cpu: add options and warnings for required cpu features
Updates #27218 Change-Id: I8603f3a639cdd9ee201c4f1566692e5b88877fc4 Reviewed-on: https://go-review.googlesource.com/c/144107 Run-TryBot: Martin Möhrmann <martisch@uos.de> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/internal/cpu/cpu.go')
-rw-r--r--src/internal/cpu/cpu.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/internal/cpu/cpu.go b/src/internal/cpu/cpu.go
index 925e4f7f6e..5e38ff7703 100644
--- a/src/internal/cpu/cpu.go
+++ b/src/internal/cpu/cpu.go
@@ -155,8 +155,9 @@ var options []option
type option struct {
Name string
Feature *bool
- Specified bool // Stores if feature value was specified in GODEBUGCPU.
- Enable bool // Stores if feature should be enabled.
+ Specified bool // whether feature value was specified in GODEBUGCPU
+ Enable bool // whether feature should be enabled
+ Required bool // whether feature is mandatory and can not be disabled
}
// processOptions enables or disables CPU feature values based on the parsed env string.
@@ -196,7 +197,7 @@ field:
if key == "all" {
for i := range options {
options[i].Specified = true
- options[i].Enable = enable
+ options[i].Enable = enable || options[i].Required
}
continue field
}
@@ -222,6 +223,11 @@ field:
continue
}
+ if !o.Enable && o.Required {
+ print("GODEBUGCPU: can not disable \"", o.Name, "\", required feature\n")
+ continue
+ }
+
*o.Feature = o.Enable
}
}