branch: externals/hotfuzz
commit ff72f544e03dd2afb358f28014b15529104c1d89
Author: Kim Schmider <[email protected]>
Commit: Axel Forsman <[email protected]>
Allow C module to be built on Windows
---
hotfuzz-module.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/hotfuzz-module.c b/hotfuzz-module.c
index 04eeb64b92..3636652bec 100644
--- a/hotfuzz-module.c
+++ b/hotfuzz-module.c
@@ -10,7 +10,20 @@
#include <string.h>
#include <emacs-module.h>
#include <pthread.h>
+
+#ifdef _WIN32
+#include <sysinfoapi.h>
+long get_max_workers() {
+ SYSTEM_INFO sysinfo;
+ GetSystemInfo(&sysinfo);
+ return sysinfo.dwNumberOfProcessors;
+}
+#else
#include <unistd.h>
+long get_max_workers() {
+ return sysconf(_SC_NPROCESSORS_ONLN);
+}
+#endif
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
@@ -278,7 +291,7 @@ int emacs_module_init(struct emacs_runtime *rt) {
emacs_env *env = rt->get_environment(rt);
if ((size_t) env->size < sizeof *env) return 2;
- long max_workers = sysconf(_SC_NPROCESSORS_ONLN);
+ long max_workers = get_max_workers();
struct Data *data;
if (!(data = malloc(sizeof *data + max_workers * sizeof
*data->threads)))
return 1;