tweaked to work with gcc and cgo