 import Foundation
 
 // Via <mach/machine.h>
+// TODO: Public or private? Depends if we decide to return cpu_type to user
 
 let CPU_TYPE_X86       : cpu_type_t = 7
 let CPU_TYPE_I386      : cpu_type_t = CPU_TYPE_X86

    // Assuming x86 for now
    
    public func isProcforeign(procCPUType: cpu_type_t) -> Bool {
        return procCPUType == CPU_TYPE_X86_64 || procCPUType == CPU_TYPE_X86
    }
    
    

        let data = UnsafePointer<task_power_info_data_t>(powerInfo).memory
        
        powerInfo.dealloc(Int(TASK_POWER_INFO_COUNT))
        
        return data
    }
    
    
    private func processPowerInformationV2(process: task_t) -> task_power_info_v2_data_t {
        // Doesn't seem to work. Maybe need a newer GPU? Discrete GPU?
        // GPU - Returns the total gpu time used by the all the threads of the task
        
        var count = TASK_POWER_INFO_V2_COUNT
        var powerInfo = task_info_t.alloc(Int(TASK_POWER_INFO_V2_COUNT))
        var result = task_info(process, UInt32(TASK_POWER_INFO_V2), powerInfo, &count)
        
        if result != KERN_SUCCESS {
           let temp = task_power_info_data_t(total_user                 : 0,
                            total_system               : 0,
                            task_interrupt_wakeups     : 0,
                            task_platform_idle_wakeups : 0,
                            task_timer_wakeups_bin_1   : 0,
                            task_timer_wakeups_bin_2   : 0)
            let gpu_temp = gpu_energy_data(task_gpu_utilisation: 0, task_gpu_stat_reserved0: 0, task_gpu_stat_reserved1: 0, task_gpu_stat_reserved2: 0)
            return task_power_info_v2_data_t(cpu_energy: temp, gpu_energy: gpu_temp)

        }
        
        let data = UnsafePointer<task_power_info_v2_data_t>(powerInfo).memory
        
        powerInfo.dealloc(Int(TASK_POWER_INFO_V2_COUNT))
        
        return data
    }
