Пример #1
0
Файл: p.go Проект: 2thetop/go
func F() {
	if b {
		for {
		}
	}
	C.f()
}
Пример #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
}
Пример #3
0
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
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
func main() {
	_ = C.f(1) // ERROR HERE
}
Пример #8
0
func main() {
	fmt.Println(Random())
	fmt.Println(C.f(2))
}
Пример #9
0
func F(p *x) {
	C.f(p) // ERROR HERE
}
Пример #10
0
func main() {
	if r := C.f(); r != 1 {
		panic(r)
	}
}