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 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 char* buffer_end = buffer + 1 + size; | 81 char* buffer_end = buffer + 1 + size; |
82 buffer_end[0] = '\n'; | 82 buffer_end[0] = '\n'; |
83 | 83 |
84 // Now, find a line that starts with "Features", i.e. look for | 84 // Now, find a line that starts with "Features", i.e. look for |
85 // '\nFeatures ' in our buffer. | 85 // '\nFeatures ' in our buffer. |
86 const char features[] = "\nFeatures\t"; | 86 const char features[] = "\nFeatures\t"; |
87 const size_t features_len = sizeof(features)-1; | 87 const size_t features_len = sizeof(features)-1; |
88 | 88 |
89 char* line = (char*) memmem(buffer, buffer_end - buffer, | 89 char* line = (char*) memmem(buffer, buffer_end - buffer, |
90 features, features_len); | 90 features, features_len); |
91 if (line == NULL) { // Weird, no Features line, bad kernel? | 91 if (line == nullptr) { // Weird, no Features line, bad kernel? |
92 SkDebugf("Could not find a line starting with 'Features'" | 92 SkDebugf("Could not find a line starting with 'Features'" |
93 "in /proc/cpuinfo ?\n"); | 93 "in /proc/cpuinfo ?\n"); |
94 break; | 94 break; |
95 } | 95 } |
96 | 96 |
97 line += features_len; // Skip the "\nFeatures\t" prefix | 97 line += features_len; // Skip the "\nFeatures\t" prefix |
98 | 98 |
99 // Find the end of the current line | 99 // Find the end of the current line |
100 char* line_end = (char*) memchr(line, '\n', buffer_end - line); | 100 char* line_end = (char*) memchr(line, '\n', buffer_end - line); |
101 if (line_end == NULL) | 101 if (line_end == nullptr) |
102 line_end = buffer_end; | 102 line_end = buffer_end; |
103 | 103 |
104 // Now find an instance of 'neon' in the flags list. We want to | 104 // Now find an instance of 'neon' in the flags list. We want to |
105 // ensure it's only 'neon' and not something fancy like 'noneon' | 105 // ensure it's only 'neon' and not something fancy like 'noneon' |
106 // so check that it follows a space. | 106 // so check that it follows a space. |
107 const char neon[] = " neon"; | 107 const char neon[] = " neon"; |
108 const size_t neon_len = sizeof(neon)-1; | 108 const size_t neon_len = sizeof(neon)-1; |
109 const char* flag = (const char*) memmem(line, line_end - line, | 109 const char* flag = (const char*) memmem(line, line_end - line, |
110 neon, neon_len); | 110 neon, neon_len); |
111 if (flag == NULL) | 111 if (flag == nullptr) |
112 break; | 112 break; |
113 | 113 |
114 // Ensure it is followed by a space or a newline. | 114 // Ensure it is followed by a space or a newline. |
115 if (flag[neon_len] != ' ' && flag[neon_len] != '\n') | 115 if (flag[neon_len] != ' ' && flag[neon_len] != '\n') |
116 break; | 116 break; |
117 | 117 |
118 // Fine, we support Arm NEON ! | 118 // Fine, we support Arm NEON ! |
119 result = true; | 119 result = true; |
120 | 120 |
121 } while (0); | 121 } while (0); |
(...skipping 15 matching lines...) Expand all 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 |