* tree-vect-loop-manip.c (vect_do_peeling): Do not use
[official-gcc.git] / libgo / misc / cgo / test / cthread.go
blobaf44911756a9e13f3aa1b2f9c367af54be089ba2
1 // Copyright 2013 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.
5 package cgotest
7 // extern void doAdd(int, int);
8 import "C"
10 import (
11 "runtime"
12 "sync"
13 "testing"
16 var sum struct {
17 sync.Mutex
18 i int
21 //export Add
22 func Add(x int) {
23 defer func() {
24 recover()
25 }()
26 sum.Lock()
27 sum.i += x
28 sum.Unlock()
29 var p *int
30 *p = 2
33 func testCthread(t *testing.T) {
34 if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") {
35 t.Skip("the iOS exec wrapper is unable to properly handle the panic from Add")
37 sum.i = 0
38 C.doAdd(10, 6)
40 want := 10 * (10 - 1) / 2 * 6
41 if sum.i != want {
42 t.Fatalf("sum=%d, want %d", sum.i, want)