| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 The Android Open Source Project | 3 * Copyright 2012 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkUtilsArm.h" | 9 #include "SkUtilsArm.h" |
| 10 | 10 |
| 11 #if SK_ARM_NEON_IS_DYNAMIC | 11 #if SK_ARM_NEON_IS_DYNAMIC |
| 12 | 12 |
| 13 #include <unistd.h> | 13 #include <unistd.h> |
| 14 #include <fcntl.h> | 14 #include <fcntl.h> |
| 15 #include <errno.h> | 15 #include <errno.h> |
| 16 #include <string.h> | 16 #include <string.h> |
| 17 #include <pthread.h> | 17 #include <pthread.h> |
| 18 | 18 |
| 19 #if SK_BUILD_FOR_ANDROID | 19 #if defined(SK_BUILD_FOR_ANDROID) |
| 20 # include <cpu-features.h> | 20 # include <cpu-features.h> |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 // A function used to determine at runtime if the target CPU supports | 23 // A function used to determine at runtime if the target CPU supports |
| 24 // the ARM NEON instruction set. This implementation is Linux-specific. | 24 // the ARM NEON instruction set. This implementation is Linux-specific. |
| 25 static bool sk_cpu_arm_check_neon(void) { | 25 static bool sk_cpu_arm_check_neon(void) { |
| 26 // If we fail any of the following, assume we don't have NEON instructions | 26 // If we fail any of the following, assume we don't have NEON instructions |
| 27 // This allows us to return immediately in case of error. | 27 // This allows us to return immediately in case of error. |
| 28 bool result = false; | 28 bool result = false; |
| 29 | 29 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 void sk_cpu_arm_probe_features(void) { | 137 void sk_cpu_arm_probe_features(void) { |
| 138 sHasArmNeon = sk_cpu_arm_check_neon(); | 138 sHasArmNeon = sk_cpu_arm_check_neon(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool sk_cpu_arm_has_neon(void) { | 141 bool sk_cpu_arm_has_neon(void) { |
| 142 pthread_once(&sOnce, sk_cpu_arm_probe_features); | 142 pthread_once(&sOnce, sk_cpu_arm_probe_features); |
| 143 return sHasArmNeon; | 143 return sHasArmNeon; |
| 144 } | 144 } |
| 145 | 145 |
| 146 #endif // SK_ARM_NEON_IS_DYNAMIC | 146 #endif // SK_ARM_NEON_IS_DYNAMIC |
| OLD | NEW |