2026-03-29 09:28:49 +08:00
|
|
|
extern "C" {
|
2023-10-05 19:06:15 +08:00
|
|
|
#include "libc.h"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef __MINGW32__
|
2026-04-15 16:16:46 +08:00
|
|
|
#include <_mingw.h>
|
2023-10-05 19:06:15 +08:00
|
|
|
#endif
|
|
|
|
|
|
2026-03-29 09:28:49 +08:00
|
|
|
template <uint32_t Major, uint32_t Minor>
|
2023-10-05 19:06:15 +08:00
|
|
|
class version_t {
|
|
|
|
|
constexpr static auto buflen() noexcept {
|
|
|
|
|
unsigned int len = 2; // "."
|
2026-03-29 09:28:49 +08:00
|
|
|
if (Major == 0) {
|
2023-10-05 19:06:15 +08:00
|
|
|
len++;
|
2026-03-29 09:28:49 +08:00
|
|
|
} else {
|
2023-10-05 19:06:15 +08:00
|
|
|
for (auto n = Major; n; len++, n /= 10);
|
2026-03-29 09:28:49 +08:00
|
|
|
}
|
2023-10-05 19:06:15 +08:00
|
|
|
|
2026-03-29 09:28:49 +08:00
|
|
|
if (Minor == 0) {
|
2023-10-05 19:06:15 +08:00
|
|
|
len++;
|
2026-03-29 09:28:49 +08:00
|
|
|
} else {
|
2023-10-05 19:06:15 +08:00
|
|
|
for (auto n = Minor; n; len++, n /= 10);
|
2026-03-29 09:28:49 +08:00
|
|
|
}
|
2023-10-05 19:06:15 +08:00
|
|
|
return len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char buf[buflen()] = {};
|
|
|
|
|
|
2026-03-29 09:28:49 +08:00
|
|
|
public:
|
2023-10-05 19:06:15 +08:00
|
|
|
constexpr version_t() noexcept {
|
|
|
|
|
auto ptr = buf + buflen();
|
|
|
|
|
*--ptr = '\0';
|
|
|
|
|
|
|
|
|
|
if (Minor == 0) {
|
|
|
|
|
*--ptr = '0';
|
|
|
|
|
} else {
|
2026-03-29 09:28:49 +08:00
|
|
|
for (auto n = Minor; n; n /= 10) {
|
2023-10-05 19:06:15 +08:00
|
|
|
*--ptr = "0123456789"[n % 10];
|
2026-03-29 09:28:49 +08:00
|
|
|
}
|
2023-10-05 19:06:15 +08:00
|
|
|
}
|
|
|
|
|
*--ptr = '.';
|
|
|
|
|
if (Major == 0) {
|
|
|
|
|
*--ptr = '0';
|
|
|
|
|
} else {
|
2026-03-29 09:28:49 +08:00
|
|
|
for (auto n = Major; n; n /= 10) {
|
2023-10-05 19:06:15 +08:00
|
|
|
*--ptr = "0123456789"[n % 10];
|
2026-03-29 09:28:49 +08:00
|
|
|
}
|
2023-10-05 19:06:15 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-29 09:28:49 +08:00
|
|
|
constexpr operator const char*() const {
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
2023-10-05 19:06:15 +08:00
|
|
|
};
|
|
|
|
|
|
2026-03-29 09:28:49 +08:00
|
|
|
template <uint32_t Major, uint32_t Minor>
|
2023-10-05 19:06:15 +08:00
|
|
|
constexpr version_t<Major, Minor> version;
|
|
|
|
|
|
2026-03-29 09:28:49 +08:00
|
|
|
extern "C" const char* ffDetectLibc(FFLibcResult* result) {
|
2023-10-05 19:06:15 +08:00
|
|
|
#ifdef _UCRT
|
|
|
|
|
result->name = "ucrt";
|
|
|
|
|
#else
|
|
|
|
|
result->name = "msvcrt";
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
result->version = version<(__MSVCRT_VERSION__ >> 8), (__MSVCRT_VERSION__ & 8)>;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|