| 1 | #include <fstream> |
|---|---|
| 2 | #include <iostream> |
| 3 | #include <string> |
| 4 | |
| 5 | thread_local int x = 0; |
| 6 | thread_local int y = 1; |
| 7 | thread_local int z = -1; |
| 8 | |
| 9 | extern int TestPOWER10(); |
| 10 | |
| 11 | int Test() { return x + y + z; } |
| 12 | |
| 13 | static bool CPUModelIsPOWER10() { |
| 14 | std::string line; |
| 15 | std::ifstream cpuinfo("/proc/cpuinfo", std::ios::in); |
| 16 | if (!cpuinfo.is_open()) |
| 17 | return false; |
| 18 | while (std::getline(is&: cpuinfo, str&: line)) { |
| 19 | if (line.find(s: "cpu") != std::string::npos && |
| 20 | line.find(s: "POWER10") != std::string::npos) |
| 21 | return true; |
| 22 | } |
| 23 | return false; |
| 24 | } |
| 25 | |
| 26 | int main() { |
| 27 | if (CPUModelIsPOWER10()) |
| 28 | return TestPOWER10(); |
| 29 | return Test(); |
| 30 | } |
| 31 |
