31 lines · cpp
1#include <fstream>2#include <iostream>3#include <string>4 5thread_local int x = 0;6thread_local int y = 1;7thread_local int z = -1;8 9extern int TestPOWER10();10 11int Test() { return x + y + z; }12 13static 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(cpuinfo, line)) {19 if (line.find("cpu") != std::string::npos &&20 line.find("POWER10") != std::string::npos)21 return true;22 }23 return false;24}25 26int main() {27 if (CPUModelIsPOWER10())28 return TestPOWER10();29 return Test();30}31