From: Jehan Date: Thu, 27 Jan 2022 16:39:49 +0000 (+0100) Subject: tools: use _putenv_s() instead of setenv() on Windows. X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~4^2~8 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8769953c4c0342f1250db01a1570cd69b71c9c71;p=babl.git 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. --- diff --git a/tools/babl-benchmark.c b/tools/babl-benchmark.c index d12dbb5..32d66c2 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 25a8abc..c857edd 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 75aaa9c..b76f707 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,