Created
November 21, 2018 14:35
-
-
Save logzero/9655eb67e39b036aad4a95f2b672c442 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 4e3b688841888cfe517fcd4f3a2d45e729316fa1 Mon Sep 17 00:00:00 2001 | |
From: Sergej Forat <core13@gmx.net> | |
Date: Wed, 21 Nov 2018 14:57:50 +0100 | |
Subject: [PATCH 1/2] Write png in binary mode. | |
Signed-off-by: Sergej Forat <core13@gmx.net> | |
--- | |
png_utils.c | 2 +- | |
1 file changed, 1 insertion(+), 1 deletion(-) | |
diff --git a/png_utils.c b/png_utils.c | |
index f3093ad..a99ad16 100644 | |
--- a/png_utils.c | |
+++ b/png_utils.c | |
@@ -34,7 +34,7 @@ int png_utils_write_png_image(const char *filename, unsigned char *pixels, int w | |
FILE *f; | |
rc = -1; /* assume failure until we eventually succeed */ | |
- f = fopen(filename, "w"); | |
+ f = fopen(filename, "wb"); | |
if (!f) { | |
fprintf(stderr, "fopen: %s:%s\n", filename, strerror(errno)); | |
return -1; | |
-- | |
2.19.1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 1f3fcc194c1b587f0bc7da8690ac0c9b45e5f750 Mon Sep 17 00:00:00 2001 | |
From: Sergej Forat <core13@gmx.net> | |
Date: Wed, 21 Nov 2018 15:12:28 +0100 | |
Subject: [PATCH 2/2] Implement Windows-compatible get_num_cpus function. | |
Signed-off-by: Sergej Forat <core13@gmx.net> | |
--- | |
gaseous-giganticus.c | 17 ++++++++++++++++- | |
1 file changed, 16 insertions(+), 1 deletion(-) | |
diff --git a/gaseous-giganticus.c b/gaseous-giganticus.c | |
index 12e44e4..f470e34 100644 | |
--- a/gaseous-giganticus.c | |
+++ b/gaseous-giganticus.c | |
@@ -1410,6 +1410,21 @@ static void create_vortices() | |
create_vortex(i); | |
} | |
+#ifdef _WIN32 | |
+#include <windows.h> | |
+static int get_num_cpus() | |
+{ | |
+ SYSTEM_INFO sysinfo; | |
+ GetSystemInfo(&sysinfo); | |
+ return sysinfo.dwNumberOfProcessors; | |
+} | |
+#else | |
+static int get_num_cpus() | |
+{ | |
+ return sysconf(_SC_NPROCESSORS_ONLN); | |
+} | |
+#endif | |
+ | |
int main(int argc, char *argv[]) | |
{ | |
int i, t; | |
@@ -1436,7 +1451,7 @@ int main(int argc, char *argv[]) | |
check_vf_dump_file(vf_dump_file); | |
- int num_online_cpus = sysconf(_SC_NPROCESSORS_ONLN); | |
+ int num_online_cpus = get_num_cpus(); | |
if (num_online_cpus > 0) | |
nthreads = num_online_cpus; | |
if (user_threads > 0 && user_threads < num_online_cpus) | |
-- | |
2.19.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment