Browse files

Compile on MacOSX systems without mach_task_self function

On Snow Leopard mach/mach_init.h has a function decl for mach_task_self,
yet later redefines as a macro to return the mach_task_self_ variable.

Newer systems have removed the function and since cgo doesn't handle macros,
compile fails: "error: 'mach_task_self' undeclared ..."

Change-Id: I8d28a9c7609656f2cbdee5588e6a4c337599ac2c
  • Loading branch information...
1 parent 34b9338 commit 95cbeda03a6dd5339030585805e928009834e073 @dougm dougm committed Oct 5, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 sigar_darwin.go
2 sigar_darwin.go
@@ -126,7 +126,7 @@ func (self *CpuList) Get() error {
// jump through some cgo casting hoops and ensure we properly free
// the memory that cpuload points to
- target := C.vm_map_t(C.mach_task_self())
+ target := C.vm_map_t(C.mach_task_self_)
address := C.vm_address_t(uintptr(unsafe.Pointer(cpuload)))
defer C.vm_deallocate(target, address, C.vm_size_t(ncpu))

0 comments on commit 95cbeda

Please sign in to comment.