示例#1
0
文件: p.go 项目: 2thetop/go
func F() {
	if b {
		for {
		}
	}
	C.f()
}
示例#2
0
文件: tc.go 项目: yonglehou/elvish
func Tcsetpgrp(fd int, pid int) error {
	i := C.f(C.int(fd), C.pid_t(pid))
	if i != 0 {
		return syscall.Errno(C.e())
	}
	return nil
}
示例#3
0
文件: tsan6.go 项目: 2thetop/go
func main() {
	var wg sync.WaitGroup
	var mu sync.Mutex
	c := make(chan []C.char, 100)
	for i := 0; i < 10; i++ {
		wg.Add(2)
		go func() {
			defer wg.Done()
			for i := 0; i < 100; i++ {
				c <- make([]C.char, 4096)
				runtime.Gosched()
			}
		}()
		go func() {
			defer wg.Done()
			for i := 0; i < 100; i++ {
				p := &(<-c)[0]
				mu.Lock()
				C.f(p)
				mu.Unlock()
			}
		}()
	}
	wg.Wait()
}
示例#4
0
文件: msan.go 项目: arnold8/go
func main() {
	a := make([]int32, 10)
	C.f((*C.int32_t)(unsafe.Pointer(&a[0])), C.int(len(a)))
	for i, v := range a {
		if i != int(v) {
			fmt.Println("bad %d: %v\n", i, a)
			os.Exit(1)
		}
	}
}
示例#5
0
文件: cgo.go 项目: achanda/go
func CgoTests() {
	var c chan bool
	C.f(*(*unsafe.Pointer)(unsafe.Pointer(&c))) // ERROR "embedded pointer"
	C.f(unsafe.Pointer(&c))                     // ERROR "embedded pointer"

	var m map[string]string
	C.f(*(*unsafe.Pointer)(unsafe.Pointer(&m))) // ERROR "embedded pointer"
	C.f(unsafe.Pointer(&m))                     // ERROR "embedded pointer"

	var f func()
	C.f(*(*unsafe.Pointer)(unsafe.Pointer(&f))) // ERROR "embedded pointer"
	C.f(unsafe.Pointer(&f))                     // ERROR "embedded pointer"

	var s []int
	C.f(*(*unsafe.Pointer)(unsafe.Pointer(&s))) // ERROR "embedded pointer"
	C.f(unsafe.Pointer(&s))                     // ERROR "embedded pointer"

	var a [1][]int
	C.f(*(*unsafe.Pointer)(unsafe.Pointer(&a))) // ERROR "embedded pointer"
	C.f(unsafe.Pointer(&a))                     // ERROR "embedded pointer"

	var st struct{ f []int }
	C.f(*(*unsafe.Pointer)(unsafe.Pointer(&st))) // ERROR "embedded pointer"
	C.f(unsafe.Pointer(&st))                     // ERROR "embedded pointer"

	// The following cases are OK.
	var i int
	C.f(*(*unsafe.Pointer)(unsafe.Pointer(&i)))
	C.f(unsafe.Pointer(&i))

	C.f(*(*unsafe.Pointer)(unsafe.Pointer(&s[0])))
	C.f(unsafe.Pointer(&s[0]))

	var a2 [1]int
	C.f(*(*unsafe.Pointer)(unsafe.Pointer(&a2)))
	C.f(unsafe.Pointer(&a2))

	var st2 struct{ i int }
	C.f(*(*unsafe.Pointer)(unsafe.Pointer(&st2)))
	C.f(unsafe.Pointer(&st2))

	C.CBytes([]byte("hello"))
}
示例#6
0
文件: msan2.go 项目: 2thetop/go
func main() {
	a := make([]int32, 10)
	C.f((*C.int32_t)(unsafe.Pointer(&a[0])), C.int(len(a)))
	a[4] = 1
	C.g((*C.int32_t)(unsafe.Pointer(&a[0])), C.int(len(a)))
}
示例#7
0
文件: issue16116.go 项目: 2thetop/go
func main() {
	_ = C.f(1) // ERROR HERE
}
示例#8
0
文件: cgo.go 项目: aimeiyan/gocode
func main() {
	fmt.Println(Random())
	fmt.Println(C.f(2))
}
示例#9
0
文件: issue16591.go 项目: achanda/go
func F(p *x) {
	C.f(p) // ERROR HERE
}
示例#10
0
文件: msan3.go 项目: 2thetop/go
func main() {
	if r := C.f(); r != 1 {
		panic(r)
	}
}