user945620
user945620

Reputation:

iOS: How to ascertain the CPU type, e.g. A4 or A5, or instruction set architecture arm6 or arm7?

Does Apple provide an API that gives access to this information?

Does the ARM have an equivalent to the x86 CPUID instruction that I could use in an asm block?

Thanks.

Upvotes: 5

Views: 3095

Answers (2)

leanid.chaika
leanid.chaika

Reputation: 2432

I need CPU model info and instruction set. So I try to do it as simple as possible:

std::string GetCPUModel()
{
    // you can compare results with https://www.theiphonewiki.com/wiki/List_of_iPhones

    struct utsname systemInfo;
    uname(&systemInfo);

    std::string version(systemInfo.version);

    size_t cpuModelPos = version.find("RELEASE_");

    if (cpuModelPos != String::npos)
    {
        // for example: will return "ARM64_S8000" - for iPhone S6 plus
        return version.substr(cpuModelPos + strlen("RELEASE_"));
    }

    return {};
}

Upvotes: 0

MOK9
MOK9

Reputation: 375

Erica Sadun has written a number of useful queries. I would begin checking out the uidevice extensions code and see if you can find what you are looking for there.

https://github.com/erica/uidevice-extension

Also, as Gapton says, keep in mind that some device queries will not get App Store approval, especially the unpublished ones, but a fair number of them are okay to use.

Upvotes: 1

Related Questions