• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: determine CPU type at runtime
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: determine CPU type at runtime


  • Subject: Re: determine CPU type at runtime
  • From: "Daniel Lord" <email@hidden>
  • Date: Tue, 26 Feb 2008 12:16:05 -0800

Rick,

No need. Pilot error. I performed the call multiple times but foolishly forgot that the thrid parameter, size_t *oldlenp, was volatile. Oops!

sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen); 
I _hate_ when that happens. Note to self: CRTFM (as in CAREFULLY read the freaking manual).

Daniel

On 2/26/08, Rick Altherr <email@hidden> wrote:
Care to post your code?  I'm fairly certain the sysctl command-line tool uses sysctlbyname() internally and it works fine with hw.model.

 
Rick

 

On Feb 26, 2008, at 11:35 AM, Daniel Lord wrote:

Paul,

 
use sysctl() not sysctlbyname() as syscntrlbyname() seems to be broken as in the results I get on Leopard 10.5.2:

 
sysctl:
-------------------------------------------
CTL_HW, HW_MACHINE: i386
CTL_HW, HW_MODEL: MacBookPro2,2

 
sysctlbyname:
-------------------------------------------
hw.machine:i386
hw.model:i386

 
Chris,
Is is worth filing a bug report or is this well-known?

 
Daniel

 
On 2/25/08, Chris Espinosa <email@hidden> wrote:

On Feb 25, 2008, at 1:48 PM, Paul Archibald wrote:


> One of the apps I am working on has minor issues when running on an
> Intel Mac, so I would like to be able to detect the cpu type at
> runtime. I just need a method like:
>
> bool ThisAppIsRunningOnAPowerPC()
>
> Is this a job for Gestalt? It looks so complicated.


It's an API question, not a tools question, so it's not a job for
Xcode.  (Though you got two tools-based replies that you might find
useful).

The droid you're looking for is sysctlbyname().

x-man-page://sysctlbyname
file:///usr/include/sys/sysctl.h

You're looking for CTL_HW, HW_MODEL.


Chris

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)

This email sent to email@hidden

 
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)

This email sent to email@hidden

--
Rick Altherr
Architecture and Performance Group
email@hidden

 



 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >determine CPU type at runtime (From: Paul Archibald <email@hidden>)
 >Re: determine CPU type at runtime (From: Chris Espinosa <email@hidden>)
 >Re: determine CPU type at runtime (From: "Daniel Lord" <email@hidden>)
 >Re: determine CPU type at runtime (From: Rick Altherr <email@hidden>)

  • Prev by Date: Problem excluding /usr/local/lib
  • Next by Date: Re: Problem excluding /usr/local/lib
  • Previous by thread: Re: determine CPU type at runtime
  • Next by thread: PackageMaker 3.0.1 question
  • Index(es):
    • Date
    • Thread