1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #include <cpu-features.h> 17 #include <stdio.h> 18 19 int main(void) 20 { 21 AndroidCpuFamily family = android_getCpuFamily(); 22 switch (family) { 23 case ANDROID_CPU_FAMILY_ARM: 24 printf("CPU family is ARM\n"); 25 break; 26 case ANDROID_CPU_FAMILY_X86: 27 printf("CPU family is x86\n"); 28 break; 29 case ANDROID_CPU_FAMILY_MIPS: 30 printf("CPU family is MIPS\n"); 31 break; 32 default: 33 fprintf(stderr, "Unsupported CPU family: %d\n", family); 34 return 1; 35 } 36 37 if (family == ANDROID_CPU_FAMILY_ARM) { 38 uint64_t features = android_getCpuFeatures(); 39 printf( "Supported ARM features:\n"); 40 if ((features & ANDROID_CPU_ARM_FEATURE_ARMv7) != 0) { 41 printf( " ARMv7\n" ); 42 } 43 if ((features & ANDROID_CPU_ARM_FEATURE_VFPv3) != 0) { 44 printf( " VFPv3\n" ); 45 } 46 if ((features & ANDROID_CPU_ARM_FEATURE_NEON) != 0) { 47 printf( " NEON\n" ); 48 } 49 if ((features & ANDROID_CPU_ARM_FEATURE_LDREX_STREX) != 0) { 50 printf( " ldrex/strex\n" ); 51 } 52 } 53 54 if (family == ANDROID_CPU_FAMILY_X86) { 55 uint64_t features = android_getCpuFeatures(); 56 printf( "Supported x86 features:\n"); 57 if ((features & ANDROID_CPU_X86_FEATURE_SSSE3) != 0) { 58 printf( " SSSE3\n"); 59 } 60 if ((features & ANDROID_CPU_X86_FEATURE_POPCNT) != 0) { 61 printf( " POPCNT\n"); 62 } 63 if ((features & ANDROID_CPU_X86_FEATURE_MOVBE) != 0) { 64 printf( " MOVBE\n"); 65 } 66 } 67 68 int count = android_getCpuCount(); 69 printf( "Number of CPU cores: %d\n", count); 70 return 0; 71 } 72