Merge pull request #483 from lunixbochs/go-binding-version

expose version from Go bindings
This commit is contained in:
Nguyen Anh Quynh 2016-03-25 10:07:45 +07:00
commit 6e8f3e7409

View File

@ -62,9 +62,14 @@ type UcOptions struct {
Timeout, Count uint64 Timeout, Count uint64
} }
func NewUnicorn(arch, mode int) (Unicorn, error) { func Version() (int, int) {
var major, minor C.uint var major, minor C.uint
C.uc_version(&major, &minor) C.uc_version(&major, &minor)
return int(major), int(minor)
}
func NewUnicorn(arch, mode int) (Unicorn, error) {
major, minor := Version()
if major != C.UC_API_MAJOR || minor != C.UC_API_MINOR { if major != C.UC_API_MAJOR || minor != C.UC_API_MINOR {
return nil, UcError(ERR_VERSION) return nil, UcError(ERR_VERSION)
} }