* tree-vect-loop-manip.c (vect_do_peeling): Do not use
[official-gcc.git] / libgo / misc / cgo / test / issue4029.go
blob5789b99ef67034f4644bac0aa9186e40675a1cf4
1 // Copyright 2012 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 // +build !windows
7 package cgotest
9 /*
10 #include <dlfcn.h>
11 #cgo linux LDFLAGS: -ldl
13 extern void call4029(void *arg);
15 import "C"
17 import (
18 "testing"
21 var callbacks int
23 //export IMPIsOpaque
24 func IMPIsOpaque() {
25 callbacks++
28 //export IMPInitWithFrame
29 func IMPInitWithFrame() {
30 callbacks++
33 //export IMPDrawRect
34 func IMPDrawRect() {
35 callbacks++
38 //export IMPWindowResize
39 func IMPWindowResize() {
40 callbacks++
43 func test4029(t *testing.T) {
44 loadThySelf(t, "IMPWindowResize")
45 loadThySelf(t, "IMPDrawRect")
46 loadThySelf(t, "IMPInitWithFrame")
47 loadThySelf(t, "IMPIsOpaque")
48 if callbacks != 4 {
49 t.Errorf("got %d callbacks, expected 4", callbacks)
53 func loadThySelf(t *testing.T, symbol string) {
54 this_process := C.dlopen(nil, C.RTLD_NOW)
55 if this_process == nil {
56 t.Error("dlopen:", C.GoString(C.dlerror()))
57 return
59 defer C.dlclose(this_process)
61 symbol_address := C.dlsym(this_process, C.CString(symbol))
62 if symbol_address == nil {
63 t.Error("dlsym:", C.GoString(C.dlerror()))
64 return
66 t.Log(symbol, symbol_address)
67 C.call4029(symbol_address)