mirror of
https://github.com/golang/go
synced 2024-11-24 22:10:02 -07:00
53fd522c0d
Follows suit with https://go-review.googlesource.com/#/c/20111. Generated by running $ grep -R 'Go Authors. All' * | cut -d":" -f1 | while read F;do perl -pi -e 's/Go Authors. All/Go Authors. All/g' $F;done The code in cmd/internal/unvendor wasn't changed. Fixes #15213 Change-Id: I4f235cee0a62ec435f9e8540a1ec08ae03b1a75f Reviewed-on: https://go-review.googlesource.com/21819 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
42 lines
895 B
Go
42 lines
895 B
Go
// skip
|
|
|
|
// Copyright 2010 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.
|
|
|
|
package life
|
|
|
|
// #include "life.h"
|
|
import "C"
|
|
|
|
import "unsafe"
|
|
|
|
func Run(gen, x, y int, a []int32) {
|
|
n := make([]int32, x*y)
|
|
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])))
|
|
copy(a, n)
|
|
}
|
|
}
|
|
|
|
// Keep the channels visible from Go.
|
|
var chans [4]chan bool
|
|
|
|
//export GoStart
|
|
// Double return value is just for testing.
|
|
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))
|
|
go func() {
|
|
C.DoStep(xdim, ydim, xstart, xend, ystart, yend, a, n)
|
|
c <- true
|
|
}()
|
|
chans[i] = c
|
|
return int(i), int(i + 100)
|
|
}
|
|
|
|
//export GoWait
|
|
func GoWait(i C.int) {
|
|
<-chans[i]
|
|
chans[i] = nil
|
|
}
|