on 9/18/06 3:37 PM, Dan Smith at [EMAIL PROTECTED] wrote:
> After some experimentation:
>
> gestalt('sysa') doesn't work because it returns the system architecture seen
> within the Rosetta environment, which is 2 (PPC).
>
> The method described in
> http://support.realsoftware.com/listarchives/realbasic-nug/2006-05/
> msg00705.html does work, but I don't like it. It fits my definition of a
> "kludge," because it is detecting the presence of Rosetta by an
> apparently-undocumented idiosyncrasy, instead of detecting the actual hardware
> environment.
>
> I may well yet end up using this method, of course.
>
> It basically consists of obtaining the hw_model (not hw_machine) value by a
> direct call to the sysctl api. This does not return the hw_model of the
> hardware environment, but the hw_model value in the Rosetta simulated
> environment; it relies on the seemingly undocumented observation that a
> hardware PPC environment will return something like "PowerMac7,2" but the
> Rosetta environment returns "PowerMac" + chr(0) (eight characters, with a null
> byte included in the returned string.
>
> A promising method is
>
> dim s = shell
> dim arch = result
> s = new shell
> s.execute "sysctl hw.machine"
> result = s.result
> result = result.nthfield(":", 2)
> result = result.trim
>
> Apparently, in the Rosetta environment the call to the sysctl utility is
> executed within the native environment, not the Rosetta environment, and
> s.result returns "hw.machine: i386" + chr(13), and after removing everything
> up
> to the colon and trimming the result, I get "i386".
>
> Within the native-PPC environment, I get "Power Macintosh".
>
> Only time will tell what happens in the native Intel-core environment, but I
> expect to get "i386".
>
> The only riddle now is: what documentation spells out the values that
> hw.machine can assume? Will it always be i386 on Intel-architecture platforms?
> The fact that it returns "i386" on a Pentium is reassuring, but... holy cow...
> Mac OS X documentation is a mare's nest.
>
> The man page for the sysctl utility says "For a detailed description of these
> variable see sysctl(3)".
>
> http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/sysctl
> .3.html
> helpfully says
>
> HW_MACHINE
> The machine class.
>
> with no indication of _what values can be possibly be returned_ for the
> "machine class."
>
> The header file, /usr/include/sys/sysctl.h (yes, I'm learning... apparently in
> the Unix world header files are considered to be "documentation") says
>
> #define HW_MACHINE 1 /* string: machine class */
>
> with no hint as to where "machine classes" are defined. It also has a
>
> #define HW_MACHINE_ARCH 12 /* string: machine architecture */
>
> and does not explain what the difference is between a machine "class" and a
> machine "architecture" or where one would find them documented...
The Apple recommended way to detecting if your app is running under Rosetta
is:
http://developer.apple.com/documentation/MacOSX/Conceptual/universal_binary/
universal_binary_exec_a/chapter_7_section_7.html
Chris
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>