Skip to content

Commit fad6cff

Browse files
committed
feat: update gofmt code from go1.24.4
1 parent f2e10e0 commit fad6cff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1232
-198
lines changed

gofmt/internal/cfg/cfg.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ const KnownEnv = `
3737
GOARCH
3838
GOARM
3939
GOARM64
40+
GOAUTH
4041
GOBIN
4142
GOCACHE
4243
GOCACHEPROG
4344
GOENV
4445
GOEXE
4546
GOEXPERIMENT
47+
GOFIPS140
4648
GOFLAGS
4749
GOGCCFLAGS
4850
GOHOSTARCH

gofmt/internal/goarch/gengoarch.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2014 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 ignore
6+
7+
package main
8+
9+
import (
10+
"bytes"
11+
"fmt"
12+
"log"
13+
"os"
14+
"strings"
15+
)
16+
17+
var goarches []string
18+
19+
func main() {
20+
data, err := os.ReadFile("../../internal/syslist/syslist.go")
21+
if err != nil {
22+
log.Fatal(err)
23+
}
24+
const goarchPrefix = `var KnownArch = map[string]bool{`
25+
inGOARCH := false
26+
for _, line := range strings.Split(string(data), "\n") {
27+
if strings.HasPrefix(line, goarchPrefix) {
28+
inGOARCH = true
29+
} else if inGOARCH && strings.HasPrefix(line, "}") {
30+
break
31+
} else if inGOARCH {
32+
goarch := strings.Fields(line)[0]
33+
goarch = strings.TrimPrefix(goarch, `"`)
34+
goarch = strings.TrimSuffix(goarch, `":`)
35+
goarches = append(goarches, goarch)
36+
}
37+
}
38+
39+
for _, target := range goarches {
40+
if target == "amd64p32" {
41+
continue
42+
}
43+
var buf bytes.Buffer
44+
fmt.Fprintf(&buf, "// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.\n\n")
45+
fmt.Fprintf(&buf, "//go:build %s\n\n", target) // must explicitly include target for bootstrapping purposes
46+
fmt.Fprintf(&buf, "package goarch\n\n")
47+
fmt.Fprintf(&buf, "const GOARCH = `%s`\n\n", target)
48+
for _, goarch := range goarches {
49+
value := 0
50+
if goarch == target {
51+
value = 1
52+
}
53+
fmt.Fprintf(&buf, "const Is%s = %d\n", strings.Title(goarch), value)
54+
}
55+
err := os.WriteFile("zgoarch_"+target+".go", buf.Bytes(), 0666)
56+
if err != nil {
57+
log.Fatal(err)
58+
}
59+
}
60+
}

gofmt/internal/goarch/goarch.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2021 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+
// package goarch contains GOARCH-specific constants.
6+
package goarch
7+
8+
// The next line makes 'go generate' write the zgoarch*.go files with
9+
// per-arch information, including constants named $GOARCH for every
10+
// GOARCH. The constant is 1 on the current system, 0 otherwise; multiplying
11+
// by them is useful for defining GOARCH-specific constants.
12+
//
13+
//go:generate go run gengoarch.go
14+
15+
type ArchFamilyType int
16+
17+
const (
18+
AMD64 ArchFamilyType = iota
19+
ARM
20+
ARM64
21+
I386
22+
LOONG64
23+
MIPS
24+
MIPS64
25+
PPC64
26+
RISCV64
27+
S390X
28+
WASM
29+
)
30+
31+
// PtrSize is the size of a pointer in bytes - unsafe.Sizeof(uintptr(0)) but as an ideal constant.
32+
// It is also the size of the machine's native word size (that is, 4 on 32-bit systems, 8 on 64-bit).
33+
const PtrSize = 4 << (^uintptr(0) >> 63)
34+
35+
// ArchFamily is the architecture family (AMD64, ARM, ...)
36+
const ArchFamily ArchFamilyType = _ArchFamily
37+
38+
// BigEndian reports whether the architecture is big-endian.
39+
const BigEndian = IsArmbe|IsArm64be|IsMips|IsMips64|IsPpc|IsPpc64|IsS390|IsS390x|IsSparc|IsSparc64 == 1
40+
41+
// DefaultPhysPageSize is the default physical page size.
42+
const DefaultPhysPageSize = _DefaultPhysPageSize
43+
44+
// PCQuantum is the minimal unit for a program counter (1 on x86, 4 on most other systems).
45+
// The various PC tables record PC deltas pre-divided by PCQuantum.
46+
const PCQuantum = _PCQuantum
47+
48+
// Int64Align is the required alignment for a 64-bit integer (4 on 32-bit systems, 8 on 64-bit).
49+
const Int64Align = PtrSize
50+
51+
// MinFrameSize is the size of the system-reserved words at the bottom
52+
// of a frame (just above the architectural stack pointer).
53+
// It is zero on x86 and PtrSize on most non-x86 (LR-based) systems.
54+
// On PowerPC it is larger, to cover three more reserved words:
55+
// the compiler word, the link editor word, and the TOC save word.
56+
const MinFrameSize = _MinFrameSize
57+
58+
// StackAlign is the required alignment of the SP register.
59+
// The stack must be at least word aligned, but some architectures require more.
60+
const StackAlign = _StackAlign
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 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+
package goarch
6+
7+
const (
8+
_ArchFamily = I386
9+
_DefaultPhysPageSize = 4096
10+
_PCQuantum = 1
11+
_MinFrameSize = 0
12+
_StackAlign = PtrSize
13+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 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+
package goarch
6+
7+
const (
8+
_ArchFamily = AMD64
9+
_DefaultPhysPageSize = 4096
10+
_PCQuantum = 1
11+
_MinFrameSize = 0
12+
_StackAlign = PtrSize
13+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 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+
package goarch
6+
7+
const (
8+
_ArchFamily = ARM
9+
_DefaultPhysPageSize = 65536
10+
_PCQuantum = 4
11+
_MinFrameSize = 4
12+
_StackAlign = PtrSize
13+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 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+
package goarch
6+
7+
const (
8+
_ArchFamily = ARM64
9+
_DefaultPhysPageSize = 65536
10+
_PCQuantum = 4
11+
_MinFrameSize = 8
12+
_StackAlign = 16
13+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2022 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 loong64
6+
7+
package goarch
8+
9+
const (
10+
_ArchFamily = LOONG64
11+
_DefaultPhysPageSize = 16384
12+
_PCQuantum = 4
13+
_MinFrameSize = 8
14+
_StackAlign = PtrSize
15+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 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+
package goarch
6+
7+
const (
8+
_ArchFamily = MIPS
9+
_DefaultPhysPageSize = 65536
10+
_PCQuantum = 4
11+
_MinFrameSize = 4
12+
_StackAlign = PtrSize
13+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 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+
package goarch
6+
7+
const (
8+
_ArchFamily = MIPS64
9+
_DefaultPhysPageSize = 16384
10+
_PCQuantum = 4
11+
_MinFrameSize = 8
12+
_StackAlign = PtrSize
13+
)

0 commit comments

Comments
 (0)