aboutsummaryrefslogtreecommitdiff
path: root/src/hash
diff options
context:
space:
mode:
authorOlivier Mengué <olivier.mengue@gmail.com>2024-01-16 23:30:12 +0100
committerGopher Robot <gobot@golang.org>2024-02-19 20:44:20 +0000
commit0882ca7a73639c3886ed7673c59d2a7f489cb9e4 (patch)
tree46a631c0e0d702664c6540b5f0d69dffd4ed376d /src/hash
parent7ecef2e3448db347901826c2b58049e73391d631 (diff)
downloadgo-0882ca7a73639c3886ed7673c59d2a7f489cb9e4.tar.gz
go-0882ca7a73639c3886ed7673c59d2a7f489cb9e4.zip
hash/crc32: fix code generator to use the Go standard
Apply the Go standard for code generation (https://go.dev/s/generatedcode) to generated crc32_table_ppc64le.s despites this is not generated Go but Assembly. This is to help prevent changes like CL 478976 that changed the generated output without fixing the generator. Add gen.go to allow to launch code generation with "go generate". Change-Id: I8671284265425826c8620dbec055519b992fa04e Reviewed-on: https://go-review.googlesource.com/c/go/+/556335 Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/hash')
-rw-r--r--src/hash/crc32/crc32_table_ppc64le.s3
-rw-r--r--src/hash/crc32/gen.go7
-rw-r--r--src/hash/crc32/gen_const_ppc64le.go8
3 files changed, 12 insertions, 6 deletions
diff --git a/src/hash/crc32/crc32_table_ppc64le.s b/src/hash/crc32/crc32_table_ppc64le.s
index 453df12df4..eb9ab31a04 100644
--- a/src/hash/crc32/crc32_table_ppc64le.s
+++ b/src/hash/crc32/crc32_table_ppc64le.s
@@ -1,5 +1,4 @@
-// autogenerated: do not edit!
-// generated from crc32/gen_const_ppc64le.go
+// Code generated by "go run gen_const_ppc64le.go"; DO NOT EDIT.
#include "textflag.h"
diff --git a/src/hash/crc32/gen.go b/src/hash/crc32/gen.go
new file mode 100644
index 0000000000..fb3040a7dc
--- /dev/null
+++ b/src/hash/crc32/gen.go
@@ -0,0 +1,7 @@
+// Copyright 2023 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:generate go run gen_const_ppc64le.go
+
+package crc32
diff --git a/src/hash/crc32/gen_const_ppc64le.go b/src/hash/crc32/gen_const_ppc64le.go
index 4c1b79579f..9e51328118 100644
--- a/src/hash/crc32/gen_const_ppc64le.go
+++ b/src/hash/crc32/gen_const_ppc64le.go
@@ -89,10 +89,10 @@ func xnmodp(n uint, poly uint64, deg uint) (uint64, uint64) {
func main() {
w := new(bytes.Buffer)
- fmt.Fprintf(w, "// autogenerated: do not edit!\n")
- fmt.Fprintf(w, "// generated from crc32/gen_const_ppc64le.go\n")
+ // Standard: https://go.dev/s/generatedcode
+ fmt.Fprintln(w, `// Code generated by "go run gen_const_ppc64le.go"; DO NOT EDIT.`)
fmt.Fprintln(w)
- fmt.Fprintf(w, "#include \"textflag.h\"\n")
+ fmt.Fprintln(w, `#include "textflag.h"`)
// These are the polynomials supported in vector now.
// If adding others, include the polynomial and a name
@@ -105,7 +105,7 @@ func main() {
err := os.WriteFile("crc32_table_ppc64le.s", b, 0666)
if err != nil {
- fmt.Printf("can't write output: %s\n", err)
+ fmt.Fprintf(os.Stderr, "can't write output: %s\n", err)
}
}