Example #1
0
File: p.go Project: 2thetop/go
func F() {
	if b {
		for {
		}
	}
	C.f()
}
Example #2
0
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
}
Example #3
0
File: tsan6.go Project: 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()
}
Example #4
0
File: msan.go Project: 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)
		}
	}
}
Example #5
0
File: cgo.go Project: 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"))
}
Example #6
0
File: msan2.go Project: 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)))
}
Example #7
0
func main() {
	_ = C.f(1) // ERROR HERE
}
Example #8
0
func main() {
	fmt.Println(Random())
	fmt.Println(C.f(2))
}
Example #9
0
func F(p *x) {
	C.f(p) // ERROR HERE
}
Example #10
0
File: msan3.go Project: 2thetop/go
func main() {
	if r := C.f(); r != 1 {
		panic(r)
	}
}