Files
clang-p2996/compiler-rt/test/orc/TestCases/Linux/ppc64/Inputs/trivial-tls-main.cpp
Kai Luo 18dc8dcd76 [PowerPC][JITLink] Support R_PPC64_GOT_TLSGD_PCREL34 (#68660)
`R_PPC64_GOT_TLSGD_PCREL34` is generated for pwr10+.
2023-10-14 10:57:03 +08:00

31 lines
614 B
C++

#include <fstream>
#include <iostream>
#include <string>
thread_local int x = 0;
thread_local int y = 1;
thread_local int z = -1;
extern int TestPOWER10();
int Test() { return x + y + z; }
static bool CPUModelIsPOWER10() {
std::string line;
std::ifstream cpuinfo("/proc/cpuinfo", std::ios::in);
if (!cpuinfo.is_open())
return false;
while (std::getline(cpuinfo, line)) {
if (line.find("cpu") != std::string::npos &&
line.find("POWER10") != std::string::npos)
return true;
}
return false;
}
int main() {
if (CPUModelIsPOWER10())
return TestPOWER10();
return Test();
}