l i v e c o d e

Determing if Your Stack is Running under Intel/Rosetta
Mac OS X (OS X Only)

Now that Revolution (2.7.2 or later) is able to produce Intel native, PowerPC or Universal Binary standalones, it is important to know a couple of things: If you build standalones for specific platforms (like a separate PowerPC and separate Intel native standalone), then it may not matter. But if you ar building Universal Binary standalones, it can be helpful to know these things so your program can take action accordingly (like load separate externals or specific stacks).

To determine whether your stack is running on an Intel CPU, use this function:

function isIntel
  put shell("system_profiler SPHardwareDataType") into tData
  put matchText(tData,"(?s)CPU Type:\W*(.*?)\n",tType) into tIsMatch
  if tIsMatch then
    return (tType contains "Intel")
  else
    return "Error: Can't determine CPU type."
  end if
end isIntel
And it turns out that the processor will return "x86" if running truly native on Intel, or "Motorola PowerPC" it emulated. So you can determine if your stack is running in Rosetta with this function:
function isRosetta
  return (isIntel() and (the processor contains "PowerPC"))
end isRosetta
Enjoy!


Posted 9/9/2006 by Ken Ray


 Print this tip

News and Rumors Products Services Developer Resources Contact STS About STS