ref: cf91f3a454e5640d6d35b55b4bdd1e3ba1818755
parent: 6549be16dd7ed228466262d0cddf006d43f0ad3d
author: zamfofex <zamfofex@twdb.moe>
date: Tue Nov 14 16:20:39 EST 2023
fix Windows build
--- a/search.c
+++ b/search.c
@@ -51,6 +51,10 @@
#include <unistd.h>
#include <errno.h>
+#ifdef __MINGW32__
+#include <sysinfoapi.h>
+#endif
+
struct moonfish_search_info
{pthread_t thread;
@@ -76,11 +80,19 @@
int i, j;
struct moonfish_search_info infos[32];
int result;
+#ifdef __MINGW32__
+ SYSTEM_INFO info;
+#endif
if (ctx->cpu_count < 0)
{errno = 0;
+#ifdef __MINGW32__
+ GetSystemInfo(&info);
+ ctx->cpu_count = info.dwNumberOfProcessors;
+#else
ctx->cpu_count = sysconf(_SC_NPROCESSORS_ONLN);
+#endif
if (ctx->cpu_count <= 0)
{if (errno == 0) fprintf(stderr, "%s: unknown CPU count\n", ctx->argv0);
--
⑨