You may have better luck by asking your query in the MacOS X programming forum.
Sounds like you're writing a kext? Mach's host_info isn't exported (made visible) to the OS X kernel frameworks so you can't call that. The easiest way, even if it's a less-than-elegant workaround, may be to have a user-mode helper stub that gets this information through more conventional library calls and then notifies the kext what the hostname is.