/*
- * Copyright 2012 Facebook, Inc.
+ * Copyright 2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#define FOLLY_CPUID_H_
#include <cstdint>
+#include <folly/Portability.h>
namespace folly {
class CpuId {
public:
CpuId() {
+#ifdef _MSC_VER
+ int reg[4];
+
+ __cpuid((int *)reg, 1);
+ c_ = reg[2];
+ d_ = reg[3];
+
+#elif FOLLY_X64 || defined(__i386__)
__asm__("cpuid" : "=c"(c_), "=d"(d_) : "a"(1) : "ebx");
+#else
+ // On non-Intel, none of these features exist; at least not in the same form
+ // as they do on Intel
+ c_ = 0;
+ d_ = 0;
+#endif
}
#define X(name, r, bit) bool name() const { return r & (1U << bit); }
#define C(name, bit) X(name, c_, bit)