Commit | Line | Data |
---|---|---|
08e2be29 MW |
1 | /* -*-c-*- |
2 | * | |
3 | * CPU-specific dispatch | |
4 | * | |
5 | * (c) 2015 Straylight/Edgeware | |
6 | */ | |
7 | ||
8 | /*----- Licensing notice --------------------------------------------------* | |
9 | * | |
10 | * This file is part of Catacomb. | |
11 | * | |
12 | * Catacomb is free software; you can redistribute it and/or modify | |
13 | * it under the terms of the GNU Library General Public License as | |
14 | * published by the Free Software Foundation; either version 2 of the | |
15 | * License, or (at your option) any later version. | |
16 | * | |
17 | * Catacomb is distributed in the hope that it will be useful, | |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | * GNU Library General Public License for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU Library General Public | |
23 | * License along with Catacomb; if not, write to the Free | |
24 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, | |
25 | * MA 02111-1307, USA. | |
26 | */ | |
27 | ||
28 | /*----- Header files ------------------------------------------------------*/ | |
29 | ||
30 | #include "config.h" | |
31 | ||
32 | #include <ctype.h> | |
fac645f7 MW |
33 | #include <stdarg.h> |
34 | #include <stdio.h> | |
08e2be29 MW |
35 | #include <stdlib.h> |
36 | #include <string.h> | |
37 | ||
38 | #include <mLib/macros.h> | |
39 | ||
40 | #include "dispatch.h" | |
41 | ||
d26ad211 | 42 | /*----- Intel x86/AMD64 feature probing -----------------------------------*/ |
08e2be29 | 43 | |
0f23f75f | 44 | #if CPUFAM_X86 || CPUFAM_AMD64 |
08e2be29 | 45 | |
7680f863 MW |
46 | # define EFLAGS_ID (1u << 21) |
47 | # define CPUID1D_SSE2 (1u << 26) | |
48 | # define CPUID1D_FXSR (1u << 24) | |
49 | # define CPUID1C_AESNI (1u << 25) | |
d25653be | 50 | # define CPUID1C_RDRAND (1u << 30) |
08e2be29 MW |
51 | |
52 | struct cpuid { unsigned a, b, c, d; }; | |
53 | ||
54 | /* --- @cpuid@ --- * | |
55 | * | |
56 | * Arguments: @struct cpuid *cc@ = where to write the result | |
57 | * @unsigned a, c@ = EAX and ECX registers to set | |
58 | * | |
59 | * Returns: --- | |
60 | * | |
61 | * Use: Minimal C wrapper around the x86 `CPUID' instruction. Checks | |
62 | * that the instruction is actually available before invoking | |
63 | * it; fills the output structure with zero if it's not going to | |
64 | * work. | |
65 | */ | |
66 | ||
67 | #ifdef __GNUC__ | |
0f23f75f | 68 | # if CPUFAM_X86 |
08e2be29 MW |
69 | static __inline__ unsigned getflags(void) |
70 | { unsigned f; __asm__ ("pushf; popl %0" : "=g" (f)); return (f); } | |
71 | static __inline__ unsigned setflags(unsigned f) | |
72 | { | |
73 | unsigned ff; | |
74 | __asm__ ("pushf; pushl %1; popf; pushf; popl %0; popf" | |
75 | : "=g" (ff) | |
76 | : "g" (f)); | |
77 | return (ff); | |
78 | } | |
0f23f75f MW |
79 | # else |
80 | static __inline__ unsigned long getflags(void) | |
81 | { unsigned long f; __asm__ ("pushf; popq %0" : "=g" (f)); return (f); } | |
82 | static __inline__ unsigned long long setflags(unsigned long f) | |
83 | { | |
84 | unsigned long ff; | |
85 | __asm__ ("pushf; pushq %1; popf; pushf; popq %0; popf" | |
86 | : "=g" (ff) | |
87 | : "g" (f)); | |
88 | return (ff); | |
89 | } | |
90 | # endif | |
08e2be29 MW |
91 | #endif |
92 | ||
93 | static void cpuid(struct cpuid *cc, unsigned a, unsigned c) | |
94 | { | |
95 | #ifdef __GNUC__ | |
96 | unsigned f; | |
97 | #endif | |
98 | ||
99 | cc->a = cc->b = cc->c = cc->d = 0; | |
100 | ||
101 | #ifdef __GNUC__ | |
102 | /* Stupid dance to detect whether the CPUID instruction is available. */ | |
103 | f = getflags(); | |
fac645f7 MW |
104 | if (!(setflags(f | EFLAGS_ID) & EFLAGS_ID) || |
105 | setflags(f & ~EFLAGS_ID) & EFLAGS_ID) { | |
106 | dispatch_debug("CPUID instruction not available"); | |
107 | return; | |
108 | } | |
08e2be29 MW |
109 | setflags(f); |
110 | ||
111 | /* Alas, EBX is magical in PIC code, so abuse ESI instead. This isn't | |
112 | * pretty, but it works. | |
113 | */ | |
0f23f75f | 114 | # if CPUFAM_X86 |
08e2be29 MW |
115 | __asm__ ("pushl %%ebx; cpuid; movl %%ebx, %%esi; popl %%ebx" |
116 | : "=a" (cc->a), "=S" (cc->b), "=c" (cc->c), "=d" (cc->d) | |
117 | : "a" (a) , "c" (c)); | |
0f23f75f MW |
118 | # elif CPUFAM_AMD64 |
119 | __asm__ ("pushq %%rbx; cpuid; movl %%ebx, %%esi; popq %%rbx" | |
120 | : "=a" (cc->a), "=S" (cc->b), "=c" (cc->c), "=d" (cc->d) | |
121 | : "a" (a) , "c" (c)); | |
122 | # else | |
123 | # error "I'm confused." | |
124 | # endif | |
125 | dispatch_debug("CPUID(%08x, %08x) -> %08x, %08x, %08x, %08x", | |
126 | a, c, cc->a, cc->b, cc->c, cc->d); | |
fac645f7 MW |
127 | #else |
128 | dispatch_debug("GNU inline assembler not available; can't CPUID"); | |
08e2be29 MW |
129 | #endif |
130 | } | |
131 | ||
132 | static unsigned cpuid_maxleaf(void) | |
133 | { struct cpuid c; cpuid(&c, 0, 0); return (c.a); } | |
134 | ||
11b17977 MW |
135 | /* --- @cpuid_features_p@ --- * |
136 | * | |
137 | * Arguments: @unsigned dbits@ = bits to check in EDX | |
138 | * @unsigned cbits@ = bits to check in ECX | |
139 | * | |
140 | * Returns: Nonzero if all the requested bits are set in the CPUID result | |
141 | * on leaf 1. | |
142 | */ | |
143 | ||
08e2be29 MW |
144 | static int cpuid_features_p(unsigned dbits, unsigned cbits) |
145 | { | |
146 | struct cpuid c; | |
147 | if (cpuid_maxleaf() < 1) return (0); | |
148 | cpuid(&c, 1, 0); | |
149 | return ((c.d & dbits) == dbits && (c.c & cbits) == cbits); | |
150 | } | |
151 | ||
11b17977 MW |
152 | /* --- @xmm_registers_available_p@ --- * |
153 | * | |
154 | * Arguments: --- | |
155 | * | |
156 | * Returns: Nonzero if the operating system has made the XMM registers | |
157 | * available for use. | |
158 | */ | |
159 | ||
acbe16df MW |
160 | static int xmm_registers_available_p(void) |
161 | { | |
162 | #ifdef __GNUC__ | |
163 | unsigned f; | |
164 | /* This hack is by Agner Fog. Use FXSAVE/FXRSTOR to figure out whether the | |
165 | * XMM registers are actually alive. | |
166 | */ | |
167 | if (!cpuid_features_p(CPUID1D_FXSR, 0)) return (0); | |
0f23f75f | 168 | # if CPUFAM_X86 |
acbe16df MW |
169 | __asm__ ("movl %%esp, %%edx; subl $512, %%esp; andl $~15, %%esp\n" |
170 | "fxsave (%%esp)\n" | |
171 | "movl 160(%%esp), %%eax; xorl $0xaaaa5555, 160(%%esp)\n" | |
172 | "fxrstor (%%esp); fxsave (%%esp)\n" | |
173 | "movl 160(%%esp), %%ecx; movl %%eax, 160(%%esp)\n" | |
174 | "fxrstor (%%esp); movl %%edx, %%esp\n" | |
175 | "xorl %%ecx, %%eax" | |
176 | : "=a" (f) | |
177 | : /* no inputs */ | |
178 | : "%ecx", "%edx"); | |
0f23f75f MW |
179 | # elif CPUFAM_AMD64 |
180 | __asm__ ("movq %%rsp, %%rdx; subq $512, %%rsp; andq $~15, %%rsp\n" | |
181 | "fxsave (%%rsp)\n" | |
182 | "movl 160(%%rsp), %%eax; xorl $0xaaaa5555, 160(%%rsp)\n" | |
183 | "fxrstor (%%rsp); fxsave (%%rsp)\n" | |
184 | "movl 160(%%rsp), %%ecx; movl %%eax, 160(%%rsp)\n" | |
185 | "fxrstor (%%rsp); movq %%rdx, %%rsp\n" | |
186 | "xorl %%ecx, %%eax" | |
187 | : "=a" (f) | |
188 | : /* no inputs */ | |
189 | : "%ecx", "%rdx"); | |
190 | # else | |
191 | # error "I'm confused." | |
192 | # endif | |
193 | dispatch_debug("XMM registers %savailable", f ? "" : "not "); | |
acbe16df MW |
194 | return (f); |
195 | #else | |
fac645f7 | 196 | dispatch_debug("GNU inline assembler not available; can't check for XMM"); |
acbe16df MW |
197 | return (0); |
198 | #endif | |
199 | } | |
200 | ||
08e2be29 MW |
201 | #endif |
202 | ||
a02a22d4 MW |
203 | /*----- General feature probing using auxiliary vectors -------------------*/ |
204 | ||
205 | /* Try to find the system's definitions for auxiliary vector entries. */ | |
206 | #ifdef HAVE_SYS_AUXV_H | |
207 | # include <sys/auxv.h> | |
a0e9bb8a MW |
208 | #endif |
209 | #ifdef HAVE_LINUX_AUXVEC_H | |
210 | # include <linux/auxvec.h> | |
211 | #endif | |
212 | #ifdef HAVE_ASM_HWCAP_H | |
213 | # include <asm/hwcap.h> | |
a02a22d4 MW |
214 | #endif |
215 | ||
216 | /* The type of entries in the auxiliary vector. I'm assuming that `unsigned | |
217 | * long' matches each platform's word length; if this is false then we'll | |
218 | * need some host-specific tweaking here. | |
219 | */ | |
220 | union auxval { long i; unsigned long u; const void *p; }; | |
221 | struct auxentry { unsigned long type; union auxval value; }; | |
222 | ||
223 | /* Register each CPU family's interest in the auxiliary vector. Make sure | |
224 | * that the necessary entry types are defined. This is primarily ordered by | |
225 | * entry type to minimize duplication. | |
226 | */ | |
61bd904b MW |
227 | #if defined(AT_HWCAP) && CPUFAM_ARMEL |
228 | # define WANT_ANY 1 | |
229 | # define WANT_AT_HWCAP(_) _(AT_HWCAP, u, hwcap) | |
230 | #endif | |
a02a22d4 MW |
231 | |
232 | /* If we couldn't find any interesting entries then we can switch all of this | |
233 | * machinery off. Also do that if we have no means for atomic updates. | |
234 | */ | |
235 | #if WANT_ANY && CPU_DISPATCH_P | |
236 | ||
237 | /* The main output of this section is a bitmask of detected features. The | |
238 | * least significant bit will be set if we've tried to probe. Always access | |
239 | * this using `DISPATCH_LOAD' and `DISPATCH_STORE'. | |
240 | */ | |
241 | static unsigned hwcaps = 0; | |
242 | ||
243 | /* For each potentially interesting type which turned out not to exist or be | |
244 | * wanted, define a dummy macro for the sake of the next step. | |
245 | */ | |
246 | #ifndef WANT_AT_HWCAP | |
247 | # define WANT_AT_HWCAP(_) | |
248 | #endif | |
f013a4f2 MW |
249 | #ifndef WANT_AT_HWCAP2 |
250 | # define WANT_AT_HWCAP2(_) | |
251 | #endif | |
a02a22d4 MW |
252 | |
253 | /* For each CPU family, define two lists. | |
254 | * | |
255 | * * `WANTAUX' is a list of the `WANT_AT_MUMBLE' macros which the CPU | |
256 | * family tried to register interest in above. Each entry contains the | |
257 | * interesting auxiliary vector entry type, the name of the union branch | |
258 | * for its value, and the name of the slot in `struct auxprobe' in which | |
259 | * to store the value. | |
260 | * | |
261 | * * `CAPMAP' is a list describing the output features which the CPU family | |
262 | * intends to satisfy from the auxiliary vector. Each entry contains a | |
263 | * feature name suffix, and the token name (for `check_env'). | |
264 | */ | |
61bd904b MW |
265 | #if CPUFAM_ARMEL |
266 | # define WANTAUX(_) \ | |
267 | WANT_AT_HWCAP(_) | |
268 | # define CAPMAP(_) \ | |
269 | _(ARM_VFP, "arm:vfp") \ | |
270 | _(ARM_NEON, "arm:neon") \ | |
271 | _(ARM_V4, "arm:v4") \ | |
272 | _(ARM_D32, "arm:d32") | |
273 | #endif | |
a02a22d4 MW |
274 | |
275 | /* Build the bitmask for `hwcaps' from the `CAPMAP' list. */ | |
276 | enum { | |
277 | HFI_PROBED = 0, | |
278 | #define HFI__ENUM(feat, tok) HFI_##feat, | |
279 | CAPMAP(HFI__ENUM) | |
280 | #undef HFI__ENUM | |
281 | HFI__END | |
282 | }; | |
283 | enum { | |
284 | HF_PROBED = 1, | |
285 | #define HF__FLAG(feat, tok) HF_##feat = 1 << HFI_##feat, | |
286 | CAPMAP(HF__FLAG) | |
287 | #undef HF__FLAG | |
288 | HF__END | |
289 | }; | |
290 | ||
291 | /* Build a structure in which we can capture the interesting data from the | |
292 | * auxiliary vector. | |
293 | */ | |
294 | #define AUXUTYPE_i long | |
295 | #define AUXUTYPE_u unsigned long | |
296 | #define AUXUTYPE_p const void * | |
297 | struct auxprobe { | |
298 | #define AUXPROBE__SLOT(type, ubranch, slot) AUXUTYPE_##ubranch slot; | |
299 | WANTAUX(AUXPROBE__SLOT) | |
300 | #undef AUXPROBE_SLOT | |
301 | }; | |
302 | ||
303 | /* --- @probe_hwcaps@ --- * | |
304 | * | |
305 | * Arguments: --- | |
306 | * | |
307 | * Returns: --- | |
308 | * | |
309 | * Use: Attempt to find the auxiliary vector (which is well hidden) | |
310 | * and discover interesting features from it. | |
311 | */ | |
312 | ||
313 | static void probe_hwcaps(void) | |
314 | { | |
315 | unsigned hw = HF_PROBED; | |
316 | struct auxprobe probed = { 0 }; | |
317 | ||
318 | /* Populate `probed' with the information we manage to retrieve from the | |
319 | * auxiliary vector. Slots we couldn't find are left zero-valued. | |
320 | */ | |
321 | #if defined(HAVE_GETAUXVAL) | |
322 | /* Shiny new libc lets us request individual entry types. This is almost | |
323 | * too easy. | |
324 | */ | |
84850eec MW |
325 | # define CAP__GET(type, ubranch, slot) \ |
326 | probed.slot = (AUXUTYPE_##ubranch)getauxval(type); | |
a02a22d4 MW |
327 | WANTAUX(CAP__GET) |
328 | #else | |
329 | /* Otherwise we're a bit stuck, really. Modern Linux kernels make a copy | |
330 | * of the vector available in `/procc' so we could try that. | |
331 | * | |
332 | * The usual place is stuck on the end of the environment vector, but that | |
333 | * may well have moved, and we have no way of telling whether it has or | |
334 | * whether there was ever an auxiliary vector there at all; so don't do | |
335 | * that. | |
336 | */ | |
337 | { | |
338 | FILE *fp = 0; | |
339 | unsigned char *p = 0, *q = 0; | |
340 | const struct auxentry *a; | |
341 | size_t sz, off, n; | |
342 | ||
343 | /* Open the file and read it into a memory chunk. */ | |
344 | if ((fp = fopen("/proc/self/auxv", "rb")) == 0) goto clean; | |
345 | sz = 4096; off = 0; | |
346 | if ((p = malloc(sz)) == 0) goto clean; | |
347 | for (;;) { | |
348 | n = fread(p + off, 1, sz - off, fp); | |
349 | off += n; | |
350 | if (off < sz) break; | |
351 | sz *= 2; if ((q = realloc(p, sz)) == 0) break; | |
352 | p = q; | |
353 | } | |
354 | ||
355 | /* Work through the vector (or as much of it as we found) and extract the | |
356 | * types we're interested in. | |
357 | */ | |
358 | for (a = (const struct auxentry *)p, | |
359 | n = sz/sizeof(struct auxentry); | |
360 | n--; a++) { | |
361 | switch (a->type) { | |
362 | #define CAP__SWITCH(type, ubranch, slot) \ | |
363 | case type: probed.slot = a->value.ubranch; break; | |
364 | WANTAUX(CAP__SWITCH) | |
dfcb2a0b | 365 | case AT_NULL: goto clean; |
a02a22d4 MW |
366 | } |
367 | } | |
368 | ||
369 | clean: | |
370 | if (p) free(p); | |
371 | if (fp) fclose(fp); | |
372 | } | |
373 | #endif | |
374 | ||
375 | /* Each CPU family now has to pick through what was found and stashed in | |
376 | * `probed', and set the appropriate flag bits in `hw'. | |
377 | */ | |
61bd904b MW |
378 | #if CPUFAM_ARMEL |
379 | if (probed.hwcap & HWCAP_VFPv3) hw |= HF_ARM_VFP; | |
380 | if (probed.hwcap & HWCAP_NEON) hw |= HF_ARM_NEON; | |
381 | if (probed.hwcap & HWCAP_VFPD32) hw |= HF_ARM_D32; | |
382 | if (probed.hwcap & HWCAP_VFPv4) hw |= HF_ARM_V4; | |
383 | #endif | |
a02a22d4 MW |
384 | |
385 | /* Store the bitmask of features we probed for everyone to see. */ | |
386 | DISPATCH_STORE(hwcaps, hw); | |
387 | ||
388 | /* Finally, make a report about the things we found. (Doing this earlier | |
389 | * will pointlessly widen the window in which multiple threads will do the | |
390 | * above auxiliary-vector probing.) | |
391 | */ | |
392 | #define CAP__DEBUG(feat, tok) \ | |
393 | dispatch_debug("check auxv for feature `%s': %s", tok, \ | |
394 | hw & HF_##feat ? "available" : "absent"); | |
395 | CAPMAP(CAP__DEBUG) | |
396 | #undef CAP__DEBUG | |
397 | } | |
398 | ||
399 | /* --- @get_hwcaps@ --- * | |
400 | * | |
401 | * Arguments: --- | |
402 | * | |
403 | * Returns: A mask of hardware capabilities and other features, as probed | |
404 | * from the auxiliary vector. | |
405 | */ | |
406 | ||
407 | static unsigned get_hwcaps(void) | |
408 | { | |
409 | unsigned hw; | |
410 | ||
411 | DISPATCH_LOAD(hwcaps, hw); | |
412 | if (!(hwcaps & HF_PROBED)) { probe_hwcaps(); DISPATCH_LOAD(hwcaps, hw); } | |
413 | return (hw); | |
414 | } | |
415 | ||
416 | #endif | |
417 | ||
d26ad211 MW |
418 | /*----- External interface ------------------------------------------------*/ |
419 | ||
fac645f7 MW |
420 | /* --- @dispatch_debug@ --- * |
421 | * | |
422 | * Arguments: @const char *fmt@ = a format string | |
423 | * @...@ = additional arguments | |
424 | * | |
425 | * Returns: --- | |
426 | * | |
427 | * Use: Writes a formatted message to standard output if dispatch | |
428 | * debugging is enabled. | |
429 | */ | |
430 | ||
431 | void dispatch_debug(const char *fmt, ...) | |
432 | { | |
433 | va_list ap; | |
434 | const char *e = getenv("CATACOMB_CPUDISPATCH_DEBUG"); | |
435 | ||
436 | if (e && *e != 'n' && *e != '0') { | |
437 | va_start(ap, fmt); | |
438 | fputs("Catacomb CPUDISPATCH: ", stderr); | |
439 | vfprintf(stderr, fmt, ap); | |
440 | fputc('\n', stderr); | |
441 | va_end(ap); | |
442 | } | |
443 | } | |
444 | ||
08e2be29 MW |
445 | /* --- @check_env@ --- * |
446 | * | |
447 | * Arguments: @const char *ftok@ = feature token | |
448 | * | |
449 | * Returns: Zero if the feature is forced off; positive if it's forced | |
450 | * on; negative if the user hasn't decided. | |
451 | * | |
452 | * Use: Checks the environment variable `CATACOMB_CPUFEAT' for the | |
453 | * feature token @ftok@. The variable, if it exists, should be | |
454 | * a space-separated sequence of `+tok' and `-tok' items. These | |
455 | * tokens may end in `*', which matches any suffix. | |
456 | */ | |
457 | ||
458 | static int IGNORABLE check_env(const char *ftok) | |
459 | { | |
460 | const char *p, *q, *pp; | |
461 | int d; | |
462 | ||
463 | p = getenv("CATACOMB_CPUFEAT"); | |
464 | if (!p) return (-1); | |
465 | ||
466 | for (;;) { | |
467 | while (isspace((unsigned char)*p)) p++; | |
468 | if (!*p) return (-1); | |
469 | switch (*p) { | |
470 | case '+': d = +1; p++; break; | |
471 | case '-': d = 0; p++; break; | |
472 | default: d = -1; break; | |
473 | } | |
474 | for (q = p; *q && !isspace((unsigned char)*q); q++); | |
475 | if (d >= 0) { | |
476 | for (pp = ftok; p < q && *pp && *p == *pp; p++, pp++); | |
477 | if ((p == q && !*pp) || (*p == '*' && p + 1 == q)) return (d); | |
478 | } | |
479 | p = q; | |
480 | } | |
481 | return (-1); | |
482 | } | |
483 | ||
484 | /* --- @cpu_feature_p@ --- * | |
485 | * | |
486 | * Arguments: @unsigned feat@ = a @CPUFEAT_...@ code | |
487 | * | |
488 | * Returns: Nonzero if the feature is available. | |
489 | */ | |
490 | ||
491 | #include <stdio.h> | |
492 | ||
fac645f7 MW |
493 | static int IGNORABLE |
494 | feat_debug(const char *ftok, const char *check, int verdict) | |
495 | { | |
496 | if (verdict >= 0) { | |
497 | dispatch_debug("feature `%s': %s -> %s", ftok, check, | |
498 | verdict ? "available" : "absent"); | |
499 | } | |
500 | return (verdict); | |
501 | } | |
502 | ||
08e2be29 MW |
503 | int cpu_feature_p(int feat) |
504 | { | |
505 | int IGNORABLE f; | |
506 | IGNORE(f); | |
fac645f7 MW |
507 | #define CASE_CPUFEAT(feat, ftok, cond) case CPUFEAT_##feat: \ |
508 | if ((f = feat_debug(ftok, "environment override", \ | |
509 | check_env(ftok))) >= 0) \ | |
510 | return (f); \ | |
511 | else \ | |
512 | return (feat_debug(ftok, "runtime probe", cond)); | |
08e2be29 MW |
513 | |
514 | switch (feat) { | |
0f23f75f | 515 | #if CPUFAM_X86 || CPUFAM_AMD64 |
fac645f7 MW |
516 | CASE_CPUFEAT(X86_SSE2, "x86:sse2", |
517 | xmm_registers_available_p() && | |
518 | cpuid_features_p(CPUID1D_SSE2, 0)); | |
519 | CASE_CPUFEAT(X86_AESNI, "x86:aesni", | |
520 | xmm_registers_available_p() && | |
521 | cpuid_features_p(CPUID1D_SSE2, CPUID1C_AESNI)); | |
d25653be MW |
522 | CASE_CPUFEAT(X86_RDRAND, "x86:rdrand", |
523 | cpuid_features_p(0, CPUID1C_RDRAND)); | |
08e2be29 | 524 | #endif |
a02a22d4 MW |
525 | #ifdef CAPMAP |
526 | # define FEATP__CASE(feat, tok) \ | |
0aec0658 | 527 | CASE_CPUFEAT(feat, tok, get_hwcaps() & HF_##feat) |
a02a22d4 MW |
528 | CAPMAP(FEATP__CASE) |
529 | #undef FEATP__CASE | |
530 | #endif | |
08e2be29 | 531 | default: |
fac645f7 | 532 | dispatch_debug("denying unknown feature %d", feat); |
08e2be29 MW |
533 | return (0); |
534 | } | |
fac645f7 | 535 | #undef CASE_CPUFEAT |
08e2be29 MW |
536 | } |
537 | ||
538 | /*----- That's all, folks -------------------------------------------------*/ |