Article Preview
Buy Now
COLUMN
Detecting Rosetta
Are we running under emulation?
Issue: 5.1 (September/October 2006)
Author: Christian Schmitz
Author Bio: Christian Schmitz is the creator of the Monkeybread Software REALbasic Plugins.
Article Description: No description available.
Article Length (in bytes): 7,162
Starting Page Number: 44
Article Number: 5119
Resource File(s):
5119.zip Updated: 2006-09-28 14:14:23
Related Link(s): None
Excerpt of article text...
Recently someone asked about how to detect whether or not the application is running using Rosetta. Rosetta is Apple's name for the PowerPC emulator in Mac OS X which enables Macs with Intel CPUs to run PowerPC applications.
Knowing, from inside your application, whether the CPU is emulated or not is quite useful. You may have platform-dependent code in external libraries and need to load the correct one. Or you may need to use different code depending on whether or not the application is running under emulation.
How to check for Rosetta
There are several ways to detect Rosetta. Most of them query some specific setting from the operation system to check for a certain value. Apple describes a way in their documentation which checks for the presence of a specific key. The approach we take here is to check for a special value in a kernel variable. The kernel variable, labeled "model", contains the model name of the machine. While this variable will be model-specific on an actual PowerPC Mac, under emulation the variable will always be the same. Inside Rosetta we always get the model name "PowerMac" while on a PowerMac G5 the value is "PowerMac8,3", where the eight is for the eighth generation and the three is for the third release. On an iBook G4 the value is, for example, "PowerBook6,7".
...End of Excerpt. Please purchase the magazine to read the full article.