android-ndk.c 1.3 KB

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