mirror of
https://github.com/golang/go
synced 2024-11-25 00:37:57 -07:00
misc/cgo: prepare for 64-bit ints
In a few places, the existing cgo tests assume that a Go int is the same as a C int. Making int 64 bits wide on 64-bit platforms violates this assumption. Change that code to assume that Go int32 and C int are the same instead. That's still not great, but it's better, and I am unaware of any systems we run on where it is not true. Update #2188. R=iant, r CC=golang-dev https://golang.org/cl/6552064
This commit is contained in:
parent
0b08c9483f
commit
0a006b4923
@ -11,8 +11,8 @@ import "C"
|
|||||||
|
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
|
|
||||||
func Run(gen, x, y int, a []int) {
|
func Run(gen, x, y int, a []int32) {
|
||||||
n := make([]int, x*y)
|
n := make([]int32, x*y)
|
||||||
for i := 0; i < gen; i++ {
|
for i := 0; i < gen; i++ {
|
||||||
C.Step(C.int(x), C.int(y), (*C.int)(unsafe.Pointer(&a[0])), (*C.int)(unsafe.Pointer(&n[0])))
|
C.Step(C.int(x), C.int(y), (*C.int)(unsafe.Pointer(&a[0])), (*C.int)(unsafe.Pointer(&n[0])))
|
||||||
copy(a, n)
|
copy(a, n)
|
||||||
|
@ -24,7 +24,7 @@ var gen = flag.Int("gen", 10, "generations")
|
|||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
var a [MAXDIM * MAXDIM]int
|
var a [MAXDIM * MAXDIM]int32
|
||||||
for i := 2; i < *dim; i += 8 {
|
for i := 2; i < *dim; i += 8 {
|
||||||
for j := 2; j < *dim-3; j += 8 {
|
for j := 2; j < *dim-3; j += 8 {
|
||||||
for y := 0; y < 3; y++ {
|
for y := 0; y < 3; y++ {
|
||||||
|
@ -28,7 +28,7 @@ func parallelSleep(n int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//export BackgroundSleep
|
//export BackgroundSleep
|
||||||
func BackgroundSleep(n int) {
|
func BackgroundSleep(n int32) {
|
||||||
go func() {
|
go func() {
|
||||||
C.sleep(C.uint(n))
|
C.sleep(C.uint(n))
|
||||||
sleepDone <- true
|
sleepDone <- true
|
||||||
|
Loading…
Reference in New Issue
Block a user