Re: How to find out if running on new dual core G5
Re: How to find out if running on new dual core G5
- Subject: Re: How to find out if running on new dual core G5
- From: plumber <email@hidden>
- Date: Fri, 18 Nov 2005 20:51:50 +0100
-- BEGIN machine_info.c --
#include <mach/mach.h>
#include <mach/machine.h>
#include <mach/mach_host.h>
#include <mach/host_info.h>
#import <Carbon/Carbon.h>
unsigned int countProcessors()
{
host_basic_info_data_t hostInfo;
mach_msg_type_number_t infoCount;
infoCount = HOST_BASIC_INFO_COUNT;
host_info(mach_host_self(), HOST_BASIC_INFO,
(host_info_t)&hostInfo, &infoCount);
return (unsigned int)(hostInfo.max_cpus);
}
unsigned int isPowerPC()
{
host_basic_info_data_t hostInfo;
mach_msg_type_number_t infoCount;
infoCount = HOST_BASIC_INFO_COUNT;
kern_return_t ret = host_info(mach_host_self(), HOST_BASIC_INFO,
(host_info_t)&hostInfo, &infoCount);
return ( (KERN_SUCCESS == ret) &&
(hostInfo.cpu_type == CPU_TYPE_POWERPC) );
}
unsigned int isG3()
{
host_basic_info_data_t hostInfo;
mach_msg_type_number_t infoCount;
infoCount = HOST_BASIC_INFO_COUNT;
kern_return_t ret = host_info(mach_host_self(), HOST_BASIC_INFO,
(host_info_t)&hostInfo, &infoCount);
return ( (KERN_SUCCESS == ret) &&
(hostInfo.cpu_type == CPU_TYPE_POWERPC) &&
(hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_750) );
}
unsigned int isG4()
{
host_basic_info_data_t hostInfo;
mach_msg_type_number_t infoCount;
infoCount = HOST_BASIC_INFO_COUNT;
kern_return_t ret = host_info(mach_host_self(), HOST_BASIC_INFO,
(host_info_t)&hostInfo, &infoCount);
return ( (KERN_SUCCESS == ret) &&
(hostInfo.cpu_type == CPU_TYPE_POWERPC) &&
(hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_7400 ||
hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_7450));
}
unsigned int isG5()
{
host_basic_info_data_t hostInfo;
mach_msg_type_number_t infoCount;
infoCount = HOST_BASIC_INFO_COUNT;
kern_return_t ret = host_info(mach_host_self(), HOST_BASIC_INFO,
(host_info_t)&hostInfo, &infoCount);
return ( (KERN_SUCCESS == ret) &&
(hostInfo.cpu_type == CPU_TYPE_POWERPC) &&
(hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_970));
}
unsigned long procSpeed()
{
OSErr err;
long result;
err=Gestalt(gestaltProcClkSpeed,&result);
if (err!=nil)
return 0;
else
return result;
}
unsigned int procSpeedMHz()
{
return (unsigned int)procSpeed();
}
int main(int argc, char *argv[])
{
printf("procSpeedMHz : %i MHz\n",procSpeedMHz()/1000000);
printf("countProcessors : %i\n",countProcessors());
printf("isPowerPC : %i\n",isPowerPC());
printf("isG3 : %i\n",isG3());
printf("isG4 : %i\n",isG4());
printf("isG5 : %i\n",isG5());
return 1;
}
-- END machine_info.c --
gcc machine_info.c -o machine_info -framework Carbon
./machine_info
procSpeedMHz : 933 MHz
countProcessors : 1
isPowerPC : 1
isG3 : 0
isG4 : 1
isG5 : 0
Best Regards
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden