[babl] tools: use _putenv_s() instead of setenv() on Windows.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] tools: use _putenv_s() instead of setenv() on Windows.
- Date: Thu, 27 Jan 2022 16:41:21 +0000 (UTC)
commit 8769953c4c0342f1250db01a1570cd69b71c9c71
Author: Jehan <jehan girinstud io>
Date: Thu Jan 27 17:39:49 2022 +0100
tools: use _putenv_s() instead of setenv() on Windows.
setenv() does not exist on Windows API, hence babl tools fail to build.
Fixing the issue by using an alternative Windows API.
tools/babl-benchmark.c | 7 +++++++
tools/babl-lut-verify.c | 7 +++++++
tools/babl-verify.c | 7 +++++++
3 files changed, 21 insertions(+)
---
diff --git a/tools/babl-benchmark.c b/tools/babl-benchmark.c
index d12dbb59e..32d66c2d2 100644
--- a/tools/babl-benchmark.c
+++ b/tools/babl-benchmark.c
@@ -25,6 +25,13 @@
#define random rand
#endif
+#ifdef _WIN32
+/* On Windows setenv() does not exist, using _putenv_s() instead. The overwrite
+ * arg is ignored (i.e. same as always 1).
+ */
+#define setenv(name,value,overwrite) _putenv_s(name, value)
+#endif
+
int ITERATIONS = 4;
#define N_PIXELS (1024*1024) // a too small batch makes the test set live
// in l2 cache skewing results
diff --git a/tools/babl-lut-verify.c b/tools/babl-lut-verify.c
index 25a8abc40..c857edd9d 100644
--- a/tools/babl-lut-verify.c
+++ b/tools/babl-lut-verify.c
@@ -10,6 +10,13 @@
#define random rand
#endif
+#ifdef _WIN32
+/* On Windows setenv() does not exist, using _putenv_s() instead. The overwrite
+ * arg is ignored (i.e. same as always 1).
+ */
+#define setenv(name,value,overwrite) _putenv_s(name, value)
+#endif
+
static double
test_generic (const Babl *source, const Babl *dest)
{
diff --git a/tools/babl-verify.c b/tools/babl-verify.c
index 75aaa9ccf..b76f707c8 100644
--- a/tools/babl-verify.c
+++ b/tools/babl-verify.c
@@ -8,6 +8,13 @@
#define SPACE1 babl_space("sRGB")
//#define SPACE2 babl_space("Apple")
+#ifdef _WIN32
+/* On Windows setenv() does not exist, using _putenv_s() instead. The overwrite
+ * arg is ignored (i.e. same as always 1).
+ */
+#define setenv(name,value,overwrite) _putenv_s(name, value)
+#endif
+
int
file_get_contents (const char *path,
char **contents,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]