2 * Copyright 2014 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef FOLLY_CPUID_H_
18 #define FOLLY_CPUID_H_
21 #include "folly/Portability.h"
26 * Identification of an Intel CPU.
27 * Supports CPUID (EAX=1) feature flags.
28 * Values from http://www.intel.com/content/www/us/en/processors/processor-identification-cpuid-instruction-note.html
33 #if FOLLY_X64 || defined(__i386__)
34 __asm__("cpuid" : "=c"(c_), "=d"(d_) : "a"(1) : "ebx");
36 // On non-Intel, none of these features exist; at least not in the same form
37 // as they do on Intel
42 #define X(name, r, bit) bool name() const { return r & (1U << bit); }
43 #define C(name, bit) X(name, c_, bit)
44 #define D(name, bit) X(name, d_, bit)
119 #endif /* FOLLY_CPUID_H_ */