1*a67afe4dSAndroid Build Coastguard Worker /* contrib/arm-neon/android-ndk.c 2*a67afe4dSAndroid Build Coastguard Worker * 3*a67afe4dSAndroid Build Coastguard Worker * Copyright (c) 2014 Glenn Randers-Pehrson 4*a67afe4dSAndroid Build Coastguard Worker * Written by John Bowler, 2014. 5*a67afe4dSAndroid Build Coastguard Worker * 6*a67afe4dSAndroid Build Coastguard Worker * This code is released under the libpng license. 7*a67afe4dSAndroid Build Coastguard Worker * For conditions of distribution and use, see the disclaimer 8*a67afe4dSAndroid Build Coastguard Worker * and license in png.h 9*a67afe4dSAndroid Build Coastguard Worker * 10*a67afe4dSAndroid Build Coastguard Worker * SEE contrib/arm-neon/README before reporting bugs 11*a67afe4dSAndroid Build Coastguard Worker * 12*a67afe4dSAndroid Build Coastguard Worker * STATUS: COMPILED, UNTESTED 13*a67afe4dSAndroid Build Coastguard Worker * BUG REPORTS: [email protected] 14*a67afe4dSAndroid Build Coastguard Worker * 15*a67afe4dSAndroid Build Coastguard Worker * png_have_neon implemented for the Android NDK, see: 16*a67afe4dSAndroid Build Coastguard Worker * 17*a67afe4dSAndroid Build Coastguard Worker * Documentation: 18*a67afe4dSAndroid Build Coastguard Worker * http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html 19*a67afe4dSAndroid Build Coastguard Worker * https://code.google.com/p/android/issues/detail?id=49065 20*a67afe4dSAndroid Build Coastguard Worker * 21*a67afe4dSAndroid Build Coastguard Worker * NOTE: this requires that libpng is built against the Android NDK and linked 22*a67afe4dSAndroid Build Coastguard Worker * with an implementation of the Android ARM 'cpu-features' library. The code 23*a67afe4dSAndroid Build Coastguard Worker * has been compiled only, not linked: no version of the library has been found, 24*a67afe4dSAndroid Build Coastguard Worker * only the header files exist in the NDK. 25*a67afe4dSAndroid Build Coastguard Worker */ 26*a67afe4dSAndroid Build Coastguard Worker 27*a67afe4dSAndroid Build Coastguard Worker #include <cpu-features.h> 28*a67afe4dSAndroid Build Coastguard Worker 29*a67afe4dSAndroid Build Coastguard Worker static int png_have_neon(png_structp png_ptr)30*a67afe4dSAndroid Build Coastguard Workerpng_have_neon(png_structp png_ptr) 31*a67afe4dSAndroid Build Coastguard Worker { 32*a67afe4dSAndroid Build Coastguard Worker /* This is a whole lot easier than the linux code, however it is probably 33*a67afe4dSAndroid Build Coastguard Worker * implemented as below, therefore it is better to cache the result (these 34*a67afe4dSAndroid Build Coastguard Worker * function calls may be slow!) 35*a67afe4dSAndroid Build Coastguard Worker */ 36*a67afe4dSAndroid Build Coastguard Worker PNG_UNUSED(png_ptr) 37*a67afe4dSAndroid Build Coastguard Worker return android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && 38*a67afe4dSAndroid Build Coastguard Worker (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; 39*a67afe4dSAndroid Build Coastguard Worker } 40