Re: G4 vs G3
Re: G4 vs G3
- Subject: Re: G4 vs G3
- From: Lloyd Dupont <email@hidden>
- Date: Thu, 12 Jun 2003 08:56:54 +1000
why don't you look in the wonderful Apple's doc, as everybody seems to
think it is ?
anyway here is a code sample I use:
NSString * ucat = getSysCtlString(CTL_HW, HW_MODEL); // use
sysctl() with this constant
if([ucat hasPrefix:@"PowerBook"])
ret->Category = @"Laptop";
else if([ucat hasPrefix:@"RackMac"])
ret->Category = @"Server";
else
ret->Category = @"Work Station";
int cpufreq = getSysCtlInt(CTL_HW, HW_CPU_FREQ);
and
NSString * getSysCtlString(int firstName, int lastName)
{
int mib[2] = { firstName, lastName };
size_t len;
sysctl(mib, 2, NULL, &len, NULL, 0);
len ++; // there is a bug in sysctl(), obviously ...
char * buf = (char *) alloca(len+1);
sysctl(mib, 2, buf, &len, NULL, 0);
return [NSString stringWithCString:buf];
}
NSString * getLocalhost()
{
return getSysCtlString(CTL_KERN, KERN_HOSTNAME);
}
int getSysCtlInt(int firstName, int lastName)
{
int mib[2] = { firstName, lastName };
size_t len;
sysctl(mib, 2, NULL, &len, NULL, 0);
int ret;
sysctl(mib, 2, &ret, &len, NULL, 0);
return ret;
}
On Wednesday, June 11, 2003, at 07:47 PM, Alexander Griekspoor wrote:
>
Hi There!
>
>
Does anyone know a simple call to find out which processor type (G3 or
>
G4, PPC970 ;-) the user has?
>
Ideally, I'm looking for something like MPProcessors() which returns
>
the number of processors the machine has. Then one more small
>
question. It might be to simple for words, but for someone new to the
>
UNIX world, is there a simple way to browse to the header files like
>
mach/mach.h and other c libraries?
>
>
Many thanks in advance!
>
Alexander Griekspoor
>
>
*********************************************************
>
** Alexander Griekspoor **
>
*********************************************************
>
The Netherlands Cancer Institute
>
Department of Tumorbiology (H4)
>
Plesmanlaan 121, 1066 CX, Amsterdam
>
Tel: + 31 20 - 512 2023
>
Fax: + 31 20 - 512 2029
>
E-mail: email@hidden
>
Web: http://www.mekentosj.com
>
>
LabAssistant - Get your life organized!
>
http://www.mekentosj.com/labassistant
>
>
*********************************************************
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: | |
| >G4 vs G3 (From: Alexander Griekspoor <email@hidden>) |