Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How smart is Rosetta?



This is not the recommended way; for a better way, see http:// developer.apple.com/documentation/MacOSX/Conceptual/universal_binary/ universal_binary_exec_a/chapter_7_section_7.html

The sample code is a little more elaborate than necessary because it's designed around the idea of testing any PID to see if it's running in Rosetta, not just your own PID. In listing A-4, change sysctlbyname_with_pid to a plain sysctlbyname to simplify it. Or if you don't mind either way, just copy all the code and pass a PID of 0.



On Jun 6, 2006, at 2:51 PM, Ben Weiss wrote:

Anyway, Rosetta can be detected with the following bit of code:

bool CPSFMactel::IsRosetta() {
	bool isRosetta = false;
    char model[32];
    size_t len = sizeof(model);
    int mib[2] = { CTL_HW, HW_MODEL };
	
    if (sysctl(mib, 2, &model, &len, NULL, 0) == 0) {
		isRosetta = (len == 9 && strcmp(model, "PowerMac") == 0);
		}
	
	return isRosetta;
	}

_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: How smart is Rosetta? (From: Marc Stibane <email@hidden>)
 >Re: How smart is Rosetta? (From: Ben Weiss <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.