Hi all
I am working on a lvm2 binding for go.
The most stuff works well now, but when I call the function
lvm_vg_get_property the go compiler crashes.
in Go I have something like
func Lvm2_vg_get_property(vg C.vg_t, property string) {
xyz := C.lvm_vg_get_property(vg, C.CString(string))
}
in C the function is defined in /usr/include/lvm2app.h
struct lvm_property_value lvm_vg_get_property(const vg_t vg, const char
*name);
it will return a lvm_property_value struct also defined in lvm2app.h
typedef struct lvm_property_value {
uint32_t is_settable:1;
uint32_t is_string:1;
uint32_t is_integer:1;
uint32_t is_valid:1;
uint32_t padding:28;
union {
const char *string;
uint64_t integer;
} value;
} lvm_property_value_t;
when I call go build it tells me
bash-4.1$ go build src/pfch/lvm.go
# pfch/golvm
panic: runtime error: integer divide by zero
[signal 0x8 code=0x1 addr=0x41d0e0 pc=0x41d0e0]
goroutine 1 [running]:
main.(*Package).structType(0xf840095000, 0xf840048b80, 0xf8400c7a60, 0x1a,
0xf8400c4101, ...)
/var/lib/jenkins/workspace/LINUX_go/label/rhel6-rpm/build/BUILD/go-1.0.2/go/src/cmd/cgo/out.go:219
+0xd75
main.(*Package).writeOutputFunc(0xf840095000, 0xf8400789f0, 0xf840048b80,
0xa732500000013, 0xf840048b80, ...)
/var/lib/jenkins/workspace/LINUX_go/label/rhel6-rpm/build/BUILD/go-1.0.2/go/src/cmd/cgo/out.go:403
+0x218
main.(*Package).writeOutput(0xf840095000, 0xf840097060, 0x7fffb35ff684,
0x6570797400000008, 0x2fffffffff, ...)
/var/lib/jenkins/workspace/LINUX_go/label/rhel6-rpm/build/BUILD/go-1.0.2/go/src/cmd/cgo/out.go:381
+0x866
main.main()
/var/lib/jenkins/workspace/LINUX_go/label/rhel6-rpm/build/BUILD/go-1.0.2/go/src/cmd/cgo/main.go:260
+0xe40
goroutine 2 [syscall]:
created by runtime.main
/var/lib/jenkins/workspace/LINUX_go/label/rhel6-rpm/build/BUILD/go-1.0.2/go/src/pkg/runtime/proc.c:221
goroutine 9 [finalizer wait]:
created by runtime.gc
/var/lib/jenkins/workspace/LINUX_go/label/rhel6-rpm/build/BUILD/go-1.0.2/go/src/pkg/runtime/mgc0.c:882
bash-4.1$
I am using go version 1.02
bash-4.1$ go version
go version go1.0.2
Has anyone an Idea how to realize the function call? I think the problem is
the struct with bitfields and a union in C.
The only idea I have is to write a wrapper for the function in C. But
that's like ..... you now....
Is there another way?
Thanks
Tom
--