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.
12 #cgo linux LDFLAGS: -ldl
14 extern uintptr_t dlopen4029(char*, int);
15 extern uintptr_t dlsym4029(uintptr_t, char*);
16 extern int dlclose4029(uintptr_t);
18 extern void call4029(uintptr_t arg);
33 //export IMPInitWithFrame
34 func IMPInitWithFrame() {
43 //export IMPWindowResize
44 func IMPWindowResize() {
48 func test4029(t
*testing
.T
) {
49 loadThySelf(t
, "IMPWindowResize")
50 loadThySelf(t
, "IMPDrawRect")
51 loadThySelf(t
, "IMPInitWithFrame")
52 loadThySelf(t
, "IMPIsOpaque")
54 t
.Errorf("got %d callbacks, expected 4", callbacks
)
58 func loadThySelf(t
*testing
.T
, symbol
string) {
59 this_process
:= C
.dlopen4029(nil, C
.RTLD_NOW
)
60 if this_process
== 0 {
61 t
.Error("dlopen:", C
.GoString(C
.dlerror()))
64 defer C
.dlclose4029(this_process
)
66 symbol_address
:= C
.dlsym4029(this_process
, C
.CString(symbol
))
67 if symbol_address
== 0 {
68 t
.Error("dlsym:", C
.GoString(C
.dlerror()))
71 t
.Log(symbol
, symbol_address
)
72 C
.call4029(symbol_address
)