misc/cgo: gofmt

Change-Id: I5d02279d0593a8368b2f249a6b53650b89aed7b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/482275
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Ian Lance Taylor 2023-04-04 13:59:06 -07:00 committed by Gopher Robot
parent c1ac63e973
commit 7b1e0bb79c
40 changed files with 96 additions and 43 deletions

View File

@ -20,8 +20,9 @@ func Run(gen, x, y int, a []int32) {
// Keep the channels visible from Go. // Keep the channels visible from Go.
var chans [4]chan bool var chans [4]chan bool
//export GoStart
// Double return value is just for testing. // Double return value is just for testing.
//
//export GoStart
func GoStart(i, xdim, ydim, xstart, xend, ystart, yend C.int, a *C.int, n *C.int) (int, int) { func GoStart(i, xdim, ydim, xstart, xend, ystart, yend C.int, a *C.int, n *C.int) (int, int) {
c := make(chan bool, int(C.MYCONST)) c := make(chan bool, int(C.MYCONST))
go func() { go func() {

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build darwin
// +build darwin // +build darwin
package issue24161arg package issue24161arg

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build darwin
// +build darwin // +build darwin
package issue24161arg package issue24161arg

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build darwin
// +build darwin // +build darwin
package issue24161e0 package issue24161e0

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build darwin
// +build darwin // +build darwin
package issue24161e1 package issue24161e1

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build darwin
// +build darwin // +build darwin
package issue24161e2 package issue24161e2

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build darwin
// +build darwin // +build darwin
package issue24161res package issue24161res

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gccgo
// +build gccgo // +build gccgo
package issue9400 package issue9400

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc
// +build gc // +build gc
package issue9400 package issue9400

View File

@ -39,6 +39,7 @@ import (
// RunGoroutines starts some goroutines that don't do anything. // RunGoroutines starts some goroutines that don't do anything.
// The idea is to get some threads going, so that a signal will be delivered // The idea is to get some threads going, so that a signal will be delivered
// to a thread started by Go. // to a thread started by Go.
//
//export RunGoroutines //export RunGoroutines
func RunGoroutines() { func RunGoroutines() {
for i := 0; i < 4; i++ { for i := 0; i < 4; i++ {
@ -50,6 +51,7 @@ func RunGoroutines() {
} }
// Block blocks the current thread while running Go code. // Block blocks the current thread while running Go code.
//
//export Block //export Block
func Block() { func Block() {
select {} select {}
@ -58,6 +60,7 @@ func Block() {
var P *byte var P *byte
// TestSEGV makes sure that an invalid address turns into a run-time Go panic. // TestSEGV makes sure that an invalid address turns into a run-time Go panic.
//
//export TestSEGV //export TestSEGV
func TestSEGV() { func TestSEGV() {
defer func() { defer func() {
@ -72,11 +75,13 @@ func TestSEGV() {
} }
// Noop ensures that the Go runtime is initialized. // Noop ensures that the Go runtime is initialized.
//
//export Noop //export Noop
func Noop() { func Noop() {
} }
// Raise SIGPIPE. // Raise SIGPIPE.
//
//export GoRaiseSIGPIPE //export GoRaiseSIGPIPE
func GoRaiseSIGPIPE() { func GoRaiseSIGPIPE() {
C.CRaiseSIGPIPE() C.CRaiseSIGPIPE()

View File

@ -17,6 +17,7 @@ import (
var sigioChan chan os.Signal var sigioChan chan os.Signal
// CatchSIGIO starts catching SIGIO signals. // CatchSIGIO starts catching SIGIO signals.
//
//export CatchSIGIO //export CatchSIGIO
func CatchSIGIO() { func CatchSIGIO() {
sigioChan = make(chan os.Signal, 1) sigioChan = make(chan os.Signal, 1)
@ -24,12 +25,14 @@ func CatchSIGIO() {
} }
// ResetSIGIO stops catching SIGIO signals. // ResetSIGIO stops catching SIGIO signals.
//
//export ResetSIGIO //export ResetSIGIO
func ResetSIGIO() { func ResetSIGIO() {
signal.Reset(syscall.SIGIO) signal.Reset(syscall.SIGIO)
} }
// SawSIGIO reports whether we saw a SIGIO. // SawSIGIO reports whether we saw a SIGIO.
//
//export SawSIGIO //export SawSIGIO
func SawSIGIO() C.int { func SawSIGIO() C.int {
select { select {
@ -41,6 +44,7 @@ func SawSIGIO() C.int {
} }
// ProvokeSIGPIPE provokes a kernel-initiated SIGPIPE. // ProvokeSIGPIPE provokes a kernel-initiated SIGPIPE.
//
//export ProvokeSIGPIPE //export ProvokeSIGPIPE
func ProvokeSIGPIPE() { func ProvokeSIGPIPE() {
r, w, err := os.Pipe() r, w, err := os.Pipe()

View File

@ -25,6 +25,7 @@ import (
var sigioCount int32 var sigioCount int32
// Catch SIGIO. // Catch SIGIO.
//
//export GoCatchSIGIO //export GoCatchSIGIO
func GoCatchSIGIO() { func GoCatchSIGIO() {
c := make(chan os.Signal, 1) c := make(chan os.Signal, 1)
@ -37,12 +38,14 @@ func GoCatchSIGIO() {
} }
// Raise SIGIO. // Raise SIGIO.
//
//export GoRaiseSIGIO //export GoRaiseSIGIO
func GoRaiseSIGIO(p *C.pthread_t) { func GoRaiseSIGIO(p *C.pthread_t) {
C.CRaiseSIGIO(p) C.CRaiseSIGIO(p)
} }
// Return the number of SIGIO signals seen. // Return the number of SIGIO signals seen.
//
//export SIGIOCount //export SIGIOCount
func SIGIOCount() C.int { func SIGIOCount() C.int {
return C.int(atomic.LoadInt32(&sigioCount)) return C.int(atomic.LoadInt32(&sigioCount))

View File

@ -1,29 +1,30 @@
// Copyright 2022 The Go Authors. All rights reserved. // Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package main
package main
// #include <complex.h>
import "C" // #include <complex.h>
import "C"
//export exportComplex64
func exportComplex64(v complex64) complex64 { //export exportComplex64
return v func exportComplex64(v complex64) complex64 {
} return v
}
//export exportComplex128
func exportComplex128(v complex128) complex128 { //export exportComplex128
return v func exportComplex128(v complex128) complex128 {
} return v
}
//export exportComplexfloat
func exportComplexfloat(v C.complexfloat) C.complexfloat { //export exportComplexfloat
return v func exportComplexfloat(v C.complexfloat) C.complexfloat {
} return v
}
//export exportComplexdouble
func exportComplexdouble(v C.complexdouble) C.complexdouble { //export exportComplexdouble
return v func exportComplexdouble(v C.complexdouble) C.complexdouble {
} return v
}
func main() {}
func main() {}

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build darwin || dragonfly || freebsd || (linux && !arm64 && !riscv64) || netbsd || openbsd
// +build darwin dragonfly freebsd linux,!arm64,!riscv64 netbsd openbsd // +build darwin dragonfly freebsd linux,!arm64,!riscv64 netbsd openbsd
package main package main

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build (linux && arm64) || (linux && riscv64)
// +build linux,arm64 linux,riscv64 // +build linux,arm64 linux,riscv64
package main package main

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
// +build darwin dragonfly freebsd linux netbsd openbsd solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris
package main package main

View File

@ -15,6 +15,7 @@ import (
// RunGoroutines starts some goroutines that don't do anything. // RunGoroutines starts some goroutines that don't do anything.
// The idea is to get some threads going, so that a signal will be delivered // The idea is to get some threads going, so that a signal will be delivered
// to a thread started by Go. // to a thread started by Go.
//
//export RunGoroutines //export RunGoroutines
func RunGoroutines() { func RunGoroutines() {
for i := 0; i < 4; i++ { for i := 0; i < 4; i++ {
@ -28,6 +29,7 @@ func RunGoroutines() {
var P *byte var P *byte
// TestSEGV makes sure that an invalid address turns into a run-time Go panic. // TestSEGV makes sure that an invalid address turns into a run-time Go panic.
//
//export TestSEGV //export TestSEGV
func TestSEGV() { func TestSEGV() {
defer func() { defer func() {

View File

@ -17,6 +17,7 @@ import (
var sigioChan chan os.Signal var sigioChan chan os.Signal
// CatchSIGIO starts catching SIGIO signals. // CatchSIGIO starts catching SIGIO signals.
//
//export CatchSIGIO //export CatchSIGIO
func CatchSIGIO() { func CatchSIGIO() {
sigioChan = make(chan os.Signal, 1) sigioChan = make(chan os.Signal, 1)
@ -24,12 +25,14 @@ func CatchSIGIO() {
} }
// ResetSIGIO stops catching SIGIO signals. // ResetSIGIO stops catching SIGIO signals.
//
//export ResetSIGIO //export ResetSIGIO
func ResetSIGIO() { func ResetSIGIO() {
signal.Reset(syscall.SIGIO) signal.Reset(syscall.SIGIO)
} }
// SawSIGIO returns whether we saw a SIGIO within a brief pause. // SawSIGIO returns whether we saw a SIGIO within a brief pause.
//
//export SawSIGIO //export SawSIGIO
func SawSIGIO() C.int { func SawSIGIO() C.int {
select { select {

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// //
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// //
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// //
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// //
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// //
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// //
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// //
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// //
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// //
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -3,13 +3,14 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// The bug happened like this: // The bug happened like this:
// 1) The main binary adds an itab for *json.UnsupportedValueError / error // 1. The main binary adds an itab for *json.UnsupportedValueError / error
// (concrete type / interface type). This itab goes in hash bucket 0x111. // (concrete type / interface type). This itab goes in hash bucket 0x111.
// 2) The plugin adds that same itab again. That makes a cycle in the itab // 2. The plugin adds that same itab again. That makes a cycle in the itab
// chain rooted at hash bucket 0x111. // chain rooted at hash bucket 0x111.
// 3) The main binary then asks for the itab for *dynamodbstreamsevt.Event / // 3. The main binary then asks for the itab for *dynamodbstreamsevt.Event /
// json.Unmarshaler. This itab happens to also live in bucket 0x111. // json.Unmarshaler. This itab happens to also live in bucket 0x111.
// The lookup code goes into an infinite loop searching for this itab. // The lookup code goes into an infinite loop searching for this itab.
//
// The code is carefully crafted so that the two itabs are both from the // The code is carefully crafted so that the two itabs are both from the
// same bucket, and so that the second itab doesn't exist in // same bucket, and so that the second itab doesn't exist in
// the itab hashmap yet (so the entire linked list must be searched). // the itab hashmap yet (so the entire linked list must be searched).

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -20,8 +20,9 @@ func Run(gen, x, y int, a []int32) {
// Keep the channels visible from Go. // Keep the channels visible from Go.
var chans [4]chan bool var chans [4]chan bool
//export GoStart
// Double return value is just for testing. // Double return value is just for testing.
//
//export GoStart
func GoStart(i, xdim, ydim, xstart, xend, ystart, yend C.int, a *C.int, n *C.int) (int, int) { func GoStart(i, xdim, ydim, xstart, xend, ystart, yend C.int, a *C.int, n *C.int) (int, int) {
c := make(chan bool, int(C.MYCONST)) c := make(chan bool, int(C.MYCONST))
go func() { go func() {

View File

@ -8,7 +8,7 @@ type T int
func (T) m() { println("m") } func (T) m() { println("m") }
type I interface { m() } type I interface{ m() }
func F() { func F() {
i.m() i.m()

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -32,6 +32,7 @@ import "C"
// allocateStack extends the stack so that stack copying doesn't // allocateStack extends the stack so that stack copying doesn't
// confuse the msan data structures. // confuse the msan data structures.
//
//go:noinline //go:noinline
func allocateStack(i int) int { func allocateStack(i int) int {
if i == 0 { if i == 0 {
@ -43,6 +44,7 @@ func allocateStack(i int) int {
// F1 marks a chunk of stack as uninitialized. // F1 marks a chunk of stack as uninitialized.
// C.f returns an uninitialized struct on the stack, so msan will mark // C.f returns an uninitialized struct on the stack, so msan will mark
// the stack as uninitialized. // the stack as uninitialized.
//
//go:noinline //go:noinline
func F1() uintptr { func F1() uintptr {
s := C.f() s := C.f()
@ -51,6 +53,7 @@ func F1() uintptr {
// F2 allocates a struct on the stack and converts it to an empty interface, // F2 allocates a struct on the stack and converts it to an empty interface,
// which will call msanread and see that the data appears uninitialized. // which will call msanread and see that the data appears uninitialized.
//
//go:noinline //go:noinline
func F2() interface{} { func F2() interface{} {
return C.S{} return C.S{}

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gccgo
// +build gccgo // +build gccgo
package depBase package depBase

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build gc
// +build gc // +build gc
package depBase package depBase

View File

@ -3,10 +3,11 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// Package issue25065 has a type with a method that is // Package issue25065 has a type with a method that is
// 1) referenced in a method expression // 1. referenced in a method expression
// 2) not called // 2. not called
// 3) not converted to an interface // 3. not converted to an interface
// 4) is a value method but the reference is to the pointer method // 4. is a value method but the reference is to the pointer method
//
// These cases avoid the call to makefuncsym from typecheckfunc, but we // These cases avoid the call to makefuncsym from typecheckfunc, but we
// still need to call makefuncsym somehow or the symbol will not be defined. // still need to call makefuncsym somehow or the symbol will not be defined.
package issue25065 package issue25065

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build aix || dragonfly || freebsd || linux || netbsd || solaris
// +build aix dragonfly freebsd linux netbsd solaris // +build aix dragonfly freebsd linux netbsd solaris
package cgosotest package cgosotest

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build ignore
// +build ignore // +build ignore
package main package main