26 #if (defined(__amd64__) || defined(__i386__)) && defined(__GNUC__) \
27 && (GCC_VERSION >= 40800) && !defined(ANDROID)
29 #elif defined(__linux__) || defined(__linux)
36 #include <SDL_cpuinfo.h>
48 #if (defined(__amd64__) || defined(__i386__)) && defined(__GNUC__) \
49 && (GCC_VERSION >= 40800) && !defined(ANDROID)
51 if (__builtin_cpu_supports (
"mmx"))
53 if (__builtin_cpu_supports (
"sse"))
55 if (__builtin_cpu_supports (
"sse2"))
57 if (__builtin_cpu_supports (
"ssse3"))
59 if (__builtin_cpu_supports (
"sse4.1"))
61 if (__builtin_cpu_supports (
"sse4.2"))
63 if (__builtin_cpu_supports (
"avx"))
65 if (__builtin_cpu_supports (
"avx2"))
68 #elif defined(__linux__) || defined(__linux)
69 FILE *file = fopen(
"/proc/cpuinfo",
"r");
73 while (fgets(buf, 1000, file) !=
nullptr)
75 std::string str = buf;
78 size_t idx = str.find(
':');
79 if (idx == std::string::npos)
81 str = str.substr(idx + 1);
87 const std::string &flag = *it;
90 else if (flag ==
"sse")
92 else if (flag ==
"sse2")
94 else if (flag ==
"ssse3")
96 else if (flag ==
"sse4_1")
98 else if (flag ==
"sse4_2")
100 else if (flag ==
"avx")
102 else if (flag ==
"avx2")
112 logger->
log(
"cpu features was not detected");
129 #if SDL_VERSION_ATLEAST(2, 0, 2)
133 #if SDL_VERSION_ATLEAST(2, 0, 4)
142 logger->
log(
"cpu features not supported");
147 #if SDL_VERSION_ATLEAST(2, 0, 1)
148 logger->
log(
"System ram size: %d", SDL_GetSystemRAM());
156 std::string str(
"CPU features:");
164 str.append(
" ssse3");
168 str.append(
" sse4_2");
void log(const char *const log_text,...)
#define FOR_EACH(type, iter, array)
std::string trim(std::string const &str)
void splitToStringVector(StringVect &tokens, const std::string &text, const char separator)
bool findFirst(const std::string &str1, const std::string &str2)
StringVect::const_iterator StringVectCIter
std::vector< std::string > StringVect